akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(an);
  map<string, int> amap;
  string list_input(a, an);
  forin(v, a) {
    amap[v] += 1;
  }

  int in(bn);
  string list_input(b, bn);
  forin(v, b) {
    amap[v] -= 1;
  }

  set<string> aset(a, a + an);
  int max_value = 0;
  forin(v, aset) {
    max_value = max(max_value, amap[v]);
  }

  out(max_value);
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    string s;
    cin >> s;

    ll ans = 0;
    for(int i=0;i<(1<<(s.size()-1));i++){
        ll val = s[0]-'0';
        for(int j=0;j<s.size()-1;j++){
            if(i & (1<<j)){
                ans += val;
                val = s[j+1]-'0';
            }else{
                val *= 10;
                val += s[j+1]-'0';
            }
        }
        ans += val;
    }

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

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M) {
  if (factmemoMod == M) return factmemo[n];
  if (n <= 1) return 1;

  ll res = 1;
  for (int i = 1; i <= n; i++) res = res * i % M;
  return res;
}

ll power(ll k, ll n, int M) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

ll C(ll n, ll k, int M) {
  ll a = 1, b = 1;

  for (int i = 0; i < k; i++) {
    a *= n - i;
    b *= i + 1;
    a %= M;
    b %= M;
  }

  return a * power(b, M - 2, M) % mod;
}


int main() {
  int N, A, B;

  cin >> N >> A >> B;

  ll ans = power(2, N, mod) - 1;
  ans += mod - C(N, A, mod);
  ans += mod - C(N, B, mod);

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

int main() {
	int a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (a > b) 
		swap(a, b);
	if (a + (ll) t * v >= b + (ll) t * w)
		cout << "YES\n";
	else
		cout << "NO\n";
		
	return 0;
}	


Measured memory_bytes: 3620
#include <iostream>
#include <deque>
#include <vector>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <iomanip>

#define i64 long long
#define ui64 unsigned long long
#define REP(i,n) for(int (i)=0;(i)<(n);i++)
#define REP2(i,k,n) for(int (i)=(k);(i)<(n);i++)
#define MDIST(a,b) abs(a-b)
#define DIST(a,b) sqrt((a)*(a)+(b)*(b))
#define ATCODER 1000000007
using namespace std;
 
////////////////////////

struct po{
  double x,y;
  po(double x_,double y_):x(x_),y(y_){};
  po():x(0),y(0){};
};

struct vc{
  double x,y;
  vc():x(0),y(0){};
  vc(po f ,po t):x(t.x - f.x),y(t.y - f.y){
    // x = t.x - f.x;
    // y = t.y - f.y
  };
};

double norm(vc &a){
  return DIST(a.x,a.y);
}

double dot(vc &a,vc &b){
  return a.x*b.x+a.y*b.y;
}

int main(){
  double a,b,c,d;
  cin >> a >> b >> c >> d;
  po p(a,b),q(c,d);
  vc v1(p,q);
  cin >> a;
  cout << fixed;
  cout << setprecision(10);
  REP(i,a){
    cin >> b >> c;
    po r(b,c);
    vc v2(p,r);
    double t = dot(v1,v2) / (norm(v1) * norm(v1));
    cout << p.x+v1.x*t << " " << p.y+v1.y*t << endl;
  }
  
}

Measured memory_bytes: 3288
from itertools import *
g=lambda a,x,b:{'+':a+b,'-':a-b,'*':a*b}[x]
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(g(a,x,b),y,c),z,d)==10:return f"(({a}{x}{b}){y}{c}){z}{d}"
   if g(g(a,x,b),y,g(c,z,d))==10:return f"({a}{x}{b}){y}({c}{z}{d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5660
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;


int N, C, D[30][30], c[500][500];
int s[3],stat[3][30];
/*
30 * 30 * 30 = 27000

各%3の領域について、各色の統計を取っとけば、
領域ごとの塗り替え先を列挙しても一瞬で算出できる

500 * 500 = 250000
*/

int main() {
    cin >> N >> C;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            s[(i+j+2) % 3]++;
            stat[(i+j+2) % 3][c[i][j]-1] += 1;
        }
    }
    ll res = INF;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            if (i == j) continue;
            for (int k = 0; k < C; k++) {
                if (i == k || j == k) continue;
                ll tmp = 0;
                for (int n = 0; n < C; n++) {
                    tmp += stat[0][n] * D[n][i];
                }
                for (int n = 0; n < C; n++) {
                    tmp += stat[1][n] * D[n][j];
                }
                for (int n = 0; n < C; n++) {
                    tmp += stat[2][n] * D[n][k];
                }
                chmin(res, tmp);
            }
        }
    }
    cout << res << endl;




}



