akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...


const long mod = 1e9 + 7;

ll n;
void test_case(){
	cin>>n;
	vector<ll> v(n);
	ll res = 0;
	for(auto & el : v)
		cin>>el,res^=el;
		
	vector<ll> ans;
	for(int i = 0;i<n;++i){
		ll num = res^v[i];
		ans.push_back(num);
	}
	for(auto el : ans)
		cout<<el <<' ';

	
}





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
int n,m,a[13],b[13];
string s[13],ss[13];
void dfs1(int x,bool allow){
	if(x==m){
		cout<<"YES"<<endl;
		exit(0);
	}
	else if(b[x]!=-1) dfs1(x+1,allow);
	else{
		for(int i=x+1;i<m;i++){
			if(b[i]!=-1) continue;
			bool ok=true;
			for(int j=0;j<n;j++)
				if(s[j][x]!=s[a[j]][i]){
					ok=false;
					break;
				}
			if(ok){
				b[x]=i;
				b[i]=x;
				dfs1(x+1,allow);
				b[x]=b[i]=-1;
			}
		}
		if(allow) b[x]=x,dfs1(x+1,0),b[x]=-1;
	}
} 
void dfs2(int x,bool allow){
	if(x==n) dfs1(0,(m%2));
	else if(a[x]!=-1) dfs2(x+1,allow);
	else{
		for(int i=x+1;i<n;i++){
			if(ss[i]==ss[x]&&a[i]==-1){
				a[x]=i;
				a[i]=x;
				dfs2(x+1,allow);
				a[x]=a[i]=-1;
			}
		}
		if(allow) a[x]=x,dfs2(x+1,0),a[x]=-1;
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	for(int i=0;i<n;i++)
		ss[i]=s[i],sort(ss[i].begin(),ss[i].end());
	dfs2(0,(n%2));
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

/**
 * Created by Ayushi on 22 Mar 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        String a = buffer.readLine();
        int n = a.length();
        buffer.close();

        String ar = new StringBuilder(a).reverse().toString();
        String b = a.substring(0, (n-1)/2);
        String br = new StringBuffer(b).reverse().toString();
        String c = a.substring(((n+3)/2)-1, n);
        String cr = new StringBuffer(c).reverse().toString();

        if (a.equals(ar) && b.equals(br) && c.equals(cr)) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22100
from decimal import *
getcontext().prec = 14

N, D = map(int, input().split())


def distance(x1, x2, y1, y2):
    dx = x2-x1
    dy = y2-y1
    return (dx*dx + dy*dy).sqrt()


X = [0] * N
Y = [0] * N
ans = 0
for i in range(N):
    X[i], Y[i] = map(Decimal, input().split())
    if (distance(0, X[i], 0, Y[i]) <= D):
        ans += 1

print(ans)


Measured memory_bytes: 57424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag,                    //if  using ll change ll to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)
vector<vector<int>>v;
vector<int>  vis;
int dfs(int x)
{

	for (int i = 0; i < v[x].size(); i++)
	{
		if (vis[v[x][i]] == 0)
		{
			vis[v[x][i]] = x;
			dfs(v[x][i]);
		}
	}
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m; int a, b;
	cin >> n >> m;
	v.resize(n + 1); vis.resize(n + 1, 0);
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	vis[1] = 1;
	int f = 0;
	set<pair<int, int>> s;
	s.insert(mk(0, 1));
	while (s.size())
	{
		auto it = s.begin();
		int x = it->ss;
		int b = it->ff; s.erase(it);
		for (int i = 0; i < v[x].size(); i++)
		{
			if (vis[v[x][i]] == 0)
			{
				vis[v[x][i]] = x;
				s.insert(mk(b + 1, v[x][i]));
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (vis[i] == 0)
		{f = 1; break;}
	}

	if (f == 1)
		cout << "No";
	else
	{
		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++)
			cout << vis[i] << endl;
	}
	return 0;


}

Measured memory_bytes: 14412
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int d[]=new int[100001];
        for (int i = 0; i < n; i++) {
			d[sc.nextInt()]++;
		}
        for (int i = 1; i < d.length; i++) {
			d[i]+=d[i-1];
		}
        int ans=0;
        for (int i = 1; i < d.length; i++) {
			if(d[i]==n/2)ans++;
		}
        
        out.println(ans);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33804
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
if 0 in A:
	print(0)
	exit()

ans = 1

for a in A:
	ans *= a
	if ans > 10**18:
		print(-1)
		exit()
print(ans)


Measured memory_bytes: 87688
N =int(input())
L=list(map(int, input().split()))
LL = sorted(L)
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if LL[i]+LL[j]>LL[k]:
                if (LL[i]!=LL[j])and(LL[j]!=LL[k]):
                    count += 1
print(count)

Measured memory_bytes: 73060
import sys
sys.setrecursionlimit(10 ** 6)

def dfs(now, par):
    h = 0
    global ans
    for child in g[now]:
        if child == par: continue
        h = max(h, dfs(child, now))
    if h == k - 1 and par != 0:
        ans += 1
        h = -1
    return h + 1

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
g = [[] for _ in xrange(n)]
ans = 0
if a[0] != 1:
    a[0] = 1
    ans += 1
for i in xrange(n):
    g[a[i] - 1].append(i)
dfs(0, 0)
print ans


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

int main(){
  ll a,b,ans=2020;
  cin >> a >> b;
  for(ll i = a; i <= min(a+2019,b); i++ ){
    for(ll j = i+1; j <= min(i+2020,b); j++){
      ans = min(ans,(i*j)%2019);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int n,cnt;
int prime[300001];
int data[3000];
int main(void){
	for(int i=2;i<=300000;i++){
		if(i%7!=1 && i%7!=6)continue;
		for(int j=i*2;j<=300000;j+=i)prime[j]=1;
	}
	while(1){
		scanf("%d",&n);
		if(n==1)break;
		printf("%d: ",n);
		cnt=0;
		int j=1;
		while(j<n){
			j++;
			if(j%7!=1 && j%7!=6)continue;
			if(n%j==0 && prime[j]==0)data[cnt++]=j;
		}
		for(int i=0;i<cnt;i++)printf("%d%c",data[i],i==cnt-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 2200
#include <cstdio>
#include <algorithm>

using namespace std;

/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */
typedef long long ll;

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
ll A, B, R, C;


int main () {

	int cnt = 1;

	// 2２つの正整数の読込み
	scanf("%lld %lld", &A, &B);

	while((R = A % B) > 0) {
		A = B;
		B = R;
	}
	C = B;
	
	// 初期状態の満足度
	for(int i = 2; i <= C && i <= 1000000; i++) {
		if(C % i == 0) {
			cnt ++;
			while(C % i == 0) C /= i;
		}
	}
	cnt += (C > 1);

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

Measured memory_bytes: 128
// 基本のinclude
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

int a[12][12];
const int INF = 100010001001;

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

    vector<int> c(n);
    // vector<vector<int>> a(n, vector<int>(m));
    rep (i, n) {
        cin >> c[i];
        rep (j, m) cin >> a[i][j];
    }

    int ans = INF;
    rep(s, 1<<n) {
        int cost = 0;
        vector<int> d(n);
        rep(i, n) {
            if (s>>i&1) {
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m) if (d[j] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#N, A, B, C = map(int, inputs[0].split())
#L = [int(i) for i in inputs[1:]]

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

def dfs(cnt,a,b,c):
    if cnt == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30if min(a,b,c) > 0 else 1e9
    r0 = dfs(cnt+1,a,b,c)
    r1 = dfs(cnt+1,a+L[cnt],b,c) + 10
    r2 = dfs(cnt+1,a,b+L[cnt],c) + 10
    r3 = dfs(cnt+1,a,b,c+L[cnt]) + 10
    return min(r0,r1,r2,r3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
n = int(raw_input())
a = raw_input().split()
a.sort()

dup = 0
prev = -1
dist = 0
for i in range(0, len(a)):
    if prev == a[i]:
        if dup == 1:
            dup = 0
        else:
            dup = 1
    else:
        dist += 1
    prev = a[i]
res = dist
if dup == 1:
    res -= 1

print(str(res))

Measured memory_bytes: 11328
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
int cnt[maxn];
main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(x>0)cnt[x-1]++;
        cnt[x]++,cnt[x+1]++;
    }
    int ans=0;
    for(int i=0;i<maxn;i++)ans=max(ans,cnt[i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359



int main() {
	string N;
	ll sum;
	cin >> N;
	cout << N[0] << N.size()-2 << N[N.size()-1] << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
alist = list(map(int, input().split()))
d = deque()
for i in range(n):
    if i % 2 == 0:
        d.append(alist[i])
    else:
        d.appendleft(alist[i])
if i % 2 == 0:
    print(*reversed(d))
else:
    print(*d)

Measured memory_bytes: 25412
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
if a1*t1+a2*t2==b1*t1+b2*t2:print("infinity")
else:
  if (a1-b1)*(a2-b2)>0:print(0)
  else:
    if a1>b1:
      firstD=t1*(a1-b1)
      secondD=t2*(b2-a2)
      lead=secondD-firstD
    else:
      firstD=t1*(b1-a1)
      secondD=t2*(a2-b2)
      lead=secondD-firstD
    if lead<0:print(0);exit()
    if firstD<lead:print(1);exit()
    if firstD%lead==0:
      print((firstD//lead)*2)
    else:print((firstD//lead+1)*2-1)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){

  int a,b;
  
  while(1){
    
    scanf("%d",&a);
    if(a==0) break;

    a=1000-a;

    b=a/500;
    a-=(a/500)*500;

    b+=a/100;
    a-=(a/100)*100;

    b+=a/50;
    a-=(a/50)*50;

    b+=a/10;
    a-=(a/10)*10;

    b+=a/5;
    a-=(a/5)*5;

    b+=a;

    printf("%d\n",b);
  }

  return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _164B
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputArray = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
            long takahashiHp = inputArray[0];
            long aokiHp = inputArray[2];

            while (takahashiHp > 0 || aokiHp > 0)
            {
                aokiHp = aokiHp - inputArray[1];
                //Console.WriteLine("aoki : {0}", aokiHp);
                if (aokiHp <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                takahashiHp = takahashiHp - inputArray[3];
                //Console.WriteLine("takahashi : {0}",takahashiHp);
                if (takahashiHp <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }

            }

        }
    }
}


Measured memory_bytes: 28176
#include<stdio.h>
int h,w;
int map[102][102];
void trace(){
    int i,j;
    for(i=0;i<h;i++){
	for(j=0;j<w;j++){
	    if(i%2==0){
		printf("%d ",map[i][j]);
	    }else{
		printf(" %d",map[i][j]);
	    }
	}
	printf("\n");
    }
}
void dfs(int i,int j){
    if(i<0||i>=h||j<0||j>=w||map[i][j]==1||map[i][j]==2) return;
    map[i][j]=2;

    if(i%2==0){
	dfs(i-1,j-1); dfs(i-1,j);
	dfs(i,j-1); dfs(i,j+1);
	dfs(i+1,j-1); dfs(i+1,j);
    }else{
	dfs(i-1,j); dfs(i-1,j+1);
	dfs(i,j-1); dfs(i,j+1);
	dfs(i+1,j); dfs(i+1,j+1);
    }
}
	
int main(void){
    int i,j;
    int cnt=0;

    scanf("%d%d",&w,&h);
    h+=2;w+=2;
    for(i=0;i<h;i++){
	for(j=0;j<w;j++){
	    if(i==0||i==h-1||j==0||j==w-1){
		map[i][j]=0;
	    }else{
		scanf("%d",&map[i][j]);
	    }
	}
    }

    dfs(0,0);

    for(i=1;i<h-1;i++){
	for(j=1;j<w-1;j++){
	    if(map[i][j]==1 && i%2==0){
		if(map[i-1][j-1]==2) cnt++;
		if(map[i-1][j]==2) cnt++;
		if(map[i][j-1]==2) cnt++;
		if(map[i][j+1]==2) cnt++;
		if(map[i+1][j-1]==2) cnt++;
		if(map[i+1][j]==2) cnt++;
	    }
	    if(map[i][j]==1 && i%2==1){
		if(map[i-1][j]==2) cnt++;
		if(map[i-1][j+1]==2) cnt++;
		if(map[i][j-1]==2) cnt++;
		if(map[i][j+1]==2) cnt++;
		if(map[i+1][j]==2) cnt++;
		if(map[i+1][j+1]==2) cnt++;
	    }
	}
    }
    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 936
#include<cstdio>
int main(){
  int W, H, N;
  scanf("%d %d %d", &W, &H, &N);
  
  int x[N], y[N], a[N];
  for(int i=0; i<N; i++)
    scanf("%d %d %d", &x[i], &y[i], &a[i]);
  
  int k=H, l=0, m=W, n=0;
  for(int i=0; i<N; i++){
    if(a[i]==4){
      if(k>y[i])
        k = y[i];
    }
    else if(a[i]==3){
      if(l<y[i])
        l = y[i];
    }
    else if(a[i]==2){
      if(m>x[i])
        m = x[i];
    }  
    else{
      if(n<x[i])
        n = x[i];
    }
  }
  if(k>l && m>n)
    printf("%d", (k-l)*(m-n) );
  else
    printf("%d", 0);
  
  return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int n, k;
  cin >> n >> k;
  vector < int > a(n + 1);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  vector < int > factors;
  for (int i = 1; i <= sqrt(sum); i++) {
    if (sum % i == 0) {
      if (i * i != sum) factors.push_back(i);
      factors.push_back(sum / i);
    }
  }

  sort (factors.begin(), factors.end(), greater < int > ());
  for (auto g : factors) {
    vector < int > r;
    for (int i = 1; i <= n; i++) r.push_back(a[i] % g);
    sort (r.begin(), r.end());
    vector < int > lt (n, 0), rt(n, 0);
    lt[0] = r[0];
    for (int i = 1; i < n; i++) lt[i] = r[i] + lt[i - 1];
    rt[n - 1] = g - r[n - 1];
    for (int i = n - 2; i >= 0; i--) rt[i] = g - r[i] + rt[i + 1];
    bool ok = false;
    for (int i = 0; i < n - 1; i++) {
      if (lt[i] == rt[i + 1] && lt[i] <= k) ok = true;
    }
    if (ok) {
      cout << g << '\n';
      return 0;
    }
  }
  cout << 1 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int Age,A,B;
  cin >> Age;
  if(Age == 1)
  cout << "Hello World"<<endl;
  else if(Age == 2){
    cin >> A >> B;
    cout << A + B << endl;
  }
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,a[N];
int main()
{
    scanf("%d%d",&n,&m);
    int sum=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
    int ans=0;
    for(int i=1;i<=n;i++)
        if(a[i]*4*m>=sum) ans++;
    if(ans>=m) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
def main():
     n,k=map(int,input().split())
     a=list(map(int,input().split()))
     sum_a=sum(a)
     anskoho=[]
     for i in range(1,int(sum_a**0.5)+1):
          if sum_a%i==0:
               anskoho+=[i,sum_a//i]
     anskoho.sort(reverse=True)
     
     for i in anskoho:
          a_sub=[j%i for j in a]
          a_sub.sort()
          
          sum_L,sum_R=sum(a_sub),0
          sakai=n-1
          while sum_L!=sum_R:
               sum_L-=a_sub[sakai]
               sum_R+=i-a_sub[sakai]
               sakai-=1
          if sum_L<=k:
               print(i)
               break
if __name__ == '__main__':
     main()

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

int main() {
  string s;
  string t;
  cin >> s >> t;
  int correct = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) ++correct;
  }
  cout << correct << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from math import floor


def main():
    n, m, l = map(int, input().split())

    g = [[float("inf")] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        g[a][b] = c
        g[b][a] = c

    q = int(input())

    def f(x):
        return int(x) - 1

    st = (tuple(map(f, input().split())) for _ in range(q))

    g = csr_matrix(g)

    d = floyd_warshall(csgraph=g)

    refuel = [[float("inf")] * n for _ in range(n)]

    for i in range(n):
        for j in range(n):
            if d[i][j] <= l:
                refuel[i][j] = 1

    refuel = csr_matrix(refuel)

    ans = floyd_warshall(refuel)

    for s, t in st:
        print(int(ans[s][t] - 1) if ans[s][t] != float("inf") else -1)


if __name__ == "__main__":
    main()


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

int N;
int main(){
	while(cin >> N && N!=1){
		vector<int> ans;
		int n = N;
		for(int i=6;i<=N;i++){
			if(i%7==1 || i%7==6){
				if(N%i!=0) continue;
				bool judge = true;
				for(int j=6;j<i;j++){
					if((j%7==1 || j%7==6) && i%j==0){
						judge = false; break;
					}
				}
				if(judge){
					ans.push_back(i);
				}
			}
		}
		cout << N << ": ";
		for(int i=0;i<ans.size();i++) cout << ans[i] << (ans.size()-1!=i? " ":"\n");
	}
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N; vector<int> a;
void input()
{
    cin >> N;
    a.resize(N);
    for(int i=0; i<N; ++i) cin >> a[i];
}

void solve()
{
    ll ans = 0;
    for(int i=0; i<N; ++i){
        while(a[i]%2 == 0){
            a[i] /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3696
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int q,l,r,x[100005]={};
  bool f[100005]={};
  for(int i=2; i<=100000; i++) {
    if(!f[i]) {
      for(int j=i*2; j<=100000; j+=i) {
        f[j]=true;
      }
    }
  }
  for(int i=3; i<100000; i+=2) {
    if(!f[i]&&!f[(i+1)/2]) {
      x[i]=1;
    }
  }
  for(int i=3; i<=100000; i++) {
    x[i]+=x[i-1];
  }
  cin >> q;
  while(q--) {
    cin >> l >> r;
    cout << x[r]-x[l-1] << "\n";
  }
}

Measured memory_bytes: 1152
// “Incredible change happens in your life when you decide to take control of what
// you do have power over instead of craving control over what you don't.

// Dear online judge:
//  I've read the problem, and tried to solve it.
//  Even if you don't accept my solution, you should respect my effort.
//  I hope my code compiles and gets accepted.

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define input2d(arr, n, m) forn(i, 0, n) forn(j, 0, m) cin >> arr[i][j];
#define MOD 1000000007
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define tc    \
    ll T;     \
    cin >> T; \
    while (T--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

int32_t main()
{
    FAST;
    //tc
    {
        ll n;
        cin>> n;
        n %= 10;
        if(n==3)
            cout<<"bon\n";
        else if(n==0 or n==1 or n==6 or n==8)
            cout<<"pon\n";
        else
            cout<<"hon\n";
    }
    return 0;
}

Measured memory_bytes: 3600
N, M = map(int, input().split())
G = [[float('inf')] * N for i in range(N)]
for i in range(M):
    s, t, d = map(int, input().split())
    s, t = s - 1, t- 1
    G[s][t] = d

dp = [[float('inf')] * N for i in range(2 ** N)]
dp[1][0] = 0

for bs in range(2 ** N):
    for i in range(N):
        if not bs & (1 << i):
            continue
        for j in range(N):
            if bs & (1 << j):
                continue
            dp[bs | (1 << j)][j] = min(dp[bs | (1 << j)][j], dp[bs][i] + G[i][j])

ans = float('inf')
for i in range(N):
    ans = min(ans, dp[-1][i] + G[i][0])

print(ans if ans != float('inf') else - 1)



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    map<int, int> school;
    for (int i=0;i<n;i++)
    {
        int num;
        cin>>num;
        school.insert({num, i});
    }
    for (map<int, int>::iterator it=school.begin();it!=school.end();it++)
    {
        pair<int, int> h= *it;
        cout<<h.second+1<<" ";
    }
    return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int now=0,maxi=0,N;
string S;

int main(){
    cin>>N>>S;
    rep(i,N){
        if(S[i]=='I')now++;
        else now--;
        maxi=max(maxi,now);
    }
    out(maxi);

    
    
}


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

using namespace std;

const int N = 123;

int n, m;
char s[N];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    puts(s);
    puts(s);
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define vp(x,y) vector< pair<x,y> >
#define mp make_pair
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x));
#define DSort(x) sort(all(x), greater<>());
#define l_b lower_bound
#define u_b upper_bound
#define u_set unordered_set
#define u_map unordered_map
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)

const ll M=1e9+7;
const ld PI=3.14159265;
using namespace std;

void solve(){
	ll k,i,val=0;
	cin>>k;
	for(i=1;i<=1e7;i++){
		val=(val*10+7)%k;
		if(val==0){
			cout<<i; 
			return;
		}
	}
	cout<<"-1";
}

int main(){
    fast_io;
    ll t=1;
    while(t--){
		solve();
    }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	print1(ceiling(c,b)>ceiling(a,d)?"No":"Yes");
	return 0;
}

Measured memory_bytes: 3604
X=int(input())
if 400<=X<=599:
    print(8)
elif 600<=X<=799:
    print(7)
elif 800<=X<=999:
    print(6)
elif 1000<=X<=1199:
    print(5)
elif 1200<=X<=1399:
    print(4)
elif 1400<=X<=1599:
    print(3)
elif 1600<=X<=1799:
    print(2)
elif 1800<=X<=1999:
    print(1)

Measured memory_bytes: 9104
# B
# Balance

N = int(input())
W = [int(x) for x in input().split(" ")]

#print(N)
#print(W)

diff = []

import numpy as np

for T in range(N):

    S1 = np.sum(W[:T])
    S2 = np.sum(W)-S1
    diff.append(int(np.abs(S1-S2)))

print(np.min(diff))

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

typedef long long ll;

const int MAX = 1e5 + 5;

vector<int> adj[MAX];
bool visited[MAX];
int cnt = 0;

void dfs(int s, vector<int>& _H) {
    if (visited[s]) return;
    visited[s] = true;
    bool good = true;
    for (auto u : adj[s]) {
        if (_H[s] <= _H[u]) {
            good = false;
        }
        dfs(u, _H);
    }
    if (good) {
        cnt++;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int N, M;
    cin >> N >> M;
    vector<int> H(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
    }
    for (int j = 0; j < M; j++) {
        int A, B;
        cin >> A >> B;
        adj[A].push_back(B);
        adj[B].push_back(A);
    }
    for (int i = 1; i <= N; i++) {
        if (!visited[i]) {
            dfs(i, H);
        }
    }
    cout << cnt;
}


Measured memory_bytes: 10516
/*
Date&Time: 5:35pm 3/9/2020 
Context: ZR3月省选集训
if (sum[x] >= 2 * max[x]) {
	f[x] = sum[x] / 2;
}
else {
	int u = mp[x];
	sum[x] - max[x] + max(0 \leq k \leq f[u], 2 * k \leq 2 * max[u] - sum[u]);
}
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2000 + 10;
char ch[N];
int mx[N], sum[N], f[N], ver[N * 2], head[N], nex[N * 2], tot, mp[N], ans;//mistake: nex[N]
int n, dist, cnt[N];
inline void add(int x, int y) {
	ver[++tot] = y;
	nex[tot] = head[x];
	head[x] = tot;
}
void dfs(int x, int fa) {
	
	for (int i = head[x]; i; i = nex[i]) {
		int y = ver[i];
		if (y == fa) continue;
		dfs(y, x);
		cnt[x] += cnt[y];
		sum[x] += sum[y] + cnt[y];
		if (sum[y] + cnt[y] > mx[x]) { 
			mp[x] = y;
			mx[x] = sum[y] + cnt[y];
		}
		/*
		mistake:
		if (sum[y] > mx[x]) {
			mp[x] = y;
			mx[x] = sum[y];
		}
		*/
	
	}
	if (ch[x] == '1') {
		cnt[x]++;
	}
	if (head[x] == 0) return;

	if (sum[x] - mx[x] >= mx[x]) {

		f[x] = sum[x] / 2;
	}
	else {
		int u = mp[x];
		f[x] = sum[x] - mx[x] + min(f[u], (2 * mx[x] - sum[x]) / 2);
	}
	// cout << "dfs::x " << x << endl;
}

inline void solve(int x) {
	memset(mx, 0, sizeof(mx));
	memset(sum, 0, sizeof(sum));
	memset(cnt, 0, sizeof(cnt));
	dist = 0;
	dfs(x, 0);

	if (sum[x] % 2) return;
	if (f[x] == sum[x] / 2) {
		ans = min(f[x], ans);
	}
}
signed main() {
	ans = 1e9 + 7;
	ios::sync_with_stdio(0);
	cin >> n;
	cin >> ch + 1;
	for (int i = 1, u, v; i <= n - 1; i++) {
		cin >> u >> v;
		add(u, v);
		add(v, u);
	}
	for (int i = 1; i <= n; i++) {
		solve(i);
	}
	if (ans == 1e9 + 7) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

/*
Date&Time: 7:53pm 3/9/2020
statu: AC
*/

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const long long mod=1000000007;
const int maxn=200005;
ll inv[maxn],s[maxn];
int N,n,m,x,y;
ll Pow(ll a,int b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll C(int a,int b)
{
	if(a<0||b<0)
		return 1;
	return s[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
    scanf("%d%d",&x,&y);
    N=n+m-2;
    s[0]=1;
    for(int i=1;i<=N;i++)
    	s[i]=s[i-1]*i%mod;
    inv[0]=1;
    inv[N]=Pow(s[N],mod-2);
    for(int i=N-1;i>0;i--)
    	inv[i]=inv[i+1]*(i+1)%mod;
    ll ans=0;
    for(int i=y+1;i<=m;i++)
    {
    	ans+=C(n-x+i-2,i-1)*C(x+m-i-1,x-1)%mod;
    	ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){

    int n,X[100] = {0},Y[100] = {0};
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> X[i];
    }

    for (int i = 0; i < n; i++){
        cin >> Y[i];
    }

    double D[4] = {0.0};

    for (int i = 1; i <= 3; i++){//p=1,2,3のときの距離
        for (int j = 0; j < n; j++){
            D[i] += pow(fabs(X[j] - Y[j]), i);
        }

        D[i] = pow(D[i], 1.0 / i);
    }



    for (int i = 0; i < n; i++){//p=∞のときの距離
        if(D[0] < fabs(X[i] - Y[i])){
            D[0] = fabs(X[i] - Y[i]);
        }
    }

    printf("%.6lf\n",D[1]);
    printf("%.6lf\n",D[2]);
    printf("%.6lf\n",D[3]);
    printf("%.6lf\n",D[0]);

    return 0;

}


Measured memory_bytes: 3316
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);
vi v;
void sieve() {
    vector<bool> isPrime(mxN + 1, true);
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i <= mxN; ++i) {
        if (isPrime[i]) {
            v.pb(i);
            for (int j = i * 2; j <= mxN; j += i)
                isPrime[j] = 0;
        }
    }
}
void solve(){
    //13
    string s;
    cin>>s;
    set<char>st(allv(s));
    cout<<(sz(st)==sz(s)?"yes":"no")<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3600
#coding:utf-8
N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*b*g

for i in range(N-2):
	for d in range(N):
		j=i+d
		k=j+d
		if k>N-1:
			break
		elif S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
			ans-=1
print(ans)

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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 3006
#define mod 1000000007
#define mod2 998244353
#define inf 1e18

int dp[N][N][2];
int n;
int a[N];

int solve(int i,int j,int f)
{
    if(i>j)
        return 0;
    int &ans=dp[i][j][f];

    if(ans!=-1)
        return ans;

    int tmp;

    if(f==0)
    {
        tmp=max(a[i]+solve(i+1,j,1),a[j]+solve(i,j-1,1));
    }
    else
    {
        tmp=min(-a[i]+solve(i+1,j,0),-a[j]+solve(i,j-1,0));
    }
    ans=tmp;

    return ans;
}

int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif

  
    cin >> n;
    int i;
   
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }

    memset(dp,-1,sizeof dp);

    int ans=solve(1,n,0);

    cout << ans;




}

Measured memory_bytes: 141568
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var b = {};
  var a = o.l();
  for(var i = 0; i < n; i++){
    if(b[a[i]])b[a[i]]++;
    else b[a[i]] = 1;
  }
  if(b[0] === n)return "Yes";
  if(n%3)return "No";
  var f = 1;
  var x = 0;
  for(var i in b){
    if(b[i] !== n/3){f = 0;break;}
    x ^= i;
  }
  if(f && x === 0)return "Yes";
  var f = 0;
  for(var i in b){
    if(b[i] === n/3 && i == 0)f++;
    if(b[i] === n*2/3)f++;
  }
  return f===2?"Yes":"No";
}

Measured memory_bytes: 37776
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a[101][101],f,x,y;
int main(){
  cin>>n>>m;
  r(i,n)r(j,n)a[i][j]=1e8;
  r(j,m){
    cin>>x>>y;
    a[x][y]=-1;
  }
  r(k,n)r(i,n)r(j,n)a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
  r(i,n)if(a[i][i]<0)f++;
  cout<<(f?1:0)<<endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;







ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}


int n;
int a[maxn];

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

    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);


    cin>>n;
    set<int> s;
    int x=-1;
    for (int i=0; i<n+1; i++) {
	cin>>a[i];
	if (s.count(a[i])) {
	    x=a[i];
	}
	s.insert(a[i]);
    }
    assert(x!=-1);
    int l=-1,r=-1;
    for (int i=0; i<n+1; i++) {
	if (x==a[i]) {
	    if (l==-1) {
		l=i;
	    } else {
		r=i;
	    }
	}
    }

    assert(l!=-1 && r!=-1 && l<r);

    for (int k=1; k<=n+1; k++) {

	if (k==1) {
	    cout<<n<<"\n";
	    continue;
	}


	int left = l;
	int right = n+1-r-1;

	ll ans = nck(n+1,k) - nck(left+right,k-1);
	ans %= mod;
	ans += mod;
	ans %= mod;
	cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 31616
n = int(input())
s = input()

# 0番目、1番目を決め打つ（４通り）ことで、連鎖的に次の種類を決めることができる
# 1番の証言通りに2番を決める, ..., N-1番目の証言通りに0番目を決める
# 最初に決めた0番目の種類と、最終的に導かれた0番目の種類が異なる場合、実現不可能
# 実現が可能な場合、0番目の証言が未検証なので検証する必要がある

# True:=羊, False:=狼　とする
# True/Falseで書くことで、not演算子での反転が使えて少し楽になる
for ptn in [[True, True], [True, False], [False, True], [False, False]]:
    # 1,2,...N-1番目の証言から2,3,...,N-1,0番目の種類を決める
    for i in range(1, n):
        if ptn[i] == True and s[i] == "o":
            ptn.append(ptn[i - 1])
        elif ptn[i] == True and s[i] == "x":
            ptn.append(not ptn[i - 1])
        elif ptn[i] == False and s[i] == "o":
            ptn.append(not ptn[i - 1])
        elif ptn[i] == False and s[i] == "x":
            ptn.append(ptn[i - 1])

    # 最初に決めた0番目の種類と、最終的に導かれた0番目の種類が等しい場合
    # 0番目の証言を検証する
    if ptn[0] == ptn[-1]:
        # 0番目に相当するものが重複しているので末尾の方を除いておく
        ptn.pop(-1)
        flag = False

        if ptn[0] == True and s[0] == "o":
            if ptn[-1] == ptn[1]:
                flag = True
        if ptn[0] == True and s[0] == "x":
            if ptn[-1] != ptn[1]:
                flag = True
        if ptn[0] == False and s[0] == "o":
            if ptn[-1] != ptn[1]:
                flag = True
        if ptn[0] == False and s[0] == "x":
            if ptn[-1] == ptn[1]:
                flag = True

        # 検証の結果、0番目の証言が矛盾しなかった場合、実現可能
        if flag == True:
            ans = []
            for i in range(n):
                if ptn[i] == True:
                    ans.append("S")
                elif ptn[i] == False:
                    ans.append("W")

            print("".join(ans))
            exit()

# 矛盾しないものが見つからなかった場合
print(-1)


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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    rep(i, N) A[i] -= (i + 1);

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

    ll ans = 0;
    ll middle;
    if (N % 2 == 1)
        middle = A[N / 2];
    else
        middle = (A[N / 2] + A[N / 2 - 1]) / 2;
    rep(i, N) ans += abs(A[i] - middle);

    cout << ans << endl;
}

Measured memory_bytes: 4836
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#define mod 1000000007
#define int long long int
void subset(int arr[],vector<int> &v,int initial,int final,int mat[15][15],int n,int m,int x)
{
	if(initial>final)
	{
		int count[m+1]={0};
		int here=0;
		int j;
		if(v.size()!=0)
		{
			for(int p:v)
			{
				here+=arr[p];
				for(j=1;j<=m;j++)
				{
					count[j]+=mat[p][j];
				}
				
			}
		}
		bool result=true;
		for(j=1;j<=m;j++)
		{
			if(count[j]<x)
			{
				result=false;
				break;
			}
		}
		if(result)
		{
			//answer=min(answer,here);
		}
	}
	else
	{
		v.push_back(initial);
		subset(arr,v,initial+1,final,mat,n,m,x);
		v.pop_back();
		subset(arr,v,initial+1,final,mat,n,m,x);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int answer=0;
	if(a>=k)
	{
		cout<<k<<endl;
		exit(0);
	}
	else
	{
		answer=a;
		k=k-a;
		if(b>=k)
		{
			cout<<answer<<endl;
			exit(0);
		}
		else
		{
			k=k-b;
		}
		answer=answer-min(k,c);
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 3612
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	while (N--) {
		int Ai; cin >> Ai;
		if (Ai % 2 == 0 && Ai % 3 != 0 && Ai % 5 != 0) {
			cout << "DENIED" << endl;
			goto FIN;
		}
	}
	cout << "APPROVED" << endl;
FIN:;
	return 0;
}

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

int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
  }
  
  string result = h > sum ? "No" : "Yes";
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
val = []
skip = []
for i in range(0,n+1):
    val.append(abs(a[i+1] - a[i]))
for i in range(0,n):
    skip.append(abs(a[i+2] - a[i]))
sv = sum(val)
for i in range(n):
    print(sv +skip[i] -val[i] -val[i+1])

Measured memory_bytes: 21040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()


int main()
{
	int N;
	ll tksum = 0, aosum = 0;
	cin >> N;
	vector<pair<ll,pair<ll, ll>>> ryori(N);
	REP(i, N){
		ll A, B, sum;
		cin >> A >> B;
		sum = (A + B);
		ryori[i] = make_pair(-sum, make_pair(A, B));
	}
	sort(ALL(ryori));
	REP(i, N){
		if(i%2 == 0){
			tksum += ryori[i].second.first;
		}else{
			aosum += ryori[i].second.second;
		}
	}
	cout << tksum - aosum << "\n";
	
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int K;
  cin >> K;
  
  queue <long> q;
  for (int i = 1; i <= 9; ++i) {
    q.push(i);
  }
  
  int cnt = 0;
  long ans;
  while (cnt < K) {
    ans = q.front();
    cnt++;
    q.pop();
    
    for (int i = max(0L, ans % 10 - 1);
         i <= min(9L, ans % 10 + 1);
         ++i) {
      q.push(ans * 10 + i);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4612
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n, i=0;
  scanf("%d", &n);
  double a, b, ans;
  ans = 0;
  char s[4];
  do{
    scanf("%lf %s", &a, s);
    if(s[0]=='B'){
      a *= 380000.0;
    }
    ans += a;
    a = 0;
    i++;
  }while(i<n);
  printf("%lf\n", ans);
}


Measured memory_bytes: 384