Problem:
Laver
Nori (laver) is produced in the villages along the beaches of the Hibara Sea. All laver is formed into rectangles. When drying the laver in the sun, two sheets of laver are placed on the same rug so that the top of the first sheet is parallel to the top of the second sheet. Genm, a part-time worker, can place them parallel to each other, but he is not used to it yet, so there may be overlapping areas. The overlapped areas are not for sale, so we need to find the area of the laver that is not overlapped.
Given the position of the lower-left point, width, and height of each of the two pieces of laver placed on the same rug, write a program that outputs the area of the non-overlapping pieces of laver.
Input
The input is given in the following form.
$x_1$ $y_1$ $w_1$ $h_1$
$x_2$ $y_2$ $w_2$ $h_2$
The first line gives the coordinates of the lower left point $x_1,y_1$ ($0 \leq x_1,y_1 \leq 1,000$) and the width and height $w_1,h_1$ ($1 \leq w_1,h_1 \leq 1,000$) of the first piece of laver. The second line gives the coordinates of the lower left point $x_2,y_2$ ($0 \leq x_2,y_2 \leq 1,000$) and the width and height $w_2,h_2$ ($1 \leq w_2,h_2 \leq 1,000$) of the second piece of laver. All inputs are given as integers.
Output
Output the area of the laver in the non-overlapping area as an integer in a line.
Sample Input and Output
Sample Input 1
0 0 4 5
2 2 3 6
Sample Output 1
26
Sample Input 2
1 2 2 1
2 0 2 2
Sample Output 2
6
Sample Input 3
0 0 1 1
0 0 1 1
Sample Output 3
0

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    vector<int> a(4),b(4);
    rep(i,4) cin >> a[i];
    rep(i,4) cin >> b[i];
    
    vector<vector<int>> sum(2010,vector<int>(2010,0));
    sum[a[0]+a[2]][a[1]+a[3]]++;
    sum[a[0]][a[1]]++;
    sum[a[0]][a[1]+a[3]]--;
    sum[a[0]+a[2]][a[1]]--;

    
    sum[b[0]+b[2]][b[1]+b[3]]++;
    sum[b[0]][b[1]]++;
    sum[b[0]][b[1]+b[3]]--;
    sum[b[0]+b[2]][b[1]]--;

    rep(i,2010){
        rep(j,2009){
            sum[i][j+1] += sum[i][j];
        }
    }
    rep(i,2010){
        rep(j,2009){
            sum[j+1][i] += sum[j][i];
        }
    }

    int ans = 0;
    rep(i,2010){
        rep(j,2010){
            if(sum[i][j]==1) ans++;
        }
    }
    cout << ans << endl;

}
accuracy: 1
time_ms: 30
memory_kb: 18912
final_rank: 3

