akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	string s;
	cin >> s;
	if (s.size() == 1) {
		cout << s << endl;
		endre;
	}
	bool b = true;
	REP(i, s.size()) {
		if (s[i] != '9') {
			b = false;
			break;
		}
	}
	if (b)cout << (int)(s[0] - '0') + 9 * (s.size() - 1) << endl;
	else cout << (int)(s[0] - '0') - 1 + 9 * (s.size() - 1) << endl;
	endre;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	rep(i, n) {
		int ki;
		cin >> ki;
		a[ki]++;
	}
	int cnt = 0;
	rep(i, n + 1) {
		if (a[i] != 0) cnt++;
	}
	sort(a.begin(), a.end());
	int cnti = 0;
	if (cnt <= k) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	rep(i, n) {
		if (cnt <= k) break;
		if (a[i] != 0) {
			ans += a[i];
			cnt--;
		}
	}
	cout << ans << endl;
}

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

void solve()
{
	int n;
	cin >> n;
	ll a[n];
	for(int i = 0; i <n; i++) cin >> a[i];
	ll sum = 0;
	for(int i = 1; i <n; i++)
	{
		if(a[i] < a[i - 1])
		{
			sum += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << sum << "\n";
}

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


Measured memory_bytes: 5180
#include <stdio.h>
int main(void)
{
    int i,N[7],a,b,c,t;
    char S[102];
    
    for(i=1;i<7;i++)scanf("%d",&N[i]);
    scanf("%s",S);
    
    for(a=1,b=2,c=3,i=0;S[i];i++){
        switch(S[i]){
        case 'N':t=a,a=b,b=7-t;break;
        case 'E':t=c,c=a,a=7-t;break;
        case 'S':t=b,b=a,a=7-t;break;
        case 'W':t=a,a=c,c=7-t;break;
        }
    }
    printf("%d\n",N[a]);
}


Measured memory_bytes: 2108
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m, d = map(int, input().split())

    if d == 0:
        res = (m - 1) / n
    else:
        res = (m - 1) * 2 * (n - d) / (n ** 2)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll gcd(ll x,ll y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    x%=y;
    return gcd(x,y);
}
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=lcm(c,d);
    //cout<<x<<endl;
    ll ans=b/c+b/d-b/x-(a-1)/c-(a-1)/d+(a-1)/x;
    ans=b-a+1-ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int cnt2(int x){
    int res = 0;
    while(x % 2 == 0){
        res++;
        x /= 2;
    }
    return res;
}

int main(){
    int n; cin >> n;
    int ans = 1001001001;
    rep(i,n){
        int a; cin >> a;
        ans = min(ans, cnt2(a));
    }
    cout << ans << endl;
}

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

int n, a[500000];
long long ans = 0;

void func(int l, int r){
  if(l + 1 >= r) return;
  int m = (l + r) / 2;
  func(l, m);
  int t1[m - l + 1], t2[r - m + 1];
  for(int i = l; i < m; i++){
    t1[i - l] = a[i];
  }
  t1[m - l] = 1000000001;
  func(m, r);
  for(int i = m; i < r; i++){
    t2[i - m] = a[i];
  }
  t2[r - m] = 1000000001;
  int t1i = 0, t2i = 0;
  for(int i = l; i < r; i++){
    if(t1[t1i] <= t2[t2i]) a[i] = t1[t1i++];
    else{
      a[i] = t2[t2i++];
      ans += (m + t2i - 1) - i;
    }
  }
  return;
}

void solve(){
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  func(0, n);
  cout << ans << endl;
  return;
}

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



Measured memory_bytes: 5452
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int sz=1e5 + 5;

int x,y,n;
vector<ll> adj[sz];

pair<ll,ll> dfs(int u,int par){
	
	ll all_white = 1;
	ll total=1;
	for(int v: adj[u]){
		if(v!=par){
			pair<ll,ll> p = dfs(v,u);
			//p.first = black
			all_white = (all_white*p.second)%mod;
			total=(total*(p.first+p.second)%mod)%mod;
		}
	}
	return {all_white,total};
}

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i=1;i<n;i++){
    	cin>>x>>y;
    	adj[x].push_back(y);
    	adj[y].push_back(x);
	}
	
	pair<ll,ll> p = dfs(1,-1);
	cout<<(p.first+p.second)%mod<<"\n";
    
}