Measured memory_bytes: 1280
var
s2,s,s1:string;
x,y,z,i,j:longint;
begin
read(x,y);
str(x,s);
str(y,s1);
s2:=s+s1;
val(s2,x);
if trunc(sqrt(x))=sqrt(x) then writeln('Yes')
else
writeln('No');
end.

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 mc = -1, mf = -1;
	string ss;
	cin >> ss;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		if(ss[ii] == 'C')
		{
			mc = ii;
			break;
		}
	}
	if(mc == -1)
	{
		puts("No");
		return 0;
	}
	for(int64 ii = mc + 1;ii < ss.length();ii++)
	{
		if(ss[ii] == 'F')
		{
			mf = ii;
			break;
		}
	}
	if(mc != -1 && mf != -1)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    int n;
    scanf("%d",&n);
    int cnt =0;
    
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(i&1)cnt+=a[i];
        else cnt-=a[i];
    }
    
    for(int i=1;i<=n;i++){
        printf("%d ",cnt);
        cnt=(a[i]-cnt/2)*2;
        
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

struct card { char suit, value; };

void ss(struct card a[], int n) {
	for (int i = 0; i < n-1; i++) {
		int minj = i;
		for (int j = i; j < n ; j++) {
			if (a[j].value < a[minj].value) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
	}
	return;
}

void bs(struct card a[], int n) {
	int i = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j].value < a[j - 1].value) {
				swap(a[j], a[j - 1]);
				flag = 1;
			}
		}
		i++;
	}
	return;
}

void print(struct card a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i) {
			cout << " ";
		}
		cout << a[i].suit << a[i].value;
	}
	cout << endl;
}

bool isstable(struct card c1[], struct card c2[], int n) {
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			for (int a = 0; a < n; a++) {
				for (int b = a+1; b < n; b++) {
					if (c1[i].value == c1[j].value && c1[i].value == c2[b].value && c1[j].value == c2[a].value && c1[i].suit == c2[b].suit && c1[j].suit == c2[a].suit) {
						return false;
					}
				}
			}
		}
	}
	return true;
}