code_snippet: /*
NNMNNNMNNNNNNNMNNMNNNNNNNNNNNMNNMNNMNNMNMNNMNNMNNMNNMNMMNMMNMNMMMMNMNMMNMNMNMNMMNMNMMNMMMMMNMMNMNNMNMNMMNMMNMNNNMNNNNNNNMNMNMMNMNMNNMNMNNMNN
NMNNMMNNMMNMMNMNNNNNNNNN#NNNNNNMNMMNNMNNMNMNMNNMNNMNNMNNMNMMNMNNNNMMNMNMNMNMNMNMMNNMNMNMNMNMNNMNMMNMNNMNMNNMNMNNNMNNNNNMNNNMNNMMNMNNMNNMMNMM
MNNMNNMNNNNMNNNNN##MMB9YTTTTHMNNNNNNNNNMNMNNNMNMNMNMNMNMNMNMNNMMNMMMMNMNMMNNMNNNMNMNMNMNNMMNMNMNMNNMNMNMNMMNNMNMNNMNNNNNMMNMNMNNMNMMNMNMNMNN
NNNNNMNNNMNNNNHHMB6+gHgggHm+:<7M###MMMMNNNNNNNNNNNNNMNNNMNMNMNNMNNMNNMNNMNMNNMMNMNNMNNMMNNMMNMNMMNMNNNMNMNNMNNNNNNNNNNNNNNNNMNMMNMNNMNNNMNMN
NNMNNNNNNNNN#M#6uyWHHg@gg@gHs::?MMUuuuXMNNNN##NNNNNNNNNNNMNNMNNNMNMMNMMMNMNMNMNMNNNNNNNMNMNNMNNNNNNNNNNNNNMNNN#NN#NNNNNNNNNMNNNNMNMNNMMNMNNM
MNMNNMNNN##H#6dyyyyVVWH@@@@@H<::?uuuuXdHH##HHHH##NNNNNNNNNNNNMMNNMNMNNMNNMNNNNNNN###NNNNNNNN###MMMMMMMM#NNNN####HH##HH####NNNNMNNMNMNNMMNMNN
NMNNMNN##HM6jyyVVVWfWVyWgggggI:::wuXXMHHHHHMMNMMNMMNMMNMNNNNNNNMNNMNMNNMNNMMMHHkkkkkHHMMMMHkbbkbkbkbbbbbbkHHMMMHHH@H@HMMMMM##NNNMNNMMNNMNNMM
NNNNNN##H#1XyyVyWWVVyVVVHg@@H>:::yuWHHHH@MNMMMMMMMMMMMMMMNM###NNNMNMNMNNNNNbkkkkkkkkkbbbppfWWWWWWWWWWWWWWWppbbkkHkkbkbbkbbkkMH#NNMNNNMNMMNMN
NNNN##HH@jyyyVyWWVyVyyVWW@ggK:::(uXWHHHMMMMMMWuuuZuuuXWMMMMNMH#NNNNNMNMMNNMHbkbbkbbbpWWUT7!`    `~`  `  ??TUWWppbkkbkbkkbkbkH@H#NNMNNNMNNMNM
NNN#HHM@jyyyVVWyVyVVyWWVW@gHC:::+uXH@@MMMUZuuuXkkkQQHH@H@MMMNM#H##NNNNNNNN#NHkkbbpWWY^`       `              ?4WWpbbkkbkkkbkMHHH#NNMMNNMNNNN
NNN#HH#1yyyVVWyVyVVWWVVVW@gD:::(HQH@HHZZZZuZZZWMHHHHHHHHHHMMMMHHH#####NNNN#HMHbpWU=`                    `      .CWWpbbkbkbkHH###H#NNNMNNMMNM
NN#HHM3dyyVyWyVyVyWWVyWWWgK::::dNWHHZXkkW@HHHNMMg@HHHH#HHHHMMNM@@@@HHH###N#HHMH0=     ` ` `        `   `  `  `   .OWpbbkkkkMMMMHH#NNMNNM#NNM
H##HH@+yyVyWWVyVVVWVVWWVN#<:::jNMMZXHMMMNMMWWMNbkMMMH###N#HMMN@@@@@@@HMH#H#HMHV!    `    ` ` `  `    `             jWppbkkHH@@@H###NNNNHHHNN
HH##H$JyyVVWVyVVyWVVWWyW#>:::jNMMQMN@MMNMNNNNMNkHMMMMMMH##HMMMgg@@@H@@@HHHHMHC   `            `  `      `  `  `  `  (XpbbHHM@@@@H#NNNMNHHHHN
H##HHIdyyVyWVyyVypyVWyy#>:::jNMMNMMMMMMNMMNMNMNMMNMHMNMHHHMMNMgg@@@@H@@@HH@Hf  `  ``  `   `       ` `  `  `  `       (WpH#Mg@@@@H#NNNNN#H@HH
H##HHbjyyVVWWVyVVWVVWX3:::+dSWMNMRqNMMNMNNMMNMNNNMMMNMNHHMMMMgg@@@H@H@@@@@HK`          `  .` `       `   .     `   `  jWMH@g@@@@HHNNNMNNHH@H
####HN+WyyVyWVyyVWyyY<:::jMNQMMNMNMMMMNMMNMNMMMNHMMNMHHMMMMM@g@@@@H@@H@@H@H\   `    ` .  .:    ~-     _               .XWMMg@@@@HH#NNMNN#H@H
NN#N##NwVVyyyWWyyVY<:::+MMMMMMMMMMMMNdNMMNMN#<:<:<TMMNMMMMM@@@@@@H@H@@@@H@K`  `  `  .._  :~_  .::_.  (<. :_._.`      ` jWWMg@@@HHHNMNNMNNHH@
NNNNN#HMkXWVVWVY>::::+dMHmg@@MHWMNMMMMMNMMNN<:::::(MNNMM#HHH@@@@H@@@@@@@HMD.   `. `.:<< (<  . (<:<;_(+<~.`-~<:_        .XWMg@@@@HH#NNNMNNHH@
NMMNNNNH@gHmmQmAQggQWqmgg@MHH@mgMMMMMMMMNMNMMI::::<HMMH##HHHH@@H@@@@HHmHH93_    _  .<!.(+-.`_ _<+;<;<<~.+..`.<:_.   `   (WWHgg@@@H##NNMN#H@H
NNMNMNNH@@@@HHHHHH@gg@@@@MH#H@g@@MMMMMMMNNMM5::::::dMMHHHHH@@@H@@@HHHf^ ..(_. ` (_ .<.?ZWW;` .` (<<:<! `.WWk. (+_.   ` _ XpHHHHHHMMH#NN#H@H@
MNNMNNNHH@@HH#HHHH@@@@@@H#N#H@@@@MMMMMMMMMNMMNJ+gmjMNMMMM@@@@@@@BYYY!  _::<<:-  :+-.j'..XbW_```` _`~ ``..dHgHz.<<~    .: XW!`~?TWHHHMMM@@@@@
NMNMNN#H@@@@MMHHH@HH@HHHHNN#H@@@MMHMMNNM"MMMMMMMMMMMMMMNNH@@@@@@Hk.....(;;;1;;<-(<<1\ JfHHz{`````````` dwHgXH`<.<`` `.(:_Xk<_-.. _TWHHHg@@@@
NMNNNN#HH@@@@@@H@@@H@@HHNNN#H@@gHHS .UMN.(MNMMMMMMqqmgMMMMMM@@@@@gHma&&gggQH>;;;;;<.! jS-(O:`` ````````wk7Tdf``      (<>jp6>>;_``   _777<d@@
MNMNN#H@@H@@@@@@H@H@@HHHNNN#H@mHH0!`_OH#b  WH@HHHHmg@@@g@MMM@@@@H@@MH#HHHHMP.A<><;;<_` ?<~!`````` `````.>+<^ `     .(+>jWHs+1++<<-....-dHg@@
NMNNN#H@H@gHkHH@@H@@H@HNNMN#MHHWf ` -dMNNaJWHMH#HHm@@@@@@@@@@@H@@@H#N##HH@H!(fWmJWc<_``````````  `` `````` ` .`  .(<+1dkH@HHA&&&&&aQWHmgg@@@
NNNN#H@@@HHpppbHH@@@HH#NNNN#MHW}``-MMNMMMgg@HH##HHH@@@@@@@gHH@@@@@HH##HMMB'`dWHHHMR.```````````````````````` -.(;+&gkbbW@H@gqqqqmggggg@@@@@@
####HH@@@HpppppppHH@@H#NMNN#MNmm.d#MMMMNNMMMHHHHMHH@@@@@@gHWWHHHHHHMMHBY^   XMHHHHMm..`````` ` ```` ` ``` .~~<jgHHHHNpW%WHHqqHkmg@@@@@@@@HHH
H#HH@H@@HppfffVffpH@@HNNNNN#HMMMMMMMMMNNNNNMg@MMWWH@@@@gHH00VY77777!`    `.(WH##HHH#<?1-.``````` ````` ````.->dH##H#NpS .4UUWWpHg@@@@@@@@Hpp
HMH@@H@HHppfffVVffWg@MNNNNN#HMMMMMMMMNNNNNNMKUUZwXHqmHHHWC!` ..       ` .(;+d####HM%  .+jwe..````````` ..(<+>>dHHH#HMH$_  ?zOXXWHggg@@@@gHVy
H@@@@@H@HpfpfVVVVfpqgM#N####MNyHMMMMSWMNNNNNMh<<!`?UWWUC` -<>+++<<___(<+++=?<?MMMM9_`  (MHHMMHmJ--+1z11z>>>=??JM#HH#HN3<-   ??OXWHHHqmggHHyy
Hgg@@H@gmkppffyVVfpkqHMM####MWZZZZZZuzrWNNNNNgH;   `?O> .;>>>+111zz<<+<<<:::::(Z<:~_. .X#0HM#HHHHHHMNHMHHR+=??>zTMHHM5?1<<-.    _?7TUWWHHUXX
pHH@@@@HkkbpfVVyyfpbkqqHHMMHWZZZZyyZZuvrXMNNNNHk{      ->>>?<<<<+<<<:::::::::(J>:::~(dyf1?OOTMM#########MMI1>??>???dRz??11?<<_-...      ~??1
WpbkqmHbpppppfVyyVppbpbbpfXZXuZZZyyZuuuvtlTNNNHH[` ` .<<<>?z<<<:::::::~::~:~(JC::::(df0`.<=vwOtOZZVUVUVtOWNzz<<<>>?zNz1???=zzzz1?>><<(-..
ZyfpbbbpfVyyyVyZyyVffppfVyXzvXZZZZZZuuzvwtz?MN#MD  ` -(<:(:::<<<<<+((((::(((d>::~:(kmXZ-  <=vwrttwzzZOz=dM@!     <??dR?1=??==z==zXVWkXAAz+<-
XXWyffpVyXuuuuuuuZyyVVyyZuzvzuuuuuuuuuuuzrl=?H#MD `   ~<:(Co+:::::~:::::::+f<::::+XbHC:~:- _<=vZO===1<<(H0!   ` _1??vNz?zz=??=z?=zXpbpfWZ=?1
rvuuZZZZXwvvvvrvrXZZXXZXXwrrrzzuzzuzzuuuzrtl1+TM]  `  +::::<7w+:~:::::::(J3:::::+Wb9>:::~~.  ` _`` `  .dy}..._:~:(1?=db==zz==?=I==zWpfyXI==?
lOrrwwwOOOrrrrOOtOOOOOOOOllttOOOzvvzzzzvvrttll1v%`  ` (o:~:::::::~:~::(JY<:::::+WbY<:::::::~_.     ._(wU0:::~::::::1zzNz==zz===zz==vWXXI===>
llllz====llzzOz==l========tlllzllOOrwrrrrrrtlz1<~ `  `(zO-::(:~:::::(J3::::~::+pW3:::~:::::::(<~~~~:(dWk>:::::~::(::?zdK===zz===z===wwI=l=<.
lll=====????????=======?=llll===lllOlltOOOOO1<>>_  `  (uZXx:(<::~:(v=::::~:::jpWC:::~:::wuz<(>:::::(dbb$::~::+(::(>::?zHy===zll=lOl=zIl===~:
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
// || __
#define rep(i, n) for (LL i = 0; i < n ; i++)
//配列変数に代入、iは定義不要;
#define inputs(i,n,a) rep(i,n)cin>>a[i];
//ベクターに代入、i定義不要;
#define vec_in(i,n,a) rep(i,n){int tmp=0;cin>>tmp;a.push_back(tmp);}
#define YorN(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
//vec_outは改行か空白かを選べる。 第二引数でspace=0,endl=1;を指定する。
#define vec_out(vec,endl_or_space) for (auto& v : vec) {cout<<v; if(endl_or_space)cout<<endl;else cout<<" ";}
//modの改修を検討中
LL MOD=1000000007;
LL INF=1000000000000;
typedef pair<LL,LL> pear;
typedef  vector<vector<LL> > Graph;
//dx,dy君はグリッド等の探索に使うためのテンプレート配列
const int dx[] = { 1,0,-1,0 ,1,1,-1,-1 };
const int dy[] = { 0,1,0,-1 ,1,-1,-1,1 };
//A...65 a...97 0...48



int main() {
    LL nori[3010][3010];
    rep(i,3010){
        rep(j,3010){
            nori[i][j]=0;
        }
    }
    LL x,y,h,w;
    cin>>x>>y>>h>>w;
    for(int i=x;i<x+h;i++){
        for(int j=y;j<y+w;j++){
            nori[i][j]++;
        }
    }
     
    cin>>x>>y>>h>>w;
    for(int i=x;i<x+h;i++){
        for(int j=y;j<y+w;j++){
            nori[i][j]++;
        }
    }
    LL ans=0;
    rep(i,3010){
        rep(j,3010){
            if (nori[i][j]==1){
                ans++;
            }
        }
    }
  /*  rep(i,10){
        rep(j,10){
            cout<<nori[i][j]<<" "; 
        }
        cout<<endl;
    }*/
   
    cout<<ans<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 73844
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main()
{
	vector<vector<int>> cou(3010,vector<int>(3010,0));
	int a,b,c,d;
	for(int l = 0;l < 2;l++){
		cin >> a >> b >> c >> d;
		for(int i = a;i < a + c;i++){
			for(int j = b;j < b + d;j++){
				cou[i][j]++;
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < 3010;i++){
		for(int j = 0;j < 3010;j++){
			if(cou[i][j] == 1){
				ans++;
			}
		}
	}
	cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 38348
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF INT64_MAX;
int main(void)
{
    int x1,x2,y1,y2,h1,h2,w1,w2,sum=0;
    cin>>x1>>y1>>w1>>h1>>x2>>y2>>w2>>h2;
    vector< vector < int > > f(3002,vector<int>(3002,0));
    for(int i=y1;i<y1+h1;i++){
        for(int j=x1;j<x1+w1;j++){
            f[i][j]++;
        }
    }
    for(int i=y2;i<y2+h2;i++){
        for(int j=x2;j<x2+w2;j++){
            f[i][j]++;
        }
    }
    for(int i=0;i<=3000;i++) for(int j=0;j<=3000;j++) if(f[i][j]==1) sum++;
    cout<<sum<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 38244
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF INT64_MAX;
int main(void)
{
    int x1,x2,y1,y2,h1,h2,w1,w2,sum=0;
    cin>>x1>>y1>>h1>>w1>>x2>>y2>>h2>>w2;
    vector< vector < int > > f(3002,vector<int>(3002,0));
    for(int i=x1;i<x1+w1;i++){
        for(int j=y1;j<y1+h1;j++){
            f[i][j]++;
        }
    }
    for(int i=x2;i<x2+w2;i++){
        for(int j=y2;j<y2+h2;j++){
            f[i][j]++;
        }
    }
    for(int i=0;i<=3000;i++) for(int j=0;j<=3000;j++) if(f[i][j]==1) sum++;
    cout<<sum<<endl;
}
accuracy: 0.11538461538461539
time_ms: 10
memory_kb: 38152
final_rank: 7

code_snippet: #include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }
template<typename T=ll,size_t N>
array<T,N> arrin(){array<T,N> x;REP(i,N){ x[i]=in<T>(); }return x;}

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

class Data{
public:
	ll x,y,w,h;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	Data data[2];
	REP(i,2){
		data[i].x=in(),data[i].y=in(),data[i].w=in(),data[i].h=in();
	}

	ll K=2000;
	vvll M(K+1,vll(K+1,0));
	REP(i,2){
		M[data[i].y][data[i].x]+=1;
		M[data[i].y][data[i].x+data[i].w]-=1;
		M[data[i].y+data[i].h][data[i].x]-=1;
		M[data[i].y+data[i].h][data[i].x+data[i].w]+=1;
	}
	REP(i,K+1){
		REP(j,K){
			M[i][j+1] += M[i][j];
		}
	}
	REP(j,K+1){
		REP(i,K){
			M[i+1][j] += M[i][j];
		}
	}
	ll S=0;
	REP(i,K+1){
		REP(j,K+1) if(M[i][j]==1) S++;
	}
	out(S);
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 34492
final_rank: 4

code_snippet: #include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }
template<typename T=ll,size_t N>
array<T,N> arrin(){array<T,N> x;REP(i,N){ x[i]=in<T>(); }return x;}

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

class Data{
public:
	ll x,y,w,h;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	Data data[2];
	REP(i,2){
		data[i].x=in(),data[i].y=in(),data[i].w=in(),data[i].h=in();
	}

	vvll M(2001,vll(2001,0));
	REP(i,2){
		M[data[i].y][data[i].x]+=1;
		M[data[i].y][data[i].x+data[i].w]-=1;
		M[data[i].y+data[i].h][data[i].x]-=1;
		M[data[i].y+data[i].h][data[i].x+data[i].w]+=1;
	}
	REP(i,1001){
		REP(j,1000){
			M[i][j+1] += M[i][j];
		}
	}
	REP(j,1001){
		REP(i,1000){
			M[i+1][j] += M[i][j];
		}
	}
	ll S=0;
	REP(i,1001){
		REP(j,1001) if(M[i][j]==1) S++;
	}
	out(S);
	return 0;
}
accuracy: 0.11538461538461539
time_ms: 10
memory_kb: 34384
final_rank: 6