#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define endl '\n'
#define itn int
#define pi pair<int,int>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int N=4e5+5;
int n,m,q,a,b,ans;
vector<int> x[N];
inline void Solve(){
cin>>n>>m>>q;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)x[i].pb(j);
while(q--){
cin>>a>>b;
auto pos=lower_bound(x[a].begin(),x[a].end(),b);
if(*pos==b)x[a].erase(pos);
else{
pos=prev(pos);
if(next(pos)!=x[a].begin())x[a].erase(pos);
if(pos!=prev(x[a].end()))x[a].erase(next(pos));
for(int i=a+1;i<=n;i++){
auto it=lower_bound(x[i].begin(),x[i].end(),b);
if(*it==b){x[i].erase(it);break;}
}
for(int i=a-1;i>=1;i--){
auto it=lower_bound(x[i].begin(),x[i].end(),b);
if(*it==b){x[i].erase(it);break;}
}
}
}
for(int i=1;i<=n;i++)ans+=x[i].size();
cout<<ans;
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int T=1;
//cin>>T;
while(T--)
Solve();
return 0;
}
AC × 1
WA × 6
TLE × 7
RE × 12