akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
    int h, a[MAX+1];

    cin >> h;
    for (int i = 1; i <= h; i++) cin >> a[i];

    for (int i = 1; i <= h; i++) {
        cout << "node " << i << ": key = " << a[i] << ", ";
        if (parent(i) >= 1) {
            cout << "parent key = " << a[parent(i)] << ", ";
        }
        if (left(i) <= h) {
            cout << "left key = " << a[left(i)] << ", ";
        }
        if (right(i) <= h) {
            cout << "right key = " << a[right(i)] << ", ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3096
/*
    Flowers, wake up like the sea!
*/
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x7fffffff
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
typedef vector<int> VI;
typedef map<int,int> MII;
const int N = 2e5 + 10, MOD = 7+1e9;
int n, a[N], b[N];
int L[N], R[N];
LL s[N];
void f(bool fg, int x[])
{
    LL ts[N];
    if(fg) for(int i = 1;i <= n;i ++) ts[i] = ts[i-1] + a[n-i+1];
    else memcpy(ts, s, sizeof s);
    for(int i = 2;i <= n;i ++)
    {
        int loc = lower_bound(ts + 1, ts + i - 1, ts[i] / 2) - ts;
        if(loc > i - 1) x[i] = i - 1;
        else if(loc == 1) x[i] = 1;
        else 
        {
            if(abs(2ll * ts[loc] - ts[i]) < abs(2ll * ts[loc-1] - ts[i])) x[i] = loc;
            else x[i] = loc - 1;
        }
    }
}
LL calc(int i, int j, int k)
{
    vector<LL> G;
    G.PB(s[i]), G.PB(s[j] - s[i]);
    G.PB(s[k] - s[j]), G.PB(s[n] - s[k]);
    sort(G.begin(), G.end());
    return abs(G[0] - G[3]);
}
int main()
{
#ifdef YUUKILP
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i ++) cin >> a[i], s[i] = s[i-1] + a[i];
    f(false, L);
    f(true, R);
    LL _min = -1;
    for(int i = 2;i < n - 1;i ++)
    {
        int p1 = L[i], p2 = R[n-i];
        LL now = calc(p1, i, n-p2);
        if(_min == -1) _min = now;
        else _min = min(_min, now);
    }
    cout << _min << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    vector<int> d(13);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        ++d[t];
        if (d[t] == 3) {
            cout << 0;
            return 0;
        }
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << 13); ++mask) {
        vector<int> a(1);
        for (int j = 0; j < 13; ++j) {
            if (d[j] == 0) {
                continue;
            }
            if (d[j] == 2) {
                a.push_back(j);
                a.push_back(24 - j);
            }
            if (d[j] == 1) {
                if (mask & (1 << j)) {
                    a.push_back(24 - j);
                } else {
                    a.push_back(j);
                }
            }
        }
        int s = 100;
        for (int j = 1; j < a.size(); ++j) {
            for (int k = 0; k < j; ++k) {
                s = min(s, min(24 - abs(a[j] - a[k]), abs(a[j] - a[k])));
            }
        }
        ans = max(ans, s);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
long long mat1[100][100] = {0};
long long mat2[100][100] = {0};
long long product[100][100] = {0};
int main(){

int n,m,l;
scanf("%d %d %d",&n,&m,&l);
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        scanf("%lli",&mat1[i][j]);
    }
}
for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
        scanf("%lli",&mat2[i][j]);
    }
}
for(int i=0;i<n;i++){
    for(int j=0,k=-i;j<l;j++,k++){
        for(int p=0;p<m;p++){
            product[i][j] += mat1[i][p]*mat2[p][k+i];
        }
    }
}
for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
        if(j==0){
        printf("%lli",product[i][j]);
        }
        else {
            printf(" %lli",product[i][j]);
        }
    }
    printf("\n");
}
return 0;
}



