akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = (1 << 14) + 5;
const int MOD = 998244353;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

inline int ksm(int x, int k) {
	int ret = 1;
	for (; k; k >>= 1) {
		if (k & 1) ret = Mul(ret, x);
		x = Mul(x, x);
	}
	return ret;
}

int n, m;
int fac[MAXN], finv[MAXN];
int len, lenv, rev[MAXN], w1[MAXN], w2[MAXN];
int dp[2][MAXN], F[MAXN], G[MAXN];

inline int C(int x, int y) {
	if (x < y) return 0;
	return Mul(fac[x], Mul(finv[y], finv[x - y]));
}

void NTT_init(int m) {
	int bit = -1;
	for (len = 1; len <= m; len <<= 1, ++bit);
	lenv = ksm(len, MOD - 2);
	for (int i = 0; i < len; ++i) {
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << bit);
	}
	int Gi = 3, Gv = ksm(Gi, MOD - 2);
	for (int i = 1; i < len; i <<= 1) {
		int wn1 = ksm(Gi, (MOD - 1) / (i << 1)), wk1 = 1;
		int wn2 = ksm(Gv, (MOD - 1) / (i << 1)), wk2 = 1;
		for (int k = 0; k < i; ++k) {
			w1[i + k] = wk1;
			wk1 = Mul(wk1, wn1);
			w2[i + k] = wk2;
			wk2 = Mul(wk2, wn2);
		}
	}
}

void NTT(int *a, int type) {
	int *w = (type == 1? w1 : w2);
	for (int i = 0; i < len; ++i) {
		if (i < rev[i]) {
			swap(a[i], a[rev[i]]);
		}
	}
	for (int i = 1; i < len; i <<= 1) {
		for (int j = 0; j < len; j += (i << 1)) {
			for (int k = 0; k < i; ++k) {
				int x = a[j + k], y = Mul(w[i + k], a[j + k + i]);
				a[j + k] = Add(x, y);
				a[j + k + i] = Sub(x, y);
			}
		}
	}
	if (type == 1) return;
	for (int i = 0; i < len; ++i) {
		a[i] = Mul(a[i], lenv);
	}
}

void init() {
	read(n); read(m);
	fac[0] = 1;
	for (int i = 1; i <= n + 2; ++i) {
		fac[i] = Mul(fac[i - 1], i);
	}
	finv[n + 2] = ksm(fac[n + 2], MOD - 2);
	for (int i = n + 2; i >= 1; --i) {
		finv[i - 1] = Mul(finv[i], i);
	}
	NTT_init(n + n);
}

void solve() {
	int pre = 0, cur = 1;
	dp[pre][0] = 1;
	for (int j = 1; j <= m; ++j) {
		for (int i = 0; i <= n; ++i) {
			dp[cur][i] = Mul(dp[pre][i], C(i + 1, 2) + 1);
			F[i] = Mul(dp[pre][i], finv[i]);
		}
		G[0] = 0;
		for (int i = 1; i <= n; ++i) {
			G[i] = finv[i + 2];
		}
		for (int i = n + 1; i < len; ++i) {
			F[i] = G[i] = 0;
		}
		NTT(F, 1); NTT(G, 1);
		for (int i = 0; i < len; ++i) {
			F[i] = Mul(F[i], G[i]);
		}
		NTT(F, -1);
		for (int i = 1; i <= n; ++i) {
			Inc(dp[cur][i], Mul(F[i], fac[i + 2]));
		}
		swap(pre, cur);
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		Inc(ans, Mul(C(n, i), dp[pre][i]));
	}
	printf("%d\n", ans);
}

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



Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  double n,k;cin>>n>>k;

  double ans=0;
  rep(i,1,n+1){
    int p=0;
    while(1){
      // cout<<p<<":"<<(i<<p)<<endl;
      if((i<<p)>=k)break;
      p++;
    }
    // cout<<endl;
    ans+=pow(0.5,p);
  }

  cout<<setprecision(16)<<ans/n<<endl;
  // out(ans/n);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec chat[27];

int ans = INF;

