akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	defer stdout.Flush()

	N := readInt()
	C := readInt()
	D := vvi(C + 1)
	for i := 1; i <= C; i++ {
		for j := 1; j <= C; j++ {
			D[i][j] = readInt()
		}
	}

	es := vvi(3, C+1)
	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			c := readInt()
			es[(i+j)%3][c]++
		}
	}

	ans := int(2e+10)
	for i := 1; i <= C; i++ {
		for j := 1; j <= C; j++ {
			if i == j {
				continue
			}
			for k := 1; k <= C; k++ {
				if i == k || j == k {
					continue
				}
				score := 0
				for l := 1; l <= C; l++ {
					score += es[0][l]*D[l][i] + es[1][l]*D[l][j] + es[2][l]*D[l][k]
				}
				ans = min(ans, score)
			}
		}
	}
	println(ans)
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;


int main()
{
	int first, end, order;
	cin >> first >> end >> order;

	for (int i = 0; i < order; i++) {
		int code = first + i;
		if (code >= first && code <= end) {
			cout << code << endl;
		}
	}

	for (int i = order - 1; i >= 0; i--) {
		int code = end - i;
		if (code >= first + order && code <= end) {
			cout << code << endl;
		}
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,a,b;
	string s;
	int count = 0;
	int count2=0;
	cin>>n>>a>>b>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='a'){
			if(count<a+b){
				cout<<"Yes"<<endl;
				count++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		if(s[i]=='b'){
			if(count<a+b && count2<b){
				cout<<"Yes"<<endl;
				count++;
				count2++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		if(s[i]=='c'){
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 896
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Measured memory_bytes: 86476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	sort(all(a), greater<int>());
	priority_queue<int, vi, less<int>> pq;
	pq.push(a[0]);

	ll ans = 0;
	rep_lr(i, 1, n) {
		ans += pq.top();
		pq.pop();
		rep(j, 2)pq.push(a[i]);
	}

	cout << ans << endl;

}

Measured memory_bytes: 5104
K, N = map(int,input().split())
A = sorted([int(i) for i in input().split()])

saityou = K - A[N-1] + A[0]
start = N-1
for x in range(N-1):
    if saityou < A[x+1] - A[x]:
        saityou = A[x+1] - A[x]
        start = x
print (K-saityou)


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

int main()
{
	int c1=0,c2=0,c3=0,c0=0;
	int n;
	string s;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC")
		c0++;
		else if(s=="WA")
		c1++;
		else if(s=="TLE")
		c2++;
		else
		c3++;
		
	}
	
cout<<"AC x "<<c0<<endl
    <<"WA x "<<c1<<endl
    <<"TLE x "<<c2<<endl
    <<"RE x "<<c3<<endl; 
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

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

// 最小公倍数
ll lcm(ll m, ll n) {
  return abs(m*n)/gcd(m, n);
}

int main() {
  ll X, Y;
  cin >> X >> Y;
  if (lcm(X, Y)==X) cout << -1 << endl;
  else cout << X << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s;
    cin >> s;
    int j = 0;
    int count = 1;
    rep(i, s.length())
    {
        if (s[i] == 'A')
        {
            j = i;
            break;
        }
    }
    for (int i = s.length(); i > j; i--)
    {
        if (s[i] != 'Z')
        {
            count++;
        }
        else break;
    }
    cout << s.length() - j - count + 2 << endl;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    long long V[N];
    long long maxdraw, anstmp, ans;
    int np, nn;
    priority_queue <long long, vector<long long>, greater<long long> > que;

    np=0; nn=0;

    for(int i=0; i<N; i++){
        cin >> V[i];
        if( V[i]>=0 ){
            np++;
        }else{
            nn++;
        }
    }

    maxdraw=0;

    if( N <= K ){
        for(int i=0; i<N; i++ ){
            que.push(V[i]);
            maxdraw += V[i];
        }
        for(int i=1; i<=min(K-N,N); i++){
            maxdraw -= que.top();
            que.pop();
        }
    }

    priority_queue <long long, vector<long long>, greater<long long> >().swap(que);

    ans=0;

    for(int M=0; M<=min(K,N); M++){
        for(int MR=0; MR<=M; MR++){
            int ML = M - MR;
            anstmp=0;
            
            for(int i=1; i<=ML; i++){
                anstmp += V[i-1];
                que.push(V[i-1]);
            }
            
            for(int i=N-1; i>=N-MR; i--){
                anstmp += V[i];
                que.push(V[i]);
            }

            for(int i=1; i<=K-M; i++){
                if(que.empty()) break;
                if(que.top()>=0) break; 
                anstmp -= que.top();
                que.pop();
            }
            
            ans=max(ans,anstmp);

            priority_queue <long long, vector<long long>, greater<long long> >().swap(que);
            //cout << "M ml mr ans " << M << " " << ML << " " << MR << " " << ans << endl;
        }
    }

    ans=max(maxdraw,ans);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int N;
int W, H;
vector<int> x, y;
vector<int> xl, yl;
int l, r, u, b;
bool window[300][300];

int comp(vector<int> &X, vector<int> &XL)
{
	vector<int> xs;
	for(int i = 0; i < X.size(); i++){
		xs.push_back(X[i]);
		xs.push_back(X[i] - 1);
	}
	xs.push_back(20005), xs.push_back(-20005);
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	sort(xs.begin(), xs.end());
	
	for(int i = 0; i < X.size(); i++){
		X[i] = lower_bound(xs.begin(), xs.end(), X[i]) - xs.begin();
	}
	for(int i = 0; i < xs.size()-1; i++){
		XL.push_back(xs[i+1] - xs[i]);
	}
	return xs.size();
}

void dfs(int i, int j, bool a[300][300])
{
	if(i < 0 || i >= W || j < 0 || j >= H) return;
	if(a[i][j]) return;
	
	a[i][j] = true;
	dfs(i+1, j, a);
	dfs(i-1, j, a);
	dfs(i, j+1, a);
	dfs(i, j-1, a);
}

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		
		x.clear(), y.clear();
		int xx, yy;
		for(int i = 0; i < N; i++){
			cin >> xx >> yy;
			x.push_back(xx), y.push_back(yy);
		}
		int A[4], B[4];
		for(int i = 0; i < 4; i++) cin >> A[i] >> B[i];
		l = min(A[0], A[2]), r = max(A[0], A[2]);
		u = min(B[0], B[2]), b = max(B[0], B[2]);
		x.push_back(l), x.push_back(r);
		y.push_back(u), y.push_back(b);
		
		xl.clear(), yl.clear();
		W = comp(x, xl);
		H = comp(y, yl);
		l = x[N], r = x[N+1];
		u = y[N], b = y[N+1];
		
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				window[i][j] = false;
			}
		}
		
		int px, py, nx, ny, dx, dy;
		int difx[105], dify[105];
		
		for(int i = 0; i < N; i++) difx[i] = dify[i] = 0;
		for(int i = 0; i < N; i++){
			px = x[i], py = y[i];
			nx = x[(i+1)%N], ny = y[(i+1)%N];
			if(nx == px) dx = 0; 
			else dx = (nx - px) / abs(nx - px);
			if(ny == py) dy = 0;
			else dy = (ny - py) / abs(ny - py);
			
			if(dx < 0) dify[i]--, dify[(i+1)%N]--;
			else if(dy > 0) difx[i]--, difx[(i+1)%N]--;
		}
		for(int i = 0; i < N; i++) x[i] += difx[i], y[i] += dify[i];
		
		for(int i = 0; i < N; i++){
			px = x[i], py = y[i];
			nx = x[(i+1)%N], ny = y[(i+1)%N];
			if(nx == px) dx = 0; 
			else dx = (nx - px) / abs(nx - px);
			if(ny == py) dy = 0;
			else dy = (ny - py) / abs(ny - py);
			
			for(; px != nx || py != ny; px += dx, py += dy) window[px][py] = true;
		}
		
		bool out[300][300];
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				out[i][j] = window[i][j];
			}
		}
		dfs(0, 0, out);
		
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				if(!window[i][j] && !out[i][j]){
					dfs(i, j, window);
					goto end;
				}
			}
		}
		end:;
		
		
		for(int i = l; i < r; i++){
			for(int j = u; j < b; j++){
				window[i][j] = false;
			}
		}
		
		int ans = 0;
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				if(window[i][j]) ans += xl[i] * yl[j];
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

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

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main() {

  ll N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  ll l[Q];
  ll r[Q];
  FOR(i,0,Q-1){
    cin>>l[i]>>r[i];
  }
  ll score[N]={};

  FOR(i,1,S.size()-1){
    if(S[i-1]=='A'&&S[i]=='C'){
      score[i]=score[i-1]+1;
    }else{
      score[i]=score[i-1];
    }
  }

  FOR(i,0,Q-1){
    cout<<score[r[i]-1]-score[l[i]-1]<<endl;
  }

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


Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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

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

int main() {
    
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
        sum %= MOD_BIG;
    }
    ll ans = 0;
    REP(i, N) {
        sum += -A[i] + MOD_BIG;
        sum %= MOD_BIG;
        ans += A[i]*sum;
        ans %= MOD_BIG;
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
    int N;
    string S,T;
    cin >> N;
    cin >>S>>T;
    for(int i=0; i < N; i++){
        cout << S.at(i)<<T.at(i);
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int n = sc.nextInt();


		List<Integer> listA = new ArrayList<>();
		List<Integer> listB = new ArrayList<>();
		List<Integer> listC = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			listA.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			listB.add(b);
		}
		for (int i = 0; i < n-1 ; i++) {
			int c = sc.nextInt();
			listC.add(c);
		}

		int result = 0;
		for (int i = 0; i < n; i++) {
			int a = listA.get(i);
			int b = listB.get(a-1);
			result += b;

			int nextA = i == n-1 ? -1 : listA.get(i+1);
			if(nextA == a + 1 ){
				int c = listC.get(a-1);
				result += c;
			}
		}

		System.out.println(result);


	}
}


