akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.stream.Stream;;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = br.readLine().split(" ");
      // int  n = Integer.parseInt(lines[0]);
      int z = Integer.parseInt(lines[1]);

      final Pattern delim = Pattern.compile(" ");
      int d = delim
        .splitAsStream(br.readLine())
        .mapToInt(Integer::parseInt)
        .map(l -> l-z)
        .map(Math::abs)
        .reduce(Main::gcd)
        .getAsInt();
      
      System.out.println(d);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  
  public static int gcd(int x, int y) {
    if( x<y ) {
      int tmp = x; x = y; y = tmp;
    }
    if( (x%y) == 0 ) return y;
    else return gcd(y,x%y);
  }
}

Measured memory_bytes: 39092
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> hs(N);
  for(int i = 0; i < N; ++i) {
    cin >> hs[i];
  }
  sort(hs.begin(), hs.end(), greater<ll>());
  ll ans = 0;
  for(int i = K; i < hs.size(); ++i) {
    ans += hs[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn = 100010;
char a,b;
int main()
{
    cin>>a>>b;
    if(a > b)
        cout<<">"<<endl;
    else
        if(a < b)
            cout<<"<"<<endl;
    else
        cout<<"="<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{   
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        double a, b, arg;
        double s, l, h;
        a = double.Parse(str[0]);
        b = double.Parse(str[1]);
        arg = double.Parse(str[2]) * (Math.PI / 180);

        s = (a * b * Math.Sin(arg)) / 2;
        l = a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(arg));
        h = b * Math.Sin(arg);
     
        Console.WriteLine(string.Format("{0:f6}\n{1:f6}\n{2:f6}", s, l, h));      
    }
}


Measured memory_bytes: 17816
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 1e5 + 5;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

const int w[2][9] = {1, 2, 3, 5, 8, 13, 21, 30, 39, 1, 2, 4, 7, 12, 20, 29, 38, 52};

int n, p[15];
ll e[15][15];


ll calc(int n)
{
	ll Max = 0;
	for (int i = 0; i < n; ++i) p[i] = i;
	do {
		ll sum = 0;
		for (int i = 0; i < n - 1; ++i) sum += e[p[i]][p[i + 1]];
		Max = max(Max, sum);
	} while (next_permutation(p, p + n));
	return Max;
}

int main()
{
	n = gi();
	ll M = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < i; ++j)
			e[i][j] = e[j][i] = w[1][j] * (M + 1);
		M = calc(i + 1);
		//printf("%lld\n", M);
	}
	
	for (int i = 0; i < n; ++i, puts(""))
		for (int j = 0; j < n; ++j)
			printf("%lld ", e[i][j]);
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct Node {
    int parent;
    vi child;
};

vi ancestor;
vector<Node> nodes;

void mark(int v, int pos){
    if(ancestor[pos] == pos) return;

    ancestor[pos] = v;
    
    rep(i, nodes[pos].child.size()){
        mark(v, nodes[pos].child[i]);
    }
}

int main(void){
    ll res;
    for(int n, q; cin >> n >> q, n; cout << res << endl){
        res = 0;
        nodes = vector<Node>(n + 1);
        ancestor = vi(n + 1, 1);

        range(u, 2, n + 1){
            int p; cin >> p;

            nodes[u].parent = p;
            nodes[p].child.pb(u);
        }

        rep(i, q){
            char op; int v; cin >> op >> v;

            if(op == 'M'){
                mark(v, v);
            }
            else {
                res += ancestor[v];
            }
        }
    }

	return 0;
}

Measured memory_bytes: 13416
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d >= k) {
        cout << x - k * d << endl;
        return 0;
    }
    k -= x/d;
    x %= d;
    if(k&1) {
        x -= d;
        x = abs(x);
    }
    cout << x << endl;
}