void solve(){
  // main algorithm
  // count
  for(int i = 0; i < N; ++i) {
    chat[S[i] - 'a'].push_back(i);
  }
  // calc each charas
  for (int i = 0; i < 26; ++i)
  {
    if(chat[i].size() == 0) continue;

    int cand = 0;
    int chat_pre = -1;
    int jj;
    for(auto&& j : chat[i]) {
      jj = j;
      cand = max(cand, j - chat_pre - 1);
      chat_pre = j;
    }
    if(jj != N - 1){
      cand = max(cand, (int)N-1 - jj);
    }

    ans = min(ans, cand);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> S;
  N = S.size();
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()


def BFS(point,d):
    cost=[1e7]*(n+1)
    cost[point]=0
    Q=deque()
    Q.appendleft((0,point))
    
    while Q:
        c,p=Q.pop()
        for np in d[p]:
            if cost[np]==1e7:
                cost[np]=c+1
                Q.appendleft((c+1,np))
    return cost

n=int(input())
d=[[]for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
        
x=BFS(1,d)[1:]
y=BFS(n,d)[1:]

#print(x,y)

F=0
S=0

for s,t in zip(x,y):
    if s<=t:
        F+=1
    else:
        S+=1

if F<=S:
    print("Snuke")
else:
    print("Fennec")

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

int main(void)
{
	string s;
	int cnt;
	cin >> s;
	cnt = 0;
	rep(i, s.size())
	{
		if (s[i] == 'o')
			cnt++;
	}
	if (15 - s.size() + cnt >= 8)
		cout << "YES" << endl; 
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
'use strict';
 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});
 
process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
 
// main function .... code start ... ///
function main() {
 
 //var input = readline()
 
var ar = readline().split(' ').map(x => parseInt(x));
var a = ar[0]
var str = readline().split(' ');
var s = str[0];
 
console.log(a >= 3200 ? s : 'red');
}

Measured memory_bytes: 22332
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;
const int inv2 = MOD - MOD/2;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res * res) % MOD;
    if(p%2 == 1) res = (res * a) % MOD;
    return res;
}

pair<long long, long long> solve(const vector<int>& h, int begin, int end, int curH){
    int lowest = 1 << 30, highest = curH;
    for(int i=begin;i<end;i++){
        lowest = min(lowest, h[i]);
        highest = max(highest, h[i]);
    }
    if(lowest == highest){
        return make_pair(modPow(2, lowest - curH), (modPow(2, end - begin) + MOD - 2) % MOD);
    }
    long long all = 1;
    long long one = 1;
    int last = -1;
    int cnt = 0;
    for(int i=begin;i<=end;i++){
        if(i == end || h[i] == lowest){
            if(i < end) ++cnt;
            if(last != -1){
                auto p = solve(h, last, i, lowest);
                all = (all * (2 * p.first + p.second)) % MOD;
                one = (one * p.first) % MOD;
                last = -1;
            }
        } else {
            if(last == -1) last = i;
        }
    }
    one = (2 * one) % MOD;
    all = (all * modPow(2, cnt)) % MOD;
    all = (all + MOD - one) % MOD;
    one = (one * modPow(2, lowest - curH - 1)) % MOD;
    return make_pair(one, all);
}

