stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define maxtam 1000



using namespace std;

typedef long long ll;



int main()

{

	ll v[maxtam];

	int nums;

	cin>>nums;

	

	for(int i=0; i<nums; i++)

		cin>>v[i];

		

	sort(v,v+nums);

	cout<<v[nums-1]-v[0]<<endl;

	

	return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;

int n,a,maxi=0,mini=2e9;

int main()

{

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%d",&a);

		maxi=max(maxi,a);

		mini=min(mini,a);

	}

	printf("%d",maxi-mini);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define ll long long

#define pb push_back

#define mp make_pair

#define modulo 1000000007

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

string s;

ll k,n;

ll dp[105][105][2];

ll solve(int ind, int digit, int flag){

	if(ind>=n){

		if(digit==k)

			return 1;

		return 0;

	}

	if(dp[ind][digit][flag]!=-1)

		return dp[ind][digit][flag];

	int limit=9;

	if(!flag)

		limit=(s[ind]-'0');

	ll res=0;

	for (int i = 0; i <= limit; ++i){

		if(!flag && i==limit)

			res=res+solve(ind+1,i==0?digit:digit+1,0);

		else

			res=res+solve(ind+1,i==0?digit:digit+1,1);

	}

	dp[ind][digit][flag]=res;

	return dp[ind][digit][flag];

}

int main(){

	fast_io;

	cin>>s>>k;

	n=s.length();

	memset(dp,-1,sizeof(dp));

	ll ans=solve(0,0,0);

	cout<<ans<<"\n";

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

 

 string arr;

 long long dp[105][4][2];

int k;

 

long long back(int in, int nnzer, bool flag  ){

 

	 if(nnzer>k) return 0;

 	if(in> arr.size()) {  if(nnzer==k) return 1; else return 0;  }

	

	if(dp[in][nnzer][flag]!=-1) return dp[in][nnzer][flag];

	

 	 int limit = 9;

 	 if(!flag) limit=  arr[in-1]-'0';

	long long res =0;

	

	res+=	back(in+1,  nnzer,  flag || limit!=0);

		

 	for(int i=1; i<=limit; ++i){

 

	res+=	back(in+1,  nnzer+1, flag || i<limit);	

 	

 	}

 	

	return dp[in][nnzer][flag] = res;

 }

 

 

 

int main() {

 

	string a;

	cin>>a;

	cin>>k;

	memset(dp, -1, sizeof dp);

	 arr=a;

	 

	long long  c= back(1,0,false);

	 

	 cout<<(c)<<'\n';   

	return 0;

}

 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

 

#define fi first

#define se second

#define pb push_back

#define all(x) x.begin(), x.end()

#define mp make_pair

 

typedef long long ll;

typedef unsigned long long int ull;

typedef long double ld;

 

typedef pair<int, int> pii;

typedef pair<int, pii> piii;

 

typedef vector<ll> vll;

typedef vector<pii> vpii;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<pair<int, pii>> vpiii;

 

typedef map<string, int> msi;

typedef map<int, int> mii;

typedef map<int, ll> mill;

typedef map<int, vi> mivi;

typedef map<int, vpii> mivpii;



const int MAXN = 1e5;

const int UNSET = -1;

const int MAXK = 3;



int d[MAXN + 1];

ll dp[MAXN + 1][MAXK + 1][2];



string S;

int N, K;



void fast_io() {

	ios::sync_with_stdio(false);

	cin.tie(NULL);

}



ll solve(int pos, int k, bool r) {

	if(pos == N) return k == K;

	if(dp[pos][k][r] != UNSET) return dp[pos][k][r];

	

	int lim = (r ? d[pos] : 9);

	ll ans = 0;

	

	for(int i = 0; i <= lim; i++) {

		bool nr = (i == d[pos]) ? r : 0;

		int nk = (i) ? k + 1 : k;

		if(nk <= K) ans += solve(pos + 1, nk, nr);

	}

	return dp[pos][k][r] = ans;

}



void prepare() {

	memset(dp, UNSET, sizeof(dp));

	for(int i = 0; i < S.length(); i++)

		d[i] = S[i] - '0';

	N = S.length();

}



int main() {

	fast_io();

//	freopen("input/ABC154E.txt", "r", stdin);

	

	cin >> S >> K;

	prepare();

	cout << solve(0, 0, 1) << '\n';

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

 

#define fi first

#define se second

#define pb push_back

#define all(x) x.begin(), x.end()

#define mp make_pair

 

typedef long long ll;

typedef unsigned long long int ull;

typedef long double ld;

 

typedef pair<int, int> pii;

typedef pair<int, pii> piii;

 

typedef vector<ll> vll;

typedef vector<pii> vpii;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<pair<int, pii>> vpiii;

 

typedef map<string, int> msi;

typedef map<int, int> mii;

typedef map<int, ll> mill;

typedef map<int, vi> mivi;

typedef map<int, vpii> mivpii;



const int MAXN = 1e5;

const int UNSET = -1;

const int MAXK = 3;



int d[MAXN + 1];

int dp[MAXN + 1][MAXK + 1][2];



string S;

int N, K;



void fast_io() {

	ios::sync_with_stdio(false);

	cin.tie(NULL);

}



int solve(int pos, int k, bool r) {

	if(pos == N) return k == K;

	if(dp[pos][k][r] != UNSET) return dp[pos][k][r];

	

	int lim = (r ? d[pos] : 9);

	int ans = 0;

	

	for(int i = 0; i <= lim; i++) {

		bool nr = (i == d[pos]) ? r : 0;

		int nk = (i) ? k + 1 : k;

		if(nk <= K) ans += solve(pos + 1, nk, nr);

	}

	return dp[pos][k][r] = ans;

}



void prepare() {

	memset(dp, UNSET, sizeof(dp));

	for(int i = 0; i < S.length(); i++)

		d[i] = S[i] - '0';

	N = S.length();

}



int main() {

	fast_io();

//	freopen("input/ABC154E.txt", "r", stdin);

	

	cin >> S >> K;

	prepare();

	cout << solve(0, 0, 1) << '\n';

	

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int n;

int dp[(1 << 21)];

int a[21][21];

int solve(int msk){

  if(msk == (1 << n) - 1)

    return 1;

  int in = __builtin_popcount(msk);

//  cout << msk << ' ' << in << endl;

  int& res = dp[msk];

  if(res != -1)

    return res;

  res = 0;

  for(int i = 0;i < n;i++){

    if(!((1 << i) & msk) && a[in][i]){

      res = (1ll * res + solve(msk | (1 << i))) % MOD;

    }

  }

  return res;

}

int main()

{

//  freopen("in.txt", "r", stdin);

//  freopen("out.txt", "w", stdout);

  memset(dp, -1, sizeof(dp));

  cin >> n;

  for(int i = 0;i < n;i++)

    for(int j = 0;j < n;j++)

      cin >> a[i][j];

  cout << solve(0);

  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int n;

int dp[(1 << 21)];

int a[21][21];

int main()

{

//  freopen("in.txt", "r", stdin);

//  freopen("out.txt", "w", stdout);

  cin >> n;

  for(int i = 0;i < n;i++)

    for(int j = 0;j < n;j++)

      cin >> a[i][j];

  dp[0] = 1;

  for(int i = 0;i < (1 << n);i++){

    for(int j = 0;j < n;j++){

      int in = __builtin_popcount(i);

      if(((1 << j) & i) || !a[in][j])continue;



      dp[i | (1 << j)] = (1LL * dp[i | (1 << j)] + dp[i]) % MOD;

    }

  }

  cout << dp[(1 << n) - 1];

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<math.h>

using namespace std;

int a[105];

int main(){

	int n;

	cin>>n;

	int tot = 0;

	for(int i = 0;i<n;i++){

		cin>>a[i]; tot+=a[i];

	}

	int temp = 0;

	int minim = 1e9;

	for(int i = 0;i<n;i++){

		temp+=a[i];

		if(abs(temp - (tot-temp)) < minim){

			minim = abs(temp - (tot-temp));

		}

	}

	cout<<minim<<"\n";

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include<algorithm>

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    int a[105];

    int b[105];

    int sum=0,ans=0;

    for(int x=0;x<n;x++)

    {

        scanf("%d",&a[x]);

        sum+=a[x];

    }

    for(int x=0;x<n;x++)

    {

        b[x]=abs(sum-ans);

        sum-=a[x];

        ans+=a[x];

    }

    b[n]=abs(sum-ans);

    sort(b,b+n+1);

    printf("%d\n",b[0]);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<set>

#include<cstdio>

#include<queue>

#include<cmath>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

long long read(){

	long long f=1,x=0;

	char c=getchar();

	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}

	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}

	return f*x;

}

#define MAXN 100000

struct node{

	int t,x,y;	

	node(){}

	node(int T,int X,int Y){t=T,x=X,y=Y;}

}test[MAXN+5];

bool cmp(node a,node b){return a.t<b.t;}

int main(){

	int n=read(),tmp;

	for(int i=1;i<=n;i++)

		test[i].t=read(),test[i].x=read(),test[i].y=read();

	sort(test+1,test+n+1,cmp);

	node Now(0,0,0);

	for(int i=1;i<=n;i++)

	{

		if(test[i].x!=Now.x||test[i].y!=Now.y)	

		{

			tmp=abs(test[i].x-Now.x)+abs(test[i].y-Now.y);

			if(Now.t+tmp>test[i].t)

			{

				printf("No\n");	

				return 0;

			}

			else

				Now.t+=tmp,Now.x=test[i].x,Now.y=test[i].y;

		}

		if(test[i].x==Now.x&&test[i].y==Now.y)

		{

			if(test[i].t%2!=Now.t%2)

			{

				printf("No\n");	

				return 0;

			}

			else

				Now.t=test[i].t;

		}

	}

	printf("Yes\n");

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int N=1e5+5;

int p[N][2];

int t[N];

int Abs(int x){

	return x>0?x:-x;

}

int main()

{

    int m;

    scanf("%d",&m);

    for(int i=1;i<=m;i++){

        scanf("%d%d%d",&t[i],&p[i][0],&p[i][1]);

        int x=(p[i][0]-p[i-1][0]+p[i][1]-p[i-1][1])%2;

        x=(x+2)%2;

        if(t[i]-t[i-1]<Abs(p[i][0]-p[i-1][0]+p[i][1]-p[i-1][1])||(t[i]-t[i-1])%2!=x){

            printf("No\n");

            return 0;

        }

    }

    printf("Yes\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

	int flag=1;

	int n,t=0,x=0,y=0,tt,tx,ty;

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>tt>>tx>>ty;

		if((abs(tx-x)+abs(ty-y))%2!=(tt-t)%2||abs(tx-x)+abs(ty-y)>(tt-t))flag=0;

		t=tt;x=tx;y=ty;

	}

	if(flag)cout<<"Yes";

	else cout<<"No";

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

	int x=0,y=0;

	int n;

	scanf("%d",&n);

	int t1=0,t2;

	for(register int i=1;i<=n;i++){

		int m,n;

		scanf("%d%d%d",&t2,&m,&n);

		if((abs(m-x)+abs(n-y)>t2-t1)||(((t2-t1-(abs(m-x)+abs(n-y)))%2)==1)){

			printf("No");

			return 0;

		}

		x=m;

		y=n;

		t1=t2;

	}

	printf("Yes");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <cmath>

#include <queue>

#include <vector>

using namespace std;





int main(){

    int n;

    while(scanf("%d",&n)!=EOF){

        int last=0,a,b,c,flag=0;

        for(int i=0;i<n;i++){

            scanf("%d%d%d",&a,&b,&c);

            if(a<b+c) flag=1;

            if((a-b-c)%2==1) flag=1;

        }

        if(flag==1) printf("No\n");

        else printf("Yes\n");

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

	int x=0,y=0;

	int n;

	scanf("%d",&n);

	int t1=0,t2;

	for(register int i=1;i<=n;i++){

		int m,n;

		scanf("%d%d%d",&t2,&m,&n);

		if((abs(m-x)+abs(n-y)>t2-t1)||(((t2-t1-(abs(m-x)+abs(n-y)))%2)==1)){

			printf("No");

			return 0;

		}

		x=m;

		y=n;

		t1=t2;

	}

	printf("Yes");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstdlib>

using namespace std;



int main()

{

    int n, x = 0, y = 0, m = 0;

    scanf("%d",&n);

    bool flag = true;

    for(int i = 0;i < n;i++)

    {

        int x1, y1, m1;

        scanf("%d %d %d",&m1,&x1,&y1);

        if((abs(x1 - x) + abs(y1 - y) > abs(m1 - m)) || ((abs(x1 - x) + abs(y1 - y)) % 2 != abs(m1 - m) % 2) )

            flag = false;

        x = x1, y = y1, m = m1;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

	int x=0,y=0;

	int n;

	scanf("%d",&n);

	int t1=0,t2;

	for(register int i=1;i<=n;i++){

		int m,n;

		scanf("%d%d%d",&t2,&m,&n);

		if((abs(m-x)+abs(n-y)>t2-t1)||(((t2-t1-(abs(m-x)+abs(n-y)))%2)==1)){

			printf("No");

			return 0;

		}

		x=m;

		y=n;

		t1=t2;

	}

	printf("Yes");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int a=0,b=0,n,t,x,y,z,l=0;



int main()

{

	cin>>n;

	

	for(int i=1;i<=n;i++)

	{

	cin>>t>>x>>y;

	z=(x-a)+(y-b);

	if(z<=t && (t-z)%2==0)  	l++;

    }

    

    if(l==n)	cout<<"Yes";

    else

    {

		cout<<"No";	

	}

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h> 

#define N 100000

using namespace std;

bool flag=1;

int n,a[N|1],b[N|1],c[N|1];

int main() {

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d%d%d",c+i,a+i,b+i);

		if(abs(a[i]-a[i-1])+abs(b[i]-b[i-1])>c[i]-c[i-1])

			flag=0;

		if(abs(abs(a[i]-a[i-1])+abs(b[i]-b[i-1])-(c[i]-c[i-1]))&1)

			flag=0;

	}

	if(flag)	puts("Yes");

	else		puts("No");

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc089.contest.atcoder.jp/tasks/arc089_a>

問題文============================================================

 シカのAtCoDeerくんは二次元平面上で旅行をしようとしています。

 AtCoDeerくんの旅行プランでは、時刻 0 に 点 (0,0) を出発し、

 1 以上 N 以下の各 i に対し、時刻 ti に 点 (xi,yi) を訪れる予定です。

 

 AtCoDeerくんが時刻 t に 点 (x,y) にいる時、

 時刻 t+1 には 点 (x+1,y), (x−1,y), (x,y+1), (x,y−1) のうちいずれかに存在することができます。

 その場にとどまることは出来ないことに注意してください。

 AtCoDeerくんの旅行プランが実行可能かどうか判定してください。



=================================================================



解説=============================================================



 次地点に時間が間に合わない時はいうまでもなく no

 時間が間に合う時、

     シカは同一地点に留まることができないので、

     次地点に到達した時の残り時間が偶数のとき、時間ぴったしに到達できる

 

================================================================

*/

struct plan{

    int t,x,y;

    plan():t(0),x(0),y(0){}

};

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N; cin >> N;

    vector<plan> P(N+1);

    for(int i = 1; i <= N;i++) cin >> P[i].t >> P[i].x >> P[i].y;

    for(int i = 1; i <= N;i++){

        int diff = abs(P[i].x - P[i-1].x) + abs(P[i].y - P[i-1].y);

        if(diff > P[i].t - P[i-1].t){

            cout << "No" << endl;

            return 0;

        }else{

            if((P[i].t - P[i-1].t - diff )% 2 != 0){

                cout << "No" << endl;

                return 0;

            }

        }

    }

    cout << "Yes" << endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<cstdio>

#include<algorithm>

using namespace std;

const int maxn = 1010;

const int INF = 0x3f3f3f3f;

int main()

{

    int n;

    cin>>n;

    int nx=0,ny=0,nt=0,flag=0;

    while(n--){

        int t,x,y;

        cin>>t>>x>>y;

        int need = abs(nx-x)+abs(ny-y);

//        cout<<need<<endl;

        if(need <= (t-nt) && ((t-nt)-need)%2==0){

            nt=t;

            nx=x;

            ny=y;

        }

        else{

            flag = 1;

        }

    }

    if(!flag)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <map>

#include <set>

#include <stack>

#include <queue>

#include <vector>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

#define ll long long

#define ms(a,b) memset(a,b,sizeof(a))

using namespace std;



const int MAXN=1e5+100;

const int INF=0x3FFFFFFF;

const ll MOD=1e9+7;



int t[MAXN],x[MAXN],y[MAXN];



int main()

{

    int n;

    cin>>n;

    for(int i=1;i<=n;i++)

        cin>>t[i]>>x[i]>>y[i];

    bool flag=1;

    for(int i=1;i<=n;i++)

    {

        int disx=abs(x[i]-x[i-1]);

        int disy=abs(y[i]-y[i-1]);

        int dist=t[i]-t[i-1];

        if(disx+disy>dist||(dist-disx-disy)%2!=0)

        {

            flag=0;

            break;

        }

    }

    if(flag)    cout<<"Yes"<<endl;

    else    cout<<"No"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	int n,k,f,x,y,t,t1,t2;

	cin>>n;

	int a,b;

	a=b=0;

	f=1;

	t1=0;

	while(n--)

	{

		cin>>t2>>x>>y;

		t=t2-t1;

		k=abs(x-a)+abs(y-b);

		if(k<=t)

		{

			a=x;

			b=y;

		}

		else

		{

			f=0;

		}

		if(t%2!=k%2)

		{

			f=0;

		}

		t1=t2;

	}

	if(f)

		cout<<"Yes"<<endl;

	else

		cout<<"No"<<endl;

return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;



int main()

{

	int n;

	cin >> n;

	int T[100000+521],X[100000+521],Y[100000+521];

	for(int i = 1;i <= n;i++)

	{

		cin >> T[i] >> X[i] >> Y[i];

	}

	for(int i = 1;i <= n;i++)

	{

		if(T[i]<X[i]+Y[i])

		{

			cout << "No";

			break;

		}

		if(T[i]>X[i]+Y[i]&&(X[i]+Y[i])%2!=T[i]%2)

		{

			cout << "No";

			break;

		}

		if(i==n)

			cout <<"Yes";

	}

	

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stack>

#include<queue>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<stdlib.h>

using namespace std;

int main()

{

	int n;

	scanf("%d",&n);

	int zuo=0;

	int bushu=0;

	int you=0;

	int f=1;

	int a,b,c;

	for(int i=0;i<n;i++)

	{

		scanf("%d %d %d",&a,&b,&c);

		if(f==0)

		continue;

		int g,h;

		g=abs(b-zuo);

		h=abs(c-you);

		bushu=a-bushu;

		if(b==zuo&&c==you&&bushu%2!=0)

	    {

		   f=0;

		}

		else if((g+h)>bushu)

		{

		   f=0;

	    }

		else if(bushu%2==0&&(g+h)%2!=0)

		{

		   f=0;

		}

		else if(bushu%2!=0&&(g+h)%2==0)

		{

			f=0;

		}

		else

		{

		   zuo=b;

		   you=c;

		   bushu=a;

		}

	}

	if(f==0)

	printf("No\n");

	else if(f==1)

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem: