akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, s, t;
vector<edge> G[100005], G2[100005];
llint dist[100005], dist2[100005];
llint ans[100005];

typedef pair<llint, llint> P;

void dijkstra(vector<edge> G[], llint dist[], llint S)
{
	for(int i = 1; i <= n; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push(make_pair(0, S));
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	cin >> n >> m >> s >> t;
	llint u, v, a, b;
	for(int i = 0; i < m; i++){
		cin >> u >> v >> a >> b;
		G[u].push_back(edge(v, a));
		G[v].push_back(edge(u, a));
		G2[u].push_back(edge(v, b));
		G2[v].push_back(edge(u, b));
	}
	
	dijkstra(G, dist, s);
	dijkstra(G2, dist2, t);
	
	llint mn = inf;
	for(int i = n; i >= 1; i--){
		mn = min(dist[i] + dist2[i], mn);
		ans[i] = mn;
	}
	
	for(int i = 1; i <= n; i++){
		cout << 1000000000000000LL - ans[i] << endl;
	}
	return 0;
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007LL

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

int main(){

  ll k;
  cin >> k;

  /*
  if(k == 0) cout << "2\n1 1\n";
  else if(k == 1) cout << "2\n2 0\n";
  else if(k < 150){
    cout << "2\n";
    if(k % 2 == 0){
      ll tmp = k / 2;
      cout << 1 + tmp << " " << tmp << "\n";
    }
    else{
      ll tmp = (k - 1) / 2;
      cout << tmp << " " << tmp + 2 << "\n";
    }
  }
  else{
  */
    for(ll i = 0; i < 50LL; ++i){
      if((k + i) % 50LL == 0LL){
        ll tmp = (k + i) / 50LL;

        cout << "50\n";

        vector<ll> v(50);
        for(ll j = 0; j < 50; ++j){
          v[j] = 49 - j + tmp;
        }
        rep(j, i) v[49 - j] -= 1;

        rep(j, v.size()){
          if(j != 0) cout << " ";
          cout << v[j];
        }
        cout << "\n";
        break;
      }
    }
  //}

	return 0;
}


Measured memory_bytes: 256
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
# dp[n][w] := n個の品物のうち上限の容量wのときの価値の最大値
 
for i in range(1,N+1):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            dp[i][j]=max(dp[i-1][j-w]+v, dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
    
print(dp[-1][-1])

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

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    string tmp = to_string(i);
    if (tmp.size()%2==1) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,d;
	cin>>n>>d;
	cout<<(n+(d+d+1)-1)/(d+d+1);
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n, ans = 0; cin >> n;
	vector<int> v(n), temp;
	for (int &i : v)cin >> i;
	for (int i = 0; i < n; i++) {
		if (v[i] == i + 1)temp.push_back(i);
	}
	for (int i = temp.size() - 1; i >= 0; i--) {
		if (temp[i] == temp[i + 1] - 1) {
			ans++;
			temp.erase(temp.begin() + i);
			temp.erase(temp.begin() + i);
		}
	}
	cout << ans + temp.size();

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 4244
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	int num = 1, ans = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 2; j <= N; j++) {
			num = pow(i, j);
			if (N >= num) ans = max(num, ans);
		}
	}
	cout << ans << endl;
}


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

int main()
{
    int N;
    vector<string> S;
    cin >> N;
    map<string,int> m;
    S.resize(N);
    rep(i,N){
        cin >> S[i];
        m[S[i]]=0;
    }
    int max=1;
    rep(i,N){
        m[S[i]]++;
        if(max<m[S[i]]){
            max=m[S[i]];
        }
    }
    vector<string> S_a;
    int size=0;
    rep(i,N){
        if(m[S[i]]==max)size++;
    }
    
    S_a.resize(size);
    int j=0;
    rep(i,N){
        if(m[S[i]]==max)S_a[j++]=S[i];
    }
    sort(S_a.begin(),S_a.end());
    
    for(int i=0;i<S_a.size();i+=max){
        cout << S_a[i] << endl;
    }


}

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

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

int A[N+1],B[N];
for (int i = 0; i <= N ;i++) cin >> A[i];
for (int i = 0; i < N; i++) cin >> B[i];


long ans = 0 ;

for (int i = 0; i < N ;i++){
if (B[i] <= A[i]){
   ans += B[i];
}
else {
    if(B[i] <= A[i+1] +A[i]){
      ans += B[i];
      A[i+1] = A[i+1] +A[i] -B[i];
    }
    else {
    ans += A[i]+A[i+1];
    A[i+1] = 0;
    }
    } 
}
cout << ans << endl;
  return 0;
}





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

