Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
	ll f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//**********head by yjjr**********
#define pb push_back
#define inf 1e9
template<class T>inline void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
const int maxn=66,maxm=1e6+6,dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},mod=1e9+7;
struct node{int x,y;}a[maxn<<1],que[maxn<<2];
int n,m,K,ans,lx,ly,cnt[maxn][maxn],s1[maxm],s2[maxm],dis[maxn][maxn],head,tail;
bool fb[maxn][maxn],mark1[maxm],mark2[maxm];
vector<int>px,py;
void bfs(int x,int y){
	rep(i,0,lx)rep(j,0,ly)dis[i][j]=inf;
	dis[x][y]=0;que[head=tail=1]=(node){x,y};
	while(head<=tail){
		int nx=que[head].x,ny=que[head++].y;
		rep(i,0,3){
			int nex=nx+dx[i],ney=ny+dy[i];
			if(nex>lx||nex<0||ney>ly||ney<0||dis[nex][ney]<=dis[nx][ny]+1||fb[nex][ney])continue;
			dis[nex][ney]=dis[nx][ny]+1;que[++tail]=(node){nex,ney};
		}
	}
}
int main()
{
	n=read(),m=read(),K=read();
	px.pb(1);px.pb(n+1);py.pb(1);py.pb(m+1);
	rep(i,1,n)s1[i]=m;
	rep(i,1,m)s2[i]=n;
	rep(i,1,K){
		a[i].x=read()+1,a[i].y=read()+1;
		px.pb(a[i].x),px.pb(a[i].x+1);
		py.pb(a[i].y),py.pb(a[i].y+1);
		s1[a[i].x]--,mark1[a[i].x]=1;
		s2[a[i].y]--,mark2[a[i].y]=1;
	}
	rep(i,1,n)s1[i]=(s1[i]+s1[i-1])%mod;
	rep(i,1,m)s2[i]=(s2[i]+s2[i-1])%mod;
	rep(i,1,n-1)if(!mark1[i]&&!mark1[i+1])ans=(ans+1ll*2*s1[i]*(s1[n]-s1[i]))%mod;
	rep(i,1,m-1)if(!mark2[i]&&!mark2[i+1])ans=(ans+1ll*2*s2[i]*(s2[m]-s2[i]))%mod;
	vnique(px);vnique(py);lx=px.size()-2;ly=py.size()-2;
	rep(i,1,K)
		fb[lower_bound(px.begin(),px.end(),a[i].x)-px.begin()][lower_bound(py.begin(),py.end(),a[i].y)-py.begin()]=1;
	rep(i,0,lx)rep(j,0,ly)cnt[i][j]=1ll*(px[i+1]-px[i])*(py[j+1]-py[j])%mod;
	rep(i,0,lx)rep(j,0,ly)
		if(!fb[i][j]){
			bfs(i,j);
			rep(k,0,lx)rep(p,0,ly)
				if(!fb[k][p])ans=(ans+1ll*cnt[i][j]*dis[k][p]%mod*cnt[k][p])%mod; 
   		}
	ans=(ans+mod)%mod;ans=1ll*ans*(mod/2+1)%mod;
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:22:30: error: variable or field 'vnique' declared void
   22 | template<class T>inline void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
      |                              ^~~~~~
a.cc:22:37: error: 'vector' was not declared in this scope
   22 | template<class T>inline void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
      |                                     ^~~~~~
a.cc:7:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    6 | #include<algorithm>
  +++ |+#include <vector>
    7 | #define rep(i,a,b) for(int i=a;i<=b;i++)
a.cc:22:45: error: expected primary-expression before '>' token
   22 | template<class T>inline void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
      |                                             ^
a.cc:22:48: error: 'r' was not declared in this scope
   22 | template<class T>inline void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
      |                                                ^
a.cc:27:1: error: 'vector' does not name a type
   27 | vector<int>px,py;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:43:9: error: 'px' was not declared in this scope; did you mean 'lx'?
   43 |         px.pb(1);px.pb(n+1);py.pb(1);py.pb(m+1);
      |         ^~
      |         lx
a.cc:43:29: error: 'py' was not declared in this scope; did you mean 'ly'?
   43 |         px.pb(1);px.pb(n+1);py.pb(1);py.pb(m+1);
      |                             ^~
      |                             ly
a.cc:57:9: error: 'vnique' was not declared in this scope
   57 |         vnique(px);vnique(py);lx=px.size()-2;ly=py.size()-2;
      |         ^~~~~~