akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

#define kuriage(x)  x+=10-x%10;
using namespace std;
int main()
{
    int food[5];
    for(int i=0;i<5;i++)
    {
        cin>>food[i];
    }
    int near1 =0;//1以上の1に最も近い数探索用の変数
    for(int i=1;i<10;i++)
    {
        for(int j=0;j<5;j++)
        {
            if(food[j]%10==i)
            {
                near1=food[j];
                break;
            }
        }
        if(near1 != 0)
        {
            break;
        }
    }
    int count =0;//同じ数があることのリスク回避用変数
    for(int i=0;i<5;i++)
    {   
        if(food[i]%10==0)
        {
            continue;
        }
        else if(near1==food[i] &&count ==0)
        {
            count++;
        }
        else
        {
            kuriage(food[i])
        }
    }
    int sum=0;
    for(int i=0;i<5;i++)
    {
        sum+=food[i];
    }
cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
   
  int a,b,c,x,y,z;
   
  scanf("%d%d%d",&a,&b,&c);
   
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
   
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
   
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
   
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int G[100][100], d[100], f[100], num[100];
int t = 1;

void depth(int k){
	int i;

	d[k] = t++;
	for (i = 1; i <= num[k]; i++){
		if (d[G[k][i]] == 0)
		{
			depth(G[k][i]);
		}
	}
	f[k] = t++;
}

int main(void)
{
	int i, j, n;
	int u, k;

	scanf("%d", &n);

	//?????????
	for (i = 1; i <= n; i++){
		d[i] = f[i] = 0;
		for (j = 1; j <= n; j++){
			G[i][j] = 0;
		}
	}

	//??£??\???????????¨???
	for (i = 1; i <= n; i++){
		scanf("%d", &u);
		scanf("%d", &num[u]);
		for (j = 1; j <= num[u]; j++){
			scanf("%d", &G[u][j]);
		}
	}

	for (i = 1; i <= n; i++){
		if (d[i] == 0)
		{
			depth(i);
		}
	}

	for (i = 1; i <= n; i++){
		printf("%d %d %d\n", i, d[i], f[i]);
	}

	return 0;
}

Measured memory_bytes: 636
package main

import "fmt"

func main() {
	var n, a, b, sum, dig int
	var result = 0
	fmt.Scan(&n, &a, &b)
	for i := 1; i <= n; i++ {
		sum = 0
		j := i
		for {
			dig = j % 10
			sum += dig
			j /= 10
			if j == 0 {
				break
			}
		}
		if sum >= a && sum <= b {
			result += i
		}
		sum = 0
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
N = int(input())
A1 = map(int, input().split())
A2 = map(int, input().split()[::-1])

A1_sum = list()
sum = 0
for a1 in A1 :
    sum += a1
    A1_sum.append(sum)
A2_sum = list()
sum = 0
for a2 in A2 :
    sum += a2
    A2_sum.append(sum)
A2_sum = A2_sum[::-1]

max_score = 0
for i, a1_sum in enumerate(A1_sum) :
    if a1_sum + A2_sum[i] > max_score :
        max_score = a1_sum + A2_sum[i]

print(max_score)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define INF 1073741824
typedef pair<i64, i64> P;

int main() {
    i64 N; cin >> N;
    vector<i64> a(N);
    REP(i, N) cin >> a[i];

    map<i64, i64> dist_even;
    map<i64, i64> dist_odd;
    P top2_even[2], top2_odd[2];
    REP(i, N) {
        if (i % 2 == 0) {
            dist_even[a[i]]++;
            if (chmax(top2_even[0].S, dist_even[a[i]])) top2_even[0].F = a[i];
        } else {
            dist_odd[a[i]]++;
            if (chmax(top2_odd[0].S, dist_odd[a[i]])) top2_odd[0].F = a[i];
        }
    }

    top2_even[1].F = top2_even[0].F;
    top2_even[1].S = 0;
    for (auto it = dist_even.begin(); it != dist_even.end(); it++) {
        if ((*it).F == top2_even[0].F) continue;
        if (chmax(top2_even[1].S, (*it).S)) {
            top2_even[1].F = (*it).F;
        }
    }
    if (top2_even[1].F == top2_even[0].F) {
        top2_even[1].S = top2_even[0].S;
    }

    top2_odd[1].F = top2_odd[0].F;
    top2_odd[1].S = 0;
    for (auto it = dist_odd.begin(); it != dist_odd.end(); it++) {
        if ((*it).F == top2_odd[0].F) continue;
        if (chmax(top2_odd[1].S, (*it).S)) {
            top2_odd[1].F = (*it).F;
        }
    }
    if (top2_odd[1].F == top2_odd[0].F) {
        top2_odd[1].S = top2_odd[0].S;
    }

    i64 min_c = INF;
    REP(i, 2) REP(j, 2) {
        if (top2_even[i].F == top2_odd[j].F) continue;
        chmin(min_c, N - top2_even[i].S - top2_odd[j].S);
    }
    if (min_c == INF) {
        cout << N / 2 << endl;
    } else {
        cout << min_c << endl;
    }

    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main(void)
{
int n,a[55]={0},i,j,sum=0;
scanf("%d",&n);
  for(i=0;i<n;i++)
  {
  scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
  for(j=i+1;j<n;j++)
    sum+=a[i]*a[j];
  }
  printf("%d",sum);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int ci(char s){

	if(s=='a') return 0;
	if(s=='b') return 1;
	if(s=='c') return 2;
	if(s=='d') return 3;
	if(s=='e') return 4;
	if(s=='f') return 5;
	if(s=='g') return 6;
	if(s=='h') return 7;
	if(s=='i') return 8;
	if(s=='j') return 9;
	if(s=='k') return 10;
	if(s=='l') return 11;
	if(s=='m') return 12;
	if(s=='n') return 13;
	if(s=='o') return 14;
	if(s=='p') return 15;
	if(s=='q') return 16;
	if(s=='r') return 17;
	if(s=='s') return 18;
	if(s=='t') return 19;
	if(s=='u') return 20;
	if(s=='v') return 21;
	if(s=='w') return 22;
	if(s=='x') return 23;
	if(s=='y') return 24;
	if(s=='z') return 25;

	cout<< "ci error" <<endl;
}

int main(){

	int tmpt, tmps;
	string s, t;
	vector<int> tc(26, 0), sc(26, 0);

	cin>> s >> t;

	for(int i=0;i<t.size();i++){
		tmpt=ci(t[i]);
		tmps=ci(s[i]);

		if(tc[tmpt]==0){
			tc[tmpt]=26+tmpt-ci(s[i]);
		}else{
			if(tc[tmpt]!=26+tmpt-ci(s[i])){
				cout<< "No" << endl;
				return 0;
			}
		}
		if(sc[tmps]==0){
			sc[tmps]=26+tmps-ci(t[i]);
		}else{
			if(sc[tmps]!=26+tmps-ci(t[i])){
				cout<< "No" << endl;
				return 0;
			}
		}
	}

	cout<< "Yes" << endl;


}

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

int D,N;
int a[20];
LL Pow[20];

LL chec () {
	LL re = 1;
	for(int i = 1;i <= N / 2;++i) {
        LL yinzi = (10 - abs(a[i]));
		if(i == 1 && a[i] >= 0)
			yinzi--;
		re = re * yinzi;
	}
	if(N & 1) {
		LL yinzi = 10;
		if(N == 1)
			--yinzi;
		re = re * yinzi;
	}
	return re;
}

LL dfs (int u,LL lef) {
	if(u > N / 2) {
		if(lef != 0)
			return 0;
		return chec();
	}

	if(9 * (Pow[N - u] - Pow[u - 1]) < lef) {
		a[u] = 9;
		return dfs(u + 1,lef - 9 * (Pow[N - u] - Pow[u - 1]));
	}
	if(-9 * (Pow[N - u] - Pow[u - 1]) > lef) {
		a[u] = -9;
		return dfs(u + 1,lef + 9 * (Pow[N - u] - Pow[u - 1]));
	}
    if(lef % (Pow[N - u] - Pow[u - 1]) == 0) {
		a[u] = lef / (Pow[N - u] - Pow[u - 1]);
		return dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
    LL re = 0;
    a[u] = abs(lef) / (Pow[N - u] - Pow[u - 1]);
    if(lef > 0) {
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]++;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
	else {
		a[u] *= -1;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]--;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
	}
	return re;
}

int main () {
	//freopen("1.txt","r",stdin);
	scanf("%d",&D);
	Pow[0] = 1;
	for(int i = 1;i <= 18;++i)
		Pow[i] = Pow[i - 1] * 10;

	LL pr = 0;
	for(int i = 1;i <= 18;++i) {
		N = i;
		pr += dfs(1,D);
	}
	printf("%lld\n",pr);
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    vector<ll> time(5);
    ll speed[5] = {A,B,C,D,E};

    ll x = speed[0];
    REP(i,5){
        x = min(x,speed[i]);
    }
    
    ll ans = (N+x-1)/x+4;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 1000000
void simulate( int x, int y ){
    int R[MAX+1];
    rep(i, MAX+1) R[i] = -1;

    int q = x;
    int r;
    int i = 1;
    
    R[x] = 0;

    while(1){
	r = q % y;
	if ( r == 0 || R[r] > 0 ) {
	    if ( R[r] == -1 ) printf("%d %d\n", i-1, 0);
	    else printf("%d %d\n", R[r]-1, i-R[r]);
	    break;
	}
	R[r] = i;
	q = r*10;
	i++;
    }
}

main(){
    int x, y;
    while(1){
	scanf("%d %d", &x, &y);
	if ( x == 0 && y == 0 ) break;
	simulate(x, y);
    }
}

Measured memory_bytes: 4932
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

class BellmanFord {
 private:
  int _v;
  struct Edge {
    int fr, to;
    ll cost;
    Edge(const int &fr, const int &to, const ll &cost) {
      this->fr = fr;
      this->to = to;
      this->cost = cost;
    }
  };
  vector<Edge> _edges;
 public:
  explicit BellmanFord(const int &n);
  void add_edges(const int &fr, const int &to, const ll &cost);
  bool is_negative_loop(const int &t);
  ll solve(const int &s, const int &t);
};

BellmanFord::BellmanFord(const int &n) {
  this->_v = n;
}

void BellmanFord::add_edges(const int &fr, const int &to, const ll &cost) {
  _edges.emplace_back(fr, to, cost);
}

bool BellmanFord::is_negative_loop(const int &t) {
  int v = this->_v;
  size_t m = this->_edges.size();
  vector<ll> d(v, 0);
  for (int i = 0; i < v; ++i) {
    for (int j = 0; j < m; ++j) {
      Edge e = _edges[j];
      if (d[e.to] > d[e.fr] + e.cost) {
        d[e.to] = d[e.fr] + e.cost;
        if (i == v - 1 and e.to == t) return true;
      }
    }
  }
  return false;
}

ll BellmanFord::solve(const int &s, const int &t) {
  int v = this->_v;
  vector<ll> d(static_cast<unsigned long>(v), inf);
  size_t m = this->_edges.size();
  d[s] = 0;
  for (int j = 0; j < v; ++j) {
    bool isUpdate = false;
    for (int i = 0; i < m; ++i) {
      Edge e = _edges[i];
      if (d[e.fr] != inf and d[e.to] > d[e.fr] + e.cost) {
        d[e.to] = d[e.fr] + e.cost;
        isUpdate = true;
      }

    }
    if (not isUpdate) break;

  }
  return d[t];

}

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, m;
  ccin >> n >> m;

  BellmanFord bmf(n);

  rep(i, m) {
    ll a, b, c;
    ccin >> a >> b >> c;
    --a;
    --b;
    bmf.add_edges(a, b, -c);
  }
  if (bmf.is_negative_loop(n - 1))
    ccout << "inf" << endl;
  else
    ccout << -bmf.solve(0, n - 1) << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 384
import math

line = input()
a, b = [int(item) for item in line.strip().split(' ')]
g = max(a, b)
m = min(a, b)
m_sqrt = int(math.sqrt(m)) + 1

# 小さい方の数字の約数を見つける
m_divisors = []
for i in range(1, m_sqrt):
    if m % i == 0:
        m_divisors.append(i)
        if not i ** 2 == m:
            m_divisors.append(m // i)
m_divisors = sorted(m_divisors)

# 2つの数の公約数を見つける
common_divisors = []
for i in m_divisors:
    if g % i == 0:
        common_divisors.append(i)

# 互いに素なものだけを残す
disjoint_common_divisors = []
for c in common_divisors:
    # 1と2個目の要素は無条件で加えてよい
    if c == 1:
        disjoint_common_divisors.append(1)
        continue
    if disjoint_common_divisors == [1]:
        disjoint_common_divisors.append(c)
        continue
    # それ以外は判定が必要
    flag = True
    for d in disjoint_common_divisors[1:]:
        if c % d == 0:
            flag = False
            break
    if flag:
        disjoint_common_divisors.append(c)

print(len(disjoint_common_divisors))


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

int main(void){
  int n, i, j, k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    cout << " ";
    cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
import itertools
N = input()
l = list(map(int,input().split(" ")))
ruiseki = 0
ans = [0,0]
for pattern in [0,1]: #奇偶による+-を制御
    ruiseki = 0
    for i,num in enumerate(l):
        ruiseki += num
        if (i+pattern) %2 == 0:
            if ruiseki >= 0:
                ans[pattern] += ruiseki + 1
                ruiseki = -1
        else:
            if ruiseki <= 0:
                ans[pattern] +=1-ruiseki
                ruiseki = 1
print(min(ans))


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

int main(){
    int N,cnt=0,ans=10000;
    cin >> N;
    vector<long long> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    for(int i=0;i<N;i++){
        while(vec[i]%2==0){
            cnt++;
            vec[i]/=2;
        }
        ans=min(ans,cnt);
        cnt=0;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){	
	int n;
	while (cin >> n, n){
		int x[2] = {};
		while (n--){
			int a, b;
			cin >> a >> b;
			if (a == b) x[0] += a, x[1] += a;
			else x[a < b] += a + b;
		}
		cout << x[0] << " " << x[1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
def arith(item)
  case item
  when '+' then
    proc {|a, b| a + b}
  when '-' then
    proc {|a, b| a - b}
  when '*' then
    proc {|a, b| a * b}
  else
    raise
  end
end

def solve(items)
  stack = []
  items.reverse!
  until items.empty?
    item = items.pop
    if item.match(/[0-9]+/)
      stack.push item.to_i
    else
      v1 = stack.pop
      v2 = stack.pop
      stack.push(arith(item).(v2, v1))
    end
  end
  stack.pop
end
puts solve(gets.split(" "))



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()
#define inf 10000000000


using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/



int main(){
    IOS;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
        ll n;cin>>n;
        pair<ll,ll> p[n+1];
        FOR(i,n){
            cin>>p[i].F>>p[i].S;
        }
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(p[i].F==p[i].S){
                cnt++;
            }
            else{
                cnt=0;
            }
            if(cnt==3){
            cout<<"Yes\n";
            return 0;
            }
        }

        cout<<"No\n";
        return 0;
    }
    return 0;
} 

Measured memory_bytes: 3632
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

n = int(input())
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i, a[i])

ans = 1
for i in range(n):
    left = s.query(0, i)
    right = s.query(i+1, n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)


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

int main() {
	int n;
	cin >> n;
	vector<long long> a;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push_back(x);
		sum += x;
	}
	bool ans = true;
	if (n % 3 != 0) {
		if (sum == 0) ans = true;
		else ans = false;
	}
	else {
		sort(a.begin(), a.end());
		vector<int> b(3);
		for (int i = 0; i < 3; i++) {
			b[i] = a[n * i / 3];
			for (int j = 1; j < n / 3; j++) {
				if (a[n * i / 3 + j] != a[n * i / 3 + j - 1]) ans = false;
			}
		}
		if (b[0] != (b[1] ^ b[2])) ans = false;
		if (b[1] != (b[0] ^ b[2])) ans = false;
		if (b[2] != (b[0] ^ b[1])) ans = false;

		/*vector<int> count = { 0,0,0 };
		int j = 0;
		b[0] = a[0];
		for (int i = 1; i < n; i++) {
			if (a[i] == a[i - 1]) {
				count[j]++;
			}
			else if (j < 2) {
				j++;
				b[j] = a[i];
			}
			else ans = false;
		}
		if (count[0] != count[1]) ans = false;
		if (count[1] != count[2]) ans = false;
		if (b[0] != (b[1] ^ b[2])) ans = false;
		if (b[1] != (b[0] ^ b[2])) ans = false;
		if (b[2] != (b[0] ^ b[1])) ans = false;*/
	}


	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll s, c;
	cin >> s >> c;

	ll ans = 0;
	if ( (2 * s > c) )ans = c / 2;
	else {
		ans += s;
		c -= (2 * s);
		ans += c / 4;
	}
	cout << ans << endl;







	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

int n, m;

int dfs(int now, vii &g, int seen) {
  if(seen == (1<<n)-1) return 1;
  int res = 0;
  for(int x : g[now]) {
    if(seen & (1<<x)) continue;
    res += dfs(x, g, seen|(1<<x));
  }
  return res;
}

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

  cin >> n >> m;
  vii g(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int seen = 1<<0;
  int ans = dfs(0, g, seen);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << (b-a)/2 << endl;
    }else{
        ll ans = min(n-a, b-1);
        ans = min(ans, n-b+1+(n-(a+n-b+1))/2);
        ans = min(ans, a+(b-a-1)/2);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;

    int ans = 0;
    for(int a = 1; a < n; a++) {
        for(int b = 1; b < n; b++) {
            int c = n - a*b;
            if(c > 0) ans++;
            else break;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
object Main {
  def main(args: Array[String]): Unit ={
    import java.io.{
      BufferedReader,
      InputStreamReader,
    }
    val in = new BufferedReader(new InputStreamReader(System.in))

    val N = in.readLine().toLong;
    val InputArray = in.readLine().split(" ").map(x => BigDecimal(x));
    var answer = BigDecimal("1");

    if (InputArray.contains(0)) {
      println(0);
      return
    }

    for (i <- InputArray) {
      answer *= i;
    }

    if (answer > 1000000000000000000L) {
      println(-1);
      return;
    }

    println(answer);
  }
}


Measured memory_bytes: 80208
#include <stdio.h>
#include<stdlib.h>
int main()
{
	int x,y,z;
	scanf("%d%d", &x, &y);
	z = x + y;
	if (z>=10)
	{
		printf("error\n");
	}
	else
	{
		printf("%d\n",z);
	}
	system("pause");
}

Measured memory_bytes: 504
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 998244353;
int h[100010];
int dp[100010];
int N,K;

int main(void){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    dp[0] = INF;
    dp[1] = 0;
    
    for(int i = 2; i <= N; i++){
        for(int j = 1; j <= K; j++){
            if(j == 1){
                dp[i] = dp[i-j] + abs(h[i-1] - h[i-1-j]);
            }
            else if(i - j > 0){
                dp[i] = min(dp[i], dp[i-j] + abs(h[i-1] - h[i-1-j]) );
            }
        }
    }
    cout << dp[N] << endl;
    
}



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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

int n, len, cnt = 0, tot, a[kN], b[kN], d[kN], buc[kN], fa[kN];
bool vis[kN];
int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
void Visit(int x) { if(!vis[x]) ++tot; vis[x] = true; }
void Merge(int x, int y) {
	int f_x = Find(x), f_y = Find(y);
	if(f_x == f_y) return;
	Visit(f_x); Visit(f_y);
	fa[Find(x)] = Find(y); --tot;
}

int main() { 
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		rd(n);
		for(int i = 1; i <= n + 1; ++i) fa[i] = i;
		for(int i = 1; i <= n; ++i) rd(a[i]), d[i] = a[i], a[n + 1] ^= a[i];
		for(int i = 1; i <= n; ++i) rd(b[i]);
		d[n + 1] = a[n + 1]; std::sort(d + 1, d + n + 2);
		len = std::unique(d + 1, d + n + 2) - d - 1;
		for(int i = 1; i <= n + 1; ++i) {
			a[i] = std::lower_bound(d + 1, d + len + 1, a[i]) - d;
			++buc[a[i]];
			if(i <= n) {
				int buf = std::lower_bound(d + 1, d + len + 1, b[i]) - d;
				if(d[buf] != b[i]) return printf("-1\n"), 0;
				b[i] = buf; --buc[buf];
			}
		}
		for(int i = 1; i <= len; ++i) {
			if(buc[i] < 0) return printf("-1\n"), 0;
			if(buc[i] == 1) b[n + 1] = i;
		}
		for(int i = 1; i <= n; ++i)
			if(a[i] != b[i]) Merge(a[i], b[i]), ++cnt;
		printf("%d\n", cnt + tot - vis[a[n + 1]]);
	} return 0;
}

Measured memory_bytes: 8868
#include<stdio.h>

int main(){
  int a,b,c;
  char op;

  while(1){
    c=0;
    scanf("%d %c %d",&a,&op,&b);
    
    if(op == '?' ) break;
    else if(op == '+') {
      c=a+b;
      printf("%d\n",c);
    }
    else if(op == '-') {
      c=a-b;
      printf("%d\n",c);
    }
    else if(op == '*') {
      c=a*b;
      printf("%d\n",c);
    } 
    else if(op == '/') {
      c=a/b;
      printf("%d\n",c);
    }
  }
  return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n;
int p[25];
int main() {
	std::cin >> n;

	for (int i = 0; i < n; ++i)
		std::cin >> p[i];

	int num = 0;
	for (int i = 1, end = n - 1; i < end; ++i) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1] || p[i + 1] < p[i] && p[i] < p[i - 1])
			++num;
	}

	std::cout << num << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int H,W,k;
cin >> H >> W >> k;
vector<string> fi(H);
rep(h,H) cin >> fi[h];

int res = 0;
rep(S, bit(H)) {
    rep(T, bit(W)) {
        int cnt = 0;
        rep(h,H) {
            rep(w,W) {
                if(fi[h][w] == '.') continue;
                if(!(S & bit(h)) && !(T & bit(w))) cnt++;
            }
        }
        if(cnt == k) res++;
    }
}
cout << res << endl;
return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;cin >> S;
  if (S=="SAT") cout << 1 << endl;
  if (S=="FRI") cout << 2 << endl;
  if (S=="THU") cout << 3 << endl;
  if (S=="WED") cout << 4 << endl;
  if (S=="TUE") cout << 5 << endl;
  if (S=="MON") cout << 6 << endl;
  if (S=="SUN") cout << 7 << endl;
}

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

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start()
        {
            var N = long.Parse(Console.ReadLine());
            long min = long.MaxValue;
            for (int i = 0; i < 5; i++)
            {
                min = Math.Min(long.Parse(Console.ReadLine()), min);
            }

            Console.WriteLine(Math.Ceiling((decimal)N / min) + 4);
        }
    }
}




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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


int main(){
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
long long n,a[100000],ans=0,cnt=1;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1])cnt++;
        else ans+=cnt%2,cnt=1;
    }
    ans+=cnt%2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
int H,W;
int ans=LINF,a,b;
void f(int a,int b){
  int c=H*W-a-b;if(a<=0||b<=0||c<=0)return;
  ans=min(ans,max({a,b,c})-min({a,b,c}));
}
//main
signed main(){
  cin>>H>>W;
  for(int i=0;i<2;i++){
    //横線２本
    a=b=(H+1)/3*W;
    f(a,b);
    //縦１本->横１本
    for(int j=1;j<W;j++){//縦をどこで入れるか全探索
      a=j*H;b=H/2*(W-j);
      f(a,b);
    }
    swap(H,W);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    ll N;
    cin >> N;
    
    
    set<ll> A;
    A.insert(N);
    
    for (ll i = 2; i*i <= N; i++) {
        ll n = N;
        while (n%i == 0) {
            n /= i;
        }
        ll a = (n-i)/i;
        ll b = n-a*i;
        
        while (b >= i) {
            b -= i;
        }
    
        
        if(b == 1 && !A.count(i)){
            A.insert(i);
        }
    }
    
    
    for (ll i = 1; i*i < N; i++) {
        if((N-1)%i == 0) {
            if(!A.count((N-1)/i)){
                A.insert((N-1)/i);
            }
            
        }
    }
    
    //for (auto p : A) {
    //    cout << p << endl;
    //}

    if(N == 2) cout << 1 << endl;
    else cout << A.size() << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=max(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k+1:
        k = (k-1)//2
        seg[k] = max(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg[p])
        if q&1 == 1:
            res = max(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg[p])
    else:
        res = max(max(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = -1

#num:n以上の最小の2のべき乗
num =2**(n).bit_length()
seg=[ide_ele]*2*num

res = 0
s = [0]*(n+1)

update(p[0],0)
for i in range(1,n):
    k1 = query(p[i],n+1)
    if k1 != -1:
        update(p[k1],-1)
        k2 = query(p[i],n+1)
        s[i] = p[i]*(k1-k2) + s[k1]
        res += s[i]
        update(p[k1],k1)
    update(p[i],i)


ide_ele = -n
seg=[ide_ele]*2*num

s = [0]*(n+1)

update(p[-1],1-n)
for i in range(n-2,-1,-1):
    k1 = query(p[i],n+1)
    if k1 != -n:
        update(p[-k1],-n)
        k2 = query(p[i],n+1)
        s[i] = p[i]*(k1-k2)+s[-k1]
        res += s[i]
        update(p[-k1],k1)
    update(p[i],-i)

print(res)

Measured memory_bytes: 106644
import copy


def bubble_sort(n, A):
    for i in range(n):
        for j in reversed(range(i, n - 1)):
            if A[j + 1][1] < A[j][1]:
                A[j + 1], A[j] = A[j], A[j + 1]
    print(*A)


def selection_sort(n, B):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if B[j][1] < B[minj][1]:
                minj = j
        if minj > i:
            B[i], B[minj] = B[minj], B[i]
    print(*B)


def is_stable(C, S):
    result = "Stable"
    for i in range(1, 10):
        c = [n for n in C if str(i) in n]
        s = [n for n in S if str(i) in n]
        if not c == s:
            result = "Not stable"
            break
    print(result)


n = int(input())
A = input().split()
B = copy.copy(A)
C = copy.copy(A)
bubble_sort(n, A)
is_stable(C, A)
selection_sort(n, B)
is_stable(C, B)




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

typedef long long ll;

constexpr ll MAX = 1000010;
constexpr ll MOD = 1000000007;
ll fac[MAX + 1], facinv[MAX + 1];
// fac[i] = i!;
// facinv[i] = (i!)^-1 (mod MOD)

constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  // ll d = extgcd(b, a % b, x, y);
  // ll temp = x;
  // x = y;
  // y = temp - (a / b) * x;
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}

constexpr ll modinv(ll a, ll m) {
  // Need: gcd(a, m) = 1;
  // a^-1(mod. m)は
  // ax+my=gcd(a, m)=1;
  // を満たすxである。(それはそう,両辺をmodを法としてmodを考えてみよう)
  ll x = 0, y = 0;
  extgcd(a, m, x, y);
  return (x % m + m) % m;
}

constexpr void COMInit(ll *fac, ll *facinv) {
  // O(MAX log MOD)
  fac[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  facinv[MAX] = modinv(fac[MAX], MOD);
  for (int i = MAX - 1; i >= 0; i--) {
    facinv[i] = facinv[i + 1] * (i + 1) % MOD;
  }
}

ll comb(ll n, ll r) {
  //           n!
  // nCr = -----------
  //        r!*(n-r)!
  return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
}

int main() {
  COMInit(fac, facinv);
  ll x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  a %= MOD;
  b %= MOD;
  cout << comb((a + b) % MOD, a) << endl;
}


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {

            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            var N = vals[0];
            //var K = vals[1];
            

            var A = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            List<(long, int)> ps = new List<(long, int)>();
            for (int i = 0; i < N; i++)
            {
                ps.Add((A[i], i));
            }
            ps.Sort();
            ps.Reverse();
            List<List<long>> dp=new List<List<long>>();
            dp.Add (new List<long>());
            dp[0].Add(0);
            for (int i = 1; i <= N; i++)
            {
                dp.Add(new List<long>(new long[i + 1]));
                dp[i][0] = dp[i - 1][0] + ps[i-1].Item1 * Math.Abs((N - 1) - (i-1) - ps[i-1].Item2);
                for (int k = 1; k < i; k++)
                {
                    dp[i][k] = Math.Max(dp[i - 1][k - 1] + ps[i-1].Item1 * Math.Abs(ps[i-1].Item2 - (k - 1)),
                       dp[i - 1][k] + ps[i-1].Item1 * Math.Abs((N-1)-(i-1-k)-ps[i-1].Item2));
                }
                dp[i][i] = dp[i - 1][i - 1] + ps[i-1].Item1 * Math.Abs(ps[i-1].Item2 - (i - 1));
            }
            long ans = 0;
            for (int i = 0; i <= N; i++)
            {
                ans = Math.Max(ans, dp[N][i]);
            }
            Console.WriteLine(ans);


        }
       
       

    }
}



Measured memory_bytes: 54520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextLong();
            var b = cin.nextLong();
            var x = cin.nextLong();

            Console.WriteLine((b/x - a/x) + (a%x==0?1:0));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13268
let () = Scanf.scanf "%d\n" @@ fun n ->
  let array = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a in 
  Printf.printf "%d\n" @@
  Array.fold_left (fun acc a ->
    if a = 0 || acc = 0
    then 0
    else if acc = -1
    then -1
    else if acc <= 1000000000000000000 / a
    then acc * a
    else -1) 1 array

Measured memory_bytes: 6616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <set>
#include <map>
#include <random>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

long fact[101010];
long factinv[101010];

long mpow(long a, long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long d = mpow(a, n / 2);
        return d * d % MOD;
    }
    return a * mpow(a, n - 1) % MOD;
}

void make() {
    fact[0] = 1;
    REPI(i,1,101010) {
        fact[i] = fact[i-1] * i % MOD;
    }
    REP(i,101010) {
        factinv[i] = mpow(fact[i], MOD - 2);
    }
}

void check() {
    REP(i,101010) {
        if (fact[i] * factinv[i] % MOD != 1) {
            cout << "ERROR" << endl;
            exit(1);
        }
    }
}

long comb(long n, long k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * factinv[k] % MOD * factinv[n - k] % MOD;
}


int main() {
    make();
    long n, p;
    cin >> n >> p;
    long o = 0, e = 0;
    REP(i,n) {
        long a;
        cin >> a;
        if (a % 2) {
            o++;
        } else {
            e++;
        }
    }
    
    long ow = 0, ew = pow(2, e);
    
    if (p) {
        for (long i = 1; i <= o; i += 2) {
            ow += comb(o, i);
        }
        cout << ow * ew << endl;
        return 0;
    } else {
        for (long i = 0; i <= o; i += 2) {
            ow += comb(o, i);
        }
        cout << ow * ew << endl;
        return 0;
    }
}


Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
typedef long long LL;

int read()
{
    int x=0,flag=1;
    char c=getchar ();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=1e5+5;
int a[maxn],n;

int main()
{
    //freopen("input.txt","r",stdin);
    n=read();
    REP(i,1,n) a[i]=read();
    int ans=0,sum=0;
    REP(i,2,n)
    {
        if(a[i]<=a[i-1]) sum++,ans=max(ans,sum);
        else sum=0;
    }
    cout<<ans;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	optimizar_io
	int a, b; cin >> a >> b;
	cout << a * b << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<(a<=8&&b<=8?"Yay!":":(")<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int N=1e5+5;
int n,m,v,p;
ll a[N],sum[N];
bool check(int x){
	if(a[x]+m<a[p]) return 0;
	return 1ll*m*v<=1ll*(p-1ll)*m+1ll*(n-x+1)*m-1ll*(sum[x-1]-sum[p-1])+1ll*(a[x]+m)*(x-p);
}
signed main() {
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	int l=p,r=n,ans=p;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4792
n = int(input())
a = list(map(int,input().split()))
ans=0
ans2=0
for i in a:
  if i % 2 == 0:
    ans +=1
    if i % 3 == 0 or i % 5 == 0:
      ans2 +=1
if ans == ans2:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 9128