Measured memory_bytes: 2144
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for x,y in a:
    c = float("inf")
    for j in range(m):
        if c > abs(x-b[j][0])+abs(y-b[j][1]):
            c = abs(x-b[j][0])+abs(y-b[j][1])
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> v(9);
  for (int i=0;i<9;i++){
    cin >> v[i];
  }
  bool ans=true;
  for (int i=0;i<2;i++){
    if (!(v[3*i+3]-v[3*i]==v[3*i+3+1]-v[3*i+1]&&v[3*i+3+1]-v[3*i+1]==v[3*i+3+2]-v[3*i+2])){
      ans=false;
    }
    if (!(v[i+1]-v[i]==v[i+1+3]-v[i+3]&&v[i+1+3]-v[i+3]==v[i+1+6]-v[i+6])){
      ans=false;
    }
  }
  if (ans){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int calc(int t) {
  int res=0;
  while(t){
    res += t % 10;
    t /= 10;
  }
  return res;
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,a,b;
  cin>>n>>a>>b;

  ll res=0;
  for(int i=1;i<=n;i++){
    int t = calc(i);
    if(a<=t&&t<=b)res+=i;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MAX_D = 10000000;
const int NUM_N = 10;

int main()
{
    int h, w;
    cin >> h >> w;

    int graph[NUM_N][NUM_N];
    rep(i, 0, NUM_N)
    rep(j, 0, NUM_N)
        cin >> graph[i][j];

    int dis[NUM_N][NUM_N];
    rep(i, 0, NUM_N)
    {
        vector<int> visited(NUM_N, 0);

        dis[i][i] = 0;
        priority_queue<pii, vector<pii>, greater<pii>> que;
        que.push(make_pair(0, i));
        while(que.size() > 0)
        {
            pii d_now = que.top();
            int d = d_now.first;
            int now = d_now.second;

            que.pop();
            // cout << now << ' ' << d << ' ' << que.size() << endl;
    
            if (visited[now]) continue;
            else visited[now] = 1;

            dis[i][now] = d;

            rep(next, 0, NUM_N)
            if(visited[next] == 0)
                que.push(make_pair(d + graph[now][next], next));
        }
    }

    map<int, int> num_cnt;
    rep(i, 0, w)
    rep(j, 0, h)
    {
        int a;
        cin >> a;
        if (a == -1) continue;
        num_cnt[a]++;
    }

    ll ans = 0;
    for (auto n_c: num_cnt)
    {
        int num = n_c.first;
        int cnt = n_c.second;
        // cout << num<< ' ' << dis[num][1] << ' ' << cnt << endl;
        ans += dis[num][1] * cnt;
    }
    cout << ans << endl;

    // rep(i, 0, NUM_N)
    // rep(j, 0, NUM_N)
    //     cout << i << " " << j << " " << dis[i][j] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


s = str(input())
if s <= "2019/04/30":
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;

ll min(ll a, ll b) {
	if (a < b) { return a; }
	return b;
}

ll max(ll a, ll b) {
	if (a < b) { return b; }
	return a;
}


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

	ll H[1000];
	H[0] = 0;
	repn(i, N) cin >> H[i];

	ll dp[1000][1000] = {};

	rep(i, N + 1) {
		rep(j, K + 1) {
			dp[j][i] = INF;
		}
	}

	dp[0][0] = 0;

	rep(j, K+1) {
		repn(i, N) {
			rep(k, min(j, i-1)+1) {
				dp[j][i]=min(dp[j][i],dp[j - k][i - k - 1] + max(H[i] - H[i - 1 - k], 0));
			}

			
		}

		
	}

	ll ans = dp[K][N];

	repn(j, K) {
		ans = min(ans, dp[K - j][N - j]);
	}

	cout << ans;

	system("PAUSE");

}

Measured memory_bytes: 8312
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.math.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
     
    public static void println(Object ...x){
        for(Object o:x){
            System.out.println(o);
        }
    }
    public static void print(Object ...x){
        for(Object o:x){
            System.out.print(o);
            System.out.print(" ");
        }
        System.out.println();
    }
    public static void fprint(Object x){
        System.out.println(x);
    }
    
    public static void main(String[] args) 
    { 
        FastReader fs=new FastReader();
        long mod =1000000007;
        int a=fs.nextInt();
        int b=fs.nextInt();
        int ans1=(a*(a-1)/2);
        int ans2=(b*(b-1)/2);
        int fans=ans1+ans2;
        System.out.println(fans);
    } 
} 



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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int w, h;
int ans = 0;
bool visited[105][105];
int edx[6] = {-1, 1, -1, 0, -1, 0};
int edy[6] = {0, 0, 1, 1, -1, -1};
int odx[6] = {-1, 1, 0, 1, 1, 0};
int ody[6] = {0, 0, 1, 1, -1, -1};

bool inside (int y, int x) {
    if ((0 <= y && y <= h + 1) && (0 <= x && x <= w + 1)) return true;
    return false;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w >> h;
    int g[h + 2][w + 2] = {};
    rep(i, h)rep(j, w) cin >> g[i + 1][j + 1];
    queue<pair<int, int>> q;
    q.push({0, 0});
    while (!q.empty()) {
        pii now = q.front(); q.pop();
        int y = now.fi;
        int x = now.se;
        visited[y][x] = true;
        if (y % 2 == 0) {
            rep(i, 6) {
                int ny = y + edy[i];
                int nx = x + edx[i];
                if (!inside(ny, nx) || visited[ny][nx]) continue;
                if (g[ny][nx] == 1) {
                    ans++;
                    continue;
                }
                visited[ny][nx] = true;
                q.push({ny, nx});
            }
        }
        else {
            rep(i, 6) {
                int ny = y + ody[i];
                int nx = x + odx[i];
                if (!inside(ny, nx) || visited[ny][nx]) continue;
                if (g[ny][nx] == 1) {
                    ans++;
                    continue;
                }
                visited[ny][nx] = true;
                q.push({ny, nx});
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3108
import Data.List

main = do
  li <- getLine
  let [a,b] = map read $ words li
  let ans = compute a b
  print ans

-- 共通する素因数の個数を求める
compute :: Int -> Int -> Int
compute a b = succ $ length $ is (sub a) (sub b)

sub n = map head $ group $ primeFactors n

-- ordered intersection
is xxs@(x:xs) yys@(y:ys) =
  case compare x y of
    LT -> is xs yys
    EQ -> x : is xs ys
    GT -> is xxs ys
is _ _ = []

-- 自作の簡易素数と素因数分解
primes = 2 : 3 : 5 : sieve [(9,3),(10,5)] [7,9..]

{- (np,p)のリストと、奇数の列 -}
sieve ((q,p):qps) xxs@(x:xs) =
  case compare q x of
    LT -> sieve qps1 xxs
    EQ -> sieve qps1 xs
    GT -> x : sieve (insert (x+x,x) qps) xs
  where
    qps1 = insert (q+p,p) qps

primeFactors n = loop n primes
  where
    loop 1 _ = []
    loop n pps@(p:ps)
      | r == 0 = p : loop q pps
      | q < p  = [n]
      | True   = loop n ps
      where (q,r) = divMod n p

Measured memory_bytes: 40188
#include <stdio.h>
#include <string.h>

int main(void)
{
    char w[100][11];
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;++i)scanf("%s",w[i]);
    for(i=0;i<n-1;++i){
        for(j=i+1;j<n;++j){
            if(!strcmp(w[i],w[j])){
                puts("No");
                return 0;
            }
        }
    }
    for(i=1;i<n;++i){
        if(w[i-1][strlen(w[i-1])-1]!=w[i][0]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();
        int y = scan.nextInt();
        while (x != 0 || y != 0) {
            if (x > y) {
                System.out.println(y + " " + x);
            } else if (x < y) {
                System.out.println(x + " " + y);
            } else {
                System.out.println(x + " " + y);
            }
            x = scan.nextInt();
            y = scan.nextInt();

        }
    }
}



Measured memory_bytes: 35676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    VI vi = VI(n,0);
    for (int i = 0; i < n; ++i)
    {
        cin >> vi[i];
        vi[i] -= (i+1);
    }
    sort(vi.begin(), vi.end());
    int m = vi[n/2];
    LL cost = 0;
    for (itn i = 0; i < n; ++i)
    {
        cost += abs(vi[i] - m);
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;
        B -= 1;
        for (;;ans++){
            if (B <1)break;
            B -= (A-1);
        }
        System.out.printf("%d\n",ans);
        
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);
  for (int i = 0; i < X; i++) cin >> A.at(i);
  for (int i = 0; i < Y; i++) cin >> B.at(i);
  for (int i = 0; i < Z; i++) cin >> C.at(i);
  
  vector<long long> AB(X * Y);
  for (int i = 0, k = 0; i < X; i++)
  {
    for (int j = 0; j < Y; j++)
    {
      AB.at(k) = A.at(i) + B.at(j);
      k++;
    }
  }
  
  sort(AB.begin(), AB.end(), greater<long long>());
  
  vector<long long> ABC(min(X * Y, K) * Z);
  for (int i = 0, k = 0; i < min(X * Y, K); i++)
  {
    for (int j = 0; j < Z; j++)
    {
      ABC.at(k) = AB.at(i) + C.at(j);
      k++;
    }
  }
  
  sort(ABC.begin(), ABC.end(), greater<long long>());
  
  for (int i = 0; i < K; i++) cout << ABC.at(i) << endl;
}

Measured memory_bytes: 31616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int a, b;
int ans;

int main() {
	cin >> a >> b;
	if(a == 0) {
		if(b < 100) ans = b;
		else ans = 101;
	}
	else if(a == 1) {
		if(b < 100) ans = b * 100;
		else ans = b * 100 + 100;
	}
	else {
		if(b < 100) ans = b * 10000;
		else ans = b * 10000 + 10000;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 998244353;

vector<long long int> fac;

long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
    long long int n, a, b, k;
    cin >> n >> a >> b >> k;
    long long int res = 0;
    fac.push_back(1);
    for (int i = 1; i <= n; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    for (int i = 0; i * a <= k && i <= n; i++) {
        if ((k - i * a) % b != 0 || (k - i * a) / b > n) continue;
        long long int l1 = i, l2 = (k - i * a) / b;
        res += myc(n, l1) * myc(n, l2) % mod;
        res %= mod;
    }
    cout << res << endl;
}




Measured memory_bytes: 7404
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl=0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 0; i <= m; i++){
        c[i][0] =0;
    }
    for (int i= 0; i <= n; i++){
        c[0][i] = 0;
    }

    for (int i = 1;i <= m; i++){
        for(int j = 1; j <= n;j++){
            if(X[i] == Y[j]){
                c[i][j]=c[i-1][j-1] + 1;
            }
            else{
                c[i][j] = max(c[i-1][j],c[i][j-1]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main(){
    string s1,s2;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) <<endl;
    }
    return 0;
}


Measured memory_bytes: 7076
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append(input())
b=[]
for i in range(m):
    b.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        t=[]
        for p in range(m):
            t.append(a[i+p][j:j+m])
        #print(t)
        if t==b:
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')


Measured memory_bytes: 3064
#include <stdio.h>
int n;
int count=0;

void Process(int A[ ], int n){
	int i;
	for(i=0;i<n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[i]);
}


void SelectionSort(int A[ ], int n){
	int i,j,temp,min;
	for(i=0;i<n-1;i++){
		min=i;
		for(j=i+1;j<n;j++){
			if(A[j] < A[min]){
				min = j;
			}
		}
		if(A[i]!=A[min]){
		temp = A[i];
		A[i] = A[min];
		A[min] = temp;
		count++;
	}
	}
}


int main(void){
	int i;
	scanf("%d",&n);
	int A[100];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	
	SelectionSort(A, n);
	Process(A, n);

	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1828
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)


bool solve(int n, int m)
{
    vector<vi> G(n);
    rep(i, m){
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    
    for(vi& u : G){
        if(u.size() >= 3) return false;
    }
        
    vector<bool> finished(n, false);
    rep(i, n){
        if(G[i].size() == 1){
            int p = i;
            int u = G[i][0];
            finished[i] = finished[u] = true;
            while(G[u].size() == 2){
                int next = G[u][0] == p ? G[u][1] : G[u][0];
                p = u;
                u = next;
                finished[u] = true;
            }
        }
        else if(G[i].size() == 0){
            finished[i] = true;
        }
    }
    
    return all_of(finished.begin(), finished.end(), [](bool a){ return a; });
}

int main()
{
    int n, m;
    while(cin >> n >> m, n){
        cout << (solve(n, m) ? "yes" : "no") << endl;
    }
}

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

int main(){
    vector<string> weath;
    weath.push_back("Sunny");
    weath.push_back("Cloudy");
    weath.push_back("Rainy");
    string str ;
    cin >> str;
    
    for (int i=0;i<weath.size()-1;i++){
        if (str==weath[i] ){
            cout<<weath[i+1];
            return 0;
        }
    }

    if(str==weath[2])
        cout<<weath[0]; 
 return 0;
}

Measured memory_bytes: 256
//C++ツづ可偲?堕閉つウツづェツづ?つ「ツづゥツスツタツッツクツづーツ使ツつヲツづ篠甘按単
#include <iostream>
#include <stack>
using namespace std;

int main(){
  int n;
  stack<int> st;

  while(cin >> n){
    if(n == 0){
      cout << st.top() << endl;
      st.pop();
    }
    else{
      st.push(n);
    }
  }
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<string.h>
int main()
{
       char a[15],b[15],c[15];
       int ln,x,y,z,j,k,l;
       scanf("%s",a);
       scanf("%s",b);
       scanf("%s",c);
       x=strlen(a);
       y=strlen(b);

       if((a[x-1]==b[0])&&(b[y-1]==c[0]))
              printf("YES\n");

       else
              printf("NO\n");


       return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

using namespace std;

// The idea of binary search and achieving O(QlogN) was good
// But reassigning each value defeated the point since the worse case scenario would be O(QN), which is TLE
// Replacing the array with a count array should have been the first thing to come to my mind
// But I was way too occupied with the previous problem.

int main() {
  int N; cin >> N;
  vector<int> A(N);
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  int Q; cin >> Q;
  int B[Q];
  int C[Q];
  for (int i = 0; i < Q; i++) {
    cin >> B[i] >> C[i];
  }

  sort(A.begin(), A.end());

  // O(N)
  unordered_map<int, int> m;
  int i = 0; 
  while (i < N) {
    int num = A[i];
    int i_low = i;
    while (i < N && A[i] == num) {
      i++;
    }
    m[num] = i - i_low;
  }

  // O(QlogN)
  for (int i = 0; i < Q; i++) {
    int count = m[B[i]];
    m[B[i]] = 0; // wow this is Godly
    m[C[i]] += count;
    sum += (C[i] - B[i]) * count;
    cout << sum << endl;
  }
}

Measured memory_bytes: 8204
#include<stdio.h>

int main(){
	char a[9];
	char b[9];
	char c[9];
	int s,t;
	
	scanf("%s %s %s",a,b,c);
	
	s = -1;
	while(a[s+1] != '\0')s++;
	
	t = -1;
	while(b[t+1] != '\0')t++;
	
	if(a[s] == b[0] && b[t] == c[0]){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;
    
    // 初期条件
    dp[0][0] = 0;
    
    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
            
            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            
            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    
    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

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

using namespace std;

int n;
int main()
{
  	cin >> n;
  for(int i = 1; i <= 3; i++)
  {
	int now = n % 10;
    if(now == 7)
    {
		printf("Yes\n");
      	return 0;
    }
    n /= 10;
  }
  printf("No\n");
	return 0;
}

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

int n,m;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	if (abs(n-m)>1){
		cout << "0\n";
	}else{
		int ans=(n==m)+1;
		while (n){
			ans=1ll*ans*n%mod;
			n--;
		}
		while (m){
			ans=1ll*ans*m%mod;
			m--;
		}
		cout << ans << "\n";
	}
}

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

using namespace std;

int main(){
    string s; cin >> s;
    int a=0, b=0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '0'){
            a++;
        }else{
            b++;
        }
    }
    cout << min(a,b)*2 << endl; 
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
   int N , D , X ,a;
   cin >> N >> D >> X;
   int count = N ;
   for( int i = 0 ; i < N ; i++ ){
       cin >>a;
       count = count + ((D-1) / a ); 
       
   }  
   cout << X + count << endl;
    return 0;
}

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

bool take(int num, int a, int b){
    int sum = 0;
    while(num){
        sum += num % 10;
        num /= 10;
    }
    
    if((sum >= a) && (sum <= b)){
        return true;
    }
    return false;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    int ans[10000];
    int next = 0;
    
    for (int i = 1; i <= N; i++){
        if(take(i, A, B)){
            ans[next] = i;
            next++;
        }
    }
    
    int all_sum = 0;
    for(int i = 0; i < next; i++){
        all_sum += ans[i];
    }
    
    cout << all_sum << endl;
}

Measured memory_bytes: 256
x,y= map(int,input().split())
if x==2 or y ==2:
  print('No')
elif x in [4,6,9,11] and y in [4,6,9,11]:
  print('Yes')
elif x not in [4,6,9,11] and y not in [4,6,9,11]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long int
using namespace std;
class table{
    public: 
    ll x,y,z;
};
int main()
{
    ll n; cin>>n;
    ll a[n],c[n],b[n];
    for(ll i=0;i<n;i++) {cin>>a[i]; cin>>b[i]; cin>>c[i];}
    table dp[n]; 
    dp[0].x=a[0]; dp[0].y=b[0]; dp[0].z=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i].x=max(dp[i-1].y,dp[i-1].z)+a[i];
        dp[i].y=max(dp[i-1].x,dp[i-1].z)+b[i];
        dp[i].z=max(dp[i-1].x,dp[i-1].y)+c[i];
        //cout<<dp[i]<<" ";
    }
    ll ans =max(dp[n-1].x,dp[n-1].y);
    cout<<max(ans,dp[n-1].z);
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	int a=(s[0]-'0')*10+(s[1]-'0');
	int b=(s[2]-'0')*10+(s[3]-'0');
	if(a==0||a>12){
		if(b>0&&b<=12){
			cout<<"YYMM"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}else if(b==0||b>12){
		if(a>0&&a<=12){
			cout<<"MMYY"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}else{
		cout<<"AMBIGUOUS"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    static boolean lose(int pos, List<Integer> moves, int n) {
        int leftMost = pos;
        int rightMost = pos;
        for(int i = 0; i < moves.size(); i++) {
            int x = moves.get(i);
            if (x == -1) rightMost--;
            if (x == 1) leftMost++;
            if (x == -2) leftMost = Math.max(leftMost - 1, 1);
            if (x == 2) rightMost = Math.min(rightMost + 1, n);
            if (leftMost > n || rightMost <= 0) return true;
        }
        return false;
    }

    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int m = in.nextInt();
        int l = in.nextInt();
        int si = in.nextInt();
        int sj = in.nextInt();
        String s = in.next();
        String t = in.next();

        List<Integer> horMoves = new ArrayList<>();
        for(int i = 0; i < l; i++) {
            if (s.charAt(i) == 'L') horMoves.add(-1);
            if (s.charAt(i) == 'R') horMoves.add(1);
            if (t.charAt(i) == 'L') horMoves.add(-2);
            if (t.charAt(i) == 'R') horMoves.add(2);
        }

        List<Integer> verMoves = new ArrayList<>();
        for(int i = 0; i < l; i++) {
            if (s.charAt(i) == 'U') verMoves.add(-1);
            if (s.charAt(i) == 'D') verMoves.add(1);
            if (t.charAt(i) == 'U') verMoves.add(-2);
            if (t.charAt(i) == 'D') verMoves.add(2);
        }

        if (lose(sj, horMoves, m) || lose(si, verMoves, n))
            System.out.println("NO");
        else
            System.out.println("YES");
    }
}


Measured memory_bytes: 34424
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b,ans;
    cin >> a >> b;
    for (int i=0; i<=1010; i++){
        ans = i;
        bool condA = (0.08 * i >= a) && (0.08 * i < (a + 1));
        bool condB = (0.1 * i >= b) && (0.1 * i < (b + 1));
        if (condA && condB) break;
    }
    if (ans == 1010) cout << -1 << endl;
    else cout << ans <<endl;
    return 0;

}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

	int multi = a;
	while (multi <= b * a)
	{
		if (multi % b == c)
		{
			cout << "YES" << '\n';
			return 0;
		}
		multi += a;
	}
	cout << "NO" << '\n';
	return 0;
}


Measured memory_bytes: 3624
def B():
    n = int(input())
    a = input().split()
    
    if(len(a) != n):
        exit(1)

    i_max = 0
    i_min = 1000000001
    for i in a:
        k = int(i)
        if (i_max < k):
                i_max = k
        if (i_min > k):
                i_min = k
    print(abs( i_max - i_min))

if __name__ =='__main__':
    B()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long f[300005];
long long ans=0;
long long w,h,a,b;
void giaithua(){
	f[0]=1;
	for(long long i=1;i<=200000;i++){
		f[i]=(f[i-1]*i)%mod;
	}
}
long long power(long long x,long long y){
    if(y==0) return 1;
    if(y==1) return x;
    long long temp=power(x,y/2);
    temp=(temp*temp)%mod;
    if(y&1) temp=(temp*x)%mod;
    return temp%mod;
}
long long get(int x, int y){
   	x-=1;
   	y-=1;
   	long long p=f[x+y];
   	long long q=power(f[x],mod-2);
   	long long r=power(f[y],mod-2);
   	p=p*q;
   	p%=mod;
   	p=p*r;
   	p%=mod;
   	return p;
}
int main(){
	cin>>h>>w>>a>>b;
	giaithua();
	for(long long i=1;i<=h-a;i++){
		ans+=get(i,b)*get(h+1-i,w-b)%mod;
		ans%=mod;
	}
	cout<<ans;
}

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

#define precise(n,k) fixed<<setprecision(k)<<n

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

vector<int> memo;

int solve(vector<int>& coins, int amount) {
    if(amount < 0) return INT_MAX;
    if(amount == 0) return 0;

    if(memo[amount] != -1) return memo[amount];

    int minimum = INT_MAX;
    int curr;

    for(int coin: coins) {
        curr = solve(coins, amount - coin);
        minimum = min(minimum, ((curr==INT_MAX)?INT_MAX:curr+1));
    }
    memo[amount] = minimum;
    return memo[amount];
}

int main() {
    int n;
    
    cin >> n;
    
    
    memo.resize(100000+1, -1);
    
    vector<int> coins = {531441, 59049, 6561, 729, 81, 279936, 46656,7776, 1296,216,36,  6,   9, 1};
    
    
    sort(coins.rbegin(), coins.rend());
    


    
    int answer = solve(coins, n);
    
    cout << ((answer==INT_MAX)?-1:answer) << endl;
    
   
    
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for(ll i=0; i<n; i++) cin >> a[i];
  
  int num = 1;
  for(ll i=0; i<n; i++){
    if(num==a[i]){
      num++;
    }
  }
 
  if(num==1) cout << -1 << endl;
  else cout << n-num+1 << endl;
  
  return 0;
}

Measured memory_bytes: 4840
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format;

void main(string[] args)
{
    int[] xs = [0, 0];
    readf("%d\n", &xs[0]);
    readf("%d\n", &xs[1]);

    if (xs.canFind(1) && xs.canFind(2))
    {
        writeln(3);
    }
    else if (xs.canFind(2) && xs.canFind(3))
    {
        writeln(1);
    }
    else
    {
        writeln(2);
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	public static double game(int own, int ene, int own_score, int ene_score, ArrayList<Integer> own_hand, ArrayList<Integer> ene_hand, double dp[][][]){
		if(own == 0 && ene == 0){
			//System.out.println(own_score + " " + ene_score);
			return own_score > ene_score ? 1 : 0;
		}
		
		
		double prob = 0;
		
		for(int i = 0; i < 9; i++){
			if((own & (1 << i)) == 0){
				continue;
			}
			
			int i_count = 0;
			double i_prob = 0;
			
			for(int j = 0; j < 9; j++){
				if((ene & (1 << j)) == 0){
					continue;
				}
				
				boolean win = own_hand.get(i) > ene_hand.get(j);
				int all = own_hand.get(i) + ene_hand.get(j);
				
				i_prob += game(own & (~(1 << i)), ene & (~(1 << j)), win ? own_score + all : own_score, !win ? ene_score + all : ene_score, own_hand, ene_hand, dp);
				i_count++;
			}
			
			prob += i_prob / i_count;
			break;
		}
		
		return prob;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			ArrayList<Integer> own = new ArrayList<Integer>(9);
			ArrayList<Integer> ene = new ArrayList<Integer>(9);
			
			for(int j = 0; j < 9; j++){
				own.add(sc.nextInt());
			}
			
			for(int j = 0; j < 9; j++){
				ene.add(sc.nextInt());
			}
			
			double[][][] dp = new double[1 << 9][1 << 9][2];
			for(int j = 0; j < (1 << 9); j++){
				for(int k = 0; k < (1 << 9); k++){
					for(int l = 0; l < 2; l++){
						dp[j][k][l] = -1.0;
					}
				}
			}
			
			double prob = game((1 << 9) - 1 , (1 << 9) - 1, 0, 0, own, ene, dp);
			
			System.out.println(prob + " " + (1 - prob));
		}
	}

}

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

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

    int A, B;
    cin >> A >> B;
    int cnt = 1;
    int C = A;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    while (C < B) {
        C += A - 1;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

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

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll n;
	cin >> n;
	ll ans  = 0;
	for(ll i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			ll z = 0;
			while(n % i == 0)
				n /= i, z++;
			cerr << z << '\n';
			ll x = 1;
			while(z >= x)
				ans += 1, z -= (x++);
		}
	}
	if(n != 1)
		ans++;
	cout << ans;
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }
    if(mp.size()==3){   
        ll tmp;
        ll cxor;
        for(auto it=mp.begin();it!=mp.end();++it){
            if(it==mp.begin()){
                tmp=it->second;
                cxor=it->first;
            }
            else{
                if(it->second!=tmp){
                    cout << "No" << endl;
                    return 0;
                }
                else{
                    cxor=(cxor^it->first);
                    //cout << cxor << endl;
                }
            }
        }
        if(cxor!=0){
            cout << "No" << endl;
            return 0;
        }
        else {
            cout << "Yes" << endl;
            return 0;
        }
    }


    else if(mp.size()==2){
        auto it = mp.begin();
        if(it->first!=0 && next(it)->first==0 && it->second==2*(next(it))->second){
            cout << "Yes" << endl;
            return 0;
        }
        else if(it->first==0 && next(it)->first!=0 && 2*it->second==(next(it))->second){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }

    else if(mp.size()==1){
        if(mp.begin()->first==0){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    else{
        cout << "No" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007


ll gcd(ll a, ll b) {return (b == 0LL) ? a : gcd(b, a % b);}

vl pos(1000006, 1000008);
vl fin(1000006, -1);
vl spf(1000006,1000008);
vl v(1000006);
ll n;
vector <bool> vis(1000006, false);

void sieve() {
	for (ll i = 2; i < 1000006; i++) {
		if (!vis[i]) {
			for (ll j = i; j < 1000005; j += i) {
				if (pos[j] != 1000008)
					fin[i] = max(fin[i], pos[j]);
				spf[j] = min(spf[j], i);
				vis[j] = true;
			}
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> v[i];
		pos[v[i]] = i;
		spf[v[i]] = v[i];
	}
	sieve();
	int f = 0;
	for (ll i = 0; i < n; i++) {
		ll cur = v[i];
		if (cur == 1)
			continue;
		while (cur > 1) {
			ll d = spf[cur];
			if (fin[spf[cur]] > i) {
				f = 1;
				break;
			}
			while (cur % d == 0 && d)
				cur = cur / d;
		}
		if (f == 1)
			break;
	}
	int ff = 0;
	if (f == 0) {
		cout << "pairwise coprime" << "\n";
		ff = 1;
	}
	ll ans = v[0];
	for (ll i = 1; i < n; i++)
		ans = gcd(ans, v[i]);
	if (ans == 1 && ff == 0) {
		cout << "setwise coprime\n";
		ff = 1;
		//return 0;
	}
	if (ff == 0)
		cout << "not coprime\n";
}


Measured memory_bytes: 34480
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
    vi x(5);
    forn(i,5)
    {
        cin>>x[i];
        if(x[i]==0)
            cout<<i+1<<endl;
    }
}
int main()
{
    sws
    // tcase{
        solve();
    // }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, a, b;
	cin>>n>>a>>b;
	long long tog = n / (a + b);
	long long left = n - tog * (a + b);
	long long add = min(left, a);
	cout<<tog * a + add<<endl;
	return 0;
}

Measured memory_bytes: 256