int main(){
    int N; cin >> N;
    vector<int> h(N);
    for(auto& t : h) cin >> t;
    auto res = solve(h, 0, N, 0);
    cout << (res.first + res.second) % MOD << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    string s;
    cin >> s;
    int ans = s.size();

    rep(i, 2)
    {
        int cnt = 0;
        rep(j, s.size())
        {
            if(j%2 == 0 and s.at(j) != (char)('0' + i)) cnt++;
            if(j%2 == 1 and s.at(j) != (char)('0' + 1 - i)) cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#pragma warning(disable:4996)
using namespace std;

static const int MAX = 1000;
static const int VMAX = 10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
	int ans=0;
	bool V[MAX];

	for(int i=0; i<n; i++){
		B[i] = A[i];
		V[i] = false;
	}

	sort(B,B+n);
	for(int i=0; i<n; i++) T[B[i]] = i;
	for(int i=0; i<n; i++){
		if(V[i]) continue;
		int cur = i;
		int S=0;
		int m = VMAX;
		int an=0;
		while(1){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if( V[cur] ) break;
		}
		ans += min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}

int main(){
	cin >> n;
	s = VMAX;
	for(int i=0; i<n; i++){
		cin >> A[i];
		s = min(s,A[i]);
	}
	int ans = solve();
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

int main() {
	int n,plus=0,minus=0, zero=0;
	cin >> n;
	vector<lli> vec(n);

	rep0(i, n) {
		cin >> vec[i];
		if (vec[i] > 0)plus++;
		else if (vec[i] < 0)minus++;
		else zero++;

	}

	if (zero + plus == n || minus==1) {
		sort(all(vec));
		lli ans = -vec[0];
		rep1(i, n - 1)ans += vec[i];
		cout << ans << '\n';

		rep0(i, n - 2) {
			cout << vec[i] << ' ' << vec[i + 1] << '\n';
			vec[i + 1] = vec[i] - vec[i + 1];
		}
		cout << vec[n - 1] << ' ' << vec[n - 2] << '\n';

	}
	else if (zero + minus == n||  plus ==1) {
		sort(rall(vec));
		lli ans = vec[0];
		rep1(i, n - 1)ans -= vec[i];
		cout << ans << '\n';


		cout << vec[0] << ' ' << vec[1] << '\n';
		vec[1] = vec[0] - vec[1];

		rep1(i, n - 2) {
			cout << vec[i] << ' ' << vec[i+1] << '\n';
			vec[i + 1] = vec[i] - vec[i + 1];
		}

	}
	else if (zero > 0) {
		lli ans = 0;
		sort(rall(vec));
		rep0(i, plus)ans += vec[i];
		rep0(i, n-plus)ans -= vec[i + plus];
		cout << ans << '\n';

		rep0(i, plus-1) {
			cout << vec[plus-i] << ' ' << vec[plus - i - 1] << '\n';
			vec[plus - i - 1] = vec[plus - i] - vec[plus - i - 1];
		}
		cout << vec[0] << ' ' << vec[1] << '\n';
		vec[plus] = vec[0] - vec[1];

		rep0(i, n - plus - 1) {
			cout << vec[plus + i] << ' ' << vec[plus + i + 1] << '\n';
			vec[plus + i + 1] = vec[plus + i] - vec[plus + i + 1];
		}
	}
	else {
		
		sort(rall(vec));

		
			lli ans = 0;
			rep0(i, plus)ans += vec[i];
			rep0(i, n - plus)ans -= vec[i + plus];
			cout << ans << '\n';

			rep0(i, plus-1) {
				cout << vec[plus - i] << ' ' << vec[plus - i - 1] << '\n';
				vec[plus - i - 1] = vec[plus - i] - vec[plus - i - 1];
			}
			cout << vec[0] << ' ' << vec[1] << '\n';
			vec[plus] = vec[0] - vec[1];

			rep0(i, n - plus-1) {
				cout << vec[plus + i] << ' ' << vec[plus + i + 1] << '\n';
				vec[plus + i + 1] = vec[plus + i] - vec[plus + i + 1];

		}

	}


}

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

int main(){
    int a, b;
    cin >> a >> b;
    int plus = a+b;
    int minus = a-b;
    int times = a*b;
    if(plus >= minus && plus >= times) cout << plus << endl;
    else if(minus >= plus && minus >= times) cout << minus << endl;
    else cout << times << endl;
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  for(int i = 1; i <= N - K; i++){
    int a = N/(K+i), b = N % (K+i);
    if(!K) ans += a*i -1 + max(0, b-K+1);
    else  ans += a*i + max(0, b-K+1);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define error(x) cout << #x << " = " << x << endl
#define pb push_back
#define sz(a) int(a.size())

typedef long long int64;
typedef pair<int, int> ii;

int N, T, res;

int main() {
	// freopen("input.txt", "r", stdin);

	ios::sync_with_stdio(0);
	cin >> N >> T;
	for (int i = 0, le = -T-1; i < N; i++) {
		int t; cin >> t;
		if (t <= le) {
			int _le = max(le, t + T);
			res += max(0, _le - le);
			le = _le;
		}
		else {
			le = t + T;
			res += T;
		}
	}

	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int H,W,K;
	cin>>H>>W>>K;
	
	vector<string> S(H);
	for(int i=0;i<H;i++)cin>>S[i];
	
	int ans = 0;
	for(int i=0;i<(1<<H);i++){
		vector<string> SS;
		for(int j=0;j<H;j++){
			if((i>>j)&1){
				SS.push_back(S[j]);
			}
		}
				
		for(int j=0;j<(1<<W);j++){
			int cnt = 0;
			for(int a=0;a<SS.size();a++){
				for(int b=0;b<W;b++){
					if((j>>b)&1){
						if(SS[a][b]=='#')cnt++;
					}
				}
			}
			if(cnt==K)ans++;
		}
	}
	cout<<ans<<endl;
		
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int w[N],n,head[N],cnt,tot,sz[N],all,mxd[N],rt;
int U[N*20],V[N*20],id[N*20],fa[N];LL W[N*20],ans;
bool vis[N];
struct edge{
	int to,nxt,w;
}e[N<<1];
inline bool cmp(const int&a,const int&b){return W[a]<W[b];}
inline int find(int x){while(x!=fa[x])x=fa[x]=fa[fa[x]];return x;}
void getrt(int now,int pre){
	sz[now]=1,mxd[now]=0;
	for(int i=head[now];i;i=e[i].nxt)if(e[i].to!=pre&&!vis[e[i].to]){
		getrt(e[i].to,now),sz[now]+=sz[e[i].to],mxd[now]=max(mxd[now],sz[e[i].to]);
	}
	mxd[now]=max(mxd[now],all-sz[now]);
	if(!rt||mxd[now]<mxd[rt])rt=now;
}
LL mx;int num; 
void dfs(int now,int pre,LL s){
	if(mx>s+w[now])num=now,mx=s+w[now];
	for(int i=head[now];i;i=e[i].nxt)if(!vis[e[i].to]&&e[i].to!=pre)dfs(e[i].to,now,s+e[i].w);
}
void DFS(int now,int pre,LL s){
	U[++tot]=num,V[tot]=now,W[tot]=s+w[now]+mx,id[tot]=tot;
	for(int i=head[now];i;i=e[i].nxt)if(!vis[e[i].to]&&e[i].to!=pre)DFS(e[i].to,now,s+e[i].w);
}
void work(int now){
	mx=w[now],num=now;
	for(int i=head[now];i;i=e[i].nxt)if(!vis[e[i].to])dfs(e[i].to,now,e[i].w);
	for(int i=head[now];i;i=e[i].nxt)if(!vis[e[i].to])DFS(e[i].to,now,e[i].w);
	U[++tot]=num,V[tot]=now,W[tot]=w[now]+mx,id[tot]=tot;
}
void solve(int now){
	vis[now]=1;
	work(now);
	int sm=all;
	for(int i=head[now];i;i=e[i].nxt)if(!vis[e[i].to]){
		all=sz[now]>sz[e[i].to]?sz[e[i].to]:sm-sz[now];
		rt=0;
		getrt(e[i].to,now);
		solve(rt);
	}
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>w[i];
	for(int i=1;i<n;++i){
		int u,v,w;
		cin>>u>>v>>w;
		e[++cnt]=(edge){v,head[u],w},head[u]=cnt;
		e[++cnt]=(edge){u,head[v],w},head[v]=cnt;
	}
	all=n;
	getrt(1,0);
	solve(rt);
	sort(id+1,id+tot+1,cmp);
	for(int i=1;i<=n;++i)sz[fa[i]=i]=1;
	cnt=n-1;
	for(int j=1,i=id[1];j<=tot&&cnt;i=id[++j])if(find(U[i])!=find(V[i])){
		int u=find(U[i]),v=find(V[i]);
		if(sz[u]<sz[v])swap(u,v);
		sz[u]+=sz[v],fa[v]=u,ans+=W[i],--cnt;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mx 1000000
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL);
 
      ll a,b,c=0,k;
      cin>>a>>b>>c>>k;
      while(k--){
            if(b<=a) b*=2;
            else c*=2;
      }
      if(b>a and c>b) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
  return 0;
}

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

int main() {
  
  string s;
  int k;
  cin >> s;
  cin >> k;

  for(int i=0; i<s.size(); i++){
//    cout << s[i];
//    cout << s[i] - 'a' << endl;
    if(k == 0){
      break;
    }else if(i == s.size()-1){
//      cout << (((s[i] - 'a') + k) + 26) % 26 << endl;
      s[i] = 'a' + (((s[i] - 'a') + k) + 26) % 26;
//      cout << s[i] << endl;
      k = 0;
      break;
    }else if(s[i] != 'a' && 26 - (s[i] - 'a') <= k){
      k -= (26 - (s[i] - 'a'));
      s[i] = 'a';
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Complex{
    double r,i;
    Complex(double r,double i):r(r),i(i){}
    Complex(){}
	inline Complex operator + ( const Complex& rhs )  const  {
		return Complex ( r + rhs.r, i + rhs.i ) ;
	}
	inline Complex operator - ( const Complex& rhs )  const  {
		return Complex ( r - rhs.r, i - rhs.i ) ;
	}
	inline Complex operator * ( const Complex& rhs )  const  {
		return Complex ( r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r ) ;
	}
	inline void operator /= ( const double& x )   {
		r /= x, i /= x ;
	}
	inline void operator *= ( const Complex& rhs )   {
		*this = Complex ( r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r ) ;
	}
	inline void operator += ( const Complex& rhs )   {
		r += rhs.r, i += rhs.i ;
	}
};

const int maxn=4e6+6;
#define PI 3.14159265354
int pos[maxn];
void init ( const int& n )  {
    for ( int i = 0 ,j=0; i < n ; ++ i )  {
        pos[i]=j;for (int l = n >> 1; (j ^= l) < l; l >>= 1);
    }
}

void transform ( Complex *a, const int& n, bool inverse ) {
    for ( int i = 0; i < n ; ++ i ){
        if (i > pos[i]) std ::swap(a[i], a[pos[i]]);
    }

    for ( int l = 2 ; l <= n ; l <<= 1 )  {
        int m = l / 2;Complex omega={cos(2*PI/l),inverse?-sin(2*PI/l):sin(2*PI/l)};
        for ( Complex *p = a ; p != a + n ; p += l )  {
            Complex x={1,0};
            for ( int i = 0 ; i < m ; ++ i ,x *= omega)  {
                Complex t = x  * p [m + i] ;
                p [m + i] = p [i] - t ;p [i] += t ;
            }
        }
    }
}

void dft ( Complex *a, const int& n )  {
    transform ( a, n, 0 ) ;
}

void idft ( Complex *a, const int& n )  {
    transform ( a, n, 1) ;
    for ( int i = 0 ; i < n ; ++ i ) a [i] /= n ;
}
Complex A[maxn],B[maxn],C[maxn];
void FFT(int n,int m) {// len(A),len(B)
    int cnt=1;while(cnt<=(n+m)) cnt<<=1;
    init(cnt);dft(A,cnt);dft(B,cnt);
    for(int i=0;i<cnt;i++) C[i]=A[i]*B[i];
    idft(C,cnt);
    for(int i=0;i<=n+m;i++) C[i].r=ll(C[i].r+0.3);
}
const int mod=200003;
const int g=2;
std::vector<ll> pw(mod),rev(mod);
int main(){
	ll now=1;pw[0]=1;rev[1]=0;
	for(int i=1;i<mod-1;i++) {
		now=now*g%mod;pw[i]=now;
		rev[now]=i;
	}
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++) {
		ll tem;cin>>tem;
		if(tem==0) continue;
		ans-=tem*tem%mod;
		A[rev[tem]].r+=1;
		B[rev[tem]].r+=1;
	}
	FFT(mod,mod);	
	for(int i=0;i<=2*mod;i++) {
		ll x=C[i].r;
		ans+=pw[i%(mod-1)]*x;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 33224
n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range( n-1 ):
  num = int( raw_input( ) )  
  diff = num - minv
  if maxv < diff:
    maxv = diff
  if num < minv:
    minv = num
  
print maxv

Measured memory_bytes: 12700
#include<cstdio>

using namespace std;

int main(){
  int n,k;
  long cnt1=0,cnt2=0;
  scanf("%d %d",&n,&k);
  for(int i=1;i<=n;i++){
    if(i%k==0)
      cnt1++;
    if(i%k==k/2&&k%2==0)
      cnt2++;
  }
  printf("%ld\n",cnt1*cnt1*cnt1+cnt2*cnt2*cnt2);
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> targets;
  for(int i = 0; i < M; ++i) {
    int A;
    cin >> A;
    --A;
    targets.push_back(A);
  }
  vector<int> points(N, 0);
  for(int i = 0; i < M; ++i) {
    int hazure = 0;
    for(int j = 0; j < N; ++j) {
      int t;
      cin >> t;
      --t;
      if(t == targets[i]) {
        ++points[j];
      } else ++hazure;
    }
    points[targets[i]] += hazure;
  }
  for(int i = 0; i < N; ++i) cout << points[i] << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
     cin >> A.at(i);
    }
    sort(A.begin(), A.end(), greater<int>());
    int ans = 0;
    rep(i, N) {
        ans += A.at(i) * (i & 1 ? -1 : 1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m;
	cin>>n;
	vector<ll>v1;
	int arr[1000001]={0};
	fl(i,n) {
		cin>>j;
		v1.pb(j);
		arr[j]++;
	}
	ll ans=0;
	fl(i,n) {
		ll temp=v1[i];
		ll lim=sqrt(temp)+1;
		bool flag=0;
		fli(j,1,lim) {
			if(temp%j==0) {
				if(temp/j==temp){ 
					if(arr[temp/j]>1) {
						flag=1;
						break;
					}	
					else if(j!=temp) {
						if(arr[j]>0 ) {
							flag=1;
							break;
						}
					}
					else {
						if(arr[j]>1) {
							flag=1;
							break;
						}	
					}
				}
				else if(j==temp) {
					if(arr[j]>1) {
						flag=1;
						break;
					}	
					else if(temp/j!=temp){
						if(arr[temp/j]>0) {
							flag=1;
							break;
						}
					}	
					else {
						if(arr[temp/j]>1) {
							flag=1;
							break;
						}
					}
				}	
				else if(arr[temp/j]>0 || arr[j]>0) {
					flag=1;
					break;
				}
			}
		}
		if(!flag) ans++;
	}
	cout<<ans<<"\n";
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

int main() {

  int N;
  string S;
  cin >> N >> S;

  vector<int> E(N), W(N);
  E.at(N-1) = 0;
  W.at(0) = 0;
  
  int count = 0;
  for (int i=1; i<N; i++) {
    if (S.at(i-1) == 'W') count++;
    W.at(i) = count;
  }

  count = 0;
  for (int i=N-2; i>=0; i--) {
    if (S.at(i+1) == 'E') count++;
    E.at(i) = count;
  }

  int min = N;
  for (int i=0; i<N; i++) {
    if (E.at(i) + W.at(i) < min) {
      min = E.at(i) + W.at(i);
    }
  }

  cout << min << endl;

}

Measured memory_bytes: 3076
puts gets.to_i.times.map{gets.split}.each.with_index.map{|a,i|[a,i].flatten}.sort{|(s1,p1,i1),(s2,p2,i2)|s1!=s2 ? s1<=>s2 : p2.to_i<=>p1.to_i}.map{|i|i[-1]+1}

Measured memory_bytes: 1788
import java.util.*;
import static java.lang.Math.*;

public class Main {
    
    static int[] a;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++){
		    h[i] = sc.nextInt();
		}
		boolean[] bool = new boolean[n];
		for(int i = 0; i < m; i++){
		    int a = sc.nextInt()-1;
		    int b = sc.nextInt()-1;
		    if(h[a] >= h[b]) bool[b] = true;
		    if(h[b] >= h[a]) bool[a] = true;
		}
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    if(!bool[i]) result++;
		}
		
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 49224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_N2 = MAX_N * 2;
const int MAX_Q = 100000;

/* typedef */

struct D_UFT {
  int links[MAX_N2], ranks[MAX_N2], sizes[MAX_N2], diffs[MAX_N2];
  
  D_UFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++) {
      links[i] = links[i + n] = i + n;
      ranks[i] = ranks[i + n] = 1;
      sizes[i] = sizes[i + n] = 1;
      diffs[i] = diffs[i + n] = 0;
    }
  }

  int root(int i) {
    int i0 = i;
    int diff0 = 0;
    while (links[i0] != i0) {
      diff0 += diffs[i0];
      i0 = links[i0];
    }

    links[i] = i0;
    diffs[i] = diff0;
    return i0;
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  int diff(int i) { root(i); return diffs[i]; }
  bool same(int i, int j) { return root(i) == root(j); }
  
  int merge(int i0, int i1, int diff) {
    int r0 = root(i0), r1 = root(i1);
    int df0 = diffs[i0], df1 = diffs[i1];
    int rdf = diff + df1 - df0;
    int mr;

    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      diffs[r1] = -rdf;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      diffs[r1] = -rdf;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      diffs[r0] = rdf;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

int n, q;
D_UFT duft;

/* subroutines */

/* main */

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

  duft.clear(n);

  int a, b, c;
  string qi;
  
  while (q--) {
    cin >> qi >> a >> b;
    a--, b--;

    int ra = duft.root(a);
    int rb = duft.root(b);
    
    if (qi == "IN") {
      cin >> c;

      if (ra != rb) duft.merge(a, b, c);
      duft.diffs[a] -= c;
      duft.diffs[b] -= c;
    }
    else if (qi == "COMPARE") {
      if (ra != rb)
	cout << "WARNING" << endl;
      else
	cout << (duft.diffs[a] - duft.diffs[b]) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4336
S = input()

a = int(S[:2])
b = int(S[2:])

if a < 0 or 99 < a:
    x = 0
elif 0 <= a < 1 or 12 < a <= 99:
    x = 1
else:
    x = 2

if b < 0 or 99 < b:
    y = 0
elif 0 <= b < 1 or 12 < b <= 99:
    y = 1
else:
    y = 2

if (x == 0 or y == 0) or (x == 1 and y == 1):
    print('NA')
elif x == 1 and y == 2:
    print('YYMM')
elif x == 2 and y == 1:
    print('MMYY')
else:
    print('AMBIGUOUS')




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

int main(){
int N,M,b,cnt;
cnt = 0;
  cin >> N >> M;
  vector<int> v(M,0);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    for(int j=0;j<a;j++){
    cin >> b;
      v[b-1]++;
    }
  }
  for(int i=0;i<M;i++){
  if(v[i] == N) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 764
import java.util.*;
import java.io.*;
public class Main {
    public static int dp[];
    public static int getLen(ArrayList<ArrayList<Integer>> arr , int s){
        if(dp[s] != -1){
            return dp[s];
        }
        int ans = 0;
        for(int j = 0 ; j < arr.get(s).size() ; j++){
            int temp = arr.get(s).get(j);
            
            ans = Math.max(ans , getLen(arr , temp) + 1);
        }

        // System.out.println(ans);
        return dp[s] = ans;
    }
    public static int solve(ArrayList<ArrayList<Integer>> arr){
        int ans = 0;
        for(int i = 0 ; i < arr.size() ; i++){
            ans = Math.max(ans , getLen(arr , i));
        }
        // ans = getLen(arr , 4);
        return ans;
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        dp = new int[n];

        for(int i = 0 ; i < n ; i++){
            dp[i] = -1;
        }
        
        // int arr[][] = new int[n][n];

        ArrayList<ArrayList<Integer>> arr = new ArrayList<>();
        for(int i = 0 ; i < n ; i++){
            arr.add(new ArrayList<Integer>());
        }

        for(int i = 0 ; i < m ; i++){
            int first = s.nextInt() - 1;
            int second = s.nextInt() - 1;
            // arr[first][second] = 1;
            arr.get(first).add(second);
        }
        
        System.out.println(solve(arr));
        // for(int i = 0 ; i < n ; i++){
        //     System.out.println(dp[i]);
        // }
    }
}

Measured memory_bytes: 72748
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        StringBuilder ans = new StringBuilder();
        for (int i = (m - n) + 1; i < m + n; i++) {
            ans.append(i).append(" ");
        }
        ans.deleteCharAt(ans.length() - 1);
        System.out.println(ans);


    }

}


Measured memory_bytes: 23636
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] ary = new long[N];
        int ans = 0;
        for(int i = 0; i < N; i++){
            ary[i] = sc.nextLong();
        }
        long[] cnt_ary = new long[N+1];
        for(int i = 0; i < N; i++){
            if(N < ary[i]){
                ans++;
            }else{
                cnt_ary[(int)ary[i]]++;
            }
        }
        for(int i = 0; i < N+1; i++){
            if(cnt_ary[i] > i){
                ans += cnt_ary[i] - i;
            }else if(cnt_ary[i] < i){
                ans += cnt_ary[i];
            }
        }
		System.out.println(ans);
    }
}

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

using namespace std;

int main(){
	while(true){
		int h,w;
		cin >> h >> w;
		if(h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if((i+j)%2==0)cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int findSumOfDigits(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int N;
  cin >> N;
  int sum=findSumOfDigits(N);
  if(N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}




Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  int n = sz(s) + 1;
  vector<vector<int>> g(n);
  vector<int> in(n, 0);
  for (int i = 0; i < sz(s); i++) {
    if (s[i] == '<') {
      g[i].push_back(i + 1);
      in[i + 1]++;
    } else {
      g[i + 1].push_back(i);
      in[i]++;
    }
  }
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  for (int i = 0; i < n; i++) {
    if (in[i] == 0) {
      pq.push({0ll, i});
    }
  }
  vector<int> ans(n, 0);
  while (!pq.empty()) {
    int v = pq.top().se;
    pq.pop();
    for (auto &u : g[v]) {
      in[u]--;
      if (ans[u] < ans[v] + 1) {
        ans[u] = ans[v] + 1;
        pq.push({in[u], u});
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) res += ans[i];
  cout << res << "\n";
}



Measured memory_bytes: 35868
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define INF2 100000000000
#define LLINF 1000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  n++;
  if(n==1){
    int a;
    cin >> a;
    if(a==1){
      cout << 1 << endl;
    }else{
      cout << -1 << endl;
    }
    return 0;
  }

  int a[n];
  int mi[100002]={};
  int ma[100002]={};
  int can[100002]={};
  LOOP(i,n){
    cin >> a[i];
  }
  if(a[0]!=0){
    cout << -1 << endl;
    return 0;
  }
  can[0] = 1;
  LOOP1(i,n-1){
    can[i] = can[i-1]*2 - a[i];
    if(can[i]>LLINF){
      can[i] = LLINF;
    }
    // cerr << can[i] << " ";
  }
  // cerr << endl;
  ma[n-1] = a[n-1];
  mi[n-1] = a[n-1];

  LOOP1(cnt,n-1){
    int i = n-cnt-1;
    // cerr << i << "," << a[i] << ":";

    if(a[i] > 0){
      mi[i] = mi[i+1]/2 + a[i];
    }else{
      mi[i] = (mi[i+1]+1)/2;
    }

    ma[i] = ma[i+1] + a[i];
    // cerr << mi[i] << "->" << ma[i] << endl;
  }
  int ans = 0;
  LOOP(i,n){
    // cerr << mi[i] << "." << can[i]+a[i] << "," <<ma[i] << endl;
    if(mi[i] > (can[i]+a[i])){
      cout << -1 << endl;
      return 0;
    }
    ans += min(ma[i], can[i]+a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6748
def palindrome(str):
  n = len(str)
  for i in range(n // 2):
    if str[i] != str[n - 1 - i]:
      return False
  return True

str = input()
is_palindrome = palindrome(str)
n = len(str)
if is_palindrome and n % 2 == 1:
  is_palindrome = palindrome(str[:(n - 1)// 2]) and palindrome(str[(n + 1) // 2:])

print("Yes" if is_palindrome else "No")

Measured memory_bytes: 3060
import java.util.*;

class Main{
  static int A;
  public static void main(String[] args){
  	Scanner scan = new Scanner(System.in);
    int[] map = {1,9,7,4}; 
    boolean[] visit = new boolean[4];
    boolean flag = false;
    for(int i=0;i<4;i++){
      int A = scan.nextInt();
      for(int j=0;j<4;j++){
        if(A == map[j]){
         visit[j] = true;
        }
      }
    }
    for(int i=0;i<4;i++){
      if(!visit[i])
        flag = true;
    }
    if(flag)
        System.out.println("NO");
    else
        System.out.println("YES");
    
  }
}

Measured memory_bytes: 22740
function main(input) {
  const args = input.split(' ');
  const k = parseInt(args[0], 10);
  const x = parseInt(args[1], 10);
  
  const n = k - 1;
  var ans = "";
  
  for(var i = n; i > 0; i--){
    ans += (x - i) + " ";
  }
  ans += x
  for(var i = 1; i <= n; i++){
    ans += " " + (x + i);
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	string S;
	cin >> N >> S;

	if(N % 2) {
		cout << "No";
		return 0;
	}

	for(int i = 0; i < N / 2; i++) {
		if(S[i] != S[i + N / 2]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
LL n, ans = 1ll << 60;
LL a[maxx];

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int flag = 0;
	LL sum = 0;
	LL res = 0;
	for(int i = 1; i <= n; i++) {
		sum += a[i];
		if(flag == 0){
			if(sum <= 0) {
				res = res + 1 - sum;
				sum = 1;
			}
		}
		else {
			if(sum >= 0){
				res = res + sum + 1;
				sum = -1;
			}
		}
		flag ^= 1;
	}
	ans = min(ans, res);
	res = 0;
	sum = 0;
	flag = 0;
	for(int i = 1; i <= n; i++) {
		sum += a[i];
		if(flag == 1){
			if(sum <= 0) {
				res = res + 1 - sum;
				sum = 1;
			}
		}
		else {
			if(sum >= 0){
				res = res + sum + 1;
				sum = -1;
			}
		}
		flag ^= 1;
	}
	ans = min(ans, res);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
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;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  vector<ll> A(N, 0);
  ll sum = 0;
  rep(i, N) cin >> A[i];
  rep(i, N) sum ^= A[i];
//  cout <<sum;
  rep(i, N) {
    ll ans = sum ^ A[i];
    cout << ans;
    if (i < N-1)
      cout << " ";
    else
      cout << endl;
  }
}


Measured memory_bytes: 4716
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

#define fi first
#define se second
typedef pair<int, int> pi;

void sub1(pi *a, int n, int k)
{
    long long best = 0;
    for (int i = 0; i < (1 << n); ++i)
    {
        long long v = 0, w = 0;
        for (int j = 0; j < n; ++j)
        {
            if (i & (1 << j))
            {
                if (w + a[j].fi <= k)
                {
                    w += a[j].fi;
                    v += a[j].se;
                }
            }
        }
        best = max(best, v);
    }

    cout << best;
}

void sub2(pi *a, int n, int k)
{
    long long dp[n + 1][k + 1];
    for (int i = 0; i <= n; ++i)
    {
        //cout << i << " -> ";
        for (int j = 0; j <= k; ++j)
        {
            if (!i || !j)
                dp[i][j] = 0;
            else if (j >= a[i - 1].fi)
                dp[i][j] = max(dp[i - 1][j - a[i - 1].fi] + a[i - 1].se, dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];

            //cout << dp[i][j] << ' ';
        }
        //cout << endl;
    }
    cout << dp[n][k];
}

int main()
{
    if (fopen("Test.INP", "r"))
        freopen("Test.INP", "r", stdin);

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

    pi a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i].fi >> a[i].se;

    if (n <= 20)
        sub1(a, n, k);
    else
        sub2(a, n, k);

    return 0;
}


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

int Array[200][200];
#define START 20

void DFS(int h,int w,int c){

    if(Array[h][w] != c || Array[h][w] == 0 || Array[h][w] == 6){
      return;
    }

    int tmp=Array[h][w];

    Array[h][w] = 6;

    DFS(h-1,w,tmp);
    DFS(h,w+1,tmp);
    DFS(h+1,w,tmp);
    DFS(h,w-1,tmp);


}

int main(){

    while(1){
      int H,W;
      int Start[2],Goal[2];
      int BlockNum;
      int color,dir,xpos,ypos;


      for(int i=0;i<200;i++){
        for(int j=0;j<200;j++){
          Array[i][j] = 0;
        }
      }

      cin >> H >> W;

      if(H == 0 && W == 0){
        break;
      }

      cin >> Start[0] >> Start[1];

      cin >> Goal[0] >> Goal[1];

      cin >> BlockNum;

      for(int i=0;i<BlockNum;i++){
        cin >> color >> dir >> xpos >> ypos;
        for(int i=0;i<4;i++){
          for(int j=0;j<2;j++){
            if(!dir){//?¨?
              Array[xpos+i][ypos+j] = color;
            }
            else{
              Array[xpos+j][ypos+i] = color;
            }
          }
        }
      }

      /*for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          cout << Array[i][j];
        }
        cout << endl;
      }*/
      if(Array[Start[0]][Start[1]] != 0){
        DFS(Start[0],Start[1],Array[Start[0]][Start[1]]);
      }
      if(Array[Goal[0]][Goal[1]] == 6){
        cout << "OK" << endl;
      }
      else{
        cout << "NG" << endl;
      }

  }
    return 0;
}

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

using namespace std;

const int N = 1e5 + 10;

int n, p[N];

void run() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", p + i);
  vector < pair <int, int> > v;
  for (int i = 1; i <= n; ++i) {
    if (p[i] == i) {
      if (v.empty() || v.back().second + 1 < i) {
        v.push_back({i, i});
      } else {
        v.back().second = max(i, v.back().second);
      }
    }
  }
  int ans = 0;
  for (auto p : v) {
    int l = p.second - p.first + 1;
    ans += (l + 1) / 2;
  }
  printf("%d\n", ans);
}

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


Measured memory_bytes: 1276
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		println(sc.nextLine().toUpperCase());
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
#include <stdio.h>
int main( void ){
	int n,a,s,m;
	for(;scanf("%d",&n),n;printf("%d\n",m))
		for(s=0,m=-10000000;n--;s+=a,s>m?m=s:0,s<0?s=0:0)scanf("%d",&a);
	return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;
    string s ; cin >> s ;

    if ( n % 2 ) { cout << "No" ; return ; }

    int len = n / 2 ;
    string s1 = s.substr ( 0 , len ) ;

    string s2 = s.substr ( len , len ) ;

    if ( s1 == s2 ) cout << "Yes" ;
    else cout << "No" ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    int n;
    cin>>n;
    int ma=0,mi=int(1e5);
    rep(i,n){
        int a;
        cin>>a;
        chmax(ma,a);
        chmin(mi,a);
    }
    cout<<ma-mi<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 
int main(){
    int n;cin>>n;
    int a[n+1]={};
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    int c=0;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            int x = lower_bound(a+j,a+n+1,a[i]+a[j]) - a;
            x -= 1;
            c += (x - j);
        }
    }
    cout<<c;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;

    ll x = 1, y = 1;
    rep(i, n){
        ll t, a;
        cin >> t >> a;
        ll tmp = max((t+x-1)/t, (a+y-1)/a);
        x = tmp*t;
        y = tmp*a;
    }

    ppp(x+y);



    return 0;
}


Measured memory_bytes: 256