Measured memory_bytes: 12672
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	int H,W,black=0;
	cin>>H>>W;
	char tab[H+2][W+2];
	int num[H+2][W+2];
	for(int i=0;i<H+2;i++){
		for(int j=0;j<W+2;j++){
			tab[i][j]='@';
			num[i][j]=0;
		}
	}
	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			cin>>tab[i][j];
			if(tab[i][j]=='#') black++;
		}
	}
	queue<int> tate,yoko;
	tate.push(1);
	yoko.push(1);
	num[1][1]=1;
	while (1){
		int t=tate.front(),y=yoko.front();
		tate.pop(); yoko.pop();
		for(int k=0;k<4;k++){
			int i,j;
			if(k==0){
				i=1;
				j=0;
			}else if(k==1){
				i=-1;
				j=0;
			}else if(k==2){
				i=0;
				j=1;
			}else{
				i=0;
				j=-1;
			}
			if(tab[t+i][y+j]=='.'){
				tate.push(t+i); yoko.push(y+j);
				num[t+i][y+j]=num[t][y]+1;
				tab[t][y]='@';
				tab[t+i][y+j]='@';
			}else{
				continue;
			}
			if(t+i==H && y+j==W){
				cout<< H*W - black - num[H][W] << endl;
				return 0;
			}
		}
		if(tate.size()==0){
			cout<< -1 <<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
using namespace std;

int main(){
  int n;
  bool ans=false;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  Vsort(a);
  rep(i,n-1) if(a[i] == a[i+1]) ans=true;
  ans ? cout << "NO" : cout << "YES";
}


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

using namespace std;

int main(){


    string s;
    cin >> s;

    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;


}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  vint b(n);
  rep(i, n) cin >> a[i], b[i] = a[i]-i-1;
  sort(all(b));
  int ans = inf;
  reps(i, (n-1)/2, n/2+1) {
    int sum = 0;
    //cout<<b[i]<<endl;
    rep(j, n) sum += abs(a[j]-j-1-b[i]);
    chmin(ans, sum);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char S[211];
 
set<ll> solve(int l,int r);
 
void view( set<ll> b ){
  cout << "view" << endl;
  for( set<ll>::iterator it = b.begin(); it != b.end(); it++)
    cout << *it << " ";
  cout << endl;
}
 
int check(int l,int r){
  ll k = 0;
  for(int i=l;i<=r;i++){
    if( !isdigit(S[i]) ) return -1;
    k*=10LL;
    k+=(ll)(S[i]-'0');
  }
  return k;
}
 
set<ll> calc(set<ll> a,set<ll> b,char c){
  set<ll> ret;
  for( set<ll>::iterator it = a.begin(); it != a.end(); it++){
    for( set<ll>::iterator jt = b.begin(); jt != b.end(); jt++){
      if( c == '+' ){
    ret.insert( *it + *jt );
      } else if( c== '-' ){
    ret.insert( *it - *jt );
      } else if( c== '*' ){
    ret.insert( (*it) * (*jt) );
      } else {
    if( *jt == 0 ) continue;
    ret.insert( *it / *jt );
      }
    }
  }
  return ret;
}
 
set<ll> check2(int l,int r){
  int cnt = 0;
  set<ll> a,b;
  for(int i=l;i<=r;i++){
    if( S[i] == '(' ){
      cnt++;
    } else if (S[i] == ')' ){
      cnt--;
    }
    else if( cnt == 0  && ( S[i] == '+' || S[i] == '-' || S[i] == '*' || S[i] == '/' )){

      b = calc( solve(l,i-1), solve(i+1,r), S[i]);
      for( set<ll>::iterator it = b.begin(); it != b.end(); it++)
	a.insert( *it );

    }
  }
  //  cout << l << " "<< r << endl;
  // view(a);
  
  return a;
}
 
bool check3(int l,int r){
  int cnt = 0;
  if( S[l] != '(' ) return false;
  for(int i=l;i<=r;i++){
    if( S[i] == '(' ) cnt++;
    else if( S[i] == ')' ){
      cnt--;
      if( cnt == 0 && i == r ) return true;      
      else if( cnt == 0 ) 
	return false;
    }
  }
  return false;
}
 
set<ll> solve(int l,int r){
  if( check3(l,r) ){
    //cout << l << " "<< r << " " << " in check3" << endl;
    return solve(l+1,r-1);
  }   
  int tmp = check(l,r);
  if( tmp>-1 ){
    //cout << l << " "<< r << " " << tmp << endl;
    set<ll> s; s.insert(tmp);
    return s;
  }
   
  return check2(l,r);
}
 
 
int main(){
  while( cin >> S ){
    if( S[0] == '#' ) break;
    
    set<ll> res = solve(0,strlen(S)-1);
    cout << res.size() << endl;
    // view(res);
  }
}

Measured memory_bytes: 1244
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N,K;
vi a, s;

void solve(){
    int ans = 0;
    rep(i,N)
        s[i+1] = s[i]+a[i];
    
    for(int i = 0; i < N+1-K; i++)
        ans = max(ans, s[i+K] - s[i]);
    
    cout << ans << endl;
}

int main(){
    while(cin >> N >> K && K){
        a.resize(N,0);
        s.resize(N+1,0);

        rep(i,N)  cin >> a[i];
        
        solve();
    }
}



Measured memory_bytes: 3544
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;
  
  auto s=readln.chomp.to!(char[]);

  char[] t;
  foreach(c; s)if(c!='x') t~=c;
  bool ok=true;
  foreach(i; 0..(t.length/2)) ok&=(t[i]==t[$-i-1]);
  if(!ok){writeln(-1); return;}

  int cnt=0;
  int[] y;
  foreach(c; s){
    if(c=='x'){
      cnt++;
    }else{
      y~=cnt;
      cnt=0;
    }
  }
  y~=cnt;
  int sum=0;
  foreach(i; 0..(y.length/2)) sum+=(y[i]-y[$-i-1]).abs;
  writeln(sum);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 2840
#include <iostream>
using namespace std;
int main(){
char a[3];
cin>>a;
if(a[0]+a[1]+a[2]==3*'b'&&a[0]*a[1]+a[2]*a[1]+a[0]*a[2]=='a'*'b'+'b'*'c'+'c'*'a'&&a[0]*a[1]*a[2]=='a'*'b'*'c')cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n,d=map(int,input().split())
x=[]
for i in range(n):
    x.append(list(map(int,input().split())))
ans=0
 
 
for i in range(n-1):
    for j in range(i+1,n):
        d2=0
        for l in range(d):
            d2+=(x[i][l]-x[j][l])**2
        d2=int(d2)
        for k in range(1,d2//2+2):
            if d2==k**2:
                ans+=1
                break
 
print(ans)
 

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

const int N = pow(10,5);

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

int main() {
  long long N,a,b=0;
  long long counter=0;
  cin>>N;
  long long counter1=0;
  long long answer=1;
  queue<int>vec;
  // N以下の整数に対して素数判定をしてくれます。
  // nが素数ならば isp(n)=true、そうでなければ isp(n)=false
  sieve();
  // ex. 51から80までの素数を出力
  for (int i=2; i<=N; i++) {if (isp[i]) vec.push(i);
  else continue;}
  a=vec.size();
  counter=vec.front();
  vec.pop();
  for (int i=0; i<a; i++){
  for (int j=1; j<=N; j++){
  b=j;
  while(b%counter==0){
  counter1++;
  b=b/counter;}}
  answer=(answer*(counter1+1))%1000000007;
  counter=vec.front();
  vec.pop();
  counter1=0;}
  cout<<answer<<endl;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;

    cout<<((n*(n-1))/2L)<<endl;

}

Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if h==0 & w==0 : break
    for i in range(h):
        if (i==0) | (i==h-1):
            print('#'*w)
        elif w>2:
            print('#' + '.'*(w-2) + '#')
        elif w==2:
            print('##')
        elif w==1:
            print('#')
    print('')


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,w,r,ans;
char a[200010];
int main()
{
    scanf("%d",&n);
    scanf("%s",a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='W')
        {
            w++;
        }
    }
    r=n-w;
    for(int i=0;i<r;i++)
    {
        if(a[i]=='W')
        {
            ans++;
        }
    }
    printf("%d",ans);
}


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

int N;
string S[100];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> S[i];
    }

    set<string> st;
    rep(i, N) {
        st.insert(S[i]);
    }

    if (st.size() == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 256
// muripo
// 参考実装: https://atcoder.jp/contests/agc033/submissions/5257462
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int H, W;
static char A[1001][1001];
static bool X[1001][1001];

constexpr int DI[] = {-1, 1, 0, 0};
constexpr int DJ[] = {0, 0, -1, 1};

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

    struct Point
    {
        int i, j, s = 0;
    };
    queue<Point> q;

    cin >> H >> W;
    for (int i = 1; i <= H; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            cin >> A[i][j];
            if (A[i][j] == '#')
            {
                X[i][j] = true;
                q.push({i, j, 0});
            }
        }
    }

    int answer, ti, tj;
    // 幅優先探索
    // queueに入ってるのは黒マスのpoint
    // whileループ内ではqueueの各要素に対して前後左右に探索を行い，
    // Aの領域内でかつ白マスを見つけたらqueueuに追加してマークする
    // 白マスが見つけられなくなるまで繰り返す
    // 白マスが見つけられなくなったタイミングでのループ実行回数が解となる
    while (!q.empty())
    {
        auto n = q.front();
        answer = n.s;
        q.pop();

        for (int i = 0; i < 4; ++i)
        {
            ti = n.i + DI[i];
            tj = n.j + DJ[i];
            if (1 <= ti && ti <= H && 1 <= tj && tj <= W && !X[ti][tj])
            {
                X[ti][tj] = true;
                q.push({ti, tj, n.s + 1});
            }
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 14080
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] pri = new int[300001];
		for(int i=2;i<=300000;i++){
			pri[i] = i;
		}

		for(int i=2;i<=300000;i++){
			for(int j=i+i;j<=300000;j+=i){
					pri[j]=0;
			}
		}
		
		boolean exit = true;
		while(exit==true){
			int n = sc.nextInt();
			if(n==0)exit=false;
			if(exit==true){
				int sum=0;
				for(int i=n+1;i<=n+n;i++){
					if(pri[i]>0)sum++;
				}
				System.out.println(sum);
			}
		}
	}
	
}

Measured memory_bytes: 23404
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n;
    while(cin >> n) {
        if (n == 0) break;
        vector<int> w(n);
        rep(i, n) cin >> w[i];

        vector<vector<int>> dp(n, vector<int>(n));

        repr(b, 2, n+1) {
            rep(i, n-b+1) {
                int j = i + b - 1;

                if (dp[i+1][j-1] == b-2 && abs(w[i] - w[j]) < 2) {
                    dp[i][j] = b;
                } else {
                    repr(k, i, j) {
                        dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
                    }
                }
            }
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}
/*
4
1 2 3 4
4
1 2 3 1
5
5 1 2 3 6
14
8 7 1 4 3 5 4 1 6 8 10 4 6 5
5
1 3 5 1 3
0
*/


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

int main(int argc, char *argv[])
{
    int N, A, B;
    std::cin >> N >> A >> B;

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        std::string str = std::to_string(i);

        int sum = 0;
        for (int j = 0; j < str.size(); j++) {
            sum += (int)(str[j] - '0'); 
        }
        if ((A <= sum) && (sum <= B)) {
            ans += i;
        }
    }

    std::cout << ans;

    return 0;
}

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


int main(){
   
    string S;
    int N,ans[100009]={},tmp[100009],flag=0;
    int cnt1 = 0,cnt2 = 0,tmpi;
    cin >> S;
    N = S.size();
    for(int i = 0; i < N; i++){
        if(flag == 0){
            if(S[i] == 'L'){
                flag = 1;
                tmpi = i;
                cnt2++;
            }else{
                cnt1++;
            }
        }else if(flag == 1){
            if(S[i] == 'R'){
                ans[tmpi-1]= (cnt1/2)+(cnt1%2)+(cnt2/2);
                ans[tmpi]= (cnt2/2)+(cnt2%2)+(cnt1/2);
                cnt1 = 1;
                cnt2 = 0;
                flag = 0;
            }else{
                cnt2++;
            }
        }else{
            

        }
    }
    ans[tmpi-1]= (cnt1/2)+(cnt1%2)+(cnt2/2);
    ans[tmpi]= (cnt2/2)+(cnt2%2)+(cnt1/2);
    //cout << cnt2 << ' ';
    for(int i = 0; i < N; i++){
        cout << ans[i] << ' ';
    } 
    cout <<endl;
    return 0;
    

}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long LL;

int main() {
    LL a = 0, b = 0;
    LL q = 0;
    cin >> q;
    for ( int i = 0; i < q; ++ i ) {
        LL p, n;
        char c;
        cin >> p >> c >> n;
        if ( c == '(' ) {
            a += n;
        } else {
            b += n;
        }
        cout << ( a == b ? "Yes" : "No" ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a==b&&c!=a)
	{
		printf("Yes");
		return 0;
	}
	if(a==c&&b!=a)
	{
		printf("Yes");
		return 0;
	}
	if(b==c&&b!=a)
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        String m=sc.next();
        char[]n=m.toCharArray();
        int p=0;
        int q=0;
        for(int i=0;i<n.length;i++){
            if(n[i]=='A')
                p++;
            else
                q++;
        }
        if(p==3||q==3) 
            System.out.println("No");
        else
            System.out.println("Yes");

    }
}





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

using namespace std;
typedef long long ll;

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

    vector<int> a(n,0);
    for(int i=0;i<m;i++){
        int tmp;
        cin >> tmp;
        a[tmp-1] = 1;
    }

    ll mod = 1000000007;

    vector<ll> b(n,0);
    for(int i=0;i<n;i++){
        if(a[i] == 1) continue;
        if(i==0) b[i] = 1;
        if(i==1) b[i] = b[i-1] + 1;
        if(i>1) b[i] = b[i-1] + b[i-2];
        b[i] %= mod;
    }
    cout << b[n-1] << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int in[200050];
int in2[200050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]), in2[i] = in[i];
	sort(in2 + 1, in2 + N + 1);

	for (i = 1; i <= N; i++) {
		if (in[i] <= in2[N / 2]) printf("%d\n", in2[N / 2 + 1]);
		else printf("%d\n", in2[N / 2]);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main(){
    int ans=0,count0 = 0, count1=0;
    string S;
    cin >> S;
    for(int i=0; i<(int)S.length(); i++){
        if(S[i] == '0') count0++;
    }
    count1 = (int)S.length()-count0;
    ans = 2 * min(count0,count1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    long[] a = readln.split.to!(long[]);
    long[] b = readln.split.to!(long[]);
    long monster;
    foreach (i; 0 .. n) {
        if (a[i] < b[i]) {
            long c = min(a[i+1], b[i]-a[i]);
            a[i+1] -= c;
            monster += a[i] + c;
        } else {
            monster += b[i];
        }
    }
    monster.writeln;
}

Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a));
  int m = a.back();
  a.pop_back();
  double hf = (double)m/2;
  int ans = -1;
  rep(i, n-1){
    if(abs(ans - hf) > abs(a.at(i) - hf)){
      ans = a.at(i);
    }
  }
  cout << m << " " << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define oo 2000000000
#define mod 998244353 
const int N = 200010;

int n, x[N] , y[N];

map < pair<int,int> , bool > mp;

int get(int p,int q){
    int res = n;
    if(p == 0 && q == 0) return res;
    for(int i = 0 ;i < n;i++){
        res -= mp[make_pair(x[i] - p,y[i] - q)];
    }
    return res;
}

int main(){
    scanf("%d",&n);
    for(int i = 0 ;i < n;i++){
        scanf("%d%d",&x[i],&y[i]);
        mp[make_pair(x[i] , y[i])] = true;
    }
    int ans = n;
    for(int i = 0 ;i < n;i++){
        for(int j = 0 ;j < n;j++){
            ans = min(ans, get(x[i] - x[j] , y[i] - y[j]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
vector<int> E[N];
int n;
int dfs(int u,int fa) {
    int ret=0;
    for(int v:E[u])
        if(v!=fa) ret^=(dfs(v,u)+1);
    return ret;
}
int main() {
    cin>>n;
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].push_back(v),E[v].push_back(u);
    dfs(1,0)?puts("Alice"):puts("Bob");
    return 0;
}


Measured memory_bytes: 10368
x,n = gets.chomp.split(" ").map(&:to_i)

if n == 0
  puts("#{x}")
else
  a = gets.chomp.split(" ").map(&:to_i)
  hash = Hash.new{0}
  a.each do |e|
    hash[e] = 1
  end
  best = x
  hit = false
  while(!hit)
    if hash[best] == 0
      hit = true
    else
      best -= 1
    end
  end
  buf = best
  best = x+1
  hit = false
  while(!hit)
    if hash[best] == 0
      hit = true
    else
      best += 1
    end
  end
  if best - x < x - buf
    puts("#{best}")
  else
    puts("#{buf}")
  end
end

Measured memory_bytes: 14364
def resolve():
    N = int(input())
    B_list = list(map(int, input().split()))
 
    sum_point = B_list[-1]
    before_b = B_list[0]

    for i in range(N-1):
        sum_point += min(B_list[i], before_b)
        before_b = B_list[i]
 
    print(sum_point)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
N=int(input())
q=[]  
for i in range(N):
    q+=[list(input())]
    q[i].sort()
q.sort() 
i=0
s=0
z=0 #総得点
while i<N-1:
    if q[i]!=q[i+1]:
        z+=((s*(s+1))//2)
        s=0
    else:
        s+=1
    i+=1
z+=((s*(s+1))//2)
print(z)

Measured memory_bytes: 98392
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n, q;
    cin >> n;
    map<ll, ll> cnt;
    ll ans = 0;
    forn(i, n) {
        int x;
        cin >> x;
        cnt[x]++;
        ans += x;
    }

    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;
        cnt[c] += cnt[b];
        ans -= b * cnt[b];
        ans += c * cnt[b];
        cnt.erase(b);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7608
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int dp[3005][3005];
string s, t;
int s1, s2;
vector<char> out;
int compute(int i, int j)
{
    if(i<0||j<0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    int ans = ninf;
    if(s[i]==t[j])
    {
        ans = MAX2(ans, 1 + compute(i-1, j-1));
    }
    ans = MAX2(ans, compute(i-1, j));
    ans = MAX2(ans, compute(i, j-1));
    return dp[i][j] = ans;
}
void print_sol(int i, int j)
{
    if(i<0||j<0) return;
    if(s[i]==t[j])
    {
        out.pb(s[i]);
        print_sol(i-1, j-1);
    }
    else 
    {
        if(i==0&&j==0)
            return;
        else if(i==0)
            print_sol(i, j-1);
        else if(j==0)
            print_sol(i-1, j);
        else if(dp[i][j-1] > dp[i-1][j]) 
            print_sol(i, j-1);
        else print_sol(i-1, j);
    }
    return;
}
int main()
{
    she_told_me_dont_worry
    cin>>s;
    cin>>t;
    s1 = s.size();
    s2 = t.size();
    int i, j;
    FOR0(i, s1+2)FOR0(j, s2+2) dp[i][j] = -1;
    compute(s1-1, s2-1);
    print_sol(s1-1, s2-1);
    int si = out.size();
    FORD(j, si-1, 0)
        cout<<out[j];
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 35968
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ');
            var nums = new List<int>();
            foreach (var i in line) nums.Add(int.Parse(i));
            var nline = nums.OrderBy(x => x).ToList();

            var all = 0;
            var alist = new List<int>();
            for (var p = 0; 101 > p; p++)
            {
                foreach (var j in nline) all += (int)Math.Pow(j - p, 2);
                alist.Add(all);
                all = 0;
            }
            var ans = alist.OrderBy(x => x).ToList();
            Console.WriteLine(ans[0]);
        }
    }
}


Measured memory_bytes: 13396
H, W = map(int, input().split())

a = [[int(i) for i in input().split()] for _ in range(H)]
N = 0
ans = ''

for y in range(H):
    for x in range(W):
        if a[y][x] % 2:
            for del_y, del_x in ([1, 0], [0, 1]):
                new_y, new_x = y + del_y, x + del_x
                if new_y<=H-1 and new_x<=W-1:
                    if a[new_y][new_x] % 2:
                        a[y][x] -= 1
                        a[new_y][new_x] += 1
                        N += 1
                        ans += "{0} {1} {2} {3}\n".format(y+1, x+1, new_y+1, new_x+1) 
                        break
            else:
                if x == W-1 and y == H-1:
                    pass
                elif x == W-1:
                    a[y][x] -= 1
                    a[y+1][x] += 1
                    N += 1
                    ans += "{0} {1} {2} {3}\n".format(y+1, x+1, y+1+1, x+1)
                else:
                    a[y][x] -= 1
                    a[y][x+1] += 1
                    N += 1
                    ans += "{0} {1} {2} {3}\n".format(y+1, x+1, y+1, x+1+1)

ans = "{}\n".format(N) + ans[:-1]
print(ans)

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

signed main(void)
{
    int n;
    cin >> n;
    int a[20][20];
    memset(a,-1,sizeof(a));
    //vector<vector<int> > a(n,vector<int>(n,-1));
    for(int i=0; i<n; i++)
    {
        int cnt;
        cin >> cnt;
        for(int j=0; j<cnt; j++)
        {
            int x,y;
            cin >> x >> y;
            x--;
            a[i][x] = y;
        }
    }
    int ans = 0;
    for(int i=0; i<(1<<n); i++)
    {
        bool br = false;
        //vector<int>flag(n,-1);
        int flag[20];
        memset(flag,-1,sizeof(flag));
        int tmp=0;
        for(int j=0; j<n; j++)
        {
            if(((i>>j)&1)==1)
            {
                tmp++;
                flag[j]=1;
            }
        }
        for(int j=0; j<n; j++)
        {
            if(flag[j]==1)
            {
                for(int k=0; k<n; k++)
                {
                    if((a[j][k] ==1 && flag[k]!=1)||(a[j][k]==0 && flag[k]==1))
                    {
                        br = true;
                        break;
                    }
                    else if(a[j][k]==-1)
                    {
                        continue;
                    }
                    else
                    {
                        flag[k]=a[j][k];
                    }
                }
            }
            if(br==true)break;
        }
        if(br==false && ans < tmp)
            ans = tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 2728: Change a Password
// 2017.10.8 bal4u@uu

#include <stdio.h>
#include <string.h>

#define ABS(a) ((a)>=0?(a):-(a))
#define MIN(a,b) ((a)<=(b)?(a):(b))

char s[11], t[11], x[11]; int n;
long long  ns, pow10, diff;
char c['9'+1];

void try(int i, int mode)
{
	int j;
	long long a, b;

	if (i >= n) {
		for (a = 0, j = 0; j < n; j++) a = 10*a + (t[j]-'0');
		b = MIN(ABS(ns-a), pow10-ABS(ns-a));
		if (b > diff) diff = b, memcpy(x, t, sizeof(x));
		return;
	}
	if (mode) {
		for (j = '9'; c[j] && j >= '0'; j--);
		c[j] = 1; t[i] = j;
		try(i+1, mode);
	} else {
		for (j = '0'; c[j] && j <= '9'; j++);
		c[j] = 1; t[i] = j;
		try(i+1, mode);
	}
}

int main()
{
	int i, j;
	char *ans;

	scanf("%s", s); n = strlen(s);
	ns = 0, pow10 = 1; 
	for (i = 0; i < n; i++)
		ns = 10*ns + (s[i]-'0'), pow10 = 10*pow10;

	if (s[0] >= '5') t[0] = s[0]-5; else t[0] = s[0]+5;
	c[t[0]] = 1;
	for (i = 1; i < n; i++) {
		j = s[i];
		if (c[j]) break;
		t[i] = j, c[j] = 1;
	}

	if (i == n) ans = t;
	else {
		char c0['9'+1], t0[11]; int i0;
		diff = 0, ans = x, i0 = i;
		i0 = i, memcpy(c0, c, sizeof(c0)), memcpy(t0, t, sizeof(t0));
		for (j = s[i]-1; c[j] && j >= '0'; j--);
		if (j < '0') {
			for (j = i-1; j >= 0 && t[j] == '0'; j--) c['0'] = 0;
			i = j;
			for (c[t[i]] = 0, j = t[i]-1; c[j] && j >= '0'; j--);
		}
		c[j] = 1; t[i] = j;
		try(i+1, 1);

		i = i0, memcpy(c, c0, sizeof(c0)), memcpy(t, t0, sizeof(t0));
		for (j = s[i]+1; c[j] && j <= '9'; j++);
		if (j > '9') {
			for (j = i-1; j >= 0 && t[j] == '9'; j--) c['9'] = 0;
			i = j;
			for (c[t[i]] = 0, j = t[i]+1; c[j] && j <= '9'; j++);
		}
		c[j] = 1; t[i] = j;
		try(i+1, 0);
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 1720
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$B =  explode(" ",trim(fgets(STDIN)));

$len = strlen($S);

$N=13;
$dp=array_fill(0,$N,0);
$dp[0]=1;
$mod = 1000000007;
$mul = 1;

for($i=$len-1;$i>=0;$i--) {
  $nextDP = array_fill(0,$N,0);
  if ($S[$i]=='?') {
    for($k=0;$k<10;$k++) {
      for($j=0;$j<$N;$j++) {
        $nextDP[($k*$mul+$j)%$N] += $dp[$j];
        $nextDP[($k*$mul+$j)%$N] %= $mod;
      }
    }
  }
  else {
    $k = (int)$S[$i];
    for($j=0;$j<$N;$j++) {
        $nextDP[($k*$mul+$j)%$N] += $dp[$j];
        $nextDP[($k*$mul+$j)%$N] %= $mod;
    }
  }
  $mul *= 10;
  $mul %= $N;
  $dp=$nextDP;
}
printf("%d\n",$dp[5]);


Measured memory_bytes: 4604
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    ll n;
    cin>>n;

    vl v(n);
    ll xora = 0;
    forn(i,0,n)
    {
        cin>>v[i];
        xora = xora^v[i];
    }

    forn(i,0,n)
    {
        cout<<(xora^v[i])<<" ";
    }
        
    
        
        












    return 0;
}

Measured memory_bytes: 4776
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int n, w, x;
  ll y;
  cin >> n >> w;
  vector<int> weights;
  vector<ll> values;
  for (int i = 0; i < n; i++) {
    cin >> x;
    weights.pb(x);
    cin >> y;
    values.pb(y);
  }
  ll dp[w+1];
  bool dpb[w+1][n];
  for (int i = 0; i <= w; i++) {
    dp[i] = 0;
    for (int j = 0; j < n; j++) {
      dpb[i][j] = false;
    }
  }
  for (int i = 0; i <= w; i++) {
    for (int j = 0; j < n; j++) {
      if (i+weights[j] <= w) {
	//debug
	//cout << "i+w: " << i+weights[j] << "\n";
	//cout << "dp[i+w]: " << dp[i+weights[j]] << "\n";
	if (dp[i]+values[j] > dp[i+weights[j]] && !dpb[i][j]) {
	  for (int k = 0; k < n; k++) {
	    dpb[i+weights[j]][k] = dpb[i][k];
	  }
	  dpb[i+weights[j]][j] = true;
	  dp[i+weights[j]] = dp[i]+values[j];
	}
	//cout << "dp[i+w]: " << dp[i+weights[j]] << "\n";
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= w; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
const int MAX_NQ = 100000;
int N, Q;
string S;
int l[MAX_NQ], r[MAX_NQ];
int total_AC[MAX_NQ] = {0};

void rewriteArray() {
    int total_i = 0;
    
    for (int i = 0; i < N - 1; i++){
        if (S.substr(i, 2) == "AC") {
            total_i++;
        }
        total_AC[i+1] = total_i;
    }
}

int main() {
    cin >> N >> Q >> S;
    for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    rewriteArray();

    for (int i = 0; i < Q; i++){
        cout << total_AC[r[i] - 1]  - total_AC[l[i] - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2240
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  LL W, H, x, y; cin >> W >> H >> x >> y;
  // 任意の点 (x,y) と重心 (W/2, H/2) を結ぶ直線は長方形の面積を等分し, そのとき最適となる
  cout << (double)W * (double)H / 2.0 << " ";
  // 逆に, 長方形の面積を等分する直線は重心を通るものに限る
  cout << ((W%2 == 0 and H%2 == 0 and W/2 == x and H/2 == y)? 1 : 0) << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll ans[310][310];
int main(){
	ll h,w,k;
	string s[310];
	cin>>h>>w>>k;
	rep(i,h)cin>>s[i];
	rep(i,h)rep(j,w)ans[i][j]=-1;
	bool fi=1;
	int fip=-1;
	rep(i,h){
		bool th=0;
		rep(j,w)if(s[i][j]=='#')th=1;
		if(th){
			ll bef=-1;
			rep(j,w){
				if(s[i][j]=='#'){
					for(int r=bef+1;r<=j;r++){
						ans[i][r]=k;
					}
					k--;
					bef=j;
				}
			}
			for(int r=bef+1;r<w;r++){
				ans[i][r]=k+1;
			}
			if(fi)fip=i;
			fi=0;
		}
		else{
			if(fi==0){
				rep(j,w)ans[i][j]=ans[i-1][j];
			}
		}
	}
	rep(i,fip){
		rep(j,w)ans[i][j]=ans[fip][j];
	}
	rep(i,h){
		rep(j,w)cout<<ans[i][j]<<" ";
		cout<<endl;
	}
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
struct Node
{
	int a,b;
}p[N];
long long sum[N];
struct Fraction
{
	long long p,q;
	bool operator<(const Fraction &b)const
	{
		return (double)p/q<(double)b.p/b.q;
	}
};
long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].a,&p[i].b);
	sort(p+1,p+n+1,[=](const Node &x,const Node &y){return max(x.a,x.b)<max(y.a,y.b);});
	for(int i=n;i>=1;i--)
		sum[i]=sum[i+1]+max(p[i].a,p[i].b);
	long long to=0;
	for(int i=1;i<=n;i++)
		to+=p[i].a;
	Fraction ans=(Fraction){0,1};
	for(int i=1;i<=n;i++)
	{
		int pos=n+1;
		int l=1,r=n;
		auto check=[=](int x){return sum[x]-(x<=i?max(p[i].a,p[i].b):0)>=to-p[i].b;};
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(check(mid)) l=mid+1,pos=mid;
			else r=mid-1;
		}
		if(pos>n) continue;
		long long ret=sum[pos]-(pos<=i?max(p[i].a,p[i].b):0)-(to-p[i].b);
		Fraction res=(Fraction){1LL*(pos-1-(pos>i))*p[i].b+min(ret,(long long)p[i].b),1LL*p[i].b*n};
		ans=max(ans,res);
	}
	long long d=gcd(ans.p,ans.q);
	ans.p/=d,ans.q/=d;
	printf("%lld %lld",ans.p,ans.q);
	return 0;
}


Measured memory_bytes: 5348
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;

int dp[2001];

int main()
{
	IOS;
	int n,m;
	cin >> n >> m;
	ll sum = 1;
	int arr[n+1],brr[m+1];
	REP(i,1,n)
		cin >> arr[i];
	REP(i,1,m)
		cin >> brr[i];
	for(int i=n;i>=1;i--)
	{
		int sum2 = 0;
		for(int j=m;j>=1;j--)
		{
			int temp=sum2;
			temp+=dp[j];
			temp%=MOD;
			if(arr[i]==brr[j])
			{
				dp[j]++;
				dp[j]+=sum2;
				dp[j]%=MOD;
			}
			sum2=temp;
		}
	}
	REP(i,1,m)
	{
		sum+=dp[i];
		sum%=MOD;
	}
	cout << sum;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, k; cin >> n >> k;
    ll ans = 0ll;
	if (k==0) {
		ans = n;
		ans *= n;
	}
	else {
		FOR(b, k+1, n+1) {
			int x = 0;
			while (b*x+k<=n) {
				if (b*(x+1)-1 > n) {
					int l = b*x+k;
					int r = min(b*(x+1)-1, n);
					ans += r-l+1;
					// debug(b, x, l, r, ans);
				} else {
					ans += b-k;
					// debug(b, x, b-k, ans);
				}
				x++;
			}
			// debug(b, ans);
		}
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int max = 0, dis[3];

    for(int i = 0;i < 3;i++){

        cin >> dis[i];

        if(max < dis[i]){

            max = dis[i];
        }
    }

    for(int i = 0;i < 3;i++){

        if(max == dis[i]){

            dis[i] = 0;
            break;
        }
    }

    cout << dis[0] + dis[1] + dis[2] << endl;

    return 0;
}

Measured memory_bytes: 256