Measured memory_bytes: 22996
"""
2回目:
    kの考慮(ki, si1, ... と, k が最初に連携されてくること) が抜けていた

"""

def solve():
    N, M = map(int, input().split())
    S = [sum([2 ** (int(i) - 1) for i in input().split()][1:]) for _ in
              range(M)]
    P = [int(i) for i in input().split()]
    count = 0
    for i in range(2 ** N):
        for s, p in zip(S, P):
            if bin(s & i).count('1') % 2 != p:
                break
        else:
            count += 1
            # print(bin(i))

    print(count)


if __name__ == '__main__':
    solve()


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


int main(){
	int nen,ga,pi;
	
	while(0<=scanf("%d%d%d",&nen,&ga,&pi)){
		
		if(nen<1868){
			printf("pre-meiji\n");
			continue;
		}
		if(nen==1868){
			if(ga<9){
				printf("pre-meiji\n");
				continue;
			}else if(ga==9){
				if(pi<8){
					printf("pre-meiji\n");
					continue;
				}else{
					printf("meiji %d %d %d\n",nen+1-1868,ga,pi);
					continue;
				}
			}else{
				printf("meiji %d %d %d\n",nen+1-1868,ga,pi);
				continue;
			}
		}
		
		if(nen>1868 && nen<1912){
			printf("meiji %d %d %d\n",nen+1-1868,ga,pi);
			continue;
		}
		
		if(nen==1912){
			if(ga<7){
				printf("meiji %d %d %d\n",nen+1-1868,ga,pi);
				continue;
			}else if(ga==7){
				if(pi<30){
					printf("meiji %d %d %d\n",nen+1-1868,ga,pi);
					continue;
				}else{
					printf("taisho %d %d %d\n",nen+1-1912,ga,pi);
					continue;
				}
			}else{
				printf("taisho %d %d %d\n",nen+1-1912,ga,pi);
				continue;
			}
		}

		if(nen>1912 && nen<1926){
			printf("taisho %d %d %d\n",nen+1-1912,ga,pi);
			continue;
		}

		if(nen==1926){
			if(ga<12){
				printf("taisho %d %d %d\n",nen+1-1912,ga,pi);
				continue;
			}else if(ga==12){
				if(pi<25){
					printf("taisho %d %d %d\n",nen+1-1912,ga,pi);
					continue;
				}else{
					printf("showa %d %d %d\n",nen+1-1926,ga,pi);
					continue;
				}
			}else{
				printf("showa %d %d %d\n",nen+1-1926,ga,pi);
				continue;
			}
		}
		
		if(nen>1926 && nen<1989){
			printf("showa %d %d %d\n",nen+1-1926,ga,pi);
			continue;
		}

		if(nen==1989){
			if(ga<1){
				printf("showa %d %d %d\n",nen+1-1926,ga,pi);
				continue;
			}else if(ga==1){
				if(pi<8){
					printf("showa %d %d %d\n",nen+1-1926,ga,pi);
					continue;
				}else{
					printf("heisei %d %d %d\n",nen+1-1989,ga,pi);
					continue;
				}
			}else{
				printf("heisei %d %d %d\n",nen+1-1989,ga,pi);
				continue;
			}
		}

		printf("heisei %d %d %d\n",nen+1-1989,ga,pi);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>


int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int difA = b - a;
	int difB = c - a;

if(difA < 0){
	difA *= -1;
}
if(difB < 0){
	difB *= -1;
}

if(difA > difB){
	printf("B");
}else{
	printf("A");
}



	return 0;
}

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

int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	if(a>0)
	{
		long long x=a;
		if(k>a)
		a=0;
		else
		a=a-k;
		k=k-x;
	}
	// cout<<k<<endl;
	if(b>0 && k>0)
	{
		if(k>b)
		b=0;
		else
		b=b-k;
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
num_of_ary0 = gets.to_i
ary0        = gets.split.map &:to_i
num_of_ary1 = gets.to_i
ary1        = gets.split.map &:to_i

answer = 0

ary1.each{ |n| if ary0.include?(n) then answer += 1 end }

puts answer



Measured memory_bytes: 7120
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var KX = ReadSplitInt();
            var K = KX[0];
            var X = KX[1];
            var min = X - (K - 1);
            var max = X + (K - 1);
            for (var i = min; i <= max; i++)
            {
                if (i == max)
                    Print(i);
                else
                    Print($"{i} ");
            }
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13396
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    flag = True
    pre = input()
    done = {pre}
    for _ in range(N - 1):
        now = input()
        if now[0] != pre[-1] or now in done:
            flag = False
        pre = now
        done.add(pre)
    if flag: print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();

		int prize = 0;
		if ( X == 1 || X == 2 || X == 3 ) {
			prize += (4 - X) * 100000;
		}
		if ( Y == 1 || Y == 2 || Y == 3 ) {
			prize += (4 - Y) * 100000;
		}
		if ( X == 1 && Y == 1 ) {
			prize += 400000;
		}
		
		System.out.println(prize);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int n,m,num[20],ans,q;
struct point{
	int a,b,c,d;
}p[60];
bool cmp(point A,point B){
	return A.d>B.d;
}
int getans(){
	int res=0;
	for(int i=1;i<=q;i++){
		if(num[p[i].b]-num[p[i].a]==p[i].c)
			res+=p[i].d;
	} 
	return res;
}
void dfs(int last,int step){
	if(step==n){
		ans=max(ans,getans());
		return;
	}
	for(int i=last;i<=m;i++)
		num[step+1]=i,dfs(i,step+1);
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++)
		scanf("%d%d%d%d",&p[i].a,&p[i].b,&p[i].c,&p[i].d);
	dfs(1,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x;
    if(x == 1)
    {
        cout << "Hello World";
        return 0;
    }
    cin >> y >> k;
    cout << y + k;
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n, m;
  cin >> n >> m;
  int k, a;
  int num[m+1] ={};
  for(int i=0; i<n; ++i){
    cin >> k;
    for(int j=0; j<k; ++j){
      cin >> a;
      num[a]++;
    }
  }

  int cnt =0;
  for(int i=0; i<=m; ++i){
    if(num[i]==n) cnt++;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3568
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void read_And_write(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void raushan_kumar(){
    int d=100,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n;cin>>n;
    while(d<n){
    	d=d*1.01;
    	ans++;
    }
    cout<<ans;
}

int32_t main()
{
    read_And_write();fast;int t=1;
    // cin>>t;
    while(t--){raushan_kumar();}
}

Measured memory_bytes: 3652
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC120C
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[100000];
  scanf(" %s", &s);
  for(i=0; s[i]!='\0'; ++i)
    cou=s[i]=='1' ? cou+1 : cou; //文字数
  cou=cou>i-cou ? i-cou : cou;
  printf("%d", 2*cou);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10005
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << :  << f << endl;
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
	
 	int n;
 	cin>>n;
 	n--;
 	cout<<(n*(n+1))/2;

	return 0;
}



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

int main() {
    string s;
    cin >> s;

    for (int bit = 0; bit < (1 << 3); bit++) {
        char ops[3] = {'+', '+', '+'};
        rep(i, 3) if (bit & (1 << i)) ops[i] = '-';
        int sum = s[0] - '0';
        rep(i, 3) {
            if (ops[i] == '+')
                sum += s[i + 1] - '0';
            else
                sum -= s[i + 1] - '0';
        }
        if (sum == 7) {
            cout << s[0];
            rep(i, 3) cout << ops[i] << s[i + 1];
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def saitankeiro(s,t):
  dx = t[0] - s[0]
  dy = t[1] - s[1]
  
  # loop 1
  for i in range(0,dy):
    print('U',end='')
  
  for i in range(0,dx):
    print('R',end='')
  
  for i in range(0,dy):
    print('D',end='')

  for i in range(0,dx):
    print('L',end='')
  
  #loop 2
  print('L',end='')
  for i in range(0,dy+1):
    print('U',end='')
  
  for i in range(0, dx+1):
    print('R',end='')
  
  print('D',end='')

  print('R',end='')
  for i in range(0,dy+1):
    print('D',end='')
  
  for i in range(0, dx+1):
    print('L',end='')
  
  print('U',end='')

sx, sy, tx, ty = list(map(int, input().split()))

saitankeiro([sx,sy], [tx, ty])

Measured memory_bytes: 4468
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;



long long i,j,k,N,K,ans,n,m,D[100001],S,Q,b,c;


int main()
{
  cin>>N;
  
  for(i=0;i<=100000;i++)
  {
    D[i]=0;
  }
  
  
  for(i=0;i<N;i++)
  {
    cin>>j;
    D[j]++;
  }
  S=0;
  for(i=1;i<=100000;i++)
  {
    S+=i*D[i];
  }
  
  cin>>Q;
  for(i=0;i<Q;i++)
  {
    cin>>b>>c;
    
    S+=-b*D[b]+c*D[b];
    
    D[c]+=D[b];
    D[b]=0;
    
    cout<<S<<endl;
  }

  
  
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]==s[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def euclidean(x, y):
    if y > x:
        x, y = y, x
    while y > 0:
        x_tmp = x
        y_tmp = y
        
        x = y_tmp
        y = x_tmp % y_tmp
    
    return x
        

xy = input().split()
x = int(xy[0])
y = int(xy[1])

print(euclidean(x, y))



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


def main():
    from collections import OrderedDict

    n, m = map(int, input().split())
    d = OrderedDict()
    ans = OrderedDict()

    for i in range(m):
        d[i] = tuple(map(int, input().split()))

    prev_pref = 0
    order = 1

    for key, value in sorted(d.items(), key=lambda x: x[1]):
        pref, year = value

        if pref == prev_pref:
            order += 1
        else:
            prev_pref = pref
            order = 1

        ans[key] = '{:0=6}'.format(pref) + '{:0=6}'.format(order)

    for key, value in sorted(ans.items(), key=lambda x: x[0]):
        print(value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92988
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;

char a[2100][2100];
int s[2100][2100],r[2100][2100],d[2100][2100];
int n,m,T;

int Qs(int x1,int y1,int x2,int y2){
	if(x1>x2||y1>y2)return 0;
	return s[x2][y2]+s[x1-1][y1-1]-s[x1-1][y2]-s[x2][y1-1];
}

int Qr(int x1,int y1,int x2,int y2){
	if(x1>x2||y1>y2)return 0;
	return r[x2][y2]+r[x1-1][y1-1]-r[x1-1][y2]-r[x2][y1-1];
}

int Qd(int x1,int y1,int x2,int y2){
	if(x1>x2||y1>y2)return 0;
	return d[x2][y2]+d[x1-1][y1-1]-d[x1-1][y2]-d[x2][y1-1];
}

int main(){
	int x1,y1,x2,y2;
	scanf("%d %d %d",&n,&m,&T);
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
		for(int j=1;j<=m;j++){
			a[i][j]-='0';
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
		}
	}for(int i=1;i<=n;i++)
		for(int j=1;j<m;j++){
			r[i][j]=r[i-1][j]+r[i][j-1]-r[i-1][j-1];
			if(a[i][j]&a[i][j+1])r[i][j]++;
		}
	for(int i=1;i<n;i++)
		for(int j=1;j<=m;j++){
			d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1];
			if(a[i][j]&a[i+1][j])d[i][j]++;
		}
	while(T--){
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		printf("%d\n",Qs(x1,y1,x2,y2)-Qr(x1,y1,x2,y2-1)-Qd(x1,y1,x2-1,y2));
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

vector<vector<LL>> zero;
vector<vector<vector<LL>>> one;

void mul(vector<vector<LL>> &a, vector<vector<LL>> &b){
  vector<vector<LL>> ans(3,vector<LL>(3,0));
  rep(i,3){
    rep(j,3){
      rep(k,3){
        ans[i][j]=(ans[i][j]+a[i][k]*b[k][j])%MOD;
      }
    }
  }
  b = ans;
}

void init(){
  zero={
    {1,2,1},
    {0,1,1},
    {0,0,1}
  };
  one = vector<vector<vector<LL>>>(30);
  one[0]={
    {2,2,1},
    {1,1,1},
    {1,0,1}
  };
  rep(i,29){
    one[i+1]=one[i];
    mul(one[i+1],one[i+1]);
  }
}

void powmul(int n, vector<vector<LL>> &v){
  int i=0;
  while(n){
    if(n&1) mul(one[i],v);
    i++;
    n>>=1;
  }
}

int main(){
  init();
  int n,m;
  cin >> n >> m;
  vector<int> x(m+1);
  x[0]=0;
  rep(i,m) cin >> x[i+1];
  vector<vector<LL>> a={
    {1,0,0},
    {0,1,0},
    {0,0,1}
  };
  repp(i,1,m+1){
    powmul(x[i]-x[i-1]-1,a);
    mul(zero,a);
  }
  powmul(n-x[m]-1,a);
  cout << (a[0][0]+a[0][1]+a[0][2])%MOD << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int l, r; cin >> l >> r;
	if (r - l >= 2019) {
		cout << "0\n";
		return 0;
	}
	else {
		int ans = 2019;
		for (int i = l; i <= r; i++) {
			for (int j = i + 1; j <= r; j++) {
				ans = min(ans, i*j % 2019);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] val = new int[3];
        for(int i = 0; i < val.length; ++i) {
            val[i] = sc.nextInt();
        }

        if(val[0] <= val[1] * val[2]){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef __int128 INT;
LL a,b,c;
void solve(INT N){
    FOR(i,1,3501){
        FOR(j,1,3501){
            INT n=i;
            INT h=j;
            INT U=N*n*h;
            INT D=4*n*h-N*(n+h);
            if(D>0&&U%D==0){
                INT w=U/D;
                if(w>=1&&w<=3500){
                    a=n;
                    b=h;
                    c=w;
                    return ;
                }
            }

        }
    }

}
int main(){
    LL N;
    cin>>N;
    solve(N);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  while( 1 ){
    map<int,int> d[1024];
    int n, m, a;
    int h, p, q;
    cin >> n >> m >> a;
    if( n == 0 && m == 0 && a == 0 ) break;
    for( int i=0; i<m; i++ ){
      cin >> h >> p >> q;
      d[h][p] = q;
      d[h][q] = p;
    }
    for( int i=1000; i>0; i-- ){
      if( d[i][a] != 0 ){
        a = d[i][a];
      }
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1392
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    string S;   cin >> S;
    int l, tmp;
    tmp = 0;
    l = S.length();
    for(int i=0; i<l; i++){
        tmp += S[i] - '0';
    }
    if(tmp%9==0)    print("Yes");
    else    print("No");
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	multiset<int> S;
	bool is_zero = true;
	rep(i, 0, N) {
		int a; cin >> a; S.insert(a);
		if(a != 0) is_zero = false;
	}
	if(is_zero) {
		cout << "Yes\n"; return;
	}
	if(N % 3 != 0) {
		cout << "No\n"; return;
	}
	vector<int> vec;
	rep(i, 0, 3) {
		int a = *S.begin();
		vec.pb(a);
		rep(j, 0, N / 3) {
			if(!S.count(a)) {
				cout << "No\n"; return;
			}
			S.erase(S.lower_bound(a));
		}
	}
	// debug(vec);
	if((vec[0] ^ vec[1]) == vec[2]) cout << "Yes\n";
	else cout << "No\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    string s;
    cin >> n >> s;
    
    for(int i = 0; i < (int)s.size(); i++){
        int addn = s[i] - 'A' + n;
        if(addn >= 26) addn -= 26;
        s[i] = addn + 'A';
    }
    
    cout << s << endl;
    

    
}


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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

struct Node {
  int minj, maxj, m, cnt;
  Node():minj(100), maxj(-100), m(0), cnt(0){}
};

int w, h;
string s[61];

int realoc[61][11];
bool c_realoc[61][11];

bool path[61][61];
Node node[61];
int node_w[61];

int root_id, m_id;

const int di[4] = {1, -1, 0, 0};
const int dj[4] = {0, 0, -1, 1};

void realocate(int i, int j, int id, char c) {
  s[i][j] = '.';
  realoc[i][j] = id;
  rep(z,4) {
    int ti = i + di[z], tj = j + dj[z];
    if (ti < 0 || tj < 0 || ti >= h || tj >= w) continue;
    if (s[ti][tj] == c) realocate(ti, tj, id, c);
  }
}

void setgraph(int i, int j, int id) {
  c_realoc[i][j] = false;
  node[id].m += j;
  if (id == root_id) {
    node[id].maxj = max(j+1, node[id].maxj);
  }
  rep(z,4) {
    int ti = i + di[z], tj = j + dj[z], t_id;
    if (ti < 0 || tj < 0 || ti >= h || tj >= w) continue;
    if (!c_realoc[ti][tj]) continue;
    t_id = realoc[ti][tj];
    // another piece
    if (t_id != -1 && t_id != id && z == 1) {
      path[id][t_id] = true;
      node[t_id].minj = min(tj, node[t_id].minj);
      node[t_id].maxj = max(tj+1, node[t_id].maxj);
      setgraph(ti, tj, t_id);
    }
    // same piece
    else if (t_id == id) {
      if (realoc[ti+1][tj] != -1 && realoc[ti+1][tj] != t_id) {
        node[t_id].minj = min(tj, node[t_id].minj);
        node[t_id].maxj = max(tj+1, node[t_id].maxj);
      }
      setgraph(ti, tj, id);
    }
  }
}

int calc_cnt(int id) {
  int res = 4;
  rep(i,m_id)
  if (path[id][i]) {
    res += calc_cnt(i);
  }
  return res;
}

int calc_m(int id) {
  int res = node_w[id];
  rep(i,m_id)
  if (path[id][i]) {
    res += calc_m(i);
  }
  return res;
}

void solve() {
  memset(path, false, sizeof path);
  memset(realoc, -1, sizeof realoc);
  memset(c_realoc, true, sizeof c_realoc);
  
  rep(i,h) cin>>s[i];
  
  // reallocate id
  int id = 0;
  rep(i,h)
  rep(j,w)
  if (s[i][j] != '.'){
    realocate(i, j, id, s[i][j]);
    // init
    node[id].m = 2;
    node[id].cnt = 4;
    node[id].minj = 100;
    node[id].maxj = -100;
    id++;
  }
  m_id = id;
  
  // set graph
  rep(i,w)
  if (realoc[h-1][i] != -1) {
    root_id = realoc[h-1][i];
    node[root_id].minj = i;
    setgraph(h-1, i, root_id);
    break;
  }
  
  // calc M
  rep(i,m_id) node_w[i] = node[i].m;
  
  rep(i,m_id) {
    int rec = node[i].m;
    node[i].m += calc_m(i);
    node[i].m -= rec;
    node[i].cnt += calc_cnt(i) - 4;
  }
      
  // check
  bool flag = true;
  rep(i,m_id) {
    int icnt = node[i].cnt, iminj = node[i].minj, imaxj = node[i].maxj;
    if (!(icnt * iminj < node[i].m && node[i].m < icnt * imaxj)) {
      flag = false; //break;
    }
  }
  
  if (!flag) cout<<"UN";
  cout<<"STABLE"<<endl;;
}

int main (int argc, char const* argv[]) {
  while (cin>>w>>h, w||h) {
    solve();
  }
  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> H(N);
    rep(i,N) cin >> H[i];
    
    int ans=0,mx=0;
    repd(i,1,N){
        if(H[i-1]>=H[i])ans++;
        else{
            chmax(mx,ans);
            ans=0;
        }
    }
    chmax(mx,ans);
  

    cout << mx <<endl;
    return (0);
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(void){
	string ohn,mezikara;
	int p,n,i,o,m;
	cin>>p;
	o=0;m=0;
	for(n=0;p>n;n=n+1){
		cin>>ohn>>mezikara;
		if(ohn>mezikara){
			o=o+3;
		}
		else if(ohn<mezikara){
			m=m+3;
		}
		else if(ohn==mezikara){
			o=o+1;
			m=m+1;
		}
	}
	cout<<o<<" "<<m<<endl;
	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

int ans = 0;

int dfs(int v, vec &a, mat &chi, int K){
    int d = 0;
    for(int c: chi[v]) Max(d, dfs(c, a, chi, K));
    if(v == 0) return ans;
    else if(a[v] != 0 && d == K - 1){
        ans++;
        return 0;
    }else return d + 1;
}

signed main(){

    int N, K; cin >> N >> K;
    vec a(N); readi(a);
    if(a[0] != 0){
        a[0] = 0;
        ans++;
    }

    mat chi(N);
    FOR(i, 1, N) chi[a[i]].push_back(i);

    cout << dfs(0, a, chi, K) << endl;
    
    return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>

int main()
{
    int A, B;
    int resp;
    int r_a, r_b;

    scanf("%d %d", &A, &B);

    if (A > B)
    {
        resp = A + (A - 1);
    }
    else if (B > A)
    {
        resp = B + (B - 1);
    }
    else
    {
        resp = (A + B);
    }

    printf("%d\n", resp);

    return 0;
}


Measured memory_bytes: 128