akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())

    count = 0
    found = {}
    for _ in range(n):
        str = ''.join(sorted(input()))
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 17852
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;

int n, e[101], ans;

int num(int x) {
    int ret = 0;
    rep(i, n+1) {
        if (e[i] >= x - 1) ret++;
    }
    return ret;
}

int main() {
    cin >> n;
    REP(i, 1, n + 1) {
        int cur = i;
        REP(j, 2, i + 1) {
            while (cur % j == 0) {
                e[j]++;
                cur /= j;
            }
        }
    }

    cout << num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) 
        + num(5) * (num(5) - 1) / 2 * (num(3) - 2) << endl;
        
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
      if i ==(n-1):
         break
      if (a[i]+1) == a[i+1]: #a[i]は項数
         b[a[i]-1] += c[a[i]-1]
print(sum(b))

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

int num =0;
void rec(vector<int> h_div){
    int min = *min_element(h_div.begin(), h_div.end());
    num +=min;
    vector<int> new_h_div;
    for(int i=0;i<h_div.size();i++){
        h_div[i]-=min;
        if(h_div[i]!=0){
            new_h_div.push_back(h_div[i]);
            if(i==h_div.size()-1)rec(new_h_div);
        }
        else{
            if(!new_h_div.empty()){
                rec(new_h_div);
                new_h_div.clear();
            }
        }
    }
    return;
}


