akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define int int64_t
#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define all(v) v.begin(), v.end()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}



void solve(){
    ll n;
    cin >> n;
ll    a[n+1];
    mem(a, 0);

    rep(i, n-1)
    {
        ll x; cin >> x;
        a[x]++;
    }
    for(ll i = 1; i <= n; i++)cout << a[i] << endl;
}

main(){
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 5156
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	int k = d / s;
	//cout << k;
	if (k >= t) {
		if (k==t && d % s == 0) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		cout << "Yes";
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll a[100000];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	ll ans=0;
	rep(i,N){
		ans+=a[i]/2;
		a[i]%=2;
		if(i<N-1&&a[i]==1&&a[i+1]>0){
			a[i]--,a[i+1]--;
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

long long e = pow(10, 18);

int main() {
    int n;
    cin >> n;
    long long res = 1;
    bool neg = false;

    for (int i = 0; i < n; i++) {
        long long a;
        cin >> a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (neg || (e+1)/res < a || res*a > e) {
            neg = true;
        }
        res *= a;
    }
    if (neg) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }

    return 0;
}


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

int n;
bool M[101010]={};
ll dp[101010]={};
ll cnt=0;


int main(){
   int m;
   cin>>n>>m;
   int a;
   M[n+1]=1;
   rep(i,m){
      cin>>a;
      M[a]=1;
   }
   dp[0]=1;
   dp[1]= !M[1];
   rep(i,n-1){
      if(!M[i+2])
      dp[i+2]=dp[i]+dp[i+1];
      dp[i+2]%=1000000007;
   }
   cout<<dp[n]<<endl;
   return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
	int n;
	scanf("%d",&n);
	int a;
	unordered_map<int,int> m;
	for(int i=0;i<n;++i){
		scanf("%d",&a);
		++m[a];
	}
	bool chk=false;
	for(unordered_map<int,int>::iterator it=m.begin();it!=m.end();++it){
		if(it->second%2==0){
			chk=!chk;
		}
	}
	if(chk)
		printf("%d",m.size()-1);
	else
		printf("%d",m.size());
	return 0;
}

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

using namespace std;

#define INF (int)(1e9)

// Relevant constraints
// 2 <= N <= 10^5
// 1 <= K <= 100
// 2 secs

// Generalized version of frog1
// to K possible steps instead of 2
// Naturally, this turns the complexity
// required from O(n) to O(nK)
// This is acceptable for our constraints

// Recurrence to optimize:
// c(n) = min({c(n - 1) + cost(n, n - 1), c(n - 2) + cost(n, n - 2), ...,
//             c(n - k) + cost(n, n - k)})

// It doesn't matter how we use K in the future
// so that parameter is irrelevant for larger values
// and doesn't need to be stored
unordered_map<int, int> map_dp;
int solve_memo(const vector<int> &h, int n, int k) {
	if (n < 0)
		return INF;
	if (n == 0)
		return 0;
	if (map_dp.find(n) != map_dp.end())
		return map_dp[n];

	int min_n = INF;
	for (int i = 1; i <= k; ++i) {
		// don't access h out of bounds
		if (n - i < 0)
			break;

		min_n = min(min_n,
			    solve_memo(h, n - i, k) + abs(h[n] - h[n - i]));
	}

	return map_dp[n] = min_n;
}

int solve_tab(const vector<int> &h, int n, int k) {
	vector<int> dp(n);

	// Initial conditions
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for (int i = 2; i < n; ++i) {
		int min_n = INF;
		for (int j = 1; j <= k; ++j) {
			if (i - j < 0)
				break;

			min_n = min(min_n, dp[i - j] + abs(h[i] - h[i - j]));
		}
		dp[i] = min_n;
	}

	// dp[n - 1] represents the minimum cost
	// to get to stone n
	// in general dp[i] represents the minimum
	// cost to get to stone i
	return dp[n - 1];
}

int main() {

	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;

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

	// n - 1 to accomodate the array size
	// cout << solve_memo(h, n - 1, k) << '\n';
	cout << solve_tab(h, n, k) << '\n';

	return 0;
}


Measured memory_bytes: 1024
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<int> C;
#define X real()
#define Y imag()
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
int n,mw;
cin>>n>>mw;
int w[n],v[n];
for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];

int tv=0;
for(int i=0;i<n;i++)
tv+=v[i];

int dp[tv+2];
for(int i=1;i<=tv;i++)
dp[i]=1000000000;
dp[0]=0;
for(int i=0;i<n;i++)
{
	int we=w[i];
	int ve=v[i];
	for(int j=tv;j>=ve;j--)
	dp[j]=min(dp[j],dp[j-ve]+we);
}

for(int i=tv;i>=0;i--)
{
	if(dp[i]<=mw)
	{
		cout<<i;
		break;
	}
}

}return 0;}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 x ; cin >> x;

  i64 i = 1;
  i64 sum = 0;
  for (i = 1; sum < x; ++i) {
    sum += i;
  }

  cout << i-1 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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 SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 

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

    ll N; cin >> N;
    vector<pair<ll,ll>> vp(N);
    ll ans = N*(N+1)*(N+2)/6;
    REP(i,N-1){
      cin >> vp[i].first >> vp[i].second;
      if(vp[i].first > vp[i].second) swap(vp[i].first, vp[i].second);
      ans -= (vp[i].first) * (N-vp[i].second+1);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[175000];
int main()
{
   int n;
   cin>>n;
   int limitA,limitB;
   cin>>limitA>>limitB;
   for(int i=0;i<n;i++)
    cin>>a[i];
   int cnt1=0,cnt2=0,cnt3=0;
   for(int i=0;i<n;i++)
   {
       if(a[i]<=limitA)
        cnt1++;
       else if(a[i]>=limitA+1&&a[i]<limitB+1)
        cnt2++;
       else
        cnt3++;
   }
   cout<<min(min(cnt1,cnt2),min(cnt2,cnt3))<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef int64_t ll;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = true;
    while(a > 0 && c > 0) {
        if(flag) {
            flag = false;
            c -= b;
        }
        else {
            flag = true;
            a -= d;
        }
    }
    if(a <= 0) cout << "No";
    else cout << "Yes";
}    

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll A, B, C;

int main() {
    cin >> A >> B >> C;
    set<tuple<ll, ll, ll>> s;
    ll res = 0;
    while (!s.count(make_tuple(A, B, C))) {
        if (A % 2 || B % 2 || C % 2) {
            cout << res << endl;
            return 0;
        }
        s.insert(make_tuple(A, B, C));
        res++;
        ll a = B / 2 + C / 2, b = A / 2 + C / 2, c = A / 2 + B / 2;

        A = a, B = b, C = c;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(arg) {
    arg = arg.trim().split('\n');
    // 商品の種類
    n = arg[0].trim().split(' ')[0];
    // 人気商品M個 
    m = arg[0].trim().split(' ')[1];
    // 各商品の投票数
    a = arg[1].trim().split(' ').sort(
        (a,b)=>{
            return b - a
        });

    if(a[m-1]){
        sum = 0;
        for(i=0;i<a.length;i++){
            sum+=Number(a[i]);
        }
        if(a[m-1]>=sum/(4*m)){
            console.log("Yes")
            return
        }

    }
    console.log("No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;



int main(){
   ll n,cnt=0;
   string s;
ll ans[10101]= { };
cin>>n;
REP(i,1,101) {  
REP(j,1,101) {  
REP(k,1,101) {  
if(i*i+j*j+k*k+j*k+j*i+i*k>n)break;
ans[i*i+j*j+k*k+j*k+j*i+i*k]++;
}
} 
}

rep(i,n) {
cout<<ans[i+1]<<endl;
}

   
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int MOD = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int a, b;
    cin >> a >> b;

    if(a > b){
        for(int i = 0; i < a; i++) cout << b;
    }else{
        for(int i = 0; i < b; i++) cout << a;
    }




    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double m1, m2;
    
    int n;
    scanf("%d", &n);
    while (n != 0){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        m1 = (y2 - y1) / (x2 - x1);
        m2 = (y4 - y3) / (x4 - x3);
        (m1 == m2) ? printf("YES\n") : printf("NO\n");
        n--;
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

void  bubbleSort(double number[], int length);



int main() {

	double  N, v[102];

	scanf("%lf", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &v[i]);
	}




	for (int i = N-1; i>0; i--) {
		bubbleSort(v, (int)N);
		v[i - 1] = (v[i - 1] + v[i]) / 2;
	}
	printf("%f", v[0]);




}


//---配列を降順ソート（だんだん小さくなる）----
void  bubbleSort(double number[], int length) {
	for (int i = 0; i < length; i++)
		for (int j = i + 1; j < length; j++)
			if (number[i] < number[j]) {
				double tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define llint long long
#define mod 1000000007
#define inf 1e18

using namespace std;
typedef pair<double, llint> P;
typedef pair<llint, P> E;

llint n;
llint dp[63][2][2][2];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i <= 62; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l < 2; l++){
					dp[i][j][k][l] = 0;
				}
			}
		}
	}
	
	dp[0][0][0][0] = 1;
	for(int i = 0; i < 62; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l < 2; l++){
					for(int s = 0; s < 2; s++){
						for(int t = 0; t < 2; t++){
							if(s == 1 && t == 0) continue;
							//if(i == 0 && s != t) continue;
							int u = s ^ t, v = (j+s+t) % 2;
							int nk = k, nl = l;
							if((n&(1LL<<i)) && u == 0) nk = 0;
							if(((n&(1LL<<i)) == 0) && u == 1) nk = 1;
							if((n&(1LL<<i)) && v == 0) nl = 0;
							if(((n&(1LL<<i)) == 0) && v == 1) nl = 1;
							(dp[i+1][(j+s+t)/2][nk][nl] += dp[i][j][k][l]) %= mod;
						}
					}
				}
			}
		}
	}
	cout << dp[62][0][0][0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<int> k={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;cin >> n;
  cout << k[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,a;
  cin>>n>>a;
  cout<<(n+(a-1))/a<<endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int x, y, s;
  char gomi;
  vvi t(10, vi(10));
  while (cin >> x >> gomi >> y >> gomi >> s) {
    t[x][y]++;
    switch (s) {
      case 3:
        if (x > 1) t[x - 2][y]++;
        if (x < 8) t[x + 2][y]++;
        if (y > 1) t[x][y - 2]++;
        if (y < 8) t[x][y + 2]++;
      case 2:
        if (x > 0 && y > 0) t[x - 1][y - 1]++;
        if (x > 0 && y < 9) t[x - 1][y + 1]++;
        if (x < 9 && y > 0) t[x + 1][y - 1]++;
        if (x < 9 && y < 9) t[x + 1][y + 1]++;
      case 1:
        if (x > 0) t[x - 1][y]++;
        if (x < 9) t[x + 1][y]++;
        if (y > 0) t[x][y - 1]++;
        if (y < 9) t[x][y + 1]++;
    }
  }
  int c = 0, maxi = 0;
  rep(i, 10) rep(j, 10) {
    c += !t[i][j];
    cmax(maxi, t[i][j]);
  }
  cout << c << endl
       << maxi << endl;
}

Measured memory_bytes: 3028
#include <stdio.h>

int main() {
  int a, b, k;

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

  int cnt = 0;

  for (int i = 100; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) cnt++;

    if (cnt == k) {
      printf("%d", i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N=int(input())
D=[tuple(map(int,input().split())) for i in range(N)]
flag=0

for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        flag=1

if flag==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <set>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

class UnionFind{
    public:
    vector<int> parent;

    UnionFind(int N = 0) : parent(N, -1){}

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return;
        if(parent[x] > parent[y]) swap(x,y);

        parent[x] += parent[y];
        parent[y] = x;
    }
    
    bool same(int x, int y){ return (root(x) == root(y));}

    int size(int x){ return -parent[root(x)];}
};

int main(void){
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    REP(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a,b);
    }

    int ans = -1;
    REP(i,n){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;

    ll ans;
    // 前のマスの状態を記憶しておく
    // 1 : 縦に1つのドミノがある場合
    // 2 : 横に2つのドミノが並んでいる場合
    int prevState;
    REP(i, N)
    {
        // 初期状態
        if (i == 0)
        {
            if (S1[i] == S2[i])
            {
                ans = 3;
                prevState = 1;
            }
            else
            {
                ans = 6;
                prevState = 2;
                // 横に2マス並んでいるのでi を1増やす
                i++;
            }
        }
        else
        {
            if (S1[i] == S2[i])
            {
                if (prevState == 1)
                {
                    ans = ans * 2 % MOD;
                }
                else
                {
                    ans = ans;
                }
                prevState = 1;
            }
            else
            {
                if (prevState == 1)
                {
                    ans = ans * 2 % MOD;
                }
                else
                {
                    ans = ans * 3 % MOD;
                }
                prevState = 2;
                // 横に2マス並んでいるのでi を1増やす
                i++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")
// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1), ans(Q);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];
   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());
   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }
   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);
   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);
   BIT<int> bit(N);
   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }
   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      {
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }
      if (pos[c[l]].empty())
         continue;
      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }
   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62624
import java.util.*;

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        if(Math.abs(a[0]-a[2])<Math.abs(a[0]-a[1]))System.out.println("B");
        else System.out.println("A");
    }
}

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

int mem[100050];

int main()

{
	int a[100050];
	int n,k;
	
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
	cin>>a[i];
	
	mem[n-1] = abs(a[n] - a[n-1]);
	mem[n] = 0;
	
	
	for(int i=n-2;i>0;i--)
	{
		
		mem[i] = INT_MAX;
		
		for(int j=1;j<=k;j++)
		{
			if((i+j) > n)
			break;
			
			mem[i] = min (mem[i] , abs (a[i+j] - a[i]) + mem[i+j]);
		}
		
	}
	
	cout<<mem[1];
	
	
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

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

		for ( int i=0; i<n-k; i++ ) {
			if ( a[i]<a[i+k] ) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 60864
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
int H,W;
string S[50];
int search_range[8][2]={{-1,-1},{-1,0},{-1,+1},
                        {0,-1},{0,+1},
                        {+1,-1},{+1,0},{+1,+1}};
cin>>H>>W;
for(int i=0;i<H;i++){
    cin>>S[i];
}

for(int i=0;i<H;i++){
    
    for(int j=0;j<W;j++){
    string s=S[i].substr(j,1);
    if(s=="."){
        int cnt=0;
        int tmp_i,tmp_j;
        for(int k=0;k<8;k++){
            tmp_i=i+search_range[k][0];
            tmp_j=j+search_range[k][1];
            if(tmp_i>=0&&tmp_i<H&&tmp_j>=0&&tmp_j<W){
                if(S[tmp_i].substr(tmp_j,1)=="#"){
                    cnt++;
                }
            }
        }
        cout<<to_string(cnt);
    }
    else{
        cout<<"#";
    }
    }
    cout<<endl;
}

//system("pause");
return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;

int dp[3005][3005];

int main(){
    string s, t;
    cin >> s >> t;
    //dp[i][j] = max(dp[i][j+1], dp[i+1][j], dp[i+1][j+1] + 1 if s[i] == s[j])
    int n = s.size(), m = t.size();
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1; 
            }else{
                /* if(dp[i-1][j] > dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = dp[i][j-1];   
                } */
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i = n, j = m;
    string ns;
    while(i >= 1 && j >= 1){
        if(s[i-1] == t[j-1]){
            ns += s[i-1];
            i = i-1, j = j-1;
        }
        else if(dp[i-1][j] > dp[i][j-1])i = i-1;
        else j = j-1;
    }
    reverse(ns.begin(), ns.end());
    cout << ns << endl;
    return 0;   
}

Measured memory_bytes: 35456
x, n = map(int, input().split())
P = list(map(int, input().split()))
if not P:
    print(x)
    exit(0)
for i in range(x, 102):
    if i not in P:
        upper = i
        break
    else:
        upper = 102
for i in range(x, -1, -1):
    if i not in P:
        lower = i
        break
    else:
        lower = 0
print(lower if x-lower <= upper - x else upper)

Measured memory_bytes: 9100
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)  __builtin_popcountll(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

vi adj[MAX_N],vis(MAX_N),curr_t(MAX_N),nodes;
map<int,int>in_tm,out_tm,idx;
int cntr = 1;

void dfs(int node){
    vis[node] = 1;
    nodes.pb(node);
    idx[node] = (int)nodes.size()-1;
    curr_t[cntr] = node;
    in_tm[node] = cntr++;
    
    for(auto x:adj[node]){
        if(!vis[x]) dfs(x);
    }
    out_tm[node] = cntr;
}

void solve(){
    int n,q; cin >> n >> q;
    
    int na,nb; 
    rep(i,1,n){
        cin >> na >> nb;
        adj[na].pb(nb), adj[nb].pb(na);
    }
    
    dfs(1);
    
    // for(auto x:in_tm) cout << x.first << " " << x.second << '\n';
    // cout << '\n';
    // for(auto x:out_tm) cout << x.first << " " << x.second << '\n';
    // for(auto x:nodes) cout << x << " - " << idx[x] <<'\n';
    
    // diff Sum array
    vll d(n+1),a(n);
    d[0] = d[n] = 0;
    rep(i,1,n) d[i] = a[i] - a[i-1];
    
    while(q--){
        int vertex,x; cin >> vertex >> x;
        int id = idx[vertex],sz = abs(in_tm[vertex] - out_tm[vertex]);
        
        // deb(id);
        d[id] += x;
        d[id + sz] -= x;
    }
    
    for (int i = 0; i < n; i++) { 
        if (i == 0) a[i] = d[i]; 
        else a[i] = d[i] + a[i - 1]; 
    } 
    
    rep(i,1,n+1){
        int id = idx[i];
        cout << a[id] << ' ';
    }
}

int main() {
    IOS;
    // int t; cin >> t;
    int t = 1;
    while(t--) solve();
}

Measured memory_bytes: 63444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;

    ll ans = (n*(1+n))/2;
    ll fizzbuzz = (n/15);
    ll fizz = (n/3);
    ll buzz = (n/5);
    ans -= -(fizzbuzz*(1+fizzbuzz)*15)/2 + (fizz*(1+fizz)*3)/2 + (buzz*(1+buzz)*5)/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,sum,a[2010];
bitset<4000010>f;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	f[0]=1;
	for(i=1;i<=n;i++){
		f=f|(f<<a[i]);
		sum+=a[i];
	}
	for(i=(sum+1)/2;i<=sum;i++)if(f[i]){
		printf("%d",i);
		return 0;
	}
}

Measured memory_bytes: 2304
//kunal_goyal
#include<bits/stdc++.h>
//#include"debug.h"

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define all(x) x.begin(),x.end()
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265

//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
	
	int n;
	int1(n);
	int x=0,y=0,t=0;
	fors(i,0,n){
		int ti,xi,yi;
		int3(ti,xi,yi);
		if((abs(xi-x)+abs(yi-y)<=(abs(ti-t)))){
			if(xi-x==0 and yi-y==0){
				cout<<"No";
				return 0;
			}
			else if(((abs(xi-x)+abs(yi-y))%2)!=((abs(ti-t))%2)){
				cout<<"No";
				return 0;
			}
			else{
				t=ti;
				x=xi;
				y=yi;
			}
		}
		else{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	
    return 0;
}





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

int main() {
    int scores[5]; for (int i=0; i<5; i++) cin >> scores[i];

    int sum = 0;
    for (int i=0; i<5; i++) {
        if (scores[i] >= 40) sum += scores[i];
        else sum += 40;
    }

    cout << sum / 5 << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s=="Sunny")cout << "Cloudy" <<endl;
    if(s=="Cloudy")cout << "Rainy" <<endl;
    if(s=="Rainy")cout << "Sunny" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(void)
{
	//変数の宣言
	
	int n,x;
	int num[200010];
	int i,j;
	
	//データの読み込み
	
	scanf("%d %d",&n,&x);
	
	for(i=0;i<200010;i++){
		num[i]=0;
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(n==2){
		if(x==2){
			printf("Yes\n1\n2\n3\n");
		}else{
			printf("No");
		}
		return 0;
	}
	
	if(x==1||x==2*n-1){
		printf("No\n");
		return 0;
	}else if(x!=2*n-2){
		printf("Yes\n");
		num[n-2]=x+2;
		num[n-1]=x-1;
		num[ n ]=x;
		num[n+1]=x+1;
		
		j=1;
		for(i=0;i<n-2;i++){
			if(i+1!=x-1){
				num[i]=j;
				j++;
			}else{
				j=j+4;
				num[i]=j;
				j++;
			}
		}
		
		
		for(i=n+2;i<2*n;i++){
			if(i-3!=x-1){
				num[i]=j;
				j++;
			}else{
				j=j+4;
				num[i]=j;
				j++;
			}
		}
		
	}else if(x==2*n-2){
		printf("Yes\n");
		num[n-2]=x-2;
		num[n-1]=x+1;
		num[ n ]=x;
		num[n+1]=x-1;
		
		for(i=0;i<n-2;i++){
			num[i]=i+1;
		}
		
		for(i=n+2;i<2*n;i++){
			num[i]=i-3;
		}
	}
//	printf("計算部分終了\n");
	
	//出力
	for(i=0;i<2*n-1;i++){
		printf("%d\n",num[i]);
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  printf("%d\n", max(x, y) + max(max(x, y) - 1, min(x, y)));
  return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;
main() {
  file("threesum");
  ios;
  cin >> s;
  int n = s.size();
  string a = s.substr(0, (n - 1) / 2);
  string b = s.substr((n + 3) / 2 - 1);
  cout << (a == b ? "Yes" : "No");
  return 0;
}
/**

*/


Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces505B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	string s; cin >> s;
	ll n = s.length();
	ll ans = 1;
	bool flag = true;
	for ( int k = 1; k < n; k++ ){
		ans++;
		if (s[k] == s[k - 1] && flag) { flag = false; k++; if (k == n) ans--;}
		else flag = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int N;
vector<long long> change, need;

bool solve() {
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {
        if (change[i] > 0 && change[j] <= 0) return true;
        else if (change[i] <= 0 && change[j] > 0) return false;
        else if (change[i] > 0) {
            return (make_pair(need[i], -change[i]) 
            < make_pair(need[j], -change[j]));
        }
        else {
            return change[i] + need[i] 
            > change[j] + need[j];
        }
    });

    long long pos = 0;
    for (auto i : ids) {
        //cout << i << ": " << make_pair(change[i], need[i]) << endl;

        if (pos < need[i]) return false;
        pos += change[i];
    }
    if (pos != 0) return false;
    return true;
}

int main() {
    while (cin >> N) {
        change.clear(); need.clear();
        for (int i = 0; i < N; ++i) {
            string S;
            cin >> S;
            int pos = 0, mi = 0;
            for (auto c : S) {
                if (c == '(') ++pos;
                else --pos;
                if (pos < 0) chmax(mi, -pos);
            }
            change.push_back(pos);
            need.push_back(mi);
        }
        if (solve()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 22664
def E(a,b):
  c0,c1=a,b
  x0,x1=1,0
  y0,y1=0,1
  
  while c1!=0:
    m=c0%c1
    q=c0//c1
    c0,c1=c1,m
    x0,x1=x1,(x0-q*x1)
    y0,y1=y1,(y0-q*y1)
    
  return x0,y0
a,b=map(int,input().split())
print(*E(a,b)[:2])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a;
    int ev = 0;
    int od = 0;
    Scd(n);
    Rep(i,n){
        Scd(a);
        a%2 ? od++ : ev++;
    }

    bool ans = true;
    if( od % 2 ) ans = false;
    if( ans ) printf ( "YES\n" );
    else printf ("NO\n");

    return 0;
}



Measured memory_bytes: 256