Said to be an enhanced version, in fact, you can paste the code of the chessboard question (be careful to open long long):
#include<bits/stdc++.h> using namespace std; long long n,m,z=0,c; int main(){ cin>>n>>m; for(long long i=0;i<(n>m?m:n);++i) z+=(n-i)*(m-i); c=(1+n)*(1+m)*n*m/4-z; cout<<z<<" "<<c<<endl; return 0; }