akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main() {
	ll h, w; cin >> h >> w;
	ll mi = INF;
	for (ll i = 1; i < h; i++) {
		ll a[3];
		a[0] = i * w;
		a[1] = w * ((h-i) / (ll)2);
		a[2] = w * ((h-i + (ll)1) / (ll)2);
		sort(a, a + 3);
		mi = min(mi, a[2] - a[0]);
		a[0] = i * w;
		a[1] = (h - i)*(w / (ll)2);
		a[2] = (h - i)*((w+(ll)1) / (ll)2);
		sort(a, a + 3);
		mi = min(mi, a[2] - a[0]);
	}
	swap(h, w);
	for (ll i = 1; i < h; i++) {
		ll a[3];
		a[0] = i * w;
		a[1] = w * ((h-i) / (ll)2);
		a[2] = w * ((h -i+ (ll)1) / (ll)2);
		sort(a, a + 3);
		mi = min(mi, a[2] - a[0]);
		a[0] = i * w;
		a[1] = (h - i)*(w / (ll)2);
		a[2] = (h - i)*((w + (ll)1) / (ll)2);
		sort(a, a + 3);
		mi = min(mi, a[2] - a[0]);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[200];

void push(int x) {
    S[top++] = x;
}

int pop() {
    return S[--top];
}

int main() {
    int a = 0, b = 0;
    char s[100];
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
long long m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()
//nCk(comuseを使え)
long long combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//pCk(comuseを使え)
long long perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a,long long b){
  long long n;
  n=a/__gcd(a,b)*b;
  return n;
}

//auto A = div(n)
vector<long long> div(long long n){
  vector<long long> ret;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a,long long n,long long mod){
  long long ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

///////////////////////////////////////////////////////////


int a, b, c;

void Solve(){
  cin >> a >> b >> c;
  if(a + b + c >= 22){
    cout << "bust" <<endl;
  }  
  else{
    cout << "win" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String line = sc.nextLine();
		int count=0;
		int answer=n;
		for(int i=0;i<n;i++){
			if(line.charAt(i)=='x'){
				count+=1;
			}else{
				count=0;
			}
			if(count==2){
				answer=i;
				break;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 31444
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;

int main()
{
    FAST;

    ll n,m;
    cin>>n>>m;

    ll arr[n];
    priority_queue<ll> q;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        q.push(arr[i]);
    }

    ll i = 0;
    while(i<m)
    {
        ll tmp = q.top();
        q.pop();
        tmp/=2;
        if(tmp!=0)
        q.push(tmp);

        if(q.empty())
            break;
        i++;
    }

    ll sum = 0;
    while(!q.empty())
    {
        sum+=q.top();
        q.pop();
    }

    cout<<sum<<endl;




    return 0;
}


Measured memory_bytes: 4976
N = int(input())
ans = [[0]*3 for _ in range(N)]
ans[0] = list(map(int, input().split()))
for i in range(1, N):
    a, b, c = map(int, input().split())
    ans[i][0] = max(ans[i-1][1]+a, ans[i-1][2]+a)
    ans[i][1] = max(ans[i-1][2]+b, ans[i-1][0]+b)
    ans[i][2] = max(ans[i-1][0]+c, ans[i-1][1]+c)
print(max(ans[N-1]))


Measured memory_bytes: 22816
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func f(b, n int) int {
  cnt := 0
  for n > 0 {
    cnt += n % b
    n /= b
  }
  return cnt
}

func main() {
  n := NextInt()
  s := NextInt()
  sqrt := int(math.Sqrt(float64(n)))
  F := make([]int, sqrt + 1)
  ans := -1
  for b := 2; b < sqrt + 1; b++ {
    if F[b] < 0 { continue }
    fbn := f(b, n)
    if fbn == s {
      ans = b
      break
    }
    if fbn > s {
      k := b
      for k < sqrt + 1 {
        F[k] = -1
        k *= b
      }
    }
  }
  if ans < 0 {
    b := n + 1
    for b1 := 1; b1 < sqrt; b1++ {
      b0 := s - b1
      if n < b0 { continue }
      if b0 < 0 { break }
      if (n - b0) % b1 > 0 { continue }
      _b := (n - b0) / b1
      if _b <= b0 { continue }
      if _b < b { b = _b }
    }
    if b < n + 1 { ans = b }
    if s == 1 { ans = n }
    if n == s { ans = n + 1 }
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 3456
#include <stdio.h>

int main()
{
    int x,y,ans = 0;
    scanf("%d %d",&x,&y);

    if(x == 1)ans += 300000;
    else if(x == 2)ans += 200000;
    else if(x == 3)ans += 100000;
    if(y == 1)ans += 300000;
    else if(y == 2)ans += 200000;
    else if(y == 3)ans += 100000;
    if(x == 1 && y == 1)ans += 400000;

    printf("%d",ans);
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1005;
const int maxs = 1<<12;

LL cost[maxn];
int locks[maxn];
int N,M;
LL dp[2][maxs];

int main()
{
    cin >> N >> M;
    _for(i,0,M){
        cin >> cost[i];
        int b;cin >> b;
        int s = 0;

        _for(j,0,b){
            int k;
            cin >> k;
            k--;
            s = s | (1<<k);
        }

        locks[i] = s;

    }

    _for(i,0,2){
        _for(j,0,maxs){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    dp[1][0] = 0;

    int t = 0;
    _for(i,0,M){
        int s = locks[i];
        //cout << s << endl;
        _for(j,0,maxs){
            chmin(dp[t][j],dp[t^1][j]);
            int changed = 0;
            if(j >= s && (j ^ s) == j - s){
                changed = chmin(dp[t][j],dp[t^1][j-s] + cost[i]);
            }
            if(changed){
                LL v = dp[t][j];
                for(int k = (j-1)&j;k > 0; k = (k-1)&j){
                    chmin(dp[t][k],v);
                }
            }
        }
        t = 1^t;
    }

    if(dp[t^1][(1<<N) - 1] == INF) cout << -1 << endl;
    else cout << dp[t^1][(1<<N) - 1] << endl;

    return 0;
}


Measured memory_bytes: 384
from sys import stdin
from collections import Counter
def main():
  readline = stdin.readline
  N = int(input())
  A = list((map(int, readline().split())))
  C = Counter(A)
  A = sorted(set(A))
  flag = False
  for a in A[::-1]:
    if flag:
      if C[a] >= 2:
        print(a*b)
        break
    elif C[a] >= 4:
      print(a*a)
      break
    elif C[a] >= 2:
      b = a
      flag = True
  else:
    print(0)
if __name__ == "__main__":
  main()

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

int main() {
	int N, Y, x;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			x = 10000 * i + 5000 * j + 1000 * (N - i - j);
			if (x == Y) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#define ll long long
#define il inline
#define rgi register int

using namespace std;

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int n, ans;

int check(int x)
{
	int res = 0;
	while(x)
	{
		x /= 10;
		res++;
	}
	return res;
}

int main()
{
	n = read();
	for(rgi i = 1; i <= n; ++i)
	{
		int cnt = check(i);
		if(cnt & 1)
			ans++;
	}
	printf("%d", ans);
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, x;
    cin >> N >> x;

    vector<ll> A(N, 0);
    vector<ll> B(N-1, 0);

    REP(i, N){
        cin >> A[i];
    }

    ll ans = 0;
    REP(i, N){
        if(i==0){
            ll e = max(0LL, A[i]-x);
            ans+=e;
            A[i]-=e;
        }
        else{
            ll e = max(0LL, A[i]+A[i-1]-x);
            ans += e;
            A[i]-=e;
 
        }
    }

    // ll ans = 0;
    // REP(i, N-1){
    //     if(B[i] > x){
    //         ll dis = B[i]-x;
    //         // if(dis <= 0) continue;
    //         B[i] = x;
    //         if(i != N-1){
    //             B[i+1] -= dis; 
    //             // cout << i+1 << " " << B[i+1] << endl;
    //             // cout << B[100] << endl;
    //         }
    //         ans += dis;
    //     }
    // }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define inf 1e9
using namespace std;
int n,i,j,a,b,ret,s;
long long p[810],d[810],cnt[810],dist[810];
vector<vector<pair<int,long long> > > c(810);
void init(){
  for(i=0;i<810;i++){
    c[i].clear();
    cnt[i]=0;
  }
}

void bfs(int s){
  queue<int> que;
  que.push(s);
  fill(dist,dist+810,inf);
  dist[s]=0;
  while(que.size()){
    int u = que.front();
    que.pop();
    for(i=0;i<c[u].size();i++){
      int e = c[u][i].first;
      if(dist[e]==inf){
        dist[e]=dist[u]+c[u][i].second;
        que.push(e);
      }
    }
  }
  return;
}

int main(){
  while(cin >> n,n){
    ret = 0;
    init();
    for(i=2;i<=n;i++)cin >> p[i];
    for(i=2;i<=n;i++)cin >> d[i];
    for(i=2;i<=n;i++){
      c[i].push_back(make_pair(p[i],d[i]));
      c[p[i]].push_back(make_pair(i,d[i]));
      cnt[i]++;
      cnt[p[i]]++;
      ret+=d[i]*3;
    }
    for(i=1;i<=n;i++){
      if(cnt[i]==1){
        ret-=2*c[i][0].second;
        int fir=c[i][0].first;
        c[i].clear();
        for(j=0;j<c[fir].size();j++){
          if(c[fir][j].first==i){
            swap(c[fir][j],c[fir].back());
            c[fir].pop_back();
          }
        }
      }
      else s = i;
    }
    bfs(s);
    int u=-1,t=-1;
    for(i=1;i<=n;i++){
      if(dist[i]!=inf && (u==-1 || dist[i]>dist[u]))u = i;
    }
    bfs(u);
    for(i=1;i<=n;i++){
      if(dist[i]!=inf && (t==-1 || dist[i]>dist[t]))t = i;
    }
    ret-=dist[t];
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 3328
# 2019/01/27
# NIKKEI Programming Contest 2019 - B

# Input
n = int(input())
a = input()
b = input()
c = input()
sum = 0

# Choose Max
for idx in range(n):
    
    if a[idx] == b[idx]:
        if a[idx] == c[idx]:
            # All chars are same
            sum += 0
        else:
            # a=b, a!=c
            sum += 1
    else:
        if a[idx] == c[idx]:
            # a!=b, a=c
            sum += 1
        else:
            if b[idx] == c[idx]:
                # a!=b, b=c
                sum += 1
            else:
                # All chars are different
                sum += 2
# Output
print(sum)

Measured memory_bytes: 3064
# 合成数xはp <= math.sqrt(x) を満たす素因子pを持つことを利用
import math

def isPrime_number(a):
    for i in range(2, int(math.sqrt(a))+1):
        if a%i == 0:
            return False
    return True

n = int(input())
cnt = 0
for _ in range(n):
    if isPrime_number(int(input())):
            cnt += 1
print(cnt)


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

int main(){
  map<string,int> card;
  int N,M;
  cin >> N;
  
  string str;
  
  for(int i=0;i<N;i++){
    cin >> str;
    card[str] += 1;
  }
  
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> str;
    card[str] -= 1;
  }
  
  int res = 0;
  
  for(auto p : card) res = max(res,p.second);
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n, Q;
int ty[maxn], dic[maxn];
char s[maxn], ss[maxn];

template<typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

inline bool check1(int pos)
{
    if (pos < 1) return 1;
    for (int i = 1; i <= Q; i++)
    {
        if (ss[pos] - 'A' == ty[i]) pos += dic[i];
        if (pos < 1) return 1;
    }

    return 0;
}

inline bool check2(int pos)
{
    if (pos > n) return 1;
    for (int i = 1; i <= Q; i++)
    {
        if (ss[pos] - 'A' == ty[i]) pos += dic[i];
        if (pos > n) return 1;
    }

    return 0;
}

int main()
{
    read(n); read(Q);
    scanf("%s", ss + 1);
    for (int i = 1; i <= Q; i++) 
    {
        scanf("%s", s + 1);
        ty[i] = s[1] - 'A';
        scanf("%s", s + 1);
        dic[i] = (s[1] == 'R') ? 1 : -1;
    }
    
    int l = 0, r = n;
    while (l < r)
    {
        int mid = (l + r + 1) >> 1;
        if (check1(mid)) l = mid;
        else r = mid - 1;
    }
    int ansl = l;

    // printf("%d\n", ansl);

    l = 1, r = n + 1;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (check2(mid)) r = mid;
        else l = mid + 1;
    }
    int ansr = n - l + 1;
    // printf("%d\n", ansr);
    
    printf("%d\n", max(0, n - ansl - ansr));
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int H, W, K;
char A[800][800];
bool used[800][800];
int dist[800][800];

bool isValid(P p){
    if(p.first >= 0 && p.first < H && p.second >= 0 && p.second < W) return true;
    else return false;
}

void bfs(int d, int h, int w){
    dist[h][w] = 0;
    queue<P> que;
    que.push(P(h, w));
    used[h][w] = true;
    while(!que.empty()){
        P top = que.front();
        int y = top.first;
        int x = top.second;
        que.pop();
        if(dist[y][x] == K) continue;
        
        if(isValid(P(y-1, x)) && A[y-1][x] == '.' && !used[y-1][x]) {
            que.push(P(y-1, x));
            dist[y-1][x] = dist[y][x]+1;
            used[y-1][x] = true;
        }
        if(isValid(P(y+1, x)) && A[y+1][x] == '.' && !used[y+1][x]) {
            que.push(P(y+1, x));
            dist[y+1][x] = dist[y][x]+1;
            used[y+1][x] = true;
        }
        if(isValid(P(y, x-1)) && A[y][x-1] == '.' && !used[y][x-1]) {
            que.push(P(y, x-1));
            dist[y][x-1] = dist[y][x]+1;
            used[y][x-1] = true;
        }
        if(isValid(P(y, x+1)) && A[y][x+1] == '.' && !used[y][x+1]) {
            que.push(P(y, x+1));
            dist[y][x+1] = dist[y][x]+1;
            used[y][x+1] = true;
        }
    }
}

int main(){
    cin >> H >> W >> K;
    P s;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> A[i][j];
            if(A[i][j] == 'S') s = P(i, j);
            used[i][j] = false;
        }
    }
    bfs(0, s.first, s.second);
    int min_dist = 800;
     for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(used[i][j]){
                min_dist = min(min_dist, min({i, j, H-i-1, W-j-1}));
            }
        }
    }
    cout << 1+((min_dist+K-1)/K) << endl;
}

Measured memory_bytes: 3968
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (100000000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 200005;
int n, q, arr[N];
ll tree[2][4*N], ps[N], DP[N];

void update(int k, int node, int s, int e, int pos, ll val){
    if(s > e || pos < s || pos > e) return;
    if(s == e){
        tree[k][node] = min(tree[k][node], val);
        return;
    }
    int mid = (s+e)/2;
    update(k, LEFT(node), s, mid, pos, val);
    update(k, RIGHT(node), mid+1, e, pos, val);
    tree[k][node] = min(tree[k][LEFT(node)], tree[k][RIGHT(node)]);
}


ll query(int k, int node, int s, int e, int lo, int hi){
    lo = max(1, lo);    hi = min(n, hi);
    if(s > e || hi < s || lo > e) return MOD;
    if(s >= lo && e <= hi)  return tree[k][node];
    int mid = (s+e)/2;
    ll a = query(k, LEFT(node), s, mid, lo, hi);
    ll b = query(k, RIGHT(node), mid+1, e, lo, hi);
    return min(a, b);
}



int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>q;
    q += 2;
    for(int i=1;i<=q;i++){
        cin>>arr[i];
    }
    arr[0] = arr[2];
    for(int i=1;i<=q;i++)
        ps[i] = ps[i-1] + abs(arr[i] - arr[i-1]);

    for(int i=1;i<=4*n;i++)
        tree[0][i] = tree[1][i] = MOD;

    DP[q] = 0;
    update(0, 1, 1, n, arr[q], DP[q] + ps[q-1] - arr[q]);
    update(1, 1, 1, n, arr[q], DP[q] + ps[q-1] + arr[q]);

    for(int i=q-1;i>=2;i--){
        ll temp = DP[i+1] + abs(arr[i+1] - arr[i-1]);
        temp = min(temp, ps[q] - ps[i]);
        temp = min(temp, query(0, 1, 1, n, 1, arr[i-1]) + arr[i-1] - ps[i]);
        temp = min(temp, query(1, 1, 1, n, arr[i-1], n) - arr[i-1] - ps[i]);
        DP[i] = temp;
        update(0, 1, 1, n, arr[i], DP[i] + ps[i-1] - arr[i]);
        update(1, 1, 1, n, arr[i], DP[i] + ps[i-1] + arr[i]);
    }

// cout<<"arr: ";for(int i=1;i<=q;i++)  cout<<arr[i]<<" ";cout<<endl;
// cout<<"DP: ";for(int i=1;i<=q;i++)  cout<<DP[i]<<" ";cout<<endl;

    cout<<DP[2];
    return 0;
}











Measured memory_bytes: 16640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int InputIntAry(int *a,int nBuf,int N,int K){
    int ret=0;
    int64_t tmp;
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        tmp=atoll(ptr);
        if(tmp < K){    //Kより大きなカードは必要に決まっているし, 他のカードの判定に関係しない
            a[ret++] = (int)tmp;
            //printf("%d\n",a[ret-1]);
        }
        ptr=strtok(NULL," ");
    }
    free(buf);

    return ret;
}

#define MIN(a,b)  ( ((a)<(b))?(a):(b) )

int main(){
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    puts( (a==b && b==c)?"Yes":"No" );
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
vector< pair< int , int > > g;
int wt[1001];
int ans[1001];
int dis[101][101];
int main()
{
	int n , m;
	cin >> n >> m;
	for(int i = 1 ; i <= 100 ; i++){
		for(int j = 1 ; j <= 100 ; j++){
			if(i == j)
				dis[i][j] = 0;
			else 
				dis[i][j] = 9999999;
		}
	}
	for(int i = 0 ; i < m ; i++){
		int u , v , w;
		cin >> u >> v >> w;
		g.push_back({u,v});
		wt[i] = w;
		dis[u][v] = dis[v][u] = w;
	}
	for(int k = 1 ; k <=  n ; k++){
		for(int i = 1 ; i <= n ; i++){
			for(int j = 1 ; j <= n ; j++){
					dis[i][j] = min(dis[i][j] , dis[i][k] + dis[k][j]);
			}
		}
	}
	for(int i = 0 ; i < m ; i++){
		int u = g[i].first;
		int v = g[i].second;
		for(int j = 1 ; j <= n ; j++){
			for(int k = j + 1 ;k <= n ; k++){
				if(dis[j][u] + dis[v][k] + wt[i] == dis[j][k] ||dis[j][v] + dis[u][k] + wt[i] == dis[j][k])
					ans[i] = 1;
			}
		}
	}
	int cnt = 0;
	for(int i = 0 ; i < m ; i++)
		if(!ans[i])
			cnt++;
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
    int N, W;
    cin >> N >> W;
  
    int v[N],w[N];
     
    for(int i=0; i<N; i++){
        cin >> v[i] >> w[i];
    }
  
    int DP[N+1][W+1];
 
    for(int j=0; j<=W; j++)
        DP[N][j] = 0;
  
    for(int i=N-1; i>=0; i--){
        for(int j=0; j<=W; j++){
            if(j<w[i])
                DP[i][j] = DP[i+1][j];
            else{
                if(DP[i+1][j]>DP[i+1][j-w[i]]+v[i])
                    DP[i][j] = DP[i+1][j];
                else   
                    DP[i][j]=DP[i+1][j-w[i]]+v[i];         
             }
        }
   } 
    cout << DP[0][W] << endl;
  
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    n = n % 26;
    n = (n + 26) % 26;
    string s;
    cin >> s;
    string out = "";
    for (char c : s) {
        if ((int)c + n > 90) {
            out += char(int(c)+n-26);
        }
        else out += char((int)c + n);
    }
    cout << out;    
}


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

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
const int N = 100001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int n, fa[N];
set<int> s[N];
map<LL, int> mp;
queue<pii> q;

int findfa(int x) {
	if(fa[x] != x) fa[x] = findfa(fa[x]);
	return fa[x];
}

LL gao(int x, int y) {
	if(x > y) swap(x, y);
	return (LL)x * n + y;
}

void Merge(int x, int y) {
	s[x].insert(y), s[y].insert(x);
	mp[gao(x, y)]++;
	if(mp[gao(x, y)] == 2) 
	q.push(pii{x, y});
}

int main() {
	n = read();
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i < 2 * n - 1; i++) Merge(read(), read());
	for(int j = 1; j < n; j++) {
		int x, y;
		while(1) {
			if(q.empty()) {puts("NO"); return 0;}
			x = q.front().first, y = q.front().second; q.pop();
			x = findfa(x), y = findfa(y);
			if(x != y) break;
		}
		if(s[x].size() > s[y].size()) swap(x, y);
		mp.erase(gao(x, y)); s[y].erase(x);
		fa[x] = y; for(auto u : s[x]) {
			u = findfa(u);
			if(u == y) continue;
			mp.erase(gao(x, u));
			s[u].erase(x);
			Merge(y, u);
		}
	} puts("YES");
	return 0;
}


Measured memory_bytes: 38784
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    double ans=(v[0]+v[1])/2.0;
    for(int i=2;i<n;i++)ans=(ans+v[i])/2.0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#2020-03-19
while True:
    m, f, r = map(int,input().split())
    total = m + f
    if m == f == r == -1 :
        break
    elif  m == -1 or f == -1:
        print('F') 
    elif total >= 80:
        print('A')
        
    elif 80 > total >= 65:
        print('B')
        
    elif 65 > total >= 50:
        print('C')
        
    elif 50 > total >= 30 and  r >= 50:
        print('C')
        
    elif 50 > total >= 30:
        print('D')
        
    elif  total < 30:
        print('F') 


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  long long N;
  cin >> N;

  int ans = 0;
  for(long long i = 1;i*i <= N-1;i++) {
    if((N-1)%i == 0) ans+= 2;
    if(i*i == N-1) ans--;
    if(i == 1) ans--;
  }

  for(long long i = 1;i*i <= N;i++) {
    if(N%i == 0) {
      if(i == 1) {
        ans++;
        continue;
      }
      long long num = N;
      while(num%i==0) num /= i;
      if(num%i==1) ans++;

      if(i*i==N) continue;

      num = N;
      long long div = N/i;
      while(num%div==0) num /= div;
      if(num%div == 1) ans++;
    }
  }


  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int num[16];
vector<i_i> paths[100000];
int ans = 0;

/*
i_i dfs(int now, int from) {
    int nowcost = 0;
    for(auto tmp : paths[now]) {
        int to = tmp.first;
        int c = tmp.second;
        if(to == from) continue;
        dfs(to, now);

    }
}
*/
int dp[1<<16];


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        paths[a].push_back({b, c});
        paths[b].push_back({a, c});
    }
    for(int i = 1; i < N; i++) {
        int nowcost = 0;
        for(auto tmp : paths[i]) {
            nowcost ^= tmp.second;
        }
        num[nowcost]++;
    }
    /*
    for(int i = 0; i < 16; i++) {
        cerr << i << " " << num[i] << endl;
    }
    */
    num[0] = 0;
    int Rest = 0;
    for(int i = 0; i < 16; i++) {
        cerr << i << " " << num[i] << endl;
        ans += (num[i] + 1) / 2;
        num[i] &= 1;
        Rest |= (num[i] << i);
    }
    cerr << ans << endl;
    for(int bits = 0; bits < (1<<16); bits++) {
        for(int sub = bits + 1; ;) {
            sub--;
            if(sub <= 0) break;
            sub &= bits;
            //cerr << bits << " " << sub << endl;
            if((sub & Rest) != sub) continue;
            int xorsum = 0;
            for(int i = 0; i < 16; i++) {
                if(sub & (1 << i)) xorsum ^= i;
            }
            if(xorsum != 0) continue;
            chmax(dp[bits], dp[bits & (~sub)] + 1);
        }
        //cerr << bits << " " << dp[bits] << endl;
    }
    cout << ans - dp[(1 << 16) - 1] << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	string s;
	cin >> s;
	map<int, int> cnt;
	cnt[0] = 1;
	long long ans = 0, t = 1, cur = 0;
	for (int i = s.size() - 1; i >= 0; --i){
		int now = s[i] - '0';
		cur = (cur + now * t) % 2019;
		ans += cnt[cur]++;
		t = t * 10 % 2019;
	}
	cout << ans;
	return 0;
}



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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

inline vector<int> digit(unsigned long long n) {
  vector<int> ret;
  do { ret.push_back(n % 10); n /= 10; } while (n > 0);
  return ret;
}

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

  int n;
  cin >> n;

  cout << 111 * ((n + 110) / 111) << "\n";

  return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

void solve() {
    ll X, K; cin >> X >> K;
    vector<ll> R(K + 1);
    R[0] = 0;
    rep(i, K) cin >> R[i + 1];

    auto clip = [&] (ll &a) {
        set_min(a, X);
        set_max(a, 0LL);
    };
    auto dir = [] (int k) { return k % 2 == 0 ? -1 : 1; };

    vector<ll> sum(K + 1);
    rep(k, K) sum[k + 1] = sum[k] + (k % 2 == 0 ? -1 : 1) * (R[k + 1] - R[k]);
    
    vector<ll> h(K + 1), l(K + 1); // 満杯状態でスタート
    vector<ll> ub(K + 1), lb(K + 1);
    // a <= ub[i] なら，R[i]までで上のパーツが満杯になる無駄な時間が生じない
    // a >  ub[i] なら，R[i]までのどこかで上のパーツが満杯になる
    //                  この時，a = X も必ず満杯になるのでR[i]以降では値がa = Xと一致しているはず
    h[0]  = X;  l[0] = 0;
    ub[0] = X; lb[0] = 0;
    rep(k, K) {
        ll d = (R[k + 1] - R[k]) * dir(k);
        
        h[k + 1] = h[k] + d;
        l[k + 1] = l[k] + d;
        if(dir(k) > 0) {
            ub[k + 1] = min(ub[k], ub[k] - (h[k] + d - X));
            lb[k + 1] = lb[k];
        } else {
            lb[k + 1] = max(lb[k], lb[k] + -(l[k] + d));
            ub[k + 1] = ub[k];
        }
        clip(h[k + 1]);  clip(l[k + 1]);
        clip(ub[k + 1]); clip(lb[k + 1]);
    }
    
    ll Q; cin >> Q;
    rep(q, Q) {
        ll t, a; cin >> t >> a;
        int k = upper_bound(all(R), t) - begin(R) - 1;
        assert(k >= 0);
        ll ans = 0;
        if(a >= ub[k])
            ans = h[k];
        else if(a <= lb[k])
            ans = l[k];
        else
            ans = a + sum[k];
        ans += (t - R[k]) * dir(k);
        clip(ans);
        cout << ans << endl;
    }
    // debug(h);
    // debug(l);
    // debug(ub);
    // debug(lb);
}

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


Measured memory_bytes: 5888
#-*-coding:utf-8-*-

def main():
    a_list = list(map(int, input().split()))

    task = []
    task.append(abs(a_list[1] - a_list[0]) + abs(a_list[2] - a_list[1]))
    task.append(abs(a_list[2] - a_list[0]) + abs(a_list[1] - a_list[2]))
    task.append(abs(a_list[2] - a_list[1]) + abs(a_list[1] - a_list[0]))
    task.append(abs(a_list[0] - a_list[1]) + abs(a_list[0] - a_list[2]))
    task.append(abs(a_list[1] - a_list[2]) + abs(a_list[0] - a_list[1]))
    task.append(abs(a_list[0] - a_list[2]) + abs(a_list[1] - a_list[0]))
    print(min(task))

    
if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n = list(str(input()))

S = 0
N = 0
for i in range(len(n)):
    S += int(n[i])
    N += int(n[i]) * 10 ** (len(n) - i - 1)
if N % S == 0:
    print("Yes")
else:
    print("No")


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

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadIntArray(3);

            int a = 0;

            foreach (var item in n)
            {
                a = (a < item) ? item: a;
            }
            var s = 1;

            foreach (var item in n)
            {
                if (item != a) s *= item;
            }
            s /= 2;

            Console.WriteLine(s);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
char S[1001];
char T[1001];
int Slong, Tlong, ans;
int main(void) {
	scanf("%s", S);
	scanf("%s", T);

	for(int i = 0; S[i] != '\0'; i++){
		Slong++;
	}
	for(int i = 0; T[i] != '\0'; i++){
			Tlong++;
	}
	//printf("%d %d\n", Slong, Tlong);
	ans = Tlong;	
	
	for(int k = 0; k <= Slong - Tlong; k++){
		int cnt = 0;
		for(int j = 0; j < Tlong; j++){
			if(S[k + j] != T[j]){
				cnt++;
			}
		}
		if(cnt < ans){
			ans = cnt;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1736
var
    n,i,l,r:longint;
    a,b:array[0..200010] of int64;
    c:array[0..5] of int64;
    ans:int64;
function max(a,b:int64):int64;
begin
    if a>b then exit(a) else exit(b);
end;
function min(a,b:int64):int64;
begin
    if a<b then exit(a) else exit(b);
end;
begin
    readln(n);
    for i:=1 to n do
        begin
            read(a[i]);
            b[i]:=b[i-1]+a[i];
        end;
    l:=1;r:=3;ans:=maxlongint;
    for i:=2 to n-2 do
        begin
            while (l<i) and (abs(b[l]-(b[i]-b[l]))>=abs(b[l+1]-(b[i]-b[l+1]))) do inc(l);
            while (r<n) and (abs((b[r]-b[i])-(b[n]-b[r]))>=abs((b[r+1]-b[i])-(b[n]-b[r+1]))) do inc(r);
            c[1]:=b[l];
            c[2]:=b[i]-b[l];
            c[3]:=b[r]-b[i];
            c[4]:=b[n]-b[r];
            ans:=min(ans,max(c[1],max(c[2],max(c[3],c[4])))-min(c[1],min(c[2],min(c[3],c[4]))));
        end;
    writeln(ans);
end.

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

bool isprime(ll a)
{
	ll count=0;
	for(int i=1;i*i<=a;i++)
	{
		if(a%i==0)count+=2;
		if(i*i==a)count--;
	}
	
	if(count==2)return true;
	else
	return false;
	
}


vector<ll>d(151,0);
ll digitsum(ll n)
{
	ll s=0;
		while(n>0)
		{
			s+=n%10;
			n=n/10;
		}
		return s;
		
	
}
void solve()
{
	
ll n;
cin>>n;
ll a[n],ans[n],x=0;

for(ll i=0;i<n;i++)cin>>a[i],x^=a[i];



	
	


for(int i=0;i<n;i++)
{
	ans[i]=x^a[i];
}


for(auto i :ans)cout<<i<<" ";


 
 

 
 
	
	

}




int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 6720
n = int(input())
a = []
for i in range(n):
    a1 = int(input())
    a.append(a1)
count = 0
kuri = 0
for i in range(n):
    if a[i] % 2 == 0:
        count += int(a[i]/2)
        if a[i] == 0:
            kuri = 0
    else:
        if kuri == 1:
            count += a[i]//2 + 1
            kuri = 0
        else:
            count += a[i]//2
            kuri = 1
print(count)

Measured memory_bytes: 7072
N, A, B, C, D = map(int, raw_input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = raw_input()

f1 = True
for i in range(A, C-1):
  if S[i]=="#" and S[i+1]=="#":
    f1 = False

f2 = True
for i in range(B, D-1):
  if S[i]=="#" and S[i+1]=="#":
    f2 = False

if C<D:
  f3 = True
else:
  f3 = False
  for i in range(B-1, D):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      f3 = True

if f1 and f2 and (C<D or f3):
  print "Yes"
else:
  print "No"


Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    REP(i, H) cin >> s[i];
    vector<vector<vector<vector<int>>>> blackcon(H, vector<vector<vector<int>>>(W, vector<vector<int>>(H, vector<int>(W))));
    REP(i, H) {
        REP(j, W) {
            if(s[i][j] != '#') continue;
            vector<vector<int>> dpt(H+1, vector<int>(W+1));
            dpt[i+1][j+1] = 1;
            FOR(k, i, H) {
                FOR(l, j, W) {
                    if(k == i && l == j) continue;
                    if(s[k][l] != '#') continue;
                    dpt[k+1][l+1] = max(dpt[k+1][l], dpt[k][l+1]);
                    if(dpt[k+1][l+1] == 1) {
                        blackcon[i][j][k][l] = 1;
                        //cout << i << j << k << l << endl;
                    }
                }
            }
        }
    }
    vector<vector<int>> dp(H, vector<int>(W));
    dp[0][0] = 0;
    REP(i, H) {
        REP(j, W) {
            if(i == 0 && j == 0) {
                if(s[0][0] == '#') dp[0][0] = 1;
            } else if(i == 0) {
                dp[0][j] = dp[0][j-1] + (s[0][j] == '#' ? 1 : 0);
            } else if(j == 0) {
                dp[i][0] = dp[i-1][0] + (s[i][0] == '#' ? 1 : 0);
            } else {
                dp[i][j] = min(dp[i][j-1], dp[i-1][j]) + (s[i][j] == '#' ? 1 : 0);
            }
            REP(k, i) {
                REP(l, j) {
                    if(blackcon[k][l][i][j] == 1) {
                        if(dp[k][l] < dp[i][j]) dp[i][j] = dp[k][l];
                    } 
                }
            }
            //cout << dp[i][j] << endl;
        }
    }
    cout << dp[H-1][W-1] << endl;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   400005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[N],b[N];

int main()
{
    ll n,m,i,k=0,id,cnt=0;
    string s;
    cin>>n>>m;
    for0(i,m)
    {
        cin>>id>>s;
        if(b[id]==0 && s=="WA")
        {
            a[id]++;
        }
        else if(s=="AC" && b[id]==0)
        {
            b[id]=1;
            cnt++;
            k+=a[id];
        }
    }
    cout<<cnt<<" "<<k<<endl;
    return 0;
}
































Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int mod=1000000007;
int main() {
    int n;cin>>n;
    int a[n],dp[n];
    for(int i=0;i<n;i++)        cin>>a[i];
    
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    
    for(int i=2;i<n;i++){
        dp[i]= min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;    
    return 0;
}


Measured memory_bytes: 4356
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define watch(x) cout << (#x) << " = " << (x) << endl
#define rep(i, n) for (int(i) = (0); (i) < (n); ++(i))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	FIO;
	ll x;
	cin>>x;
	puts(x>=30?"Yes":"No");
	return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,k,a[200000]={0},i,ans=0;
	cin>>n>>k;
	for (i=1;i<=n;i++){
		a[i%k]++;
	}
	ans=a[0]*a[0]*a[0];
	for (i=1;i<=n;i++){
		if ((2*(k-(i%k)))%k==0){
			ans+=a[k-i%k]*a[k-i%k];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792