Measured memory_bytes: 3664
/**
 * @Author:      H S-J
 * @DateTime:    2017-09-16 20:01:10
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
int main(int argc, char const *argv[]) {
	// ios::sync_with_stdio(0);cin.tie(0);
	int a[11111111], k, n;
	while (cin >> n >> k) {
        rep (i, 0, n) cin >> a[i];
        int ans = 0;
        rep (i, 0, n) {
            ans += min((2 * (k - a[i])), (2 * (a[i])));
        }
        cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
ll n;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n;
	if (n%(MOD-7)==0) cout<<"0 0 0 "<<MOD-7<<" "<<n/(MOD-7)<<" 0\n";
	else cout<<"0 0 "<<MOD-7<<" 1 "<<(MOD-7)-n%(MOD-7)<<' '<<(n+999999999)/(MOD-7);
}




Measured memory_bytes: 256
import sys
s = (input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ls = ["+","-"]
ans = a+b+c+d
if ans == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a+b+c-d
if ans == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a+b-c+d
if ans == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a-b+c+d
if ans == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a-b-c+d
if ans == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a+b-c-d
if ans == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a-b+c-d
if ans == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a-b-c-d
if ans == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    sys.exit()

Measured memory_bytes: 38256
/* 

	 - If you fail to prepare, you are prepared to fail.	

	(C) Mark Spitz

*/

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

using ll = long long;

const bool dbg_flg = 1;
#define NAME(x) #x
#define debug if (dbg_flg) cerr

const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

int n, m;
ll h[MAXN];
bool bad[MAXN];

void solve() {
	cin >> n >> m;
	
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}

	while (m--) {
		int a, b;

		cin >> a >> b;

		if (h[a] >= h[b]) bad[b] = 1;
		if (h[a] <= h[b]) bad[a] = 1;
	}

	int res = 0;

	for (int i = 1; i <= n; i++) {
		res += (bad[i] ^ 1);
	}

	cout << res;
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 4532
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

typedef long long ll;

queue<char> qa;
queue<char> qb;
queue<char> qc;

string sa, sb, sc;
void pushData() {

    int i;
    for (i = 0; i < sa.length(); i++)
        qa.push(sa[i]);

    for (i = 0; i < sb.length(); i++)
        qb.push(sb[i]);

    for (i = 0; i < sc.length(); i++)
        qc.push(sc[i]);

}

