akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main (){
    long long X, K, D;
    cin >> X >> K >> D;
    if(X < 0) {
        X *= -1;
    }


    if (X/D - K >= 0)
    {
        cout << X - K*D << endl;
        //cout << 1 << endl;
    }
    else
    {
        K -= X/D;
        X -= (X/D)*D;
        if(K%2) {
            cout << D - X << endl;
        }
        else {
            cout << X << endl;
        }
        
        //cout << min(X + (K%2)*D,abs(X - D) + ((1 + K)%2)*D) << endl;
    }

    
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define KIND 26

int D;
int c[KIND];
int s[400][KIND];
Int last[KIND];

Int range(Int l, Int r) {
    Int len = r - l - 1;
    return -len * (len + 1) / 2;
}



struct ContestInfo {
    set<Int> held[KIND]; // 開催日
    vector<Int> t;
    int D;
    Int score = 0;
    ContestInfo(int D) : D(D) {
        t.resize(D, -1);
        for (int i = 0; i < KIND; i++) {
            held[i].insert(-1);
            held[i].insert(D);
            score += c[i] * range(-1, D);
        }
    }

    void add(int d, int q) {
        if (t[d] != -1) {
            cout << "add failed" << endl;
            exit(1);
        }
        t[d] = q;
        score += s[d][q];
        held[q].insert(d);
        auto it = held[q].find(d);
        auto rit = next(it);
        auto lit = prev(it);
        score -= c[q] * range(*lit, *rit);
        score += c[q] * range(*it,*rit);
        score += c[q] * range(*lit,*it);
    }

    void erase(int d) {
        if (t[d] == -1) {
            cout << "erase failed" << endl;
            exit(1);
        }
        int q = t[d];
        t[d] = -1;
        score -= s[d][q];
        auto it = held[q].find(d);
        auto rit = next(it);
        auto lit = prev(it);
        score += c[q] * range(*lit, *rit);
        score -= c[q] * range(*it,*rit);
        score -= c[q] * range(*lit,*it);
        held[q].erase(it);
    }
    void change(int d, int q) {
        erase(d);
        add(d, q);
    }

};



Int calc_score(vector<Int> t) {
    Int score = 0;
    fill(last, last + KIND, -1);
    for (int d = 0; d < D; d++) {
        score += s[d][t[d]];
        last[t[d]] = d;
        for (int i = 0; i < KIND; i++) {
            score -= c[i] * (d - last[i]);
        }
        // cout << score << endl;
    }
    return score;
}


int main() {
    cin >> D;

    for (int i = 0; i < KIND; i++) {
        cin >> c[i];
    }
    for (Int d = 0; d < D; d++) {
        for (Int i = 0; i < KIND; i++) {
            cin >> s[d][i];
        }
    }

    ContestInfo ci(D);
    for (int d = 0; d < D; d++) {
        Int t;
        cin >> t; t--;
        ci.add(d, t);
    }

    Int current_score = ci.score;

    Int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int d, q;
        cin >> d >> q;
        d--, q--;
        int old = ci.t[d];
        ci.change(d, q);
        Int new_score = ci.score;
        cout << new_score << endl;
        /*
        if (new_score < current_score) {
            ci.change(d, old);    
        }
        else {
            current_score = new_score;
        }
        */
        current_score = new_score;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll h, a;
    cin >> h >> a;
    cout << (h - 1) / a + 1 << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n;

bitset<2020> L[2020],R[2020],C[2020];
char def[2020][2020];

int main() {
	read(n);
	for(int i=2;i<=n;i++){
		cin>>(def[i]+1);
		for(int j=1;j<i;j++){
			if(def[i][j] == '0'){
				C[j][i] = 1;
			}else{
				C[i][j] = 1;
			}
		}
		
	}
	for(int i=1;i<=n;i++)L[i][i] = R[i][i] = 1;

	for(int len = 1;len<n;len++){
		for(int l = 1;l+len-1<=n;l++){
			int r = l+len-1;
			if(l>1){
				
				int c = (L[r]&R[l]&C[l-1])._Find_next(0);
				if(c<=2010) L[r][l-1] = 1;
			}
			if(r<n){
				int c = (L[r]&R[l]&C[r+1])._Find_next(0);
				if(c<=2010) R[l][r+1] = 1;
			}
		}
	}

	int ans = 0;
	for(int i=1;i<=n;i++){
		if(L[n][i] && R[1][i]){
			ans+=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5760
N, Y = map(int, input().split())

out = '-1 -1 -1'
for x in range(N + 1):
	for y in range(N + 1 - x):
		z = N - x - y
		total = 10000 * x + 5000 * y + 1000 * z
		if total == Y:
			out = '{} {} {}'.format(x, y, z)
			break
print(out)


Measured memory_bytes: 9112
s=input()
a = 0
i=0
while True:
    if s[i]=="A":
        a=i
        break
    else: i+=1
z=0
j=1
while True:
    if s[-j]=="Z":
        z=j
        break
    else: j+=1
print((len(s)-j)-i+1)
        
    

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
 
//Optimizations
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//save time
#define endl '\n'
#define db(x) cerr << "> " << #x << ": " << x << endl
typedef long long ll;
 
//for sorting
#define all(a) a.begin(),a.end()
 
//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f
 
//loops
#define REP(i,n) 	    for(int i=0;i<(n);++i)
#define FOR(i,a,b)      for(int i=(a);i<(b);++i)
#define DFOR(i,a,b)     for(int i=(a);i>=(b);--i)
 
//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb 	push_back
 
//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second
 
//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar
 
//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)
 
//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue
 
//general
#define E empty()
 
//Declare all variables and methods needed between this comment and the next one(OCD lol)
const int MAXN=0;
int main(){
  //  int res = 0;
    int n ; cin >> n ; 
// //   int ar[n];
    //R/EP(i,n)cin>>ar[i];
    vector<double> dp(n+1, 0);
    dp[0] = 1;
    REP(i,n){
        double head ; cin >> head;
        DFOR(coin, i+1,0){
            dp[coin] = (coin == 0 ? 0 : (double)dp[coin-1] *(double) head) + dp[coin]* (double)(1-head);
        }


    }
    double res = 0;
    REP(head, n+1){
        if(head > n-head ){
            res+=dp[head];
        }
    }
    cout << fixed << setprecision(10) << res << endl;

}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 300;

struct P
{
	int x, y;
	P(int x=0, int y=0) : x(x), y(y) {}
};

int dist(P p1, P p2) {
	return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

int main() {
	int h, w, d;
	cin >> h >> w >> d;
	int A[MAX][MAX];
	P table[MAX*MAX];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> A[i][j];
			A[i][j]--;
			table[A[i][j]] = {i, j};
		}
	}

	vector<vector<int>> t(d, vector<int>());
	for (int i = 0; i < d; i++) {
		t[i].push_back(0);
		for (int j = i+d; j < h*w; j += d) {
			auto p1 = table[j-d], p2 = table[j];
			t[i].push_back(dist(p1, p2));
		}
		for (int j = 1; j < t[i].size(); j++) {
			t[i][j] += t[i][j-1];
		}
	}

	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		int a = l % d, x = l / d, y = r / d;
		int ans = t[a][y] - t[a][x];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8828
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f(ll n, ll x){
	if(n >= 0)
      return n/x + 1;
  	else
      return 0;
}
int main(){
 
  ll a, b, x;
  cin >> a >> b >> x;
  //cout << (b/x) - max((a-1)/x, -1LL) << "\n";
  cout << f(b, x) - f(a-1, x) << "\n";
  
}


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

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  if(A-B>=0){
    cout << "delicious" << endl;
  }else if(X+A<B){
    cout << "dangerous" << endl;
  }else{
    cout << "safe" << endl;
  }
}

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

int L[2010][2010];
int R[2010][2010];
int U[2010][2010];
int D[2010][2010];

int main(int argc, char const *argv[])
{
	int h, w; cin >> h >> w;
	vector<string> s(h); rep(i, h) cin >> s[i];


	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '.') L[i + 1][j + 1] = L[i + 1][j] + 1;
			else L[i + 1][j + 1] = 0;
		}
	}

	for (int i = 0; i < h; ++i) {
		for (int j = w - 1; j >= 0; --j) {
			if (s[i][j] == '.') R[i + 1][j + 1] = R[i + 1][j + 2] + 1;
			else R[i + 1][j + 1] = 0;
		}
	}

	for (int j = 0; j < w; ++j) {
		for (int i = 0; i < h; ++i) {
			if (s[i][j] == '.') U[i + 1][j + 1] = U[i][j + 1] + 1;
			else U[i + 1][j + 1] = 0;
		}
	}
	for (int j = 0; j < w; ++j) {
		for (int i = h - 1; i >= 0; --i) {
			if (s[i][j] == '.') D[i + 1][j + 1] = D[i + 2][j + 1] + 1;
			else D[i + 1][j + 1] = 0;
		}
	}

	int ans = 0;
	rep(i, h)rep(j, w) {
		if (s[i][j] == '#') continue;
		int y = U[i + 1][j + 1] + D[i + 1][j + 1] - 1;
		int x = L[i + 1][j + 1] + R[i + 1][j + 1] - 1;
		ans = max(ans, x + y - 1);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 67456
#include <iostream>
using namespace std;
int main(){
int a,b;
    while(1){
cin>>a>>b;
if(a==0 && b==0)
break;
if(a<b)
cout<<a<<" "<<b;
else cout<<b<<" "<<a;
cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int t;
    cin >> t;
    rep(ti, t) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        ll ans = floor_sum(n, m, a, b);
        pr(ans);
    }
    
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
#define mod(x) ((x)%(1000003))
const int maxn = 1e6+5;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn];
vector<int>all[maxn];
queue<int>T;
int f[maxn],ans[maxn],sum;
int32_t main()
{
    IOS;
    cin>>m;
    fu(i,1,m-1)
    {
        int x,y;
        cin>>x>>y;
        all[x].push_back(y);
        all[y].push_back(x);
    }
    fu(i,1,m) {
        cin >> a[i];
    }
    sort(a+1,a+m+1);
    fu(i,1,m-1)sum+=a[i];
    int zuo=m;
    int M=-INF;
    int be;
    fu(i,1,m)
    {
        if(all[i].size()>M)
        {
           be=i;
           M=all[i].size();
        }
    }
    T.push(be);
    while(!T.empty())
    {
        auto k=T.front();
        T.pop();
        if(f[k])continue;
        ans[k]=a[zuo--];
        f[k]=1;
        for(auto i:all[k])
        {
            if(!f[i]){
                T.push(i);
            }
        }
    }
    cout<<sum<<endl;
    fu(i,1,m)cout<<ans[i]<<" ";
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int mod = 998244353;
const int MAX = 100005;
vector<pair<int , int> > lc[MAX];
ll dp[MAX];
vector<pair<int , ll> > DP;
int main()
{	
	int n , m;cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int l , r , c; cin >> l >> r >> c;
	
		l--;r--;
		lc[r].pb({l , c});
	}
	dp[0] = 0;
	DP.pb({0 , 0});
	for(int i = 1; i < n; i++)
	{
		dp[i] = mod * (ll) mod;
		for(auto x : lc[i])
		{
			//cout << x.x << " " << x.y << " " << i << endl;
			dp[i] = min(dp[i] , x.y + lower_bound(DP.begin() , DP.end() , mp(x.x , (ll)-mod))->y);
		}
		//cout << dp[i] << endl;
		while(sz(DP) &&DP.back().y >= dp[i])
			DP.pop_back();
		DP.pb({i , dp[i]});
	}
	cout << ((dp[n - 1] == mod * (ll)mod) ? -1 : dp[n - 1]);
		
}


Measured memory_bytes: 8312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(long long h, long long w) {
    vector<long long> differs;
    long long min_of_3;
    long long max_of_3;
    if (h%3 == 0 || w%3 == 0) {
        std::cout << 0 << std::endl;
    } else {
        if (h%3 == 1) {
            min_of_3 = w * (h/3);
            if (w%2 == 0) {
                differs.push_back((h-(h/3))*(w/2) - min_of_3);
            } else {
               // if (w < h-(h/3)) {
               //     differs.push_back(w);
               // } else {
               //     differs.push_back(((h-(h/3))/2 +1)*w - min_of_3);
               // }
                differs.push_back(w);
                differs.push_back((h-(h/3))*(w/2+1) - min_of_3);
            }
        } else {
            max_of_3 = w * ((h/3)+1);
            if (w%2 == 0) {
                differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2));
            } else {
                //if (w < h-((h/3)+1)) {
                //    differs.push_back(w);
                //} else {
                //    differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2+1));
                //}
                differs.push_back(w);
                differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2));
            }
        }
        long long tmp = w;
        w = h;
        h = tmp;
        if (h%3 == 1) {
            min_of_3 = w * (h/3);
            if (w%2 == 0) {
                differs.push_back((h-(h/3))*(w/2) - min_of_3);
            } else {
                differs.push_back(w);
                differs.push_back((h-(h/3))*(w/2+1) - min_of_3);
            }
        } else {
            max_of_3 = w * ((h/3)+1);
            if (w%2 == 0) {
                differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2));
            } else {
                differs.push_back(w);
                differs.push_back(max_of_3 - (h-((h/3)+1))*(w/2));
            }
        }
        std::cout << *min_element(differs.begin(), differs.end()) << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    long long h,w;

    gettimeofday(&start,NULL);

    std::cin >> h >> w;
    solve(h, w);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y,i;