int main(int argc, char const *argv[])
{
    int n;cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    rec(h);
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    //a[0]書き換える
    ll x = a[1];
    ll ans = 1;
    for(ll i=1;i*i<=x;i++){
        bool f  =true;
        if(x%i==0){
            for(ll j=2;j<n;j++){
                if(a[j]%i!=0){
                    f=false;
                    break;
                }
            }
            if(f){
                ans=max(ans,i);
            }
            ll y = x/i;
            f=true;
            for(ll j=2;j<n;j++){
                if(a[j]%y!=0){
                    f=false;
                    break;
                }
            }
            if(f){
                ans=max(ans,y);
            }
        }
    }
    //a[0]を書き換えない
    x = a[0];
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            int c=0;
            bool f=true;
            for(ll j=1;j<n;j++){
                if(a[j]%i!=0){
                    c++;
                    if(c>1){
                        f=false;
                        break;
                    }
                }
            }
             if(f){
                ans=max(ans,i);
            }
            c=0;
            f=true;
            ll y = a[0]/i;
             for(ll j=1;j<n;j++){
                if(a[j]%y!=0){
                    c++;
                    if(c>1){
                        f=false;
                        break;
                    }
                }
            }
             if(f){
                ans=max(ans,y);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N,ans=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a.at(i);
  for(int i=0;i<N;i++) if(i%2==0 && a.at(i)%2==1) ans++;
  cout<<ans;
  return 0;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,ans=0;
    cin >> n >> m;
    vector<int> x(m),y(m);
    rep(i,m) cin >> x[i] >> y[i];
    vector<int> a(n+1,1);
    vector<bool> b(n+1,false);
    b[1]=true;
    rep(i,m){
        if(b[x[i]]){
            b[y[i]]=true;
        }
        --a[x[i]];
        ++a[y[i]];
        if(a[x[i]]==0){
            b[x[i]]=false;
        }
    }
    for(int i=1;i<=n;++i){
        if(b[i]) ++ans;
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,k,ans=pow(10,9);
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
    }

    for(int i=0;i+k-1 < n;i++)
    {
        if(v.at(i)<0 && v.at(i+k-1)>=0){
            ans = min(ans,2*min(-v.at(i),v.at(i+k-1))+max(-v.at(i),v.at(i+k-1)));
        }else if(v.at(i+k-1)<0){
            ans = min(ans,-v.at(i));
        }else{
            ans = min(ans,v.at(i+k-1));
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 640
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
c,d,e,x,num = [0]*40,[0]*40,[0],[],0
def f(num,c):
    for j in range(40,-1,-1):
        if num>=2**j:
            c[j]+=1
            num-=2**j
for i in a: f(i,c)
f(k+1,d)
for i in range(40):
    if c[i]<=n//2: e.append(e[-1]+2**i)
    else: e.append(e[-1])
for i in range(39,-1,-1):
    if d[i]:
        m,m2,d2 = e[i]+num,0,[0]*40
        f(m,d2)
        for j in range(40): m2+=(2**j)*abs(n*d2[j]-c[j])
        x.append(m2)
        num+=2**i
if x: print(max(x))
else: print(sum(a))

Measured memory_bytes: 14620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            if (x.charAt(0) == x.charAt(1) || x.charAt(1) == x.charAt(2) || x.charAt(2) == x.charAt(3)) {
                out.println("Bad");
            } else {
                out.println("Good");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main(){
    int n; cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = 1;
    rep(i,n){
        ans = LCM(ans, t[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[ ,\n]+");
		double S = 0.0;
		double x0 = sc.nextDouble(), y0 = sc.nextDouble();
		double xp = sc.nextDouble(), yp = sc.nextDouble();
		while (sc.hasNext())
		{
			double x = sc.nextDouble(), y = sc.nextDouble();
			double a = d(x0,y0,xp,yp),
				   b = d(xp,yp,x,y),
				   c = d(x,y,x0,y0);
			double z = (a + b + c) / 2.0;
			S += Math.sqrt(z * (z - a) * (z - b) * (z - c));
			
			xp = x;
			yp = y;
		}
		System.out.println(S);
	}
	private static double d(double xa, double ya, double xb, double yb)
	{
		return Math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

long long f(long long a, long long b) {
    long long digit_a = 0, digit_b = 0;
    while (a > 0) {
        digit_a++;
        a /= 10;
    }
    while (b > 0) {
        digit_b++;
        b /= 10;
    }
    return max(digit_a, digit_b);
}

int main()
{
    long long N;
    cin >> N;

    long long ans = INT_MAX;
    for (long long A = 1; A * A <= N; A++) {
        if (N % A != 0)
            continue;

        long long B = N / A;
        ans = min(ans, f(A, B));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  values = []
  total = 0

  for _ in range(int(input())):
    s = input().strip()
    open_required = len(s)
    close_required = len(s)
    open_close = 0

    for i, c in enumerate(s):
      if c == '(':
        open_required = min(i, open_required)
        open_close += 1
      else:
        close_required = min(len(s) - i - 1, close_required)
        open_close -= 1

    total += open_close
    values.append([open_required, close_required, open_close, 0])

  if total != 0:
    print('No')
    return

  if len(values) > 500000:
    print('Yes')
    return

  fvals = values.copy()
  bvals = values

  fvals.sort(key=lambda x: (x[0], -x[2]))
  bvals.sort(key=lambda x: (x[1], x[2]))

  findex = 0
  bindex = 0

  while True:
    while findex < len(fvals) and fvals[findex][3] != 0:
      findex += 1

    while bindex < len(bvals) and bvals[bindex][3] != 0:
      bindex += 1

    if findex >= len(fvals) and bindex >= len(bvals):
      break

    fvals[findex][3] = 1
    bvals[bindex][3] = -1

  values = [v for v in fvals if v[3] == 1] + [v for v in bvals if v[3] == -1][::-1]

  open_close_f = 0
  open_close_b = 0

  for (oreq_f, _, ocval_f, _), (_, creq_b, ocval_b, _) in zip(values, values[::-1]):
    if oreq_f > open_close_f:
      print('No')
      return

    if creq_b > open_close_b:
      print('No')
      return

    open_close_f += ocval_f
    open_close_b -= ocval_b

  print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 208140
#include <stdio.h>

int main(){
    char m[80];
    int x;

    scanf("%d", &x);
    scanf("%s", m);

    if(x >= 3200){
        printf("%s\n", m);
    }
    else if(x < 3200){
        printf("red\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("bhar.txt", "w", stdout);
    #endif
    long long q(1);//cin>>q;
    while(q--){
       long long n,m,k,tot(0),p(0);
       string s,l;
       bool ok(0),okk(0);
       cin>>n;
       for(int i=0;i<n;i++){
       	cin>>m>>k;
       	if(m==k){
       		p++;
       	}
       	else p=0;
       	if(p==3){ok=1;}
       }
       if(ok) cout<<"Yes";
       else cout<<"No";
    }
}

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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,m;
char s1[200010],s2[200010];
int main()
{
	cin >> n >> m;
	scanf("%s%s",s1,s2);
	int x=__gcd(n,m);
	int a=n/x,b=m/x;
	for(int i=0;i<x;i++)
		if(s1[i*a]!=s2[i*b])
		{
			cout << -1 << endl;
			exit(0);
		}
	cout << 1ll*n*m/x << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    long long N, K;
    cin >> N >> K;
    vector<long long> vec(N);
    for (int i = 0; i < N; ++i)
        cin >> vec[i];
    sort(vec.begin(), vec.end(), greater<int>());
    for (int i = 0; i < K; ++i)
    {
        if (i >= N)
            break;
        vec[i] = 0;
    }
    long long tmp = 0;
    for (auto i : vec)
        tmp += i;
    cout << tmp << "\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  ll ans=0;
  rep(i,N){
    ll tmp=i+1;
    ll num=N/tmp;
    ans+=tmp*num*(num+1)/2;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 500500;
int n;
char s[N];
ll a[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
		if (s[i] == '<')
			a[i + 1] = max(a[i + 1], a[i] + 1);
	for (int i = n - 1; i >= 0; i--)
		if (s[i] == '>')
			a[i] = max(a[i], a[i + 1] + 1);
	ll ans = 0;
	for (int i = 0; i <= n; i++)
		ans += a[i];
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = Integer.valueOf(sc.nextLine());
			int[] bars = new int[n];

			if (n < 3) {
				System.out.println("0");
				return;
			}

			for (int i = 0; i < n; i++) {
				bars[i] = sc.nextInt();
			}

			if (bars.length != n) {
				System.out.println("OUT");
			}
			int ans = 0;
			for (int frist = 0; frist < n; frist++) {
				int a = bars[frist];

				for (int second = frist + 1; second < n; second++) {
					int b = bars[second];

					for (int third = second + 1; third < n; third++) {
						int c = bars[third];
						if (a ==b || b == c || a == c) {
							continue;
						} else if (isATriangle(a, b, c) && isATriangle(b, c, a) && isATriangle(c, a, b)) {
							ans++;
						}
					}
				}
			}

			System.out.println(ans);


		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	private static boolean isATriangle(int x, int y, int z) {
		return ((x + y ) > z);

	}
}


Measured memory_bytes: 36504
#include <bits/stdc++.h>
using namespace std;
int n,m,X,Y;
int main(){
  cin >> n >> m >> X >> Y;
  vector<int> x(n+1);
  vector<int> y(m+1);
  for(int i = 0;i < n;i++) cin >> x[i];
  for(int i = 0;i < m;i++) cin >> y[i];
  x[n] = X;
  y[m] = Y;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x[n] < y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{ 
  int a, b;
  scanf("%d %d", &a, &b);
  
  if (a < b) {
    printf("a < b\n");
  } else if (a == b) {
    printf("a == b\n");
  } else {
    printf("a > b\n");
  } 
  
  return 0;
} 

Measured memory_bytes: 580
import java.util.*;

class Problem {
  long n;
  long a = 0;
  long b = 0;
  final long START_DISTANCE_FROM_ORIGIN = 2;

  public Problem(long n) {
    this.n = n;
  }

  public void solve() {
    for (long i = 1; i * i <= n; i++) if (n % i == 0) update(i);
  }

  private void update(long i) {
    a = i;
    b = n / i;
  }

  public void show() {
    System.out.println(a + b - START_DISTANCE_FROM_ORIGIN);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();

    Problem p = new Problem(n);
    p.solve();
    p.show();
  }
}

Measured memory_bytes: 36012
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int n = 8;
int a[n][n];

bool isin(int i, int j){
	return i >= 0 && j >= 0 && i < n && j < n;
}

int put(int i, int j, int x, VVI &d){
	if (a[i][j] > 0) return 0;
	int y;
	if (x == 1) y = 2;
	else y = 1;
	int dx[] = {1,1,1,0,0,-1,-1,-1}, dy[] = {1,0,-1,1,-1,1,0,-1};
	int res = 1;
	d[i][j] = 1;
	REP(k,8){
		int ii = i + dx[k], jj = j + dy[k];
		while (isin(ii,jj) && a[ii][jj] == y){
			ii += dx[k];
			jj += dy[k];
		}
		if (isin(ii,jj) && a[ii][jj] == x){
			for (int iii = i + dx[k], jjj = j + dy[k]; iii != ii || jjj != jj; iii += dx[k], jjj += dy[k]){
				d[iii][jjj] = 1;
				res++;
			}
		}
	}
	return res;
}

int main(){
	REP(i,n){
		string s;
		cin >> s;
		REP(j,n){
			if (s[j] == 'o') a[i][j] = 1;
			if (s[j] == 'x') a[i][j] = 2;
		}
	}
	bool p1 = false, p2 = false;
	int turn = 1;
	while (!p1 || !p2){
		int m = 0;
		VVI c(n,VI(n));
		if (turn == 1){
			REP(i,n) REP(j,n){
				VVI d(n,VI(n));
				int x = put(i,j,turn,d);
				if (x > m){
					m = x;
					c = d;
				}
			}
			if (m <= 1){
				p1 = true;
			}else{
				p1 = false;
				REP(i,n) REP(j,n) if (c[i][j]) a[i][j] = 1;
			}
		}else{
			REP(i,n) REP(j,n){
				VVI d(n,VI(n));
				int x = put(i,j,turn,d);
				if (x >= m){
					m = x;
					c = d;
				}
			}
			if (m <= 1){
				p2 = true;
			}else{
				p2 = false;
				REP(i,n) REP(j,n) if (c[i][j]) a[i][j] = 2;
			}
		}
		turn = ((turn-1) ^ 1) + 1;

	}

	string cake = ".ox";
	REP(i,n){
		REP(j,n){
			cout << cake[a[i][j]];
		}
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	for (ll i = 1; i*i <= M; i++) {
		if (M%i == 0) {
			if (N*i <= M) {
				ans = max(ans, i);
			}
			ll d = M / i;
			if (N*d <= M) {
				ans = max(ans, d);
			}
		}
	}
	cout << ans << endl;
}

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

const int MAX_N = 100000;

int main() {
  int n, x, a[2];
  long long ans = 0;
  cin >> n >> x >> a[0];
  for (int i=1; i<n; i++) {
    int j = i % 2;
    cin >> a[j];
    int sum = a[0] + a[1], e = sum - x;
    if (e > 0) {
      ans += e;
      if (a[j] > e) {
        a[j] -= e;
      } else {
        a[j] = 0;
      }
    }
  }

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


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

void solve(std::string a, std::string b) {
  if (a == "H") {
      cout << b << endl;
  } else {
    if (b == "H") {
	cout << "D" << endl;
    } else {
	cout << "H" << endl;
    }
  }
}

int main() {

  std::string a;
  std::cin >> a;
  std::string b;
  std::cin >> b;
  solve(a, b);
  return 0;
}


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

const int N = 3e5 + 10;
int n, x[N], ind[N];
vector<pair<int, int> > v;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x[i];
		v.push_back({x[i], i});
	}	
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++)
		ind[v[i].second] = i;
		
	int m = (n + 1) / 2;
	m--;
	//cout << m << endl;
	
	for (int i = 0; i < n; i++){
		if(ind[i] <= m)
			cout << v[m + 1].first << ' ';
		else
			cout << v[m].first << ' ';
	}
}


Measured memory_bytes: 5488
#include <iostream>
using namespace std;
int main () {
  int n, k;
  cin >> n >> k;
 int ans = 0;
  for (int i = 0 ; i < n ; ++ i) {
    int a;
    cin >> a;
    if (a >= k)
      ++ans;
  }
  cout << ans;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {

            var hw = Input3();
            if (hw[0] == 1 || hw[1] == 1) Console.WriteLine(1);
            else Console.WriteLine((hw[0] * hw[1] + 1) / 2);
            /* var abc = Input3();

             var a = Math.Sqrt(abc[0]);
             var b = Math.Sqrt(abc[1]);
             var c = Math.Sqrt(abc[2]);

             if (a + b < c) Console.WriteLine("Yes");
             else Console.WriteLine("No");*/




        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public ulong[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            ulong[] res = new ulong[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = ulong.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 13140
n, m = map(int, input().split())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key=lambda x:x[0])
ans = 0
cou = 0
num = 0
while cou < m:
    nu = min(lis[num][1], m - cou)
    cou += nu
    ans += lis[num][0] * nu
    num += 1
print(ans)

Measured memory_bytes: 29028
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
 */
import java.util.*;
import java.util.Arrays;

public class Main {
	
	boolean binSearch(int[] s, int x, int a, int b) {
		int left = 0;
		int right = s.length;
		while (left < right) {
			int mid = (left + right) / 2;
			if (s[mid] == x) return true;
			else if (s[mid] > x) right = mid;
			else left = mid + 1;
		}
		return false;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(s);
		
		int cnt = 0;
		for (int i = 0; i < q; i++) {
			if (binSearch(s, t[i], 0, s.length - 1)) cnt++;
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 68180
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(1LL << n);
    rep(i, 1LL << n){
        cin >> a[i];
    }
    vector<ll> dp(1LL << n);
    dp[0] = 0;
    vector<Pll> v(1LL << n, Pll(0,0));
    rep(mask,1LL << n){
        for(int t = mask; ; t = ((t-1) & mask)){
            // debug(mask, t);
            if(v[mask].second < a[t])v[mask].second = a[t];
            if(v[mask].first < v[mask].second) swap(v[mask].first, v[mask].second);
            if(t == 0)break;
        }
    }
    

    reps(i, (1LL << n) - 1){
        chmax(dp[i], max(dp[i-1], v[i].first + v[i].second));
    }

    reps(i, (1LL << n) - 1){
        cout << dp[i] << endl;
    }
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 101010;
int n; ll a, b;
VL h(N);
bool cheak(ll x) {
	ll cnt = 0;
	ll diff = a - b;
	rep(i, n) {
		ll rem = h[i] - b * x;
		cnt += max(0LL, (rem + diff - 1) / diff);
	}
	return cnt <= x;
}
int main() {
	cin >> n >> a >> b;
	rep(i, n) {
		cin >> h[i];
	}
	sort(all(h), greater<ll>());
	ll ng = 0, ok = 1e9 + 1;
	while (ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		if (cheak(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string.h>
using namespace std;
#define Nmax 20000

int main()
{
	int a[Nmax] = { 0 }, b[Nmax] = { 0 };
	char op[Nmax][2] = { 0 };
	int n = 0;

	for (int i = 0; i < Nmax; i++) {
		n = i;
		cin >> a[i] >> op[i] >> b[i];
		if (strcmp(op[i],"?") == 0) {
			break;
		}
	}

	for (int i = 0; i < n; i++) {
		int res = 0;
		if (strcmp(op[i], "+") == 0) {
			res = a[i] + b[i];
		}
		else if (strcmp(op[i], "-") == 0) {
			res = a[i] - b[i];
		}
		else if (strcmp(op[i], "*") == 0) {
			res = a[i] * b[i];
		}
		else if (strcmp(op[i], "/") == 0) {
			res = a[i] / b[i];
		}
		cout << res << endl;
	}

	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int x,y;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>x >>y;
    int s = x*2, z = 1;
    while (s < y && s <= x*4 && z <= x) {
        s += 2;
        z++;
    }
    if (s == y)
        cout <<"Yes";
    else
        cout <<"No";


    return 0;
}


Measured memory_bytes: 3632
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    int t=1;
    //cin>>t;
    while(t--){
        read(n);
        int ans=0;
        multiset <int> s;
        fr(i,n){
            read(x);
            s.insert(x);
        }
        int steps=0;
        for(auto it=s.begin();it!=s.end();++it){
            int k=*it;
            bool found=0;
            if(k>1){
            for(int i=1;i*i<=k;++i){
                if(k%i==0){
                    if((s.find(k/i)!=s.end() && i!=1) || s.find(i)!=s.end()){found=1;break;}
                }
            }
            }
            if(steps){
                --it;
                if(*it==k) found=1;
                ++it;
            }
            if(steps<n-1){
                ++it;
                if(*it==k) found=1;
                --it;
            }
            if(!found) ans++;
            steps++;
        }
        cout << ans;
    }
    return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<int> count(N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  bool flg = true;
  int current = 0;
  int answer = 0;

  while (flg) {
    int v_ = a[current] - 1;
    if (count[v_] == 0) {
      answer++;
      count[current]++;
      current = v_;
      if (v_ == 1){
        flg = false;
      }
    } else {
      flg = false;
      answer = -1;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 1024
INF = 10**9

class RmQ:
    def __init__(self, a):
        self.n = len(a)
        self.size = 2**(self.n - 1).bit_length()
        self.data_min = [INF] * (2*self.size-1)
        self.initialize(a)

    # Initialize data
    def initialize(self, a):
        for i in range(self.n):
            self.data_min[self.size + i - 1] = a[i]
        for i in range(self.size-2, -1, -1):
            self.data_min[i] = min(self.data_min[i*2 + 1], self.data_min[i*2 + 2])

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data_min[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data_min[k] = min(self.data_min[2*k+1], self.data_min[2*k+2])

    # Min value in [l, r)
    def query(self, l, r):
        L = l + self.size; R = r + self.size
        s = INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data_min[R-1])
            if L & 1:
                s = min(s, self.data_min[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

class RMQ:
    def __init__(self, a):
        self.n = len(a)
        self.size = 2**(self.n - 1).bit_length()
        self.data_max = [-INF] * (2*self.size-1)
        self.initialize(a)

    # Initialize data_min
    def initialize(self, a):
        for i in range(self.n):
            self.data_max[self.size + i - 1] = a[i]
        for i in range(self.size-2, -1, -1):
            self.data_max[i] = max(self.data_max[i*2 + 1], self.data_max[i*2 + 2])

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data_max[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data_max[k] = max(self.data_max[2*k+1], self.data_max[2*k+2])

    # Max value in [l, r)
    def query(self, l, r):
        L = l + self.size; R = r + self.size
        s = -INF 
        while L < R:
            if R & 1:
                R -= 1
                s = max(s, self.data_max[R-1])
            if L & 1:
                s = max(s, self.data_max[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

n = int(input())
a = [int(item) for item in input().split()]
indexes = [0] * n
for i, item in enumerate(a):
    indexes[item - 1] = i
indexes.reverse()

a_min = [-1] * 2 + [INF] * n + [n] * 2
a_max = [-1] * 2 + [-INF] * n + [n] * 2
rMq = RMQ(a_max)
rmq = RmQ(a_min)
ans = 0
for i, idx in enumerate(indexes):
    num = n - i
    L1 = rMq.query(0, idx+2)
    L2 = rMq.query(0, L1+2)
    R1 = rmq.query(idx+2, n+4)
    R2 = rmq.query(R1+3, n+4)
    ans += (L1 - L2) * (R1 - idx) * num 
    ans += (idx - L1) * (R2 - R1) * num 
    rMq.update(idx+2, idx)
    rmq.update(idx+2, idx)
print(ans)

Measured memory_bytes: 101544
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll n, k;
    cin >> n >> k;
    int a[n], g = 0, mx = 0;
    rep(i, n) {
        cin >> a[i];
        g = __gcd(g, a[i]);
        chmax(mx, a[i]);
    }

    cout << (mx >= k && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if (A + B > C + D)
	{
		cout << "Left";
	}
	else if (A + B < C + D)
	{
		cout << "Right";
	}
	else
	{
		cout << "Balanced";
	}

	return 0;
}

Measured memory_bytes: 3644
n,*q=ARGF.read.split.map &:to_i;j=[0];n.times{|i|j[q[i]]=i+1};t=f=0;n.downto(2).map{|i|x=j[f];y=j[i-1];z=j[i];(z>y)^(y>x)^(x>z)&&(t+=1)&f=i};p t

Measured memory_bytes: 32236
using System;
class Program
{
    static void Main(string[] args)
    {
        int[] alphabet = new int[26];
        string line = "";
        while ((line = Console.ReadLine()) != null)
        {
            char[] data = line.ToCharArray();
            for (int i = 0, count = data.Length; i < count; i++)
            {
                if (data[i] >= 'A' && data[i] <= 'Z')
                {
                    alphabet[data[i] - 'A']++;
                }
                else if (data[i] >= 'a' && data[i] <= 'z')
                {
                    alphabet[data[i] - 'a']++;
                }
            }
        }

        char chara = 'a';
        for (int i = 0; i < 26; i++)
        {
            Console.WriteLine("{0} : {1}", chara, alphabet[i]);
            chara++;
        }
    }
}

Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)



int main(){
    ll n;cin>>n;
    ll a[n];
    fr(i,n)cin>>a[i];
    ll ans = 0;
    ll now;
    fr(i,n){
        if(i == 0){
            ans += a[0]/2;
            now = a[0]%2;
        }
        else{
            if(a[i]-now>=0){
                ans += now;
                a[i] -= now;
            }
            ans += a[i]/2;
            now = a[i]%2;
        }
    }
    cout << ans << endl;
}

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

// 任意の隣接3項のビットごとの排他的論理和が0 <=> "Yes"
// => 3つおきに等しくなる

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

    int flag = 0;
    sort(a.begin(), a.end());

    if(a.back() == 0) flag = 1;
    if(N % 3 == 0){
        int k = N / 3;
        if(a[0] == a[k-1] && a[k] == a[k*2 - 1] && a[k*2] == a[N-1]){
            if((a[0] ^ a[k] ^ a[k*2]) == 0) flag = 1;
        }
    }

    if(flag == 1){
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m;
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int main()
{
    while(cin>>n>>m){
        int d=gcd(n,m);
        int lcm=n/d*m;
        cout<<d<<" "<<lcm<<endl;
    }
    return 0;
}



Measured memory_bytes: 3044
s=input()
n=len(s)
ans=100000
l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s+="a"
for i in l:
    s=s[0:n]+i
    c=0
    p=0
    for j in range(n+1):
        if s[j]==i:
            p=max(c,p)
            c=0
        else:
            c+=1
    ans=min(ans,p)
print(ans)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> cake(h,vector<char>(w));
  rep(i,h)rep(j,w)cin >> cake[i][j];
  vector<vector<int>> ans(h,vector<int>(w,0));
  int t=1;
  rep(i,h)rep(j,w)if(cake[i][j]=='#')ans[i][j]=t,t++;
  rep(i,h){
    int p=-1;
    rep(j,w){
      if(ans[i][j]!=0){
        for(int l=p+1;l<j;l++)ans[i][l]=ans[i][j];
        p=j;
      }
    }
    if(p!=-1&&ans[i][w-1]==0)for(int l=p+1;l<w;l++)ans[i][l]=ans[i][p];
  }
  rep(i,h){
    if(i==0)continue;
    if(ans[i][0]==0)rep(j,w)ans[i][j]=ans[i-1][j];
  }
  for(int i=h-1;i>=0;i--){
    if(i==0)continue;
    if(ans[i-1][0]==0)rep(j,w)ans[i-1][j]=ans[i][j];
  }
  rep(i,h){
    rep(j,w)cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


ll modadd(long long a, long long b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(long long a, long long b){return a%MOD*b%MOD%MOD;}
ll modexp(long long a, long long n){if (a==0) return 0; if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(long long n){return modexp(n%MOD,MOD-2);}
ll modfact(long long n){long long res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(long long n, long long r){long long numer=1;long long denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}




int main() {

    int N; cin >> N;
    ll a[N]; rep(i,N) cin >> a[i];

    ll sum = 0;
    rep(i,N) {
        sum += a[i];
        sum %= MOD;
    }
    
    ll suq = 0;
    rep(i,N) {
        suq += a[i]*a[i];
        suq %= MOD;
    }

    ll ans = sum*sum - suq;
    ans %= MOD;
    ans = modmul(ans, modinv(2));

    cout << ans << endl;


    return 0;
}





Measured memory_bytes: 5108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, M;
int a[MAX_N], b[MAX_N];

int main(void)
{
  cin >> N >> M;
  REP(i, M) cin >> a[i] >> b[i];
  priority_queue<P, vector<P>, greater<P>> q;
  REP(i, M) q.push(P(b[i], a[i]));

  int cnt = 0;
  // 中心
  int x = 0;
  while (!q.empty()) {
    P p = q.top();
    q.pop();
    int ai = p.second, bi = p.first;
    // a[i] <= x なら OK
    if (ai > x) {
      x = max(x, bi - 1);
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

 
int main() {
  int i,j,k,l,ans;
  string t,s;
  cin >> t;
  l=t.length();
  for(i=0;i<l;i++){
    if(t.at(i)=='?')
      t.at(i)='D';
  }
  cout << t << endl;
}

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

int main(){

    int n;
    cin>>n;
    int minx=n;
    int ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        minx=min(minx,x);
        if(x<=minx) ans++;
    }
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 256
a,b,c,k=map(int,input().split())
ans=0
if k>a:
    ans+=a
    k-=a
    if k>=b:
        k-=b
        if k>=c:
            ans-=c
            print(ans)
        else:
            ans-=k
            print(ans)
else:
    ans+=k
    print(ans)

Measured memory_bytes: 9124