int main() {

    cin >> sa >> sb >> sc;


    pushData();

    char turnIndex = 'a';
    turnIndex = qa.front();
    qa.pop();

    while (1) {
        if (turnIndex == 'a') {
            if (qa.empty() && turnIndex == 'a') {
                cout << "A"; break;
            }
            turnIndex = qa.front();
            qa.pop();

        }

        else if (turnIndex == 'b') {
            if (qb.empty() && turnIndex == 'b') {
                cout << "B"; break;
            }
            turnIndex = qb.front();
            qb.pop();

        }

        else if (turnIndex == 'c') {
            if (qc.empty() && turnIndex == 'c') {
                cout << "C"; break;
            }
            turnIndex = qc.front();
            qc.pop();

        }

    }



    return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int l, r, d; cin >> l >> r >> d;
	cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3592
import heapq
n, m = map(int, input().split())
a = [i*-1 for i in list(map(int, input().split()))]
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a)*-1
    heapq.heappush(a, (x//2)*-1)
print(sum(a)*-1)

Measured memory_bytes: 20332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pb push_back
#define mk make_pair
int main(){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x;
  cin>>x;
  ll a=100;
  ll ans=0;
  while(a<x){
	  a=a+a*1/100;
      ans++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {

    ll K,N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

    sort(ALL(A));

    ll ANS = INF;
    REP(i,N-1) {
        // その地点と次の地点の大きく結ぶ
        chmin(ANS,K-(A[i+1]-A[i]));
    }
    // corner
    chmin(ANS,A[N-1]-A[0]);
    cout << ANS << endl;

}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 1792
// Problem : D - Lunlun Number
// Contest : AtCoder - AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll k;
    cin>>k;
    queue<ll> q;
    vector<ll> v;
    rep(i,1,10)
    {
    	q.push(i);
    	v.pb(i);
    }
    ll cnt=0;
    ll u,x;
    while(cnt<k+10)
    {
    	u=q.front();
    	q.pop();
    	x=u%10;
    	if(x!=0)
    	{
    		q.push(u*10+x-1);
    		v.pb(u*10+x-1);
    		cnt++;
    	}
    	q.push(u*10+x);
    	v.pb(u*10+x);
    	cnt++;
    	if(x!=9)
    	{
    		cnt++;
    		q.push(u*10+x+1);
    		v.pb(u*10+x+1);
    	}
    }
    cout<<v[k-1];
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1656
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	while(cin>>S) {
		ll ans = INF;
		REP(bi, 2) {
			ll lans = 0;
			REP(i, S.size()) {
				lans += (S[i]-'0') != ((i&1)^bi);
			}
			minUpdate(ans, lans);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 1e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

vector<int>adj[nmax];
int inDegree[nmax];
int dist[nmax];

void dfs(int u)
{
    for(int v:adj[u])
    {
        dist[v] = max(dist[v] , dist[u]+1);
        inDegree[v]--;

        if(inDegree[v]==0)
            dfs(v);
    }
}

int main()
{
    optimizeIO();

    int n,m;
    cin>>n>>m;

    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        inDegree[b]++;
    }

    for(int i=1;i<=n;i++)
    {
        adj[0].push_back(i);
        inDegree[i]++;
    }

    dfs(0);

    int ans = 0;

    for(int i=1;i<=n;i++)
        ans = max(ans,dist[i]);

    cout<<ans-1<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vi p(A), q(B);
    priority_queue<int> r;
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) {
        int R;
        cin >> R;
        r.push(R);
    }
    GSORT(p); GSORT(q);
    priority_queue<int, vi, greater<int>> que;
    int res = 0;
    rep(i, X) {que.push(p[i]); res+=p[i];}
    rep(i, Y) {que.push(q[i]); res+=q[i];}

    while(!r.empty() && !que.empty()) {
        int t = que.top();
        que.pop();
        res -= t;
        int tr = r.top();
        r.pop();
        if(t < tr) {
            res += tr;
        } else res += t;
    }

    cout << res << endl;
    
 
    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
	int N; cin >> N;
	vector<ll> P, M;
	rep(i,N){
		ll a; cin >> a;
		if(a>0){
			P.push_back(a);
		}else{
			M.push_back(-a);
		}
	}
	sort(all(P), greater<ll>());
	sort(all(M), greater<ll>());
	ll x[N-1], y[N-1]; ll ans;
	int i = 0;
	if(N==2){
		if((P.size()==1)&&(M.size()==1)){
			cout << P[0]+M[0] << endl;
			cout << P[0] << ' ' << -M[0] << endl;
		}else if(P.size()==2){
			cout << P[0]-P[1] << endl;
			cout << P[0] << ' ' << P[1] << endl;
		}else{
			cout << M[0]-M[1] << endl;
			cout << -M[1] << ' ' << -M[0] << endl;
		}
	}else{
		if(P.size()==0){
			x[i] = -M[M.size()-1]; y[i] = -M[M.size()-2];
			P.push_back(x[i]-y[i]);
			remove(M, M.size()-1); remove(M, M.size()-1);
			i++;
		}
		if(M.size()>0){
			while(P.size()>1){
				x[i] = -M[0]; y[i] = P[0];
				M.push_back(M[0]+P[0]);
				remove(P, 0); remove(M, 0);
				i++;
			}
			while(i<N-1){
				x[i] = P[0]; y[i] = -M[0];
				P[P.size()-1] += M[0];
				remove(M, 0);
				i++;
			}
		}else{
			// if(N%2==1){
			// 	while(P.size()>1){
			// 		x[i] = P[P.size()-1]; y[i] = P[0];
			// 		remove(P, P.size()-1); remove(P, 0);
			// 		M.push_back(y[i]-x[i]);
			// 		i++;
			// 	}
			// 	while(M.size()>0){
			// 		x[i] = P[0]; y[i] = -M[0];
			// 		P[0] = x[i] - y[i];
			// 		remove(M, 0);
			// 		i++;
			// 	}
			// }else{
			// 	while(P.size()>0){
			// 		x[i] = P[P.size()-1]; y[i] = P[0];
			// 		M.push_back(y[i]-x[i]);
			// 		i++;
			// 		remove(P, P.size()-1); remove(P, 0);
			// 	}
			// 	sort(all(M), greater<ll>());
			// 	x[i] = -M[M.size()-1]; y[i] = -M[0];
			// 	P.push_back(x[i]-y[i]);
			// 	remove(M, M.size()-1); remove(M, 0);
			// 	i++;
			// 	while(M.size()>0){
			// 		// x[i] = -M[M.size()-1]; y[i] = -M[0];
			// 		// P.push_back(x[i]-y[i]);
			// 		// remove(M, M.size()-1); remove(M, 0);
			// 		// i++;
			// 		x[i] = P[0]; y[i] = -M[0];
			// 		P[0] += M[0];
			// 		remove(M, 0);
			// 		i++;
			// 	}
			// }
			x[i] = P[P.size()-1]; y[i] = P[P.size()-2];
			M.push_back(y[i]-x[i]);
			remove(P, P.size()-1); remove(P, P.size()-1);
			i++;
			while(P.size()>1){
				x[i] = -M[0]; y[i] = P[P.size()-1];
				M[0] += P[P.size()-1];
				i++;
				remove(P, P.size()-1);
			}
			x[i] = P[0]; y[i] = -M[0];
			P[0] += M[0];
		}

		cout << P[P.size()-1] << endl;
		rep(i,N-1){
			cout << x[i] << ' ' << y[i] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4340
from collections import Counter
N = int(input())

march = ("M", "A", "R", "C", "H")
cnt = Counter()
for _ in range(N):
    S = input()
    if S[0] in march:
        cnt[S[0]] += 1

res = 0

for m in range(2):
    for a in range(2):
        for r in range(2):
            for c in range(2):
                for h in range(2):
                    if m+a+r+c+h == 3:
                        x = 1
                        if m:
                            x *= cnt["M"]
                        if a:
                            x *= cnt["A"]
                        if r:
                            x *= cnt["R"]
                        if c:
                            x *= cnt["C"]
                        if h:
                            x *= cnt["H"]
                        res += x

print(res)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
vector<vector<int>> mem[301];
vector<int> v;
int k, n;
ll mod=998244353;
ll dp(int x, int y, int nm){
	// cout<<x<<" "<<y<<" "<<nm<<endl;
	if(nm>k){
		return 0;
	}
	// cout<<"###"<<v[x]<<endl;
	if(x+2==v.size()){

        // cout<<x<<" "<<y<<" "<<nm<<" "<<1<<endl;
		// cout<<"##"<<endl;
		return 1;
	}
	if(mem[x][y][nm]!=-1){
		return mem[x][y][nm];
	}
	// cout<<"EE"<<endl;
	ll res=0;
    for(int i=y+1; i<=y+v[x+1]-v[x]-1; ++i){
        res+=dp(x+1, i, nm+i-y);
        res%=mod;
    }
    for(int i=0; i<=y; ++i){
        res+=dp(x+1, i, nm);
        res%=mod;
    }
    // cout<<x<<" "<<y<<" "<<nm<<" "<<res<<endl;
	mem[x][y][nm]=res;
	return res;
}
char s[333];
int main(){
        ll ans=0;
        scanf("%s%d",s,&k);
        n=strlen(s);
        reverse(s, s+n);
        ll tmp=0, tmp1=0;
        for(int i=0; i<n; ++i){
        	if(s[i]=='0'){
        		int ii=v.size();
        		mem[ii].resize(tmp+5);
        		tmp1+=tmp;
        		for(int j=0; j<tmp+2; ++j){
        			mem[ii][j].resize(tmp1+5);
        			for(int l=0; l<mem[ii][j].size(); ++l){
        				mem[ii][j][l]=-1;
        			}
        		}
        		v.push_back(i);
        	}
        	else{
        		++tmp;
        	}
        }
        if(v.size()==0){
        	cout<<1<<endl;
        	return 0;
        }
        v.push_back(n);
        // for(auto it:v){
        // 	cout<<it<<endl;
        // }
        for(int i=0; i<n; ++i){
        	if(s[i]=='0'){
        		ans+=dp(0, 0, 0);
        		break;
        	}
        	ans+=dp(0, i+1, i+1);
            ans%=mod;
        }
        ans%=mod;
        printf("%lld\n",ans);
    // }
  return 0;
}




Measured memory_bytes: 973944
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;
const int maxlen = 100001;
const int p = 1000000007;

ll f[maxlen];

void fac(int n) {
	f[0] = 1; f[1] = 1;
	for (int i = 2; i <= n; i++) 
		f[i] = (f[i - 1] % p)* (i % p) % p;
}

ll fastpow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % p;
		b >>= 1;
		a = a * a % p;
	}
	return res;
}

ll A(int n, int m) {
	return (f[n] % p) * (fastpow(f[n - m], p -2) % p) % p;
}

int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0 << endl;
	}
	else {
		int maxv = max(n, m);
		int minv = min(n, m);
		fac(1ll * maxv);
		ll res = A(maxv, maxv);
		res = res * A(minv, maxv - 1) % p;
		if (maxv == minv) {
			res = 2 * res % p;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if     ( (a-b) > 0 ) printf("a > b\n");
    else if( (a-b) < 0 ) printf("a < b\n");
    else                 printf("a == b\n");
    
    return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int[][] p = new int[n][d];
        for(int i = 0;i < n;i++){
            for(int j = 0;j < d;j++){
                p[i][j] = sc.nextInt();
            }
        }

        int ans = 0;
        for(int i = 0;i < n;i++) {
            for (int j = i+1; j < n; j++) {
                int dis = 0;
                for(int k = 0;k < d;k++){
                    dis += Math.pow(p[i][k]-p[j][k], 2);
                }
                double sqrt = Math.sqrt((double)dis);
                if((double)((int)sqrt) == sqrt){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }

}



Measured memory_bytes: 23636
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
typedef long long LL;
LL dp[5];
int main(void){
	int n,p;
	scanf("%d%d",&n,&p);
	dp[0]=1;
	for (int i=1;i<=n;++i){
		int t;
		scanf("%d",&t);
		t&=1;
		if (t){
			dp[1]+=dp[0];
			dp[0]=dp[1];
		}
		else{
			dp[0]<<=1;
			dp[1]<<=1;
		}
	}
	printf("%lld\n",dp[p]);
	return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  std::cin >> N;

  std::vector<int> v;
  int x;
  int A[N];
  for (size_t i = 0; i < N; i++) {
    std::cin >> x;
    A[i] = x;
    v.push_back(x);
  }
  sort(v.begin(),v.end());

  for (size_t i = 0; i < N; i++) {
    if (A[i] <= v[(N-1)/2]) {
      std::cout << v[(N+1)/2] << '\n';
    }else{
      std::cout << v[(N-1)/2] << '\n';
    }
  }

  return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);
  
  sort(p.begin(), p.end());
  
  int sum = 0;
  rep(i,k) 
  {
    sum += p.at(i);
  }

  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int a,b,t;
    while(1){
        cin>>a>>b;
        if(a==0){
            if(b==0){
                break;
            }
        }
        if(a>b){
            t=a;
            a=b;
            b=t;
        }
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  int n;
  cin >> n;
  bool ans = true;
  int t,x,y;
  int time = 0;
  int dx = 0;
  int dy = 0;
  rep(i,n){
    cin >> t >> x >> y;
    time = abs(time-t);
    dx = abs(dx - x);
    dy = abs(dy - y);
    if(time < (dx+dy)) ans = false;
    if(time %2 != (dx+dy) %2 ) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;

}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;

int t, n, m;
string a, b;
pair<int,int> rodzic[3005][3005];
int dp[3005][3005];
vector<char> ciag;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>a;
    cin>>b;
    
    for( int i=1; i<=a.size(); i++ )
    {
        for( int j=1; j<=b.size(); j++ )
        {
            if( a[i-1]==b[j-1] )
            {
                dp[i][j]=dp[i-1][j-1]+1;
                rodzic[i][j].first=i-1;
                rodzic[i][j].second=j-1;
            }
            else
            {
                int x=dp[i-1][j], y=dp[i][j-1];
                dp[i][j]=max( x, y );
                if( x>y  )
                {
                    rodzic[i][j].first=i-1;
                    rodzic[i][j].second=j;
                }
                else{
                    rodzic[i][j].first=i;
                    rodzic[i][j].second=j-1;
                }
            }
        }
    }
    
    int x=a.size(), y=b.size();
    while(  x!=0 and y!=0 )
    {
        pair<int,int> pole=rodzic[x][y];
        if( a[x-1]==b[y-1] ) ciag.push_back( a[x-1] );
        x=pole.first;
        y=pole.second;
    }
    for( int i=ciag.size()-1; i>=0; i-- )
        cout<<ciag[i];

}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insertKey(int key) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node* findKey(Node *u, int key) {
    while (u != NIL && u->key != key) {
        if (key < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }
    return u;
}

Node* getMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node* getSuccessor(Node *z) {
    if (z->right != NIL) return getMinimum(z->right);
    Node *y = z->parent;
    while (y != NIL && z == y->right) {
        z = y;
        y = y->parent;
    }
    return y;
}

Node* deleteNode(Node *z) {
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL) y = z;
    else y = getSuccessor(z);

    if (y->left != NIL) x = y->left;
    else x = y->right;

    if (x != NIL) x->parent = y->parent;

    if (y->parent == NIL) root = x;
    else if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;

    if (y != z) z->key = y->key;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int m, k;
    string com;
    cin >> m;
    
    REP(i,m) {
        cin >> com;
        if (com == "print") {
            inorder(root);
            cout << '\n';
            preorder(root);
            cout << endl;
        } else {
            cin >> k;
            if (com == "insert") insertKey(k);
            else if (com == "find") {
                if (findKey(root, k) != NIL) cout << "yes" << endl;
                else cout << "no" << endl;
            } else {
                deleteNode(findKey(root, k));
            }
        }
    }
}


Measured memory_bytes: 21964
from collections import defaultdict

N = int(input())
D = list(map(int, input().strip().split()))
d_dict = defaultdict(lambda:0)
for d in D:
    d_dict[d] += 1
del D
M = int(input())
T = list(map(int, input().strip().split()))

for t in T:
    if t not in d_dict:
        break
    else:
        tmp = d_dict[t]
        if tmp == 0:
            break
        else:
            d_dict[t] -= 1
else:
    print('YES')
    exit()
print('NO')
exit()


Measured memory_bytes: 45792
import itertools

n = int(input())
tt = [[] for _ in range(n + 1)]
for i in range(n ):
	j = int(input())
	for _ in range(j):
		a, b = list(map(int, input().split()))
		tt[i].append([a - 1, b])

#print(tt)
max_ans = 0
for xx in list(itertools.product([0, 1], repeat = n)):
	flg = 1
	for i in range(n):
		x = xx[i]
		if x == 1:
			for t in tt[i]:
				if xx[t[0]] != t[1]:
					flg = 0
					break
	if flg == 1:
		#print(xx)
		max_ans = max(max_ans, sum(xx))

print(max_ans)



Measured memory_bytes: 8892
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  ULL a, b, x;
  cin >> a >> b >> x;

  ULL ans = b / x - a / x;
  if(a % x == 0) ans++;
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n== 0 and x == 0:
        break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::pow;
using std::min;

typedef long long ll;

int main() {
  int n;
  long long cost = 10000000;

  cin >> n;

  long long a[n];

  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    a[i] = num;
  }

  for (int i = -100; i < 101; i++) {
    long long t = 0;
    for (int j = 0; j < n; j++) {
      long long diff = a[j] - i;
      t += pow(diff, 2);
    }
    cost = min(cost, t);
  }
  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool vis[1000006];
vector<long long>prime;
void sieve() {
    prime.push_back(2);
    for(int i=3; i<=1000000; i+=2) {
        if(!vis[i]) {
            prime.push_back(i);
            for(long long j=i*1LL*i; j<=1000000; j+=(i<<1)) {
                vis[j]=1;
            }
        }
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    sieve();
    long long n;
    cin>>n;
    int ans=0;
    for(int i=0; i<(int)prime.size() && prime[i]*prime[i]<=n; i++) {
        if(n%prime[i]==0) {
            long long x=prime[i];
            while(n%x==0) {
                n/=x;
                ans++;
                x*=prime[i];
            }
            while(n%prime[i]==0) n/=prime[i];
        }
    }
    if(n>1) ans++;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5232
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int main(){
  int n;
  int point[100005];
  long long minimum=LLONG_MAX;
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>point[i];
  }
  
  sort(point,point+n);
  
  for(int i=point[0];i<=point[n-1];i++){
    long long sum=0;
    for(int j=0;j<n;j++){
      sum+=(point[j]-i)*(point[j]-i);
    }
    minimum=min(minimum,sum);
  }
  cout<<minimum<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(void){
  string s;
  char c='\0';
  int a[200010]={0},l=0;
  int spFlg=0;
  
  cin >> s;
  for (int i=0; i<s.size(); i++){
    if (s[i]!=c){
      a[l++]=1;
      c = s[i];
    } else {
      a[l-1]++;
    }
  }
//  for (int i=0; i<l; i++) cout << " " << a[i];
//  cout << endl;
  for (int i=0; i<l; i+=2){
    for (int j=0; j<a[i]-1; j++){
      if (spFlg) cout << " ";
      else spFlg = 1;
      cout << 0;
    }
    if (spFlg) cout << " ";
    else spFlg = 1;
    cout << (a[i]/2+a[i]%2+a[i+1]/2);
    cout << " " << (a[i]/2+a[i+1]%2+a[i+1]/2);
    for (int j=0; j<a[i+1]-1; j++){
      cout << " " << 0;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1408