akhauriyash/Code-Regression huggingface dataset:
/*

        /////////     /////        ////      ////
        //           //   //      //   //  // //
        //////      //    //     //     //   //
            //     // /// //    //          //
      ////////    //      //   //          //
*/

#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fo(i,s,n) for(int i=s;i<n;i++)
#define pb(x) push_back(x);
#define mod 1000000007


int main()
{
    Fast
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    fo(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
    int dp[n][3];
    memset(dp,-1,sizeof(dp));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

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

typedef long long ll;

typedef pair<ll, pair<int, int> > p;

class UnionFind {
private:
	vector<ll> parents;
	vector<ll> ranks;

public:
	vector<ll> sizes;

	UnionFind(ll s): parents(s), ranks(s), sizes(s, 1) {
		for(ll i = 0; i < s; i++) parents[i] = i;
	}

	int find(ll x) {
		if(parents[x] == x) return x;
		else return parents[x] = find(parents[x]);
	}

	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(ranks[x] < ranks[y]) {
			parents[x] = y;
			sizes[y] += sizes[x];
		} else {
			parents[y] = x;
			sizes[x] += sizes[y];
			if(ranks[x] == ranks[y]) ranks[x]++;
		}
	}

	bool same(ll x, ll y) {
		return find(x) == find(y);
	}
};

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

    int N;
    cin >> N;

    vector<pair<ll, int> > x(N);
    vector<pair<ll, int> > y(N);

    for(int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        x[i] = make_pair(a, i);
        y[i] = make_pair(b, i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<p> n(2 * N - 2);

    for(int i = 0; i < N - 1; i++) {
        n[i] = make_pair(x[i + 1].first - x[i].first, make_pair(x[i + 1].second, x[i].second));
        n[i + N - 1] = make_pair(y[i + 1].first - y[i].first, make_pair(y[i + 1].second, y[i].second));
    }

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

    UnionFind uf(N);

    ll ans = 0;

    for(int i = 0; i < 2 * N - 2; i++) {
        p q = n[i];
        ll l = q.first;
        int p1 = q.second.first;
        int p2 = q.second.second;
        if(uf.same(p1, p2)) continue;
        ans += l;
        uf.unite(p1, p2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	string S;
	cin>>S;
	int i=0;
	int n=S.size();
	for( i=0;i<n;i++){
		if(i%2==0 && (S[i]!='R' && S[i]!='U' && S[i]!='D')){
			break;
		}
		if(i%2==1 && (S[i]!='L' && S[i]!='U' && S[i]!='D'))
			break;
	}
	// cout<<i<<endl;
	if(i==n){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const double PI = acos(-1.0);

int main()
{
	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << (w * h) * 0.5 << " " << ((x == w * 0.5 && y == h * 0.5) ? 1 : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, t;
	cin >> n >> t;
	Vec a(n);
	rep(i, n) cin >> a[i];
	Vec b(n);
	repr(i, n){
		b[i] = a[i];
		if(i < n-1) chmax(b[i], b[i+1]);
	}

	ll max = 0;
	rep(i, n-1) chmax(max, b[i+1]-a[i]);
	ll cnt = 0;
	rep(i, n-1){
		if(b[i+1]-a[i] == max) cnt++;
	}
	co(cnt);

	return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		int n = str.length();

		for (int i = 0; i < n - 2; i++) {
			str = str.substring(0, str.length() - 1);

			String front = str.substring(0, str.length() / 2);
			String back = str.substring(str.length() / 2, str.length());

			if (str.length() % 2 != 0) {
				continue;
			}

			if (front.equals(back)) {
				System.out.println(str.length());
				return;
			}
		}
	}
}

Measured memory_bytes: 32480
import sys
s = list(map(int, list(input())))

def excute(b, c):
    if (c == 0):
        return  b
    else:
        return  b*(-1)

def combart(a):
    if (a == 0):
        return '+'
    else:
        return '-'
        
for i in range(8):
    flag = '{:03b}'.format(i)
    
    sum = int(s[0])

    for j in range(3):
        sum += excute(s[j+1], int(flag[j]))
        
    if (sum == 7):
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(s[0], combart(int(flag[0])), s[1], combart(int(flag[1])), s[2], combart(int(flag[2])), s[3]))
        sys.exit(0)

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

using namespace std;

int n,a[100500],dp[100500],k;

int main(){
     cin >> n >> k;
     for(int i = 1; i <= n; i++){
     	cin >> a[i]; 
     	dp[i] = 1e9 + 9;
     }
     dp[1] = 0;
     for(int i = 1; i <= n; i++){
     	for(int j = 1; j <= k; j++){
     		if(i + j <= n) dp[i + j] = min(dp[i + j],dp[i] + abs(a[i] - a[i + j]));	
     	}	
     }
     cout << dp[n];
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  rep(i,100) {
    if(n<0) break;
    if(n%7==0) {
      pr("Yes");
      return;
    }
    n-=4;
  }
  pr("No");
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<vector>
using namespace std;

const int N = 100;
int a[N+3];
int num[N+3];
vector<int> ans;
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=n; i>=1; i--)
	{
		bool found = false;
		for(int j=i; j>=1; j--)
		{
			if(a[j]==j)
			{
				for(int k=j; k<i; k++) a[k] = a[k+1];
				ans.push_back(j);
				found = true; break;
			}
		}
		if(found==false) {puts("-1"); return 0;}
	}
	for(int i=ans.size()-1; i>=0; i--) printf("%d\n",ans[i]);
	return 0;
}

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

long long int f(int n, long long int a_list[]){
    if(a_list[n] !=0)
        return a_list[n];

    else{
        a_list[n] = f(n-1, a_list)+f(n-2, a_list);
        return f(n-1, a_list)+f(n-2, a_list);
    }
}


int main(void){
    long long int ans, a_list[87]={0};
    int n;
    cin>>n;
    a_list[0] = 2;
    a_list[1] = 1;
    cout<<f(n, a_list)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
bool pan(int x){
	int s=1;
	while (s<x) s*=2;
	if (s==x) return 1; else return 0;
}
int main()
{
	scanf("%d",&n);
	if (pan(n)) printf("%s\n","No");
	else {
		printf("%s\n","Yes");
		for (int i=1;i<=(n-1)/2;i++) 
		 {
		 	printf("%d %d\n",1,1+i*2);
		 	printf("%d %d\n",1+i*2,i*2);
		 	printf("%d %d\n",1,n+i*2);
		 	printf("%d %d\n",n+i*2,n+i*2+1);
		 } 
		printf("%d %d\n",2,n+1);
		if (n%2==0) {
			for (int i=2;i<=n-1;i++) if ((n^1^i)>1&&(n^1^i)<=n-1&&(n^1^i)!=i) 
			{
				if (i%2==1) printf("%d %d\n",n,i); else printf("%d %d\n",n,n+i);
				if ((n^1^i)%2==1) printf("%d %d\n",n<<1,(n^1^i)); else printf("%d %d\n",n<<1,(n^1^i)+n);
				break;
			}
		} 
	}
}

Measured memory_bytes: 2304
#include<iostream>
main(){
int n,i,A,B,C;
 for(std::cin>>n;n-->0;puts(C-11?"YES":"NO"))
 for(B=C=i=0;i++<10;){
  std::cin>>A;
  if(B<A)B=A;else C=C<A?A:11;
 }
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int cnt[4];
int a[5];
main()
{
	while(cin>>a[0],a[0])
	{
		cnt[1]=cnt[2]=cnt[3]=0;
		int C=0;
		for(int i=1;i<5;i++)cin>>a[i];
		for(int i=0;i<5;i++)C+=!cnt[a[i]]++;
		if(C==2)
		{
			if(cnt[1]&&cnt[2])
			{
				for(int i=0;i<5;i++)
				{
					cout<<2-(a[i]==1)<<endl;
				}
			}
			else if(cnt[1]&&cnt[3])
			{
				for(int i=0;i<5;i++)
				{
					cout<<2-(a[i]==3)<<endl;
				}
			}
			else
			{
				for(int i=0;i<5;i++)
				{
					cout<<2-(a[i]==2)<<endl;
				}
			}
		}
		else cout<<"3\n3\n3\n3\n3\n";
	}
}



Measured memory_bytes: 3076
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
lis=LI()
lis.sort()
if lis[N//2-1] != lis[N//2]:
    print(lis[N//2] - lis[N//2-1])
else:
    print(0)


Measured memory_bytes: 14120
#include <iostream>

using namespace std;

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

    cin >> a >> b >> c;

    int i, j, k;

    i = j = k = 0;

    char next = 'a';
    char ans;

    while (true)
    {
        if (next == 'a')
        {
            if (i == a.length())
            {
                ans = 'A';
                break;
            }

            next = a[i];
            i++;
        }
        else if (next == 'b')
        {
            if (j == b.length())
            {
                ans = 'B';
                break;
            }

            next = b[j];
            j++;
        }
        else if (next == 'c')
        {
            if (k == c.length())
            {
                ans = 'C';
                break;
            }

            next = c[k];
            k++;
        }
    }

    cout << ans << endl;


    return 0;
}

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

int main() {
    int N;
    string S, T;

    cin >> N;
    cin >> S >> T;

    string ans = "";

    for (int i = 0; i < N; ++i) {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  string s; cin >> s;
  int cnt, k = s.length();
  rep(i,k) {
    if (s[i] == 'o') cnt++;
  }
  if (15-k + cnt >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//package AtCoder.ABC155;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        HashMap<String, Integer> ma = new HashMap<>();
        int n = in.NI();
        int maxcoun = 0;
        for (int i=0;i<n;i++) {
            String x = in.next();
            if (!(ma.containsKey(x))) {
                ma.put(x, 1);
                maxcoun = Integer.max(maxcoun, 1);
            } else {
                int pval = ma.get(x);
                ma.put(x, pval+1);
                maxcoun = Integer.max(maxcoun, pval+1);
            }
        }
        List<String> ans = new ArrayList<>();
        for (String key: ma.keySet()) {
            if (ma.get(key ) == maxcoun) {
                ans.add(key);
            }
        }
        Collections.sort(ans);
        for (int i=0;i<ans.size();i++){
            out.println(ans.get(i));
        }
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    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();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 64640
#include <iostream>
#include <cmath>

using namespace std;

const int INF = 1e9;

int n[10];
int len;
long ans=0;

void dfs(int i, long tmp_sum, long tmp) {

  if (i == len) {
    ans += tmp_sum + tmp;
    return;
  }
  dfs(i+1, tmp_sum, tmp*10+n[i]);

  dfs(i+1, tmp_sum+tmp, n[i]);
}
int main() {
  ios::sync_with_stdio(false);

  std::string s;
  cin >> s;
  len = s.length();

  for (int i=0; i<len; i++) {
    n[i] = s[i] - '0';
  }
  dfs(1, 0, n[0]);
  cout << ans;
}

Measured memory_bytes: 256
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))

count=0

for i in range(N):
    count += min(A[i],B[i])
    nx = min(A[i+1],B[i]-min(B[i],A[i]))
    count += nx
    A[i+1]-=nx

print(count)


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

int main()
{
	int n;
	vector<int> d;
	cin >> n;
	d.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	if (n % 2 == 0)
	{
		cout << d[n / 2] - d[n / 2 - 1] << endl;
	}
	else
	{
		cout << "0" << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N, M;
vector<ll> a, b;
vector<ll> c;

const int MAX = 1 << 12;
ll dp[MAX];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  a.resize(M);
  b.resize(M);
  c.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      int ci;
      cin >> ci;
      c[i] |= (1 << (ci - 1));
    }
  }

  fill(dp, dp + MAX, LL_INF);
  dp[0] = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      ll next = j | c[i];
      dp[next] = min(dp[next], dp[j] + a[i]);
    }
  }

  int idx = (1 << N) - 1;
  if (dp[idx] == LL_INF) {
    cout << -1 << endl;
  } else {
    cout << dp[idx] << endl;
  }

  return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
  for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
  T x;
  cin >> x;
  return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
  cin >> head;
  CIN(move(tail)...);
}
#define CINT(...)                                                              \
  int __VA_ARGS__;                                                           \
  CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
  ll __VA_ARGS__;                                                            \
  CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
  string __VA_ARGS__;                                                        \
  CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
  {                                                                          \
  FOREACH(x, v) { cout << x << " "; }                                    \
    cout << "\n";                                                          \
    }

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll W, H, t, p;
vector<VL> a;

void transpose(ll &h, ll &w, vector<VL> &a){
  vector<VL> b(w,VL(h));
  REP(i,h)REP(j,w){
    b[j][i]=a[i][j];
  }
  a.swap(b);
  swap(h,w);
}

signed main(){
  while(1){
    cin>>W>>H>>t>>p;
    if(W==0 && H==0 && t==0 && p==0) break;
    a.assign(H,VL(W,1));
    while(t--){
      LCIN(d,c);
      if(d==2) transpose(H,W,a);
      ll wl=max(c,W-c);
      vector<VL> b(H,VL(wl));
      REP(i,H)REP(j,W){
	ll jl = j<c?c-j-1:j-c;
	b[i][jl]+=a[i][j];
      }
      a.swap(b);
      W = wl;
      if(d==2) transpose(H,W,a);
    }
    while(p--){
      LCIN(x,y);
      cout << a[y][x] << "\n";
    }
  }
}



Measured memory_bytes: 3172
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
解説PDFを読んで書き直した。
ワーシャル-フロイド法を用いる。
"""

def warshall_floyd(c_lsit_list):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                c_lsit_list[j][k] = min(
                    c_lsit_list[j][i] + c_lsit_list[i][k],
                    c_lsit_list[j][k]
                )
    min_c_list = [c_lsit_list[i][1] for i in range(10)]
    return min_c_list

def main():
    H, W = map(int, input().split())
    c_lsit_list = [list(map(int, input().split())) for i in range(10)]
    A_lsit_list = [list(map(int, input().split())) for i in range(H)]

    A_bucket = [0]*10
    for A_list in A_lsit_list:
        for A in A_list:
            if A >= 0:
                A_bucket[A] += 1

    min_c_list = warshall_floyd(c_lsit_list)

    print(sum([A_bucket[i]*min_c_list[i] for i in range(10)]))
    return

if __name__ == "__main__":
    main()



Measured memory_bytes: 9408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>

#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 300001
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;

int main(){
    string s; cin >> s;
    int cnt = 0, mx = 0;
    for (int i = 0; i < sz(s); i++){
        if (s[i] == 'R') cnt++, mx = max(mx, cnt);
        else cnt = 0;
    }
    cout << mx << endl;
}

Measured memory_bytes: 3188
using System;

class PrimeNum
{
    //private static int k;
    public static int Check(int num)
    {
        int k=0;
        if (num == 2)
            return 1;
        if (num % 2 == 0 && num !=2)
            return 0;

        for (int j = 2; j <= (int)Math.Sqrt(num); j++)
        {
            if (num % j == 0)
            {
                k = 1;
                break;
            }
        }
        if (k==0)
            return 1;
        return 0;
    }
}
class Program
{
    static void Main()
    {
        int count = 0;
        int n = int.Parse(Console.ReadLine());
        for(int i=0;i<n;i++)
        {
            int num = int.Parse(Console.ReadLine());
            count += PrimeNum.Check(num);
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9280
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int H, W, n;

pll seg[1 << 20];
vector<int> X;

void init(int i, int s, int e, int v) {
    seg[i] = pll(v - X[s], 0);
    if (s == e) return;
    int m = (s + e) / 2;
    init(i << 1, s, m, v);
    init(i << 1 | 1, m + 1, e, v);
}

void update(int i, int s, int e, int x, int y, int v) {
    if (e < x || y < s) return;
    if (x <= s && e <= y) {
        seg[i].fs += v;
        seg[i].se += v;
        return;
    }
    int m = (s + e) / 2;
    update(i << 1, s, m, x, y, v);
    update(i << 1 | 1, m + 1, e, x, y, v);
    seg[i].fs = max(seg[i << 1].fs, seg[i << 1 | 1].fs) + seg[i].se;
}

const llong inf = 1e18;
llong query(int i, int s, int e, int x, int y) {
    if (e < x || y < s) return -inf;
    if (x <= s && e <= y) return seg[i].fs;
    int m = (s + e) / 2;
    return max(query(i << 1, s, m, x, y), query(i << 1 | 1, m + 1, e, x, y)) + seg[i].se;
}

int find(int x) {
    return lower_bound(X.begin(), X.end(), x) - X.begin();
}

void update(vector<pii> &st, int x, int y, int mx) {
    while (!st.empty() && st.back().se >= y) {
        pii e = st.back();
        st.pop_back();
        int s = st.empty() ? 0 : st.back().fs;
        update(1, 0, X.size() - 1, find(s), find(e.fs) - 1, mx - e.se);
    }
    int s = st.empty() ? 0 : st.back().fs;
    update(1, 0, X.size() - 1, find(s), find(x) - 1, y - mx);
    st.emplace_back(x, y);
}

int solve(vector<pii> &P) {
    sort(P.begin(), P.end());
    int Hs = 0, Hm = H / 2, He = H;
    X.clear();
    X.push_back(0);
    for (pii i : P) X.push_back(i.fs);
    X.push_back(W);
    X.erase(unique(X.begin(), X.end()), X.end());
    init(1, 0, X.size() - 1, He - Hs);
    int ret = 0;
    vector<pii> U, D;
    for (int i = 0, j = 0; i < X.size(); ++i) {
        ret = max(ret, (int)query(1, 0, X.size() - 1, 0, i) + X[i]);
        while (j < P.size() && P[j].fs <= X[i]) {
            if (Hm <= P[j].se) update(U, P[j].fs, P[j].se - Hm, He - Hm);
            if (Hm >= P[j].se) update(D, P[j].fs, Hm - P[j].se, Hm - Hs);
            ++j;
        }
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> W >> H >> n;
    vector<pii> P;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        if (x == 0 || x == W || y == 0 || y == H) continue;
        P.emplace_back(x, y);
    }
    int ans = solve(P);
    swap(H, W);
    for (pii &i : P) swap(i.fs, i.se);
    ans = max(ans, solve(P));
    printf("%d\n", ans << 1);
    return 0;
}


Measured memory_bytes: 24940
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, now;
  scanf("%lld", &n);
  if(n == 2) {
    printf("1");
    return 0;
  }
  vector<ll> a;
  for(i = 1; i * i <= n; ++i) if(!(n % i)) a.push_back(i);
  for(i = a.size() - 1; i >= 0; --i) if(a[i] * a[i] != n) a.push_back(n / a[i]);
  for(i = 1; i < a.size(); ++i) {
    now = n;
    while(!(now % a[i])) now /= a[i];
    if(!((now - 1) % a[i])) ++ans;
  }
  for(i = 1; i * i < n; ++i) if(!((n - 1) % i)) {
    ans++;
    if(i != 1 && i * i != n - 1) ans++;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 384
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
using namespace std;

void solve(int cnum){
	int n,k;
	cin >> n >> k;
	vector<int>arr(n);
	for(int i = 0;i < n; ++i)
		cin >> arr[i];
	sort(arr.begin(),arr.end());
	int ans = 0;
	for(int i = 0; i < k; ++i)
		ans+=arr[i];
	cout << ans <<"\n";

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//cout.tie(nullptr);
	int t;
	int count = 1;
	for(t = 1;t--; solve(count));
	return 0;
}

Measured memory_bytes: 3656
import math
import calendar
import fractions
import itertools

n, k = map(int, input().split())
p = list(map(int, input().split()))

ans_list = []

for i in p:
    if i % 2 == 0:
        ans_list.append(i / 2 + 0.5)
    else:
        ans_list.append(i // 2 + 1)


ans = 0
total = 0
for i in range(0, n - k + 1):
    if i == 0:
        for j in range(k):
            total += ans_list[j]
            ans = total
    else:
        total -= ans_list[i - 1]
        total += ans_list[i + k - 1]
    ans = max(ans, total)
print(ans)


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

using namespace std;

long long func(long long a, long long b) {
  if (b == 0) {
    return 0;
  }
  long long q = a / b;
  return (2 * q - (a % b == 0)) * b + func(b, a - q * b);
}

int main() {
  long long n, x;
  cin >> n >> x;
  long long p = x, q = n - x;
  if (p < q) {
    swap(p, q);
  }
  cout << n + func(p, q) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a%12>=6){
		b*=-1;
		c*=-1;
	}
	if(a%6==0)cout<<b<<" "<<c<<endl;
	if(a%6==1)cout<<b-c<<" "<<c<<endl;
	if(a%6==2)cout<<b-c<<" "<<b<<endl;
	if(a%6==3)cout<<-c<<" "<<b<<endl;
	if(a%6==4)cout<<-c<<" "<<b-c<<endl;
	if(a%6==5)cout<<-b<<" "<<b-c<<endl;
}




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

int main ()
{
  int x[5]={1,2,3,4,5};
  int xin[5];

  for(int i = 0; i < 5 ; i++)
    {
      cin >> xin[i];
      if(x[i] != xin[i])
        {
          cout << i+1 << endl;
          break;
        }
    }

  return 0;
}

Measured memory_bytes: 3588
fun main(args: Array<String>){
  val k: Int = readLine()!!.toInt()
  var c: Int = 0
  for(i in 1..k){
    for(j in i..k){
      if(i % 2 == 0) if(j % 2 == 1) c++;
      else           if(j % 2 == 0) c++;
    }
  }
  println("$c")
}

Measured memory_bytes: 31688
#include <stdio.h>

int main()
{
	int i, j, k, A[4][4], N, b[11];
	for (i = 1; i <= 3; i++) {
		for (j = 1; j <= 3; j++) scanf("%d", &(A[i][j]));
	}
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(b[i]));

	int B[4][4] = {};
	for (k = 1; k <= N; k++) {
		for (i = 1; i <= 3; i++) {
			for (j = 1; j <= 3; j++) if (b[k] == A[i][j]) B[i][j] = 1;
		}
	}
	
	int flag = 0, count = 0;
	for (i = 1; i <= 3; i++) {
		count = 0;
		for (j = 1; j <= 3; j++) count += B[i][j];
		if (count == 3) flag = 1;
	}
	for (j = 1; j <= 3; j++) {
		count = 0;
		for (i = 1; i <= 3; i++) count += B[i][j];
		if (count == 3) flag = 1;
	}
	count = 0;
	for (i = 1; i <= 3; i++) count += B[i][i];
	if (count == 3) flag = 1;
	count = 0;
	for (i = 1; i <= 3; i++) count += B[i][4-i];
	if (count == 3) flag = 1;
	
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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

int main()
{
  int a, b, c, x1, x2, x3, ans;

  cin >> a >> b >> c;
  x1 = max(max(a, b), c);
  x3 = min(min(a, b), c);
  if (max(b, c) == x1 && min(b, c) == x3)
    x2 = a;
  else if (max(a, c) == x1 && min(a, c) == x3)
    x2 = b;
  else
    x2 = c;
  ans = x1 - x2;
  x3 += ans;
  if (x3 % 2 == x1 % 2)
    ans += (x1 - x3) / 2;
  else
    ans += (x1 - x3 + 1) / 2 + 1;
  cout << ans << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
std::string L;
int N;
ll dp[100100][2][2];

ll rec(int i, bool over, bool carry){
    if(i == N){
        return carry == 0;
    }

    if(dp[i][over][carry] != -1){
        return dp[i][over][carry];
    }

    ll res = 0;

    for(int x=0;x<2;++x){
        for(int y=0;y<2;++y){
            for(int z=0;z<2;++z){
                if(!over && (x ^ y ^ z) > (L[i] - '0')){
                    continue;
                }

                unless(!carry || x + y + z >= 2){
                    continue;
                }

                unless(!(x + y + z >= 2) || carry){
                    continue;
                }

                if((x ^ y ^ z) != (x ^ y)){
                    continue;
                }

                res = (res + rec(i + 1, over || (x ^ y ^ z) < (L[i] - '0'), z)) % MOD;
            }
        }
    }

    return dp[i][over][carry] = res;
}

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

    std::cin >> L;

    N = L.size();

    memset(dp, -1, sizeof(dp));

    ll res = rec(0, 0, 0);
    std::cout << res << std::endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  ll A, B;
  int K;
  cin >> A >> B >> K;
  REP(i, K)
  {
    if (i % 2 == 0)
    {
      if (A % 2 != 0)
        A--;
      B += A / 2;
      A /= 2;
    }
    else
    {
      if (B % 2 != 0)
        B--;
      A += B / 2;
      B /= 2;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}


int main() {
    
    int n;cin>>n;
    int x = 0;
    int temp = n;
    while(temp!=0){
        x+= temp%10;
        temp/=10;
    }
    
    if(n%x == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}







Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;
class bTree{
	int Id;
	int parent;
	int depth;
	int degree;
	int sibling;
	int hight;
	string type;
	int left, right;
public:
	bTree(){
		Id = 0, parent = -1, depth = 0, type = "", left = -1, right = -1,
			degree = 0, sibling = -1, hight = 0;
	}	
	int takeId(){ return this->Id; }
	int takeParent(){ return this->parent; }
	int takeDepth(){ return this->depth; }
	int takeDegree(){ return this->degree; }
	int takeSibling(){ return this->sibling; }
	int takeHight(){ return this->hight; }
	int takeLeft(){ return this->left; }
	int takeRight(){ return this->right; }
	string takeType(){ return this->type; }
	void setId(int a){ this->Id = a; }
	void setParent(int a){ this->parent = a; }
	void setDepth(int a){ this->depth = a; }
	void setSibling(int a){ this->sibling = a; }
	void setLeft(int a){ this->left = a; }
	void setRight(int a){ this->right = a; }
	void setHight(int a){ this->hight = a; }
	void setType(){
		if (this->parent == -1) this->type = "root";
		else if (this->left == -1 && this->right==-1) this->type = "leaf";
		else this->type = "internal node";
	}
	void setDegree(){
		if (this->left == -1 && this->right == -1) this->degree = 0;
		else if (this->left == -1 || this->right == -1) this->degree = 1;
		else this->degree = 2;
	}
};
bTree nodes[25];

void preorder(int id){
	cout << ' ' << id;
	int left = nodes[id].takeLeft();
	if(left!=-1) preorder(left);
	int right = nodes[id].takeRight();
	if (right != -1) preorder(right);
	return;
}
void inorder(int id){
	int left = nodes[id].takeLeft();
	if (left != -1) inorder(left);	
	cout << ' ' << id;
	int right = nodes[id].takeRight();
	if (right != -1) inorder(right);	
	return;
}
void postorder(int id){
	int left = nodes[id].takeLeft();
	if (left != -1) postorder(left);
	int right = nodes[id].takeRight();
	if (right != -1) postorder(right);
	cout << ' ' << id;
	return;
}
int main(){
	int n; scanf("%d",&n);
	for (int i = 0; i < n;++i){
		int id, Lchild, Rchild; scanf("%d %d %d", &id, &Lchild, &Rchild);
		nodes[id].setId(id);
		nodes[id].setLeft(Lchild);
		if (Lchild != -1) {
			nodes[Lchild].setParent(id);
		}
		nodes[id].setRight(Rchild);
		if (Rchild != -1){
			nodes[Rchild].setParent(id);
		}
	}
	int p = -1;
	for (int i = 0; i < n; ++i) if (nodes[i].takeParent() == -1){ p = i; break; }
	cout << "Preorder\n";
	preorder(p); cout << '\n';
	cout << "Inorder\n";
	inorder(p); cout << '\n';
	cout << "Postorder\n";
	postorder(p); cout << '\n';
}

Measured memory_bytes: 1220
use std::fmt::Debug;
use std::io::stdin;
use std::str::FromStr;

fn read<T>() -> Vec<T>
where
  T: FromStr,
  <T as FromStr>::Err: Debug,
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  s.trim()
    .split_whitespace()
    .map(|c| T::from_str(c).unwrap())
    .collect()
}

fn main() {
  let input: Vec<u32> = read();
  println!(
    "{}",
    match input.into_iter().find(|&v| v > 8) {
      Some(_v) => ":(",
      _ => "Yay!",
    }
  )
}


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

int main()
{
    int n;
    cin >> n;
    vector<long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
    }
    long ans = numeric_limits<long>::max();
    for (int i = n - 2; i >= 0; i--) {
        ans = min(ans, abs(2 * a[i] - a[n - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	vector<int>a;
	map<int, int>mp;
	set<int>se;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		a.push_back(x);
		if (se.count(a[i]) == 1) {
			x = mp[a[i]];
			mp[a[i]] = x + 1;
		}
		else {
			mp[a[i]] = 1;
			se.insert(a[i]);
		}
	}
	if (n % 3 != 0) {
		if (mp[a[0]] == n&&a[0]==0) {
			printf("Yes\n");
			return 0;
		}
		else {
			printf("No\n");
			return 0;
		}
	}
	v = true;
	n /= 3;
	f(i, 3*n) {
      x=mp[a[i]];
		if (x % n != 0)v=false;
	}
	sort(a.begin(), a.end());
	x = a[0];
	y = a[n];
	z = a[(2 * n)];
	if (((x^y) ^ z) != 0)v = false;
	if(v)printf("Yes\n");
	else printf("No\n");


	return 0;
}

Measured memory_bytes: 7800
a = 0
r, c = [int(i) for i in input().split()]
li = [[int(i) for i in input().split()] for _ in range(r)]
for row in li:
    print(*row, sum(row))
for i in range(c):
    t = sum([row[i] for row in li])
    a += t
    print(t, end=" ")
print(a)



Measured memory_bytes: 6240
#include<stdio.h>

void Island(int x,int y,int number);
void solve(int w,int h);

int map[52][52]={{0}};

int main(void){
  int w,h;
  while(scanf("%d%d",&w,&h) && w!=0 && h!=0){
    solve(w,h);
  }
  return 0;
}

void solve(int w,int h){
  int i,j;
  int x,y;
  int number=2;
  
  for(i=0;i<52;i++) for(j=0;j<52;j++) map[i][j]=0;
  
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%d",&map[i][j]);
    }
  }
  for(x=1;x<=h;x++){
    for(y=1;y<=w;y++){
      if(map[x][y]==1){
        Island(x,y,number);
        number++;
      }
    }
  }
  printf("%d\n",number-2);
  return 0;
}


void Island(int x,int y,int number){
  int i,j;
  map[x][y]=number;
  for(i=-1;i<=1;i++){
    for(j=-1;j<=1;j++){
      if(map[x+i][y+j]==1){
        Island(x+i,y+j,number);
      }
    }
  }
}

  

Measured memory_bytes: 792
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;

	int max_ = A + B;
	max_ = max(A + A - 1, max_);
	max_ = max(B + B - 1, max_);

	cout << max_ << endl;	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(len(A)):
    if(A[i] == B[i] and B[i] == C[i]):
        continue
    if(A[i] == B[i] or B[i] == C[i] or A[i] == C[i]):
        ans +=1
        continue
    ans += 2

print(ans)

Measured memory_bytes: 3064
import sys

num, total = list(map(int, sys.stdin.read().split(" ")))
for i in range(total // 10000, -1, -1):
  amount = total - 10000 * i
  if amount == 0 and i == num:
    print("%d 0 0"%i)
    sys.exit(0)
  for j in range(amount // 5000, -1, -1):
    amountj = amount - 5000 * j
    if amountj == 0 and i+j == num:
      print("%d %d 0"%(i, j))
      sys.exit(0)
    k = amountj // 1000
    if i+j+k == num:
      print("%d %d %d"%(i, j, k))
      sys.exit(0)
print("-1 -1 -1")


Measured memory_bytes: 3188
N,K = [int(x) for x in input().split()]
A = [0]+[int(x) for x in input().split()]
dp = [10**9]*(N+1)
dp[1] = 0
for i in range(1,N):
  k =1
  while k<=K and i+k<=N:
    dp[i+k] = min(dp[i+k],dp[i]+abs(A[i]-A[i+k]))
    k+=1
print(dp[N])



Measured memory_bytes: 52704
//xenowi`tz -- Jai Shree Ram
#include<bits/stdc++.h>
using namespace std;

#define fori(i,a,b) for (long long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define MAXN 400005
#define pb push_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin >> n;

	ll ans = (n/500)*1000 + ((n%500)/5)*5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=10;

int n;
vvi a,b;

int main(){
	cin>>n;
	a=vvi(n,vi(M));
	b=vvi(n,vi(M+1));
	for(int i=0;i<n;i++) for(int j=0;j<M;j++) cin>>a[i][j];
	for(int i=0;i<n;i++) for(int j=0;j<=M;j++) cin>>b[i][j];
	ll res=-inf;
	for(int i=1;i<1<<M;i++){
		ll tmp=0;
		for(int j=0;j<n;j++){
			int cnt=0;
			for(int k=0;k<M;k++) if((i&1<<k)&&a[j][k]) cnt++;
			tmp+=b[j][cnt];
		}
		res=max(res,tmp);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
using System;

namespace AtCoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            int X = int.Parse(a[0]);
            int Y = int.Parse(a[1]);

            Console.WriteLine(X + Y / 2);
       }
    }
}


Measured memory_bytes: 11092