int main(){
  cin>>n>>k;
  r=n-1;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
}


Measured memory_bytes: 5184
import math
from functools import reduce
import time

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

sum = 0

for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            G = gcd(a,b,c)
            if a == b and b == c:
                sum += G
            elif a == b or b == c:
                sum += G*3
            else:
                sum += G*6

print(sum)



Measured memory_bytes: 9636
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
# define INF 0x3f3f3f3f 
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}

// vl sum(500001);


void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    int flag = 0;
    ll count1 = 0;
    ll count2 = 0;
    while(count1<k){
        if(b>a){
            flag = 1;
            break;
        }
        else{
            count1++;
            b = b*2;
        }
    }
    if(flag == 0){
        cout<<"No";
    }
    else{
        // flag = 0;
        count2 = k - count1;
        if(c*pow(2,count2) > b){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }

    }

    
    

}

int main()
{

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#include <iomanip>      
#define pb push_back
#define x first
#define y second
#define mp make_pair
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
using namespace std;
 
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
 
typedef pair<int, int> point;
 
const string FILENAME = "input";

int n;
vector<pair<int, point>> que;

int main() {
	ios::sync_with_stdio(0);
	srand(time(0));
	//read(FILENAME);
	que.pb({0, {0, 0}});
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int t, a, b;
		cin >> t >> a >> b;
		que.pb({t, {a, b}});
		if ((t & 1) != ((a + b) & 1)) {
			cout << "No" << endl;
			return 0;
		}
	}
	sort(que.begin(), que.end());
	for (int i = 0; i < n; ++i) {
		if (abs(que[i].y.x - que[i + 1].y.x) + abs(que[i].y.y - que[i + 1].y.y) > abs(que[i].x - que[i + 1].x)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

bool pal(string str){
	string temp = str;
	reverse(all(temp));
	return str == temp;
}

void solve(){
	string str;
	cin >> str;
	
	int N = str.size()/2;
	string t1, t2, t3;
	t1 = str;
	t2 = str.substr(0,N);
	t3 = str.substr(N+1, N);
	
	if(pal(t1) && pal(t2) && pal(t3)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			long[] A = new long[N];
			int sum = 0;
			for(int i = 0 ; i < N ; i++){
				A[i] = sc.nextLong();
				sum+= A[i];
			}
			sc.close();


			int p1 = 0;
			int p2 = 0;

			int ans = 0;
			int ans2 = 0;
			if(sum%N == 0){
				p1 = sum/N;

				for(int i = 0 ; i < N ; i++){
					ans += Math.pow(Math.abs(A[i]-p1), 2);
				}
				System.out.println(ans);
			}
			else{
				p1 = sum/N;
				p2 = p1+1;

				for(int i = 0 ; i < N ; i++){
					ans += Math.pow(Math.abs(A[i]-p1), 2);
					ans2 += Math.pow(Math.abs(A[i]-p2), 2);
				}
				System.out.println(Math.min(ans, ans2));
			}

	}
}


Measured memory_bytes: 22868
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var A, B, C int
	fmt.Fscanf(reader, "%d %d %d", &A, &B, &C)
	nums := []int{A, B, C}
	nMap := make(map[int]int)
	for _, num := range nums {
		nMap[num]++
	}
	for num, count := range nMap {
		if count == 1 {
			fmt.Fprintf(writer, "%d\n", num)
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;

Int h, w;

Int sol1(Int h, Int w) {
    Int h1,h2,h3;
    h1 = h / 2;
    h2 = h - h1;
    h3 = h;
    Int w12, w3;
    Int s1,s2,s3;
    Int r = h * w;
    for (Int m = 1; m < w; m++){
        w12 = m;
        w3 = w - m;
        s1 = h1 * w12;
        s2 = h2 * w12;
        s3 = h3 * w3;
        Int r2 = max({s1,s2,s3}) - min({s1,s2,s3});
        if (r2 < r) r = r2;
    }
    return r;
}
Int sol2(Int h, Int w) {
    if (h == 2) return h*w;
    
    Int h1,h2,h3;
    h1 = h / 3;
    h2 = (h - h1) / 2;
    h3 = (h - h1 - h2);
    return (max({h1,h2,h3}) - min({h1,h2,h3})) * w;
}
void solve() {
    cin >> h >> w ;
    Int rs[] = {sol1(h,w), sol1(w,h), sol2(h,w), sol2(w,h)};
    cout << *min_element(rs, rs + 4) << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int dic[10] = {0,2,5,5,4,5,6,3,7,6};

bool compare(vi atk,int j,vi def){
  int m = atk.size();
  atk.at(j)++;
  int a = 0;
  int d = 0;
  rep(i,m){
    a += atk.at(i);
    d += def.at(i);
  }
  if(a > d) return true;
  else if(a < d) return false;
  
  rep(i,m){
    if(atk.at(i) == def.at(i)) continue;
    if(atk.at(i) > def.at(i)) return true;
    else return false;
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a.at(i);
  sort(a.begin(),a.end(),greater<int>());
  vector<vector<int>> dp(n+1,vector<int>(m,0));
  //rep(i,m) dp.at(0).at(i) = 0;
  vector<bool> flag(n+1,false);
  flag.at(0) = true;
  rep(i,n){
    //if(dp.at(i).at(0) == -1) continue;
    if(!flag.at(i)) continue;
    rep(j,m){
      int num = a.at(j);
      int match = dic[num];
      if(i+match > n) continue;
      flag.at(i+match) = true;
      if(compare(dp.at(i),j,dp.at(i+match))){
        rep(k,m){
          if(k == j) dp.at(i+match).at(k) = dp.at(i).at(k) + 1;
          else dp.at(i+match).at(k) = dp.at(i).at(k);
        }
      }
    }
  }
  int cnt = 0;
  rep(i,m){
    rep(j,dp.at(n).at(i)){
      cout << a.at(i);
      cnt += dic[a.at(i)];
    }
  }
  cout << endl;
  //cout << cnt << endl;
  /*rep(i,n+1){
    cout << i << ":";
    rep(j,m) cout << dp.at(i).at(j);
    cout << endl;
  }*/
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=1e6+10;
map<int,int> mp;
int n;
int a[maxn];
int main()
{
    scanf("%d",&n);
    int f=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        int pre=a[i];
        vector<int> v;v.clear();
        for(int j=2;j*j<=a[i];j++){
            if(pre%j==0){
                while(pre%j==0){
                    pre/=j;
                }
                if(mp[j]>0){
                    f=1;break;
                }
                //mp[pre]++;
                v.push_back(j);
            }
        }
        if(pre>1){
            if(mp[pre]>0){
                f=1;break;
            }
            //mp[pre]++;
            v.push_back(pre);
        }
        if(f){
            break;
        }
        else{
            int len=v.size();
            for(int j=0;j<len;j++){
                mp[v[j]]++;
            }
        }
    }
    if(f==0){
        printf("pairwise coprime\n");
    }
    else{
        int gcd=a[1];
        for(int i=2;i<=n;i++){
            gcd=__gcd(gcd,a[i]);
        }
        if(gcd==1){
        printf("setwise coprime\n");
        }
        else{
            printf("not coprime\n");
        }
    }
    return 0;
}


Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else{
        ll temp = (k-a);
        if(temp<=b) cout<<a;
        else{
            temp-= b;
            cout<<(a-temp);
        }
    }
}

Measured memory_bytes: 3600
import copy

def solve(h,w,k,stage,nh,nw):
    if nh == h and nw == w:
        res = 0
        for row in stage:
            res += row.count('#')
        if res == k:
            return 1
        else:
            return 0
    
    elif nh == h:
        nwn = nw + 1
        stagen = copy.deepcopy(stage)
        for i in range(h):
            stagen[i][nw] = '.'

        return solve(h,w,k,stage,nh,nwn) + solve(h,w,k,stagen,nh,nwn)
    
    else:
        nhn = nh + 1
        stagen = copy.deepcopy(stage)
        stagen[nh] = list('.'*w)
        return solve(h,w,k,stage,nhn,nw) + solve(h,w,k,stagen,nhn,nw)




if __name__ == '__main__':
    h,w,k = map(int,input().split())
    stage = []
    for i in range(h):
        row = list(input())
        stage.append(row)
    
    print(solve(h,w,k,stage,0,0))
        




Measured memory_bytes: 78580
h,w = gets.split.map(&:to_i)
a = h.times.map{gets.split('').map{|t|t=='.' ? 0 : 1}}

ans = h.times.map{[10**4]*w}
ans[0][0] = a[0][0]
q = [0]
while q.size!=0
  now = q.shift
  x = now%w
  y = now/w
  if x+1<w
    if a[y][x+1]==a[y][x] || a[y][x+1]==0
      if ans[y][x+1] > ans[y][x]
        q.unshift(y*w+x+1)
        ans[y][x+1] = ans[y][x] 
      end
    else
      if ans[y][x+1] > ans[y][x]+1
        q.push(y*w+x+1)
        ans[y][x+1] = ans[y][x]+1 
      end
    end
  end
  if y+1<h
    if a[y+1][x]==a[y][x] || a[y+1][x]==0
      if ans[y+1][x] > ans[y][x]
        q.unshift((y+1)*w+x)
        ans[y+1][x] = ans[y][x] 
      end
    else
      if ans[y+1][x] > ans[y][x]+1
        q.push((y+1)*w+x)
        ans[y+1][x] = ans[y][x]+1 
      end
    end
  end
end

p ans[h-1][w-1]


Measured memory_bytes: 2300
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,n;
string s,t;

void solve()
{
    cin>>s>>t;
    int ans=0;
    for(i=0;i<sz(s);++i)
    {
        ans+=(s[i]!=t[i]);
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().ToArray().Select(x => int.Parse(x.ToString()));
            var count = input.Count(x => x == 1);
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * 3 for _ in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(N-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i+1][k])



print(max(dp[-1]))

Measured memory_bytes: 104988
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int N=100000+10;
typedef long long LL;
LL a[N];
LL minsy(LL a,LL b){
	if(b%a==0) return a;
	return minsy(b%a,a);
}
int main()
{
	int n;
	LL k;
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	if(a[n-1]<k) printf("IMPOSSIBLE");
	else if(a[n-1]==k) printf("POSSIBLE");
	else {
		if(a[0]==a[n-1]) printf("IMPOSSIBLE");
		else {
			LL ys=minsy(a[0],a[n-1]);
			if(ys==1) printf("POSSIBLE");
			else {
				bool flag=0;
				for(int i=0;i<n;i++){
					if(minsy(a[i],ys)==1){
						flag=1;
						break;
					}
					else ys=minsy(a[i],ys);
				}
				if(flag) printf("POSSIBLE");
				else {
					if(k%ys==0) printf("POSSIBLE");
					else printf("IMPOSSIBLE");
				}
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var points = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[0]).ToArray();
        long res = long.MaxValue;
        for (int i = 0; i + k <= n; i++)
        {
            for (int j = i + k; j <= n; j++)
            {
                long height = points[j - 1][0] - points[i][0];
                var cands = points.Take(j).Skip(i).OrderBy(x => x[1]).ToArray();
                for (int l = 0; l + k <= cands.Length; l++)
                {
                    long width = cands[l + k - 1][1] - cands[l][1];
                    res = Min(res, height * width);
                }
            }
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13652
#include<iostream>
#include<math.h>
using namespace std;
int main(void){
    long long N;
    cin>>N;
    for(int i = sqrt(N); i >= 1; i--){
        if(N%i==0) {
            cout<<int(log10(N/i)+1)<<endl;
            break;
            }
    }
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int i, k, m, n = 0;
    int h[100], w[100];
    while(1) {
        scanf("%d %d", &h[n], &w[n]);
        if(h[n] == 0 && w[n] == 0) break;
        n++;
    }
    for(i = 0; i < n; i++) {
        for(k = 0; k < h[i]; k++) {
            for(m = 0; m < w[i]; m++) {
                if(k % 2 == 0) {
                    if(m % 2 == 0) printf("#");
                    else printf(".");
                } else {
                    if(m % 2 == 0)printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

void dfs(vector<int> g[],int i,int vis[],stack<int> &s)
{
	vis[i] = 1;
	for(auto it : g[i])
	{
		if(vis[it])
			continue;
		dfs(g,it,vis,s);
	}
	s.push(i);
}


int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> g[n];
	int i;
	for(i = 0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		g[x].pb(y);
	}
	int vis[n]={0};
	stack<int> s;
	for(i=0;i<n;i++)
	{
		if(vis[i])
			continue;
		dfs(g,i,vis,s);
	}
	vector<int> v;
	while(!s.empty())
	{
		v.pb(s.top());
		s.pop();
	}
	int ans[n] = {0};
	int maxs = 0;
	for(i=n-1;i>=0;i--)
	{	
		ans[v[i]] = 0;
		for(auto it : g[v[i]])
		{
			ans[v[i]] = max(ans[v[i]],1+ans[it]);
		}
		maxs = max(maxs,ans[v[i]]);
	}
	cout<<maxs;
	return 0;

}


Measured memory_bytes: 12920
#include<stdio.h>
int main(){
  int n;
  int a[100]={},b[100]={};
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    b[n-i+1]=a[i];
  }
  for(i=1;i<=n;i++){
    printf("%d",b[i]);
    if(i<n)printf(" ");
    if(i==n)printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,t=1,i,j,k,sum=0,ans,f=0,x,y,w,a,b,c,d;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		cin>>a>>b>>c>>d;
		int i=0;
		while(1){
			i++;
			if(i%2==1) {
				c=c-b;
				if(c<=0){
					cout<<"Yes"; return 0;
				
				}
			}
			else{
				a=a-d;
				if(a<=0){
					cout<<"No"; return 0;
				}
			}
		}
		//int a[n];rep(i,n) cin>>a[i];

	}
	return 0;
}




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

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == (b + c) || (a + b) == c || (a + c) == b){
  	cout << "Yes" << endl; 
  }
	else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main() {
    string w, t;
    int ans = 0;
    cin >> w;
    for (int i=0; i<w.size(); i++){
        w[i] = toupper(w[i]);
    }
    while (1){
        cin >> t;
        if (t == "END_OF_TEXT"){
            break;
        } else {
            for (int j=0; j<t.size(); j++){
                t[j] = toupper(t[j]);
            }
            if (t == w) ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> PLL;
const int M=2e5+5;
const LL INF=0x7fffffffffffffff;
// s + t = sum
// s - t = sum - t*2

// for k numbers
// t = k*x + D*i  sum(0,k-1) <= i <= sum(n-k,n-1)
// classify by mod D, t for each k will be an interval

map<LL,vector<PLL>> ma;

LL sum[M];
LL getsum(int l,int r)
{
	if(l) return sum[r]-sum[l-1];
	return sum[r];
}

int main()
{
	LL n,x,d;
	scanf("%lld%lld%lld",&n,&x,&d);
	if(d==0)
	{
		if(x==0)
		{
			printf("1\n");
			return 0;
		}
		else
		{
			printf("%lld\n",n+1);
			return 0;
		}
	}
	if(d<0)
		d=-d,x=-x;
	for(LL i=1;i<n;i++)
		sum[i]+=sum[i-1]+i;
	ma[0].emplace_back(0,0);
	ma[0].emplace_back(0,1);
	for(LL k=1;k<=n;k++)
	{
		LL modd=(k*x%d+d)%d;
		LL bg=k*x/d+getsum(0,k-1);
		LL ed=k*x/d+getsum(n-k,n-1);
		ma[modd].emplace_back(bg,0);
		ma[modd].emplace_back(ed,1);
	}
	LL ans=0;
	
	for(auto &p:ma)
	{
		auto &vec=p.second;
		sort(vec.begin(),vec.end());
		LL psum=0,st=0;
		for(auto &p:vec)
		{
			if(p.second)
			{
				psum--;
				if(!psum) ans+=p.first-st+1;
			}
			else
			{
				if(!psum) st=p.first;
				psum++;
			}
		}
	}

	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26752
#include<stdio.h>
int main()
{
	int H;
	int A;
	scanf("%d %d",&H,&A);
	if(H%A ==0){
		printf("%d",H/A);
	}
	else if (H%A !=0){
		printf("%d",H/A+1);	
	}
	return 0;
}

Measured memory_bytes: 1688
//ABC118C

#include<bits/stdc++.h>
#include<queue>
using namespace std;
#define loop(key,range) for(key = 0;key < (range);key++)
#define INF 10000000
#define MAX_N 1000001
int N,A[MAX_N],ans;
int gcd(int x,int y){
    if(y == 0){
        return x;
    }else{
        return gcd(y, x%y);
    }
}


int main(){
    cin >> N;
    cin >> A[0] >> A[1];
    ans = gcd(A[0],A[1]);
    for(int i = 2;i < N;i++){
        cin >> A[i];
        ans = gcd(ans,A[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;i--)
#define ll long long
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,x,y,a[N],w,G[N];
int d[20],dd[20];
int pd(int x,int w){
	return (x&(1<<w))>0;
}
struct no{
	bool bz[20];
}k;
void build(int x,int y,int l,int r,no k){
	if(l==r)return;
	int mi=l+r>>1;
	fo(i,0,n-1)if(pd(x,i)^pd(y,i)){
		fo(j,l+1,mi)a[j]^=pd(x,i)?1<<i:0;
		fo(j,mi+1,r-1)a[j]^=pd(y,i)?1<<i:0;
		k.bz[i]=1;
		if(G[x^a[mi]]%2==0){
			fo(j,0,n-1)if(!k.bz[j]){
				a[mi]^=1<<j;
				a[mi+1]^=1<<j;
				break;
			}
		}
		build(x,a[mi],l,mi,k);
		build(a[mi+1],y,mi+1,r,k);
		return;
	}
}
int main(){
	scanf("%d %d %d\n",&n,&x,&y);
	fo(i,0,1<<n)G[i]=G[i>>1]+(i&1);
	if(G[x^y]%2==0){
		printf("NO");
		return 0;
	}
	w=(1<<n)-1;
	a[0]=x;a[w]=y;
	build(x,y,0,w,k);
	printf("YES\n");
	fo(i,0,w)printf("%d ",a[i]);
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  bool is_prime[1001] = {false};
  ll prime_num[1001] = {0};
  ll N;
  ll sum = 1;
  ll mod = 1000000007;

  cin >> N;
 
  /* 判定フラグ */
  int flag;
 
  /* 素数かどうかを判定 */
  for( int i=2;i<=1000;++i ) {
    flag = 0;
    for( int j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }
    /* 判定結果を出力 */
    if( flag==0 ) is_prime[i] = true;
      
  }
 

  /*for(int i=0; i<100; i++) {
    if( is_prime[i] ) cout << i << endl;
    }*/

  for(int i=2; i<=N; i++) {
    int tmp = i;
    for(int j=2; j<=N; j++) {
      if( is_prime[j] ) {
	while( tmp % j == 0 ) {
	  tmp /= j;
	  prime_num[j]++;
	}
      }
    }
  }

  for(int i=2; i<=N; i++) {
    if( prime_num) sum *= (prime_num[i] + 1);
    sum %= mod;
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#define _[2<<17]
struct T{int a,b;}A _;long P _,M=1e9+7,F _,I _={1},X;i,j,k,t;c(a,b)struct T*a,*b;{t=a->a-b->a?:a->b-b->b;}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<2<<17;)I[X]=p(s=F[X]=X*s%M,M-2);for(k=A;~scanf("%d",k);k+=4)i++-1||gets(P);for(qsort(A,i/=2,8,c);j<i;P[j++]=X)for(X=f(s=A[k=j].a-=1,t=A[j].b-=1);k--;)X=t<A[k].b?X:(X-f(s-A[k].a,t-A[k].b)*P[k]%M+M)%M;printf("%d",X);}

Measured memory_bytes: 8444
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	fmt.Println(train(n, a))
}

func train(n int, a []int) int {
	p := 1
	for c := range a {
		p = a[p-1]
		if p == 2 {
			return c + 1
		}
	}
	return -1
}


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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//int main(void) {
//	int  R;
//	double tmp;
//
//	i_cin(R);
//
//	f_cout((double)R * 3.14*2.0);
//
//	return 0;
//}

int main(void) {
	int N, M,i;
	int A[10001];
	int cnt = 0;
    i_cin2(N, M);
	i_cins(M, A);

	for (i = 0; i < M; i++) {
		cnt += A[i];
		if (N < cnt) { i_cout(-1); return 0; }
	}
	i_cout(N - cnt);
	return 0;
}
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



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

const int N = 100100;
typedef pair<int, int> ii;
vector<ii> g[N];
bool vis[N];
int dis[N];

bool dfs(int v) {
    for (const auto &edge : g[v]) {
        int u = edge.first;

        if (vis[u]) {
            if (dis[u] != dis[v] + edge.second) {
                return false;
            }
        } else {
            vis[u] = true;
            dis[u] = dis[v] + edge.second;
            if (!dfs(u))
                return false;
        }
    }

    return true;
}


int main() {
    int n, m;
    int a, b, c;
    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        vis[i] = true;
    }

    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, -c});
        vis[a] = false;
        vis[b] = false;
    }

    for (int i = 1; i <= n; i++) {
        if (vis[i] == false) {
            vis[i] = true;
            dis[i] = 0;
            if (dfs(i) == false) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    double l;cin>>l;
    l/=3.0;
    l=l*l*l;
    put_double(l);
    return 0;
}


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

int main()
{
	int n, m, l;
	int i, j, k;
	int array[100][100] = {};
	int brray[100][100] = {};
	long crray[100][100] = {};

	cin >> n >> m >> l;

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			cin >> array[i][j];
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++)
			cin >> brray[i][j];
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++)
				crray[i][j] += array[i][k] * brray[k][j];
			cout << crray[i][j];
			if (j != l-1) cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3228
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d=0;
    cin>>a>>b;
    a++;
    for(int j=1;j<=b;j++){
        cin>>c;
        d+=c;
    }
    if(d%a==0){
        d=d/a;
    }else{
        d=d/a+1;
    }
    cout<<d<<endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	ll k,n;
	ll a[200100];
	ll b[200100];
	cin>>k>>n;
	rep(i,n)
		cin>>a[i];
	rep(i,n-1)
		b[i]=a[i+1]-a[i];
	b[n-1]=k+a[0]-a[n-1];
	sort(b,b+n);
	cout<<k-b[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 3456