int main() {
	card c1[100], c2[100],c[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c1[i].suit >> c1[i].value;
	}
	for (int i = 0; i < n; i++) {
		c2[i] = c1[i];
		c[i] = c1[i];
	}
	bs(c1, n);
	ss(c2, n);
	print(c1, n);
	if (isstable(c1, c, n)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	print(c2, n);
	if (isstable(c2, c, n)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll ans[10];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll h,w;
    cin>>h>>w;
    ll n;
    cin>>n;
    vector<ii> v;
    while(n--){
        ll a,b;
        cin>>a>>b;
        if(a>=3 && b>=3){
            v.pb({a-2,b-2});
        }
        if(a>=3 && b>=2 && b+1<=w){
            v.pb({a-2,b-1});
        }
        if(a>=3 && b>=1 && b+2<=w){
            v.pb({a-2,b});
        }
        if(a>=2 && b>=3 && a+1<=h){
            v.pb({a-1,b-2});
        }
        if(a>=2 && b>=2 && a+1<=h && b+1<=w){
            v.pb({a-1,b-1});
        }
        if(a>=2 && b>=1 && a+1<=h && b+2<=w){
            v.pb({a-1,b});
        }
        if(a>=1 && b>=3 && a+2<=h){
            v.pb({a,b-2});
        }
        if(a>=1 && b>=2 && a+2<=h && b+1<=w){
            v.pb({a,b-1});
        }
        if(a>=1 && b>=1 && a+2<=h && b+2<=w){
            v.pb({a,b});
        }
    }
    sort(v.begin(),v.end());
    v.pb({h+1,w+1});
    ll count=1;
    ii temp=v[0];
    for(ll i=1;i<v.size();i++){
        if(v[i]==temp){
            count+=1;
        }
        else{
            ans[count]+=1;
            count=1;
            temp=v[i];
        }
    }
    ll answer=0;
    for(int i=0;i<10;i++){
        answer+=ans[i];
    }
    ans[0]=(h-2)*(w-2)-answer;
    for(int i=0;i<10;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 18664
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string x; cin >> x;
    int n = (int)x.size();
    int ans = n, now = 0;
    rep(i, n) {
        if(x[i] == 'S') ++now;
        else {
            if(now > 0) {
                ans -= 2;
                now --;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

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

typedef long long ll;

int main(){
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.length();i++){
    if(s==t) {
      cout << "Yes" << endl;
      return 0;
    }
    s = s+s[0];
    s = s.substr(1);
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mod 1000000007
#define N 2010
#define lint long long
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
int dp[N][N],f[N*N],fi[N*N];
inline int fast_pow(int x,int k,int ans=1)
{	for(;k;k>>=1,x=(lint)x*x%mod) (k&1)?ans=(lint)ans*x%mod:0;return ans; }
inline int prelude(int n)
{
	for(int i=f[0]=1;i<=n;i++) f[i]=(lint)f[i-1]*i%mod;
	fi[n]=fast_pow(f[n],mod-2);
	for(int i=n-1;i>=0;i--) fi[i]=fi[i+1]*(i+1ll)%mod;
	return 0;
}
inline int C(int n,int m)
{
	if(m>n||m<0||n<0) return 0;
	return (lint)f[n]*fi[m]%mod*fi[n-m]%mod;
}
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	dp[0][0]=1,prelude(n*k);
	if(k==1) return !printf("1\n");
	rep(i,0,n-1) rep(j,i,n) if(dp[i][j])
		(i<j?(dp[i+1][j]+=dp[i][j])%=mod:0),
		(dp[i][j+1]+=(lint)dp[i][j]*C((j+1)*(k-1)+i-1,k-2)%mod)%=mod;
//	rep(i,0,n) rep(j,i,n) debug(i)sp,debug(j)sp,debug(dp[i][j])ln;
	return !printf("%lld\n",(lint)dp[n][n]*f[n]%mod);
}

Measured memory_bytes: 47488
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n;
  scanf("%d",&n);
  int a[n];
  FOR(n)scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),u);
  int ans=0;
  int p[a[n-1]],cnt=0;
  for(int i=1;i<=(int)sqrt(a[n-1]);i++){
    if(a[n-1]%i<1){
      p[cnt]=i;
      p[cnt+1]=a[n-1]/i;
      cnt+=2;
    }
  }
  qsort(p,cnt,sizeof(int),u);
  FOR(n-1){
    int x=0;
    while(p[x]<a[i])x++;
    ans+=p[x]-a[i];
  }
  PRN(ans);
  return 0;
}



Measured memory_bytes: 2316
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin>>n;
	long long tot=0;
	
	for(int i=1; i<=n; i++){
		if(i%3 && i%5) tot+=i;
	}
	cout<<tot;

    return 0;
}

Measured memory_bytes: 3652
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    if (m == 1) {
        if (K == 1) {
            cout << 1 << '\n';
        } else {
            cout << 0 << '\n';
        }
        return 0;
    }

    const long long MOD = 1000000007;

    int M = 1 << (m - 1);

    vector<long long> dp(m, 0);
    dp[0] = 1;

    auto ndp = dp;
    for (int _ = 0; _ < n; ++_) {
        fill(ndp.begin(), ndp.end(), 0);
        for (int i = 0; i < m; ++i) {
            if (dp[i] == 0) {
                continue;
            }
            for (int j = 0; j < M; ++j) {
                if (j & (j >> 1)) {
                    continue;
                }

                int ni = -1;
                for (int k = -1; k < 1; ++k) {
                    int x = i + k;
                    if (x >= 0 && (j & (1 << x))) {
                        assert(ni == -1);
                        ni = k < 0 ? i - 1 : i + 1;
                    }
                }
                if (ni == -1) {
                    ni = i;
                }
                (ndp[ni] += dp[i]) %= MOD;
            }
        }
        swap(ndp, dp);
    }

    cout << dp[K - 1] << '\n';

    return 0;
}

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

using namespace std;

int dfs(int & n, int & a, int & b, int & c, vector<int> & l,
		 int ptr, int ca, int cb, int cc){
	if(ptr == n){
		if(min({ca, cb, cc}) <= 0) return 1e9;
		return abs(a - ca) + abs(b - cb) + abs(c - cc);
	}

	int ress = dfs(n, a, b, c, l, ptr + 1, ca, cb, cc);
	int resa = dfs(n, a, b, c, l, ptr + 1, ca + l[ptr], cb, cc) + (ca > 0 ? 10 : 0);
	int resb = dfs(n, a, b, c, l, ptr + 1, ca, cb + l[ptr], cc) + (cb > 0 ? 10 : 0);
	int resc = dfs(n, a, b, c, l, ptr + 1, ca, cb, cc + l[ptr]) + (cc > 0 ? 10 : 0);
	return min({ress, resa, resb, resc});	
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> l(n);
	for(int i = 0; i < n; ++i){
		cin >> l[i];
	}

	cout << dfs(n, a, b, c, l, 0, 0, 0, 0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

void dfs(vector<int>&visited, vector<vector<int> >&G, int N, int p)
{
  visited[p] = 1;
  for(int i=0; i < N; i++){
    if(G[p][i] == 1 && visited[i] == 0)
      dfs(visited, G, N, i);
  }
  return;
}


int main()
{
  int N,M;
  cin >> N >> M;
  vector<vector<int> >G(N, vector<int>(N, 0));
  vector<int>A(M);
  vector<int>B(M);
  for(int i=0; i < M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    A[i] = a;
    B[i] = b;
    G[a][b] = 1;;
    G[b][a] = 1;
  }
  int ans=0;
  for(int i=0; i < M; i++){
    int a,b;
    a = A[i];
    b = B[i];
    G[a][b] = 0;
    G[b][a] = 0;
    vector<int>visited(N, 0);
    dfs(visited, G, N, 0);
    bool no = false;
    for(int j=0; j < N; j++)
        if(visited[j] == 0)
	  no = true;
    if(no)
      ans++;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,i,mn[N],mx,lt[N],f[N],g[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
struct arr{int x,k;}a[N];
bool operator < (arr A,arr B){return A.x<B.x;}
bool cmp(arr A,arr B){return A.k<B.k;}
int main(){
	for (n=read(),i=1;i<=n;i++)
		a[i]=(arr){read(),read()};
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++) a[i].x=i;
	sort(a+1,a+n+1,cmp);
	for (mn[n]=a[n].x,i=n-1;i;i--)
		mn[i]=min(mn[i+1],a[i].x);
	for (i=1;i<=n;i++){
		mx=max(mx,a[i].x);
		lt[mx]=max(lt[mx],mn[i]);
	}
	f[0]=g[0]=1;mx=0;
	for (i=1;i<=n;i++){
		f[i]=(g[i-1]-(mx?g[mx-1]:0))%mo;
		g[i]=(g[i-1]+f[i])%mo;
		mx=max(mx,lt[i]);
	}
	printf("%d",((g[n]-(mx?g[mx-1]:0))%mo+mo)%mo);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod  200003//1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)



int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   char c;
   cin>>c;
   if((int(c))>=65 && (int(c)<=90)){
      cout<<'A';
   }else{
      cout<<'a';
   }
  
   return 0;
}

Measured memory_bytes: 3668
#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 PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# 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 dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

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

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

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

    int n = s.size() ;
    int ans = 0 ;

    for ( int i=0 ; i < n ; i ++ )
    {
        ans += ( s[i] != t[i] ) ;
    }

    cout << ans ; line ;
}

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

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  map<char,ll> s;
  for(ll i=0;i<n;i++) {
    string temp;
    cin >> temp;
    s[temp[0]]++;
  }
  vector<pll> count;
  for(auto p:s) {
    if(p.first=='M'||p.first=='A'||p.first=='R'||p.first=='C'||p.first=='H') {
      count.push_back(pll(p.second,p.first));
    }
  }
  if(count.size()<3) {
    cout << 0 << endl;
    return 0;
  }
  ll ans=0;
  for(ll i=0;i<count.size();i++) {
    for(ll j=i+1;j<count.size();j++) {
      for(ll k=j+1;k<count.size();k++) {
        ans+=count[i].first*count[j].first*count[k].first;
      } 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD ((ll)1e9+7)

int main() {

	int N, M;
	cin >> N >> M;
	vector<int> a(100001, 0);
	if (M != 0) {
		for (int i = 0; i < M; i++) {
			cin >> a[i];
		}
	}

	vector<ll> dan(N + 1);
	dan[0] = 1;
	int j = 0;
	for (int i = 1; i < N + 1; i++) {
		if (i == a[j]) {
			if (dan[i - 1] == 0) {
				cout << 0;
				return 0;
			}
			else {
				dan[i] = 0;
			}

			if (j < M - 1) { j++; }
		}
		else {
			if (i == 1) {
				dan[i] = dan[i - 1];
			}
			else {
				dan[i] = dan[i - 1] + dan[i - 2];
			}
		}
		dan[i] %= MOD;
	}
	cout << dan[N];
	return 0;
}

Measured memory_bytes: 1408
def score(x):
  sc = 0
  th = 1
  for _ in [0]*10:
    a = 2
    b = 3
    if x[th]==10: a=1
    elif x[th]+x[th+1]!=10: b=2
    sc += sum(x[th:th+b])
    th += a
  return x[0],sc

while 1:
  n = input()
  if n==0: break
  A = [score(map(int,raw_input().split())) for _ in [0]*n]
  for a, b in sorted(A, key=lambda x: (-x[1], x[0])):
    print a,b

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

int main() {
	string a,b,c;
	int aa,bb,cc;
	int A=1,B=0,C=0;
	char x;
	cin >> a >> b >> c;
	aa=a.size();
	bb=b.size();
	cc=c.size();
	x=a[0];
	while(1){
		if(A==aa+1){
		 cout<< "A" <<endl;
		 break;
	}
	if(B==bb+1){
		 cout<< "B" <<endl;
		 break;
	}
	if(C==cc+1){
		 cout<< "C" <<endl;
		 break;
	}
	if(x=='a'){
		x=a[A];
		A++;
	}else if(x=='b'){
		x=b[B];
		B++;
	}else if(x=='c'){
		x=c[C];
		C++;
	}
	
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    string S, T;
    cin >> S >> T;
    int max_count = 0;
    for(int i=0; i<=S.size()-T.size(); i++) {
        int count=0;
        for(int j=0; j<T.size(); j++) {
            if(S[i+j] == T[j]) count++;
        }
        max_count = max(max_count, count);
    }
    cout << T.size()-max_count << endl;
}

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


int main() {
	
	int N, sum=0;
	cin >> N;
	vector<int> l(N);
	for(auto &i:l) cin >> i;
	sort(l.begin(), l.end());
	for(int i=0; i<N-1; i++) sum += l.at(i);
	if(l.at(N-1)<sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int dp[5010], rdp[5010][5010];

signed main(){
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	rdp[N][0] = 1;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < K; ++j) {
			rdp[N - i - 1][j] = rdp[N - i][j];
			if (j - a[N - i - 1] >= 0) {
				rdp[N - i - 1][j] |= rdp[N - i][j - a[N - i - 1]];
			}
		}
	}
	for(int i = 0; i <= N; ++i) {
		for(int j = 1; j <= K; ++j) {
			rdp[i][j] += rdp[i][j - 1];
		}
		for(int j = K + 1; j > 0; --j) {
			rdp[i][j] = rdp[i][j - 1];
		}
		rdp[i][0] = 0;
	}
	int cnt = 0;
	dp[0] = 1;
	for(int i = 0; i < N; ++i) {
		bool f = false;
		for(int j = 0; j < K; ++j) if (dp[j]) {
			int l = max(K - a[i] - j, 0LL), u = K - j;
			//cerr << i << "," << j << "," << l << "," << u <<"," << rdp[i + 1][l] << "," << rdp[i + 1][u] << endl;
			if (rdp[i + 1][u] - rdp[i + 1][l] > 0) {
				f = true;
			}
		}
		if(f) {
			//cerr << a[i] << endl;
			++cnt;
		}
		for(int j = K; j >= a[i]; --j) {
			dp[j] |= dp[j - a[i]];
		}
	}
	cout << N - cnt << endl;

	return 0;
}


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

#define maxn 1005

int n;
char ans[maxn][maxn];
char s3[5][5] = {"aa.", "..b", "..b"};
char s4[5][5] = {"aabd", "ccbd", "deff", "degg"};
char s5[6][6] = {"aaeff", "b.e.g", "b.jjg", ".ccih", "dd.ih"};
char s6[8][8] = {"aabcc.", "b.b..d", "baa..d", "cc.aab", "..db.b", "..dbaa"};
char s7[8][8] = {"a.aa.a.", "a....ac", ".dd.bbc", "b..b..a", "b..b..a", ".ee.ccb", "cc.aa.b"};

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans[i][j] = '.';
    if (n == 2)
    {
        printf("-1\n");
        return 0;
    }
    if (n == 7)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                printf("%c", s7[i][j]);
            printf("\n");
        }
        return 0;
    }
    if (n == 3)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                printf("%c", s3[i][j]);
            printf("\n");
        }
        return 0;
    }
    if (n == 6)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                printf("%c", s6[i][j]);
            printf("\n");
        }
        return 0;
    }
    if (n == 11)
    {
        for (int i = 0; i < 6; i++)
        {
            for (int j = 0; j < 6; j++)
                ans[i][j] = s6[i][j];
        }
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 5; j++)
                ans[6 + i][6 + j] = s5[i][j];
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                printf("%c", ans[i][j]);
            printf("\n");
        }
        return 0;
    }
    int x, y;
    // 4x+5y=n
    for (int i = 0; i * 4 <= n; i++)
    {
        if ((n - 4 * i) % 5 == 0)
        {
            x = i;
            y = (n - 4 * i) / 5;
        }
    }
    //printf("%d %d\n", x, y);
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
                ans[i * 4 + j][i * 4 + k] = s4[j][k];
        }
    }
    for (int i = 0; i < y; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            for (int k = 0; k < 5; k++)
                ans[4 * x + i * 5 + j][4 * x + i * 5 + k] = s5[j][k];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            printf("%c", ans[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if(A==B){
        cout << 2*A << endl;
    }
    else{
        cout << 2*max(A,B)-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli         long long int
#define pb          push_back
#define pll         pair<lli,lli>
#define vl          vector<lli>
#define mp          make_pair
#define vll         vector<pll>
#define mll          map<lli,lli>
#define mpl         map<pii,lli>
#define endl        '\n'
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(i=a;i<b;i++)
#define it(b)       for(__typeof(b.begin())it=b.begin();it!=b.end();it++)

using namespace std;


//binary search
lli b_s(lli a[],lli l,lli r,lli result)
{ lli m;
    while(r>=l)
    {
        m=l+(r-l)/2;
        if(a[m]==result)
        return m;
        else if(a[m]>result)
        r=m-1;
        else
        l=m+1;
    }
    return -1;
}

/*


//dfs

void initialize() {
    for(int i = 0;i < nodes;++i)
     visited[i] = false;
}

lli nodes;
vector <lli> adj[nodes];
bool visited[nodes];
void dfs(int s)
{
    visited[s] = true;
    for(int i = 0;i < adj[s].size();++i)
    {
     if(visited[adj[s][i]] == false)
         dfs(adj[s][i]);
    }
}

*/


//bfs




//mastermind
void solve ()
{   lli n,i,j,k;
    cin>>n>>k;
    lli h[n];

    rep(i,0,n) cin>>h[i];
      vl dp(n,hell);
    dp[0]=0;
    rep(i,0,n)
    {
        for(j=i+1;j<=i+k;j++)
        {   if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
        }
    }
    //cout<<6;
cout<<dp[n-1];
}



//driver code
int main ()
{
  ios::sync_with_stdio (false);
  cin.tie (0);
  cout.tie (0);

  lli t=1;
// cin >> t;
  while (t--)
    {
      solve ();
    }
  return 0;
}



Measured memory_bytes: 4768
NIL = -1

def assignColor():
    id = 1
    for i in range(n):
        color[i] = NIL
    for u in range(n):
        if color[u] == NIL:
            dfs(u, id)
            id += 1

def dfs(r, c):
    S = []
    S.append(r)
    color[r] = c
    while S:
        u = S.pop()
        for v in (G[u]):
            if color[v] == NIL:
                color[v] = c
                S.append(v)


nums=list(map(int,input().split()))
n = nums[0]
m = nums[1]
G = []
color = [NIL] * n

for i in range(n):
    G.append(set())
    
for i in range(m):
    nodes=list(map(int,input().split()))
    G[nodes[0]].add(nodes[1])
    G[nodes[1]].add(nodes[0])

assignColor()

q = int(input())
for i in range(q):
    questions=list(map(int,input().split()))
    if color[questions[0]] == color[questions[1]]:
        print("yes")
    else:
        print("no")









Measured memory_bytes: 39312
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			if (i - 1 != 0) {
				
				if (n / (i - 1) == n % (i - 1)) {
					ans += i - 1;
				}
			}
			if (n / i - 1 != 0) {
				if (n / (n / i - 1) == n % (n / i - 1)) {
					ans += n / i - 1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 200005;
int num[N];
int main(){
    int n;
    scanf("%d",&n);
    int sum = 0;
    FOR(i, 1, n){
        scanf("%d",&num[i]);
        sum ^= num[i];
    }
    FOR(i, 1, n){
        printf("%d ",sum^num[i]);
    }
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
int main(){
	long long n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	long long sum=0;
	for(int i=n-1-k;i>=0;i--){
		sum+=a[i];
	}
	cout<<sum;
	
	
	
	return 0;
} 

Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long n;
	cin >> n;
	vector<long long> geko;
	REP(i, n) {
		long long a;
		cin >> a;
		geko.push_back(a);
	}
	sort(geko.begin(), geko.end());
	cout << geko[geko.size() - 1] - geko[0] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int a[55];
int x[105], y[105];

int main(){
    int n;
    scanf("%d",&n);
    int maxn = 1, minn = 1;
    for(int i = 1; i <= n; i++){ 
        scanf("%d",&a[i]);
        if(a[i]>a[maxn]) maxn = i;
        if(a[i]<a[minn]) minn = i;
    }
    int size = 0;
    if(a[maxn]+a[minn]>=0){
        for(int i = 1; i <= n; i++){
            x[++size] = maxn; y[size] = i;
        }
        for(int i = 1; i <= n-1; i++){
            x[++size] = i; y[size] = i+1;
        }
    }
    else{
        for(int i = 1; i <= n; i++){
            x[++size] = minn; y[size] = i;
        }
        for(int i = n; i >= 2; i--){
            x[++size] = i; y[size] = i-1;
        }
    }
    printf("%d\n",size);
    for(int i = 1; i <= size; i++) printf("%d %d\n",x[i],y[i]);
    return 0;
}


Measured memory_bytes: 1736
from collections import defaultdict
from heapq import heappop, heappush


class Graph():

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra():

    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float("inf"))
        self.dist[start] = 0

        self.prev = defaultdict(lambda: None)

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)

            if self.dist[u] < dist_u:
                continue

            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):

        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal

        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]


import sys
input=sys.stdin.readline
n,m=map(int,input().split())
g=Graph()

for _ in range(m):
    l,r,c=map(int,input().split())
    g.add_edge(l,r,c)
for i in range(2,n+1):
    g.add_edge(i,i-1,0)


d = Dijkstra(g,1)
ans=d.shortest_distance(n)
print(ans if ans!=float("inf") else -1)


Measured memory_bytes: 110428
if __name__ == '__main__':
	 N = int(input())
	 
	 ans = 0

	 for i in range(1,N+1):
	 	w5 = i%5
	 	w3 = i%3
	 	if w5 != 0 and w3 !=0:
	 		ans += i

	 print(ans)

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

void bannedK(int N, vector<int> &array, vector<long long> &numCount) {
	long long ans = 0;
	for(auto &num : numCount) {
		if (num < 2) {
			continue;
		}
		ans += (num * (num - 1)) / 2;
	}

	for (int i = 0; i < N; i++) {
		cout << (ans - numCount[array[i] - 1] + 1) << endl;
	}
}

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

	vector<int> array(N, 0);
	vector<long long> numCount(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> array[i];
		numCount[array[i] - 1]++;
	}

	bannedK(N, array, numCount);

	return 0;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k - n) << endl;
	return 0;
}



Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;



int n, m, k;
bool check(vector<vector<char>>&c, vector<int> &a, vector<int> &b) {
	int res = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (!a[i] && !b[j] && c[i][j] == '#') {
				++res;
			}
		}
	}
	return res == k;
}
signed main() {
	speed;
	cin >> n >> m >> k;
	vector<vector<char>> c(n, vector<char>(m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> c[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); ++i) {
		for (int j = 0; j < (1 << m); ++j) {
			vector<int> a(n), b(m);
			for (int t = 0; t < n; ++t) {
				if (i & (1 << t)) {
					a[t] = 1;
				}
			}
			for (int t = 0; t < m; ++t) {
				if (j & (1 << t)) {
					b[t] = 1;
				}
			}
			ans += check(c, a, b);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656