map<int64_t, int> prime_factor(int64_t n)
{
    map<int64_t, int> ret;
    for (int64_t i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main()
{
    long N;
    cin >> N;
    long ans = 0;
    for (auto p : prime_factor(N))
    {
        for (int i = 1; i < 100; i++)
        {
            p.second -= i;
            if (p.second < 0)
                break;
            ans++;
        }
    }
    cout << ans << endl;
}


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

typedef long long LL;

const int N=500000;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

int a[N+9];
LL ans;

void Dfs_a0(int p,int v){
  a[p]=max(a[p],v);
  if (p>1&&s[p-1]=='>') Dfs_a0(p-1,v+1);
}

void Dfs_a1(int p,int v){
  a[p]=max(a[p],v);
  if (p<=n&&s[p]=='<') Dfs_a1(p+1,v+1);
}

void Get_ans(){
  for (int i=1;i<=n+1;++i) a[i]=-1;
  for (int i=1;i<=n+1;++i)
	if ((i==1||s[i-1]=='>')&&(i==n+1||s[i]=='<')){
	  a[i]=0;
	  Dfs_a0(i-1,1);
	  Dfs_a1(i+1,1);
	}
  for (int i=1;i<=n+1;++i) ans+=a[i];
}

void work(){
  Get_ans();
}

void outo(){
  printf("%lld\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 6252
#include <stdio.h>


int main(){

	
	int h, w, y, x;

	while(1){

		scanf( "%d %d", &h, &w );

		if( h==0 && w==0 ) break;

		for( y=0; y<h; y++ ){
			for( x=0; x<w; x++ ){
				if( ((y%2)+x)%2 == 0 ) 
					printf( "#" );
				else printf( "." );
			}
			printf( "\n" );
		}

		printf( "\n" );

	}

	return 0;

}

Measured memory_bytes: 572
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
VI g[110];
int d[110];


signed main(){
    cin >> n;
    rep(i, 0, n){
        int u, k;
        cin >> u >> k;
        u--;
        int v;
        rep(j, 0, k){
            cin >> v;
            g[u].pb(v-1);
        }
    }

    fill(d, d+n, -1);
    queue<int> q;
    d[0] = 0;
    q.push(0);
    while(!q.empty()){
        int p = q.front(); q.pop();
        rep(i, 0, SZ(g[p])) if(d[g[p][i]] == -1) d[g[p][i]] = d[p]+1, q.push(g[p][i]);
    }

    rep(i, 0, n) cout << i+1 << ' ' << d[i] << endl;

    return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void func() {
  LL MM = 998244353;
  LL N;
  cin >> N;

  vector<LL> D(N);
  vector<LL> C(N,0);
  LL max_d = 0;
  REP(i, N) {
    LL d;
    cin >> d;
    D[i] = d;
    C[d] ++;
    if (max_d < d) {
      max_d = d;
    }
  }

  if (D[0] != 0) {
    cout << 0;
    return;
  }
  for (LL i = 1; i < N; ++i) {
    if (D[i] == 0) {
      cout << 0;
      return;
    }
  }

  LL cnt = 1;
  for (LL d = 1; d <= max_d; ++d) {
    LL c1 = C[d - 1];
    LL c2 = C[d];
    LL c = modpow(c1, c2, MM);
    /*
    c1 %= MM;
    
    LL c = 1;
    REP(j, c2) {
      c *= (c1 % MM);
    }
    */
    //cnt *= (LL)powl((LD)c1, (LD)c2);
    cnt *= c;
    cnt %= MM;
  }
  cout << cnt;
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int n,k,a,d,cnt,i,j,flg[101]={0};
	scanf("%d %d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d",&d);
		for(j=0;j<d;j++){
			scanf("%d",&a);
			flg[a]=1;
		}
	}
	for(i=1;i<=n;i++){
		if(flg[i]==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

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

  long long N;
  cin >> N;
  vector<long long> A(N + 1), B(N);
  for(long long i = 0; i < N + 1; ++i) {
    cin >> A[i];
  }
  for(long long i = 0; i < N; ++i) {
    cin >> B[i];
  }

  long long ans = 0;
  for(long long i = 0; i < N; ++i) {
    long long left = min(A[i], B[i]);
    ans += left;
    A[i] -= left;
    B[i] -= left;

    long long right = min(A[i + 1], B[i]);
    ans += right;
    A[i + 1] -= right;
    B[i] -= right;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    if (n % 2 == 0) OUT(n)
    else OUT(n*2)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    int cnt[4] = {};
    rep(i, s.size()) {
        if (s[i] == 'N') cnt[0]++;
        if (s[i] == 'W') cnt[1]++;
        if (s[i] == 'S') cnt[2]++;
        if (s[i] == 'E') cnt[3]++;
    }
    if ( ((cnt[0]==0 && cnt[2]==0) || (cnt[0]>0 && cnt[2]>0)) && ((cnt[1]==0 && cnt[3]==0) || (cnt[1]>0 && cnt[3]>0)) ) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h+n);
    int ans = 1e9;
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
a_list = list(map(int, input().split()))

sorted_list = sorted(a_list, reverse=True)
x_list = []

for i, a1 in enumerate(sorted_list[:-1]):
    a2 = sorted_list[i+1]
    x = abs(a1-a2)
    x_list.append(x)

ans = sum(x_list)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int cnt[1010][1010];

int get(vector<vector<int>> &v,int x1,int y1,int x2,int y2){
    return v[x2][y2]+v[x1][y1]-v[x2][y1]-v[x1][y2];
}

int main(){
    int n,d;
    cin>>n>>d;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        cnt[x%d][y%d]++;
    }
    int ma=0;
    rep(i,d)rep(j,d){
        int k=1;
        int rt=sqrt(cnt[i][j]);
        if(rt*rt<cnt[i][j])++rt;
        ma=max(rt,ma);
    }

    vector<vector<int>> sum1(2*d+2,vector<int>(2*d+2)),sum2(2*d+2,vector<int>(2*d+2));
    int tot1=0,tot2=0;
    rep(i,d)rep(j,d){
        if(cnt[i][j]>ma*(ma-1)){
            ++sum1[i][j],
            ++sum1[i+d][j],
            ++sum1[i][j+d],
            ++sum1[i+d][j+d],
            ++tot1;
        }
        else if(cnt[i][j]>(ma-1)*(ma-1)){
            ++sum2[i][j],
            ++sum2[i+d][j],
            ++sum2[i][j+d],
            ++sum2[i+d][j+d],
            ++tot2;
        }
    }
    rep(i,2*d)rep(j,2*d){
        sum1[i+1][j]+=sum1[i][j];
        sum2[i+1][j]+=sum2[i][j];
    }
    rep(i,2*d)rep(j,2*d){
        sum1[i][j+1]+=sum1[i][j];
        sum2[i][j+1]+=sum2[i][j];
    }

    int ok=d,ng=-1,mid;
    while(ok-ng>1){
        mid=(ok+ng)/2;
        bool can=false;
        rep(i,d)rep(j,d){
            if(get(sum1,i,j,i+mid,j+mid)==tot1&&
            get(sum2,i+mid,j+mid,i+d,j+d)==0){
                can=true;
                break;
            }
        }
        if(can)ok=mid;
        else ng=mid;
    }

    cout<<(ma-1)*d+ok-1 <<endl;
}


Measured memory_bytes: 35584
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


    int n;
    cin >> n;
	vector<uint64_t> a(n);
	uint64_t sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		sum ^= a[i];
	}
	uint64_t output = 0;
	for(int i = 0; i < n; ++i){
		output = sum ^ a[i];
		if(i != 0) cout << " ";
		cout << output;
	}
	cout << "\n";
    
	return 0;
}

Measured memory_bytes: 4752
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	s, _ := nextString()
	return strconv.Atoi(s)
}

func nextString() (string, bool) {
	succeeded := scanner.Scan()
	if succeeded {
		return scanner.Text(), succeeded
	}
	return "", succeeded
}

func printArr(arr []string) {
	fmt.Println(strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]"))
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	n, _ := nextInt()
	if n == 1 {
		fmt.Println(0)
		return
	}

	s, succeeded := nextString()
	if !succeeded {
		fmt.Errorf("Scan failed")
		return
	}
	nOX := 0
	i := 1
	for {
		if s[i] != s[i-1] {
			nOX++
			i++
		}
		i++
		if i >= n {
			break
		}
	}
	fmt.Println(nOX)
}



Measured memory_bytes: 1368
// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))

#define max_n 123456
#define mod 1000000007
// #define mod 998244353
#define myPrime 97654321
#define inf 1e9
#define eps 1e-9

#define fr first
#define se second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n;
ll x[123];
ll y[123];
ll h[123];

int main() {
	// ll start_time = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// cout << fixed << setprecision(12);
	cin >> n;
	for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> h[i];
	for(ll X=0; X<=100; X++) {
		for(ll Y=0; Y<=100; Y++) {
			bool f = 1;
			ll H = 1e18;
			set <ll> Hst;
			for(int i=0; i<n; i++) {
				ll len = abs(X - x[i]) + abs(Y - y[i]);
				if(h[i] > 0) Hst.insert(h[i] + len);
				else H = min(H, len);
				if(sz(Hst) > 1) {
					f = 0;
					break;
				}
			}
			if(f) {
				if(sz(Hst) == 0) {
					if(H > 0) {
						cout << X << " " << Y << " " << *Hst.begin() << endl;
						return 0;
					}
				}
				else if(H >= *Hst.begin()) {
					cout << X << " " << Y << " " << *Hst.begin() << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

// sorted or not
// mutiset vs set
// clear when it's multi-testcase

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::string S;
    std::cin >> S;

    std::vector<int> leftsum(N + 1, 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            leftsum[i+1] = leftsum[i] + 1; 
        } else {
            leftsum[i+1] = leftsum[i];
        }
    }

    std::vector<int> rightsum(N + 1, 0);
    for (int i = 0; i < N; i++) {
        if (S[N-i-1] == 'E') {
            rightsum[i+1] = rightsum[i] + 1; 
        } else {
            rightsum[i+1] = rightsum[i];
        }
    }

    int ans = 0;
    int min = MOD;
    for (int i = 0; i < N; i++) {
        ans = leftsum[i] + rightsum[N-i-1];
        if (min > ans) {
            min = ans;
        }
    }

    std::cout << min << std::endl;

    return 0;
}

Measured memory_bytes: 3076
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vec<ll> h(N);
  REP(i, N) cin >> h[i];

  sort(ALL(h));
  ll answer = numeric_limits<ll>::max();
  for (ll i = 0; i < N; i++) {
    if (i + K > N) {
      break;
    }
    const ll diff = h[i + K - 1] - h[i];
    answer = min(answer, diff);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    string S;   cin >> S;
    int l = S.length();
    int cnt, ans;
    cnt = 0;
    ans = 0;
    for(int i=0; i<l; i++){
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')    cnt++;
        else    cnt = 0;
        ans = max(ans,cnt);
    }
    print(ans);
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;


map<int,int> res;
void prime_factor(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1) res[n]++;
    return;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    rep(i,n+1){
        prime_factor(i);
    }
    ll ans =0;
    rep(i,n){
        if(res[i]>=74) ans++;
    }
    rep(i,n){
        rep(j,n){
            if(i !=j &&res[i]>=2 &&res[j]>=24) ans++;
        }
    }

    rep(i,n){
        rep(j,n){
            if(i !=j &&res[i]>=4 &&res[j]>=14) ans++;
        }
    }
    rep(i,n){
        rep(j,n){
            for(int k=j+1;k<n;k++){
                if(i !=j && i!=k && res[i]>=2 && res[j]>=4 && res[k]>=4){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
public class Main{
  public static void main(String[] args) throws Exception{
    char[] kari=new char[10];
    for(int i=0;i<10;i++) kari[i]=(char)System.in.read();
    kari[3]='8';
    for(int i=0;i<10;i++) System.out.print(kari[i]);
    System.out.print("\n");
  }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,b1,a2,b2;
	bool f=false;
	cin>>a1>>b1>>a2>>b2;
	if(a1==1&&b1==31)
	f=true;
	if(a1==2&&b1==28)
	f=true;
	if(a1==3&&b1==31)
	f=true;
	if(a1==4&&b1==30)
	f=true;
	if(a1==5&&b1==31)
	f=true;
	if(a1==6&&b1==30)
	f=true;
	if(a1==7&&b1==31)
	f=true;
	if(a1==8&&b1==31)
	f=true;
	if(a1==9&&b1==30)
	f=true;
	if(a1==10&&b1==31)
	f=true;
	if(a1==11&&b1==30)
	f=true;
	if(a1==12&&b1==31)
	f=true;
	if(f)
	cout<<1;
	else
	cout<<0;
}

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

using namespace std;
	
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false); cin.tie(NULL);
typedef long long li;
const int N = 1e5 + 10;


void solve(){

	int a,b;
	cin>>a>>b;
	int ans = max(a+b , max(a+a-1 , b+b-1));
	cout<<ans<<endl;
}
signed main(){

	int t;
	t = 1;
	//cin>>t;

	while(t--)
		solve();

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,m;
	string s,t;
	cin >> n >> m >> s >> t;
	long long len=1LL*n*m/__gcd(n,m);
	for (int i=0;i<n;i++)
	{
		long long idx=1LL*i*m;
		if (idx%n==0 && idx/n<m && s[i]!=t[idx/n])
		{
			len=-1;
			break;
		}
	}
	cout << len;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  LL n,m; cin>>n>>m;
  LL an = (m*(m-1)/2) + (n*(n-1)/2);
  cout<<an<<endl;
  return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(All(h));
    vector<ll> div(n - k + 1);
    rep(i, n - k + 1)
    {
        div[i] = h[i + k - 1] - h[i];
    }

    sort(All(div));
    c(div[0]);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string> 
using namespace std;
string s;
int n,a[1010];
double b[1010],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=double(1)/double(a[i]);
		ans+=b[i];
	}
	cout<<1/ans<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    size_t w;
    cin >> w;
    for(size_t i = 0; i < s.size(); i += w)
    {
        cout << s[i];
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long LL;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define mxN (int) 2e5 + 2
#define MP make_pair
bool isPal(string s)
{
    string r(s);
    reverse(all(r));
    return s == r;
}

int main()
{
    int n;
    cin >> n;
    map<LL, LL> mp;
    vector<LL> a(n);
    for(int i = 0; i < n; i++)
    {
        LL x;
        cin >> x;
        a[i] = x;
        mp[x]++;
    }
    LL ttl = 0;
    for(auto x : mp)
    {
        ttl += (x.SS * (x.SS - 1)) / 2;
    }
    for(auto x : a)
    {
        cout << ttl - (mp[x] - 1) << endl;
    }


}





Measured memory_bytes: 11904
#include<cstdio>
#include<string.h>

int main(){
    char s[100005];
    int c=0;
    scanf("%s", s);
    if(s[0] == '1'){
        for(int i=0;i<strlen(s);i++){
            if(i % 2 == 0 and s[i] == '0'){
                c++;
            }
            if(i % 2 != 0 and s[i] == '1'){
                c++;
            }
        }
    }else{
        for(int i=0;i<strlen(s);i++){
            if(i % 2 == 0 and s[i] == '1'){
                c++;
            }
            if(i % 2 != 0 and s[i] == '0'){
                c++;
            }
        }
    }
    printf("%d", c);
    return 0;
}



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

int main(){
  int n, A[45];
  A[0] = A[1] = 1;
  cin >> n;
  for(int i = 2; i <= n; i++) A[i] = A[i-1] + A[i-2];
  cout << A[n] << endl;
  return 0;
}



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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());

        int diff = INT_MAX;
        for (int i = 0; i < n - 1; ++i) {
            diff = min(diff, a[i + 1] - a[i]);
        }
        cout << diff << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)

char ans[40];
string strdir = "URDL";
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
int h,w;
string ba;
bool solve(int y, int x, int dd, int c) {
  if (c==0) return 1;
  for (int i=-1;i<=1;++i) {
    int d = (dd+i+4)%4;
    int yy=y, xx=x;
    while(1) {
      yy+=dy[d];
      xx+=dx[d];
      if (yy<0||yy>=h||xx<0||xx>=w) break;
      if (ba[yy*w+xx] == 'o') {
        ba[yy*w+xx] = '.';
        ans[c]=strdir[d];
        if (solve(yy,xx,d,c-1)) return 1;
        ba[yy*w+xx] = 'o';
        break;
      }
    }
  }
  return 0;
}
int main() {
  cin>>h>>w;
  ba="";
  REP(i,h) {string s;cin>>s;ba+=s;}
  int y,x,d;
  int c=0;
  REP(i,h) REP(j,w) {
    REP(k,4) if (ba[i*w+j]==strdir[k]) y=i,x=j,d=k;
    if (ba[i*w+j] == 'o') c++;
  }
  solve(y,x,d,c);
  for (int i=c; i>0; --i) cout<<ans[i];cout<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    bool f[10]={};
    for(int i=0;i<k;i++){
        int t;
        cin>>t;
        f[t]++;
    }
    for(int i=n;;i++){
        if(i>=10000&&f[i/10000%10])continue;
        if(i>=1000&&f[i/1000%10])continue;
        if(i>=100&&f[i/100%10])continue;
        if(i>=10&&f[i/10%10])continue;
        if(f[i%10])continue;
        cout<<i<<endl;
        break;
    }
    return 0;
}

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

int main(){
	
	int x,h,i,con=0;
	double ru=0,num[200]={0},y;
		for(i=0;;i++){
	scanf("%d %d",&x,&h);
			
			ru=(double)x*x/4+h*h;
			y=sqrt(ru);
			num[i]=(double)x*x+2*x*y;
			con=con+1;
	if((x==0)&&(h==0)){
			con=con-1;
			break;
		}
	}
	for(i=0;i<con;i++)printf("%f\n",(double)(num[i]));
	return 0;
}
	

Measured memory_bytes: 1060
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int N;
int x[MAX_N], y[MAX_N];

struct edge {
  int cost, u, v;
  edge(int c, int a, int b) {
    cost = c; u = a; v = b;
  }
};

bool comp(edge& e1, edge& e2) {
  return e1.cost < e2.cost;
}

static const int MAX_UF = MAX_N;

template <class T> class UnionFind {
private:
  T par[MAX_UF];
  T rank[MAX_UF];
  
public:
  T find(T x);
  void init(T n);
  void unite(T x, T y);
  bool same (T x, T y);
};

template <class T> void UnionFind<T>::init(T n) {
  for (T i = 0; i < n; ++i) {
    par[i] = i;
    rank[i] = 0;
  }
}

template <class T> T UnionFind<T>::find(T x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

template <class T> void UnionFind<T>::unite(T x, T y) {
  x = find(x); y = find(y);
  if (x == y) {
    return;
  } else {
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) ++rank[y];
    }
  }
}

template <class T> bool UnionFind<T>::same(T x, T y) {
  return find(x) == find(y);
}

int main() {
  cin >> N;
  rep(i,N) cin >> x[i] >> y[i];
  vector<pii> vx, vy;
  rep(i,N) {
    vx.push_back(pii(x[i], i));
    vy.push_back(pii(y[i], i));
  }

  sort(all(vx)); sort(all(vy));

  vector<edge> evx, evy;
  for (int i = 0; i < N-1; ++i) {
    evx.push_back(edge(vx[i+1].fi-vx[i].fi, vx[i+1].sc, vx[i].sc));
    evy.push_back(edge(vy[i+1].fi-vy[i].fi, vy[i+1].sc, vy[i].sc));
  }

  sort(all(evx), comp); sort(all(evy), comp);
  

  ll ans = 0;
  UnionFind<int> uf;
  uf.init(N);
  int indx = 0, indy = 0;
  while (indx < N || indy < N) {
    if (indx == N) {
      if (uf.same(evy[indy].u, evy[indy].v)) {
        ++indy;
      } else {
        ans += evy[indy].cost;
        uf.unite(evy[indy].u, evy[indy].v);
        ++indy;
      }
      continue;
    }

    if (indy == N) {
      if (uf.same(evx[indx].u, evx[indx].v)) {
        ++indx;
      } else {
        ans += evx[indx].cost;
        uf.unite(evx[indx].u, evx[indx].v);
        ++indx;
      }
      continue;
    }

    if (comp(evx[indx], evy[indy])) {
      if (uf.same(evx[indx].u, evx[indx].v)) {
        ++indx;
      } else {
        ans += evx[indx].cost;
        uf.unite(evx[indx].u, evx[indx].v);
        ++indx;
      }
      continue;
    } else {
      if (uf.same(evy[indy].u, evy[indy].v)) {
        ++indy;
      } else {
        ans += evy[indy].cost;
        uf.unite(evy[indy].u, evy[indy].v);
        ++indy;
      }
      continue;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int tenall(int num){
	int a = 0;
	while(num){
		a += num % 10;
		num /= 10;
	}
	return a;
}

int main() {
	int N;
	cin >> N;
	if(N % tenall(N) == 0){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

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

using namespace std;

const int inf = 1e5;

int f[21][21];
int used[21][21];

int res = 0;
int n, m;

bool in(int x, int l, int r) {
	return (l <= x && x < r);
}

void bfs(int ci, int cj) {
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++)
		used[i][j] = f[i][j] == '#';
	
	int curr = 0;
	vector < pair< pair<int,int>, int> > que;
	que.push_back({{ci, cj}, 0});
	used[ci][cj] = 1;
	int head = 0, tail = 0;
	for (; head <= tail; head++) {
		//cout<<"head = "<<head<<endl;
		for (int di = -1; di <= 1; di++)
		for (int dj = -1; dj <= 1; dj++) {
			int i = que[head].first.first;
			int j = que[head].first.second;
						
			if (di * dj == 0 && in(i + di, 0, n) && in(j + dj, 0, m) && !used[i + di][j + dj]) {
				tail++;
				used[i + di][j + dj] = 1;
				que.push_back({{i + di, j + dj}, que[head].second + 1});
			}
			//cout<<"pass\n";
		}
	}
	for (int i = 0; i < que.size(); i++)
		curr = max(curr, que[i].second);
	res = max(curr, res);
}

int main() {
	ios::sync_with_stdio(false);
	cin>>n>>m;	
	for (int i = 0; i < n; i++) {
		string s;
		cin>>s;
		for (int j = 0; j < m; j++)
			f[i][j] = s[j];
	}
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++)
		if (f[i][j] == '.') bfs(i, j);
		
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int S, h, m, s;
  cin >> S;
  h = S/3600;
  m = S%3600/60;
  s = S-(h*3600+m*60);
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

typedef long long ll;

int dp[500][20];

int rec(int cost, int coin){
	if (cost < 0) return 0;
	if (cost <= 3) return 1;
	int &res = dp[cost][coin];
	if (res >= 1) return res;

	res = 1;
	for (int i = coin; i >= 2; --i){
		res += rec(cost - i*i, i);
	}
	return res;
}

int main(){
	int n;
	while (cin >> n, n){
		cout << rec(n, 17) << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int a,b,c; 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
     int a, b, length, circum ;
     scanf("%d %d", &a, &b) ;
     length = a * b ;
     circum = 2 * (a+b) ;
     printf("%d %d", length, circum);
     cout << endl;
    return 0;
}



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n,k;
    cin >> n >> k;
    vector<LL> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    LL ans = INT64_MAX;
    for (int i = 0; i < x.size() - k + 1; i++) {
        if (x[i] < 0 and x[i+k-1] >= 0) {
            ans = min(ans,min(-x[i],x[i+k-1])*2+max(-x[i],x[i+k-1]));
        }
        else {
            ans = min(ans,max(abs(x[i]),abs(x[i+k-1])));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int a,b,s;
int main()
{
    string s1;
    cin>>a>>b;
    cin>>s1;
    if(s1[a]!='-')
    {
        cout<<"No"<<endl;
        return 0;
    }
    s1[a]='1';
    for(int i=0;i<=a+b;i++)
    {
        if(s1[i]<'0'||s1[i]>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
} 

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

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int main() {
  int n;
  string s;
  cin >> n >> s;
  REP(i, s.size()) { s[i] = (s[i] - 'A' + n) % 26 + 'A'; }
  cout << s << endl;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int w;
  cin >> w;

  int i = 0;
  while(i < s.size()) {
    cout << s[i];
    i += w;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

#define ll long long

int main()
{
  ll N, x, crnt, prev = 0, cnt = 0;

  cin >> N >> x;

  for(ll i = 0; i < N; i++) {
    cin >> crnt;

    if(prev + crnt > x) {
      cnt += (prev + crnt) - x;
      crnt -= (prev + crnt) - x;
    }
    prev = crnt;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans1=0,n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%2==0) continue;
		int ans=0;
		for(int j=1;j<sqrt(i);j++)
		{
			if(i%j==0) ans++;
		}
		ans*=2;
		if(sqrt(i)==(int)sqrt(i)) ans++;
		if(ans==8) ans1++;
	}
	printf("%d\n",ans1);
	return 0;
}

Measured memory_bytes: 256
#N, M, Qの制約がしょぼいので、総当たりで計算する。O(MCN)で済む。
import itertools
N, M, Q = map(int, input().split())
point = []
for i in range(Q):
    a = list(map(int, input().split()))
    point.append(a)
#まず1 ~ MからNコ選んだ数列をすべて作る。
all = list(itertools.combinations_with_replacement([i + 1 for i in range(M)], N - 1))
ans = []
m = 0
for i in all:
    now = [1]
    now += list(i)
    p = 0
#    print("i", now)
    for j in point:
#        print("j", j)
        a, b, c, d = j[0], j[1], j[2], j[3]
        if now[b - 1] - now[a - 1] == c:
            p += d
    if p > m:
#        print(p, i)
        m = p
        ans = now
print(m)


Measured memory_bytes: 14828
import sys

n=int(input())
s=input()
k=n//2
ans=0
if n%2 !=0:
    print('No')
    sys.exit()
for i in range(k):
    if s[i]==s[k+i]:
        ans+=1
    
if ans==k:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while((str = br.readLine()) != null) {
			String ns[] = str.split(",");
			double d[][] = new double[4][2];
			for(int i = 0; i < 4; i++) {
				for(int j = 0; j < 2; j++) {
					d[i][j] = Double.parseDouble(ns[i * 2 + j]);
				}
			}
			int ret = 0;
			for(int i = 0; i < 4; i++) {
				if(((d[(i + 1) % 4][0] - d[i][0]) * (d[(i + 2) % 4][1] - d[(i + 1) % 4][1]) - 
						(d[(i + 1) % 4][1] - d[i][1]) * (d[(i + 2) % 4][0] - d[(i + 1) % 4][0])) > 0) {		
					ret += 1;
				} else {
					ret -= 1;
				}
			}
			
			if(Math.abs(ret) == 4) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

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

using namespace std;

int main() {
  int n;
  string c;
  cin >> n >> c;

  int w = 0;
  int r = 0;

  for(int i = 0; i < n; i++){
    if(c[i] == 'W'){
      w++;
    }
  }
  r = n - w;

  int w1 = 0;
  int r1 = 0;
  for(int i = n; i < n - w; i--){
    if(c[i] == 'W'){
      w1++;
    }
  }
  for(int i = 0; i < r; i++){
    if(c[i] == 'R'){
      r1++;
    }
  }

  if(r1 >= w1){
    cout << r - r1 << endl;
  }
  else{
    cout << w - w1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3728
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	V a(n+2);
	REP(i, 1, n+1) scanf("%ld", &a[i]);
	a[0] = a[n+1] = 0;

	V l(n+2), r(n+2);
	REP(i, 0, n+1){
		l[i+1] = l[i] + labs(a[i+1] - a[i]);
		r[n-i] = r[n-i+1] + labs(a[n-i+1]-a[n-i]);
	}

	REP(i, 1, n+1){
		ll mid = labs(a[i+1] - a[i-1]);
		printf("%ld\n", l[i-1] + mid + r[i+1]);
	}
	return 0;
}



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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    int n, m, a;
    array<int, 50> c = {0};
    cin >> n >> m;
    REP(i, m){
        REP(j, 2){
            cin >> a;
            c[a-1]++;
        }
    }
    REP(i, n){
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0
using namespace std;
int n;
int dp[110][4][4][4];
signed main() {
	cin>>n;
	dp[0][3][3][3]=1;
	rep(i,n){
		rep(j,4){
			rep(k,4){
				rep(l,4){
					rep(m,4){
						if(i==0||i==1||(!(k==0&&l==2&&m==1)&&!(k==2&&l==0&&m==1)&&!(k==0&&l==1&&m==2)&&!(j==0&&l==2&&m==1)&&!(j==0&&k==2&&m==1)))dp[i+1][k][l][m]+=dp[i][j][k][l];
						dp[i+1][k][l][m]%=moder;
					}
				}
			}
		}
	}
	int ans=0;
	rep(i,4){
		rep(j,4){
			rep(k,4)ans+=dp[n][i][j][k];
			ans%=moder;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
uses crt;
var
       // f: text;
        x,cs: array [0..100000] of longint;
        i,j,n,k,cr: longint;

begin
      //  assign (f, fi); reset(f);
        readln ( n,k);
        for i:=1 to n do read ( x[i]);

        for i:=0 to k do cs[i]:=2;

        for i:=x[1] to k do
        for j:=1 to n do
        begin
        if i - x[j] >= 0 then
        begin
            cr:= i - x[j];
            if cs[cr] = 2 then cs[i]:= 1;
        end;

        end;

        If cs[k] = 2 then write ('Second') else write ('First');
        readln;
end.


Measured memory_bytes: 512
N = int(input())

A = []
for i in range(N):
    a = int(input())
    A.append([a, i])
    
A_ = sorted(A, reverse=True)

#print(A_)

for i in range(N):
    if A_[0][1] == i:
        print(A_[1][0])
    else:
        print(A_[0][0])


Measured memory_bytes: 39384