stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.178752946246849x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.8136438468622085x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 9.797472629912287x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.21872154338394x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.2051713195388025x):
#include<cstdio>

#include<vector>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=100005;

struct point

{

	int t,x,y;

}p[MAXN];

bool cmp(point a,point b)

{

	return a.t<b.t;

}

int n;

int main()

{

	scanf("%d",&n);

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

	{

		scanf("%d %d %d",&p[i].t,&p[i].x,&p[i].y);

	}

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

	int x=0,y=0,t=0;

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

	{

		int a=abs(p[i].x-x)+abs(p[i].y-y);

		int tt=p[i].t-t;

		t=p[i].t;

		x=p[i].x;

		y=p[i].y;

		if(tt<a||((tt-a)%2==1))

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.211706668714544x):
#include<cstdio>

#include<algorithm>

#define MAXN 100006

using namespace std;

int n;

struct node

{

	int t,x,y;

}q[MAXN];

int main()

{

	scanf("%d",&n);

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

		scanf("%d%d%d",&q[i].t,&q[i].x,&q[i].y);

	int ok=1;

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

	{

		int dt=q[i].t-q[i-1].t;

		int dx=abs(q[i].x-q[i-1].x);

		int dy=abs(q[i].y-q[i-1].y);

		if(dt<dx+dy||(dt-dx-dy)%2==1)

		{

			ok=0;

			break;

		}

	}

	if(ok) printf("Yes");

	else printf("No");

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.227499632266602x):
#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");

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.225163883105546x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.293974490690768x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.2367659622026865x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.23735047640419x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.213346043615862x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.282001021112952x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.224921882099006x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.225505074295083x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.2386191484754745x):
#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;

}