akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <numeric>
//#include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a) ((int)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;

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

const int INF = 2e9;
const LL MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VI h(N);
  INPUT(h);
  VI dp(N+2, INF);
  dp[0] = 0;
  REP(int, i, N)
  {
    chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
    chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[N-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
int f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    string a,b;
    int aa,bb;
    cin>>a>>b>>aa>>bb;
    string c;
    cin>>c;
    if(c==a) aa--;
    if(c==b) bb--;
    cout<<aa<<' '<<bb<<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

llong N;
vector<vector<lpair>> A;

int main() {
  cin >> N;
  A.resize(N);
  for (auto &in: A) {
    llong a;
    cin >> a;
    for (int i = 0; i < a; i++) {
      llong x, y;
      cin >> x >> y;
      in.push_back(lpair(x-1, y));
    }
  }

  llong ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool ok = true;
    for (int j = 0; j < N; j++) {
      if (!((i>>j)&1)) continue;
      for (auto a: A[j]) {
        ok &= ((i&(1<<a.first)) > 0) == a.second;
      }
    }
    if (ok) {
      ans = max(ans, llong(__builtin_popcountll(i)));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define r 100005
int n;
ll mul(ll a ,ll b)
{
    return a*b%M;
}
vi g[r];
pii dfs(int u , int p)
{
    ll w=1;
    ll b=1;
    for(int v:g[u])
    {
        if(v!=p)
        {
            pii x=dfs(v,u);
           // cout<<"hi";
            w = mul(w , (x.ff + x.ss)%M)%M;
            b = mul(b, x.ss)%M;
        }
    }
    return {b,w};
}
void solve()
{
    cin>>n;
    loop(i,1,n)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    pii y = dfs(1,-1);
    cout<<(y.ff+y.ss)%M;
}
int main() {
	// your code goes here
	io;
	int t ;
    solve();
	return 0;
}


Measured memory_bytes: 12672
a[12][12];i,j,s,k;main(n){for(;scanf("%d",&n)*n;){for(i=++n;--i;*a[i]=0)for(j=n;--j;)scanf("%d",a[j]+i);for(i=n;i--;s=!printf("%5d\n",s))for(j=n;--j;*a[j]+=k,s+=k)printf("%5d",k=a[j][i]);}}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n, k;
    cin >> n >> k;

    if (k % 2 == 0)
    {
        long long t = n / k;
        if (n % k >= k / 2)
            t += 1;
        cout << (n / k) * (n / k) * (n / k) + t * t * t;
    }
    else
        cout << (n / k) * (n / k) * (n / k);
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int, input().split())
    s=m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1 or s <30:
        print('F')
    elif s <50 and r <50:
        print('D')
    elif s <65:
        print('C')
    elif s <80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 7612
import sys
n,X = map(int,input().split())

if not 1000*n <= X <= 10000*n:
  print(-1,-1,-1)
  sys.exit()
  
for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    if z < 0:
      break
    if 1000*z + 5000*y + 10000*x == X:
      print(x,y,z)
      sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 9116
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//Towns alogn a Highway
public class Main{
	
	int n;
	int[] rs;
	int[][] a;
	int[] p, c;
	Set<String> res;
	Map<String, Set<String>> ref;
	
	
	boolean check(){
		String key = trans(p);
		String mm = trans(c);
		if(ref.containsKey(key)){
			if(ref.get(key).contains(mm))return false;
			ref.get(key).add(mm);
			return true;
		}
		ref.put(key, new HashSet<String>());
		ref.get(key).add(mm);
		return true;
	}
	
	void dfs(int k, int l, int r){
		if(k<0){
			res.add(trans(p)); return;
		}
		if(c[k]==0){
			dfs(k-1, l, r); return;
		}
		if(!check())return;
		int d = k;
		if(p[0]==-1){
			a[0][n-1]=a[n-1][0]=d;
			p[0] = 0; p[n-1] = d; c[d]--; dfs(k, l+1, r-1);
			p[0] = d; p[n-1] = 0; dfs(k, l+1, r-1); c[d]++;
			return;
		}
		for(int i=0;i<n;i++){
			if(p[i]!=-1||(i!=l&&i!=r))continue;
			for(int j=0;j<n;j++){
				if(p[j]==-1)continue;
				int pos = p[j]-d;
				if(0<=pos&&pos<=400){
					boolean ok = true;
					for(int m=0;m<n;m++){
						if(p[m]==-1)continue;
						int dif = Math.abs(p[m]-pos);
						a[i][m]=a[m][i]=dif;
						c[dif]--;
						if(c[dif]<0)ok = false;
					}
					if(ok){
						boolean f = i==l;
						p[i] = pos; dfs(k, f?l+1:l, f?r:r-1); p[i] = -1;
					}
					for(int m=0;m<n;m++){
						if(p[m]==-1)continue;
						int dif = Math.abs(p[m]-pos);
						a[i][m]=a[m][i]=-1;
						c[dif]++;
					}
				}
				pos = p[j]+d;
				if(0<=pos&&pos<=400){
					boolean ok = true;
					for(int m=0;m<n;m++){
						if(p[m]==-1)continue;
						int dif = Math.abs(p[m]-pos);
						a[i][m]=a[m][i]=dif;
						c[dif]--;
						if(c[dif]<0)ok = false;
					}
					if(ok){
						boolean f = i==l;
						p[i] = pos; dfs(k, f?l+1:l, f?r:r-1); p[i] = -1;
					}
					for(int m=0;m<n;m++){
						if(p[m]==-1)continue;
						int dif = Math.abs(p[m]-pos);
						a[i][m]=a[m][i]=-1;
						c[dif]++;
					}
				}
			}
		}
	}
	
	String trans(int[] p){
		String r = "";
		int[] t = p.clone();
		Arrays.sort(t);
		for(int i=1;i<n;i++)r+=String.format("%03d", t[i]-t[i-1]);
		return r;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			ref = new HashMap<String, Set<String>>();
			a = new int[n][n];
			for(int[]b:a)Arrays.fill(b, -1);
			c = new int[401];
			rs = new int[n*(n-1)/2];
			int k = 0;
			for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
				int d = sc.nextInt();
				rs[k++] = d;
				c[d]++;
			}
			p = new int[n];
			Arrays.fill(p, -1);
			res = new HashSet<String>();
			dfs(400, 0, n-1);
			PriorityQueue<String> q = new PriorityQueue<String>();
			for(String t:res)q.add(t);
			while(!q.isEmpty()){
				String t = q.poll();
				List<Integer> l = new ArrayList<Integer>();
				for(int i=0;i<t.length();i+=3)l.add(Integer.parseInt(t.substring(i, i+3)));
				for(int i=0;i<l.size();i++)System.out.print(l.get(i)+(i==l.size()-1?"\n":" "));
			}
			System.out.println("-----");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    float   ans=0;
    if(h>w){
        ans = (n*1.0)/h;
    }else if(h<w){
        ans = (n*1.0)/w;
    }else{
        ans = (n*1.0)/h;
    }

    ans = ceil(ans);
    int a = (int)ans;
    cout<<a;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p){return id<p.id;}
};
static const int MAX =1000000;
static const int NIL = -1;
int n;
Point P[MAX];
Node T[MAX];
int np;
bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}
int makeKDTree(int l,int r, int d){
  if(!(l<r))return NIL;
  int mid=(l+r)/2;
  int t=np++;
  nth_element(P+l,P+mid,P+r,(d&1 ? lessY : lessX));
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,d+1);
  T[t].r=makeKDTree(mid+1,r,d+1);
  return t;
}
void find(int v,int sx,int tx,int sy,int ty,int d,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].location]);
  if(d%2==0){
    if(T[v].l!=NIL)if(sx<=x)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(x<=tx)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
  else{
    if(T[v].l!=NIL)if(sy<=y)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(y<=ty)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
}
int main(){
  int x,y;
  cin>>n;
  rep(i,n){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }
  np=0;
  int root=makeKDTree(0,n,0);
  int q;
  cin>>q;
  int sx,sy,tx,ty;
  vector<Point>ans;
  rep(i,q){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    rep(j,ans.size())printf("%d\n",ans[j].id);
    cout<<endl;
  }return 0;
}


Measured memory_bytes: 16500
#include <iostream>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    
    int lst[n+k];
    for(int i=0;i<n;i++){
        cin>>lst[i];
    }
    for(int i=n;i<n+k;i++){
        lst[i]=0;
    }
    
    int dp[n+k];
    dp[0]=0;
    for(int i=1;i<n+k;i++){
        dp[i]=1000000000;
    }

    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(lst[i]-lst[i+j]));
        }
    }
    
    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 1024
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)
int x[MAXN], y[MAXN];
int h, w, m;

int vmax(int a[MAXN], int s) {
	int ret = 0;
	for (int i = 1; i <= s; i++) {
		ret = max(ret, a[i]);
	}
	return ret;
}

vector<int> vmaxs(int a[MAXN], int v, int l) {
	vector<int> ret;
	for (int i = 1; i <= l; i++) {
		if (a[i] == v) {
			ret.push_back(i);
		}
	}
	return ret;
}

set<pair<int, int> > s;

int r[MAXN], c[MAXN];

void print(vector<int> v) {
	for (int i = 0; i < v.size(); i++) {
		cerr << v[i] << " ";
	}
	cerr << endl;
}

int cntx[MAXN];
int cnty[MAXN];

void fillv(vector<int> v, int a[MAXN]) {
	for (int i = 0; i < v.size(); i++) {
		a[v[i]] = 1;
	}
}

int main() {
	cout << fixed << setprecision(12);	
	cin >> h >> w >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
		r[x[i]]++;
		c[y[i]]++;
		s.insert(make_pair(x[i], y[i]));
	}
	int mx = vmax(r, h);
	int my = vmax(c, w);
	vector<int> vx = vmaxs(r, mx, h);
	vector<int> vy = vmaxs(c, my, w);
	fillv(vx, cntx);
	fillv(vy, cnty);
	//print(vx);
	//print(vy);
	int ret = mx + my;
	int cnt = 0;
	int rect = (ll) vx.size() * (ll) vy.size();
	if (rect <= m) {
		for (int i = 0; i < m; i++) {
			if (cntx[x[i]] && cnty[y[i]]) {
				cnt++;
			}
		}
	}
	if (cnt == rect) {
		ret--;
	}
	cout << ret << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 27824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int a;
	int b;
	public void run() {
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if((a*b)%2 == 0) System.out.println("Even");
		else System.out.println("Odd");
		sc.close();
	}
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a==1) a+=100;
    if(b==1) b+=100;
    
    if(a<b) puts("Bob");
    if(a==b) puts("Draw");
    if(a>b) puts("Alice");
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define PII pair<int ,int>

using namespace std;

int main() {
	char a; cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') cout << "vowel\n";
	else cout << "consonant\n";
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    string ls;
    REP(i,26)ls.push_back('a'+i);
    REP(i,26)ls.push_back('A'+i);
    REP(i,26)ls.push_back('a'+i);
    REP(i,26)ls.push_back('A'+i);

    while(1){
        int n;
        cin >> n;
        if(n==0)break;
        vector<int> k;
        REP(i,n){
            int t;
            cin >> t;
            k.push_back(t);
        }
        string s,ans="";
        cin >> s;
        REP(i,s.size()){
            if(s[i]<='Z'){
                ans.push_back(ls[s[i]-'A'+26*3-k[i%n]]);
            }
            else{
                ans.push_back(ls[s[i]-'a'+26*2-k[i%n]]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3188
#!/usr/bin/env python3
import math
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

b.sort(reverse=True)
m = max(a)
s = [0]
for i in range(N):
    b[i] = max(b[i], m)
    s.append(s[-1] + b[i])
    if s[-1] >= H:
        print(i + 1)
        break
else:
    print(max(N + 1, math.ceil((H - sum(b)) / m) + N))


Measured memory_bytes: 15144
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto m = readInt();
        if(m == 0) {
            return;
        }
        int[] a, b;
        foreach(i; iota(m)) {
            auto ab = readInts();
            a ~= ab[0];
            b ~= ab[1];
        }
        auto dp = new long[][](m+1, 1001);
        dp[0][0] = 1;
        foreach(i; iota(m)) {
            foreach(j; iota(1001)) {
                foreach(k; iota(b[i]+1)) {
                    if(j+k*a[i] > 1000) {
                        continue;
                    }
                    dp[i+1][j+k*a[i]] += dp[i][j];
                }
            }
        }
        auto g = readLong();
        foreach(i; iota(g)) {
            auto n = readInt();
            writeln(dp[m][n]);
        }
    }

}

Measured memory_bytes: 2616
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
 while(x->left != NIL) x = x->left;
 return x;
 
}
 
Node treeMaximum(Node x){
 
}
 
Node treeSearch(Node u, int k){
 
  if(u == NIL || k == u->key) return u;
 
  if(k < u->key) return treeSearch(u->left,k);
 
  else return treeSearch(u->right,k);
 
}
 
Node treeSuccessor(Node x){
 Node a;
 
 if(x->right != NIL) return treeMinimum(x->right);

 a = x->parent;
 while(a != NIL && x == a->right)
 {
  x = a;
  a = a->parent;
 }

 return a;
}
 
void treeDelete(Node z){
  Node p;
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left == NIL || z->right == NIL)  y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key; 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL)
    {
      y = x;
      if(z->key < x->key) x = x->left;
      else x = x->right;
    }
 
  z->parent = y;
 
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
 
}
 
void inorder(Node u){
 
  if(u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
   
}
 
void preorder(Node u){
 
  if(u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
 
  
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}


Measured memory_bytes: 20432
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	vector<int> dp(200001, 0);

	int N, K;
	cin >> N >> K;
	int A;
	for (int i = 0; i < N; i++) {
		cin >> A;
		dp[A] += 1;
	}

	sort(dp.begin(), dp.end(), greater<int>());

	int ans = 0;
	for (int i = K; i < 200000; i++) {
		ans += dp[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3796
/* kadai3_4
   nabe9393 */
 
#include<stdio.h>
 
int main(void){
  int number, divisor, answer=0; //answerの値で判断。
  scanf("%d", &number ); //入力
  for(divisor=1; divisor < 10; divisor++){ //初期化　条件判定　更新
    if(number % divisor == 0 && number / divisor < 10){ //割り切れて尚且つ商が１０未満
      answer++; //answerに１を足す
    }
  }
  if(answer != 0){ //answerが０ではない時がYes
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
return 0;
} 

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

int main() {
  int N;
  cin >> N;
  pair<int,int>data=make_pair(0,0);
  int y;
  cin >> y;
  data.first=y;
  int count=1;
  for(int i=1;i<N;i++){
    int x;
    cin >> x;
    if(x>data.first&&data.second==2){
      count++;
      data.second=0;
    }
    else if(x<data.first&&data.second==1){
      count++;
      data.second=0;
    }
    else if(x>data.first&&data.second==0){
      data.second=1;
    }
    else if(x<data.first&&data.second==0){
      data.second=2;
    }
    data.first=x;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MAXN 100005
vector<int>G[MAXN];
int deg[MAXN], dis[MAXN];
int n, m, ans;
int dfs(int i){
    if(dis[i] > 0) return dis[i];
    int &ret = dis[i];
    for(int j = 0; j < G[i].size(); j++){
        int k = G[i][j];
        ret = max(ret, dfs(k)+1);
    }
    return ret;
}
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        deg[v]++;
    }
    for(int i = 1; i <= n; i++)
        if(deg[i] == 0){
            dfs(i);
            ans = max(ans, dis[i]);
        }
    printf("%d\n", ans);
}

Measured memory_bytes: 11136
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b){
			System.out.println(c);
		}else if(a == c){
			System.out.println(b);
		}else{
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 23892
N = int(input())
# 出力結果[[(1, 1)], [(0, 1)], []]
evidences = [[] for _ in range(N)]
for i in range(N):
    # i人目の証言A個
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        # 例1だと人1,2,3だからリストで0,1,2になる、yは0が0番目で問題ない
        evidences[i].append((x - 1, y))

result = 0
# 8パターンあって順に縦に回してく
for i in range(1, 2 ** N):
    consistent = True
    # 例題1では3桁を横に回す
    for j in range(N):
      # 例えば3個目の010をj=1ずらして0なら続ける1のフラグが立ってたら次の処理
        if (i >> j) & 1 == 0:
            continue
        # 人2が本当ならそれぞれ証言と照らし合わせて
        for x, y in evidences[j]:
            # 010の場合x=1つまり人1がy=1に対してフラグは立ってないこれは間違い
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        # 2進数に変換して最初の0bを消す。フラグの数を数える
        result = max(result, bin(i)[2:].count('1'))
print(result)
# 000　全員嘘つき
# 001 アだけ
# 010 イだけ
# 011 アとイ
# 100 ウだけ
# 101 アとウ
# 110 イとウ
# 111 アイウ全員


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

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (!n)
    {
      break;
    }
    int h[101];
    for (int i=0; i<=n; i++)
    {
      cin >> h[i];
    }

    int def[4] = { h[1]-h[0],
		   h[2]-h[1],
		   h[3]-h[2],
		   h[4]-h[3] };

    if (def[0]==def[1] && def[1]==def[2] && def[2]==def[3])
    {
      for (int i=5; i<=n; i++)
      {
	if (h[i]-h[i-1] != def[0])
	{
	  cout << h[i] << endl;
	  break;
	}
      }
    }
    else if (def[0] == def[3])
    {
      cout << h[2] << endl;
    }
    else if (def[1] == def[2])
    {
      if (def[2] == def[3])
      {
	cout << h[0] << endl;
      }
      else
      {
	cout << h[4] << endl;
      }
    }
    else
    {
      if (def[0]+def[1] < def[2]+def[3])
      {
	cout << h[1] << endl;
      }
      else
      {
	cout << h[3] << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  long long int N,K;
  cin >> N >> K;
  int a[N],b[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  vector< pair<int,int> > v;
  for(int i = 0; i < N; i++) {
    v.push_back(pair<int, int>(a[i],b[i]));
  }

  sort(v.begin(),v.end());
  long long int sum = 0;
  for(int i = 0; i < N; i++) {
    if(sum + v[i].second >= K) {
      cout << v[i].first << endl;
      break;
    } else {
      sum += v[i].second;
    }
  }





}


Measured memory_bytes: 2168
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

const int N=100005;

struct node{
	int x,y;
}a[N];
int n,m,ans,x,y;
int cnt[N];
bool vis[N];

bool cmp(node a,node b){
	return a.x<b.x;
}

int main(){
	int i;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d%d",&a[i].x,&a[i].y);
	for (i=1;i<=n;i++) vis[i]=0,cnt[i]=1;
	vis[1]=1;
	for (i=1;i<=m;i++){
		x=a[i].x; y=a[i].y;
		cnt[x]--; cnt[y]++;
		vis[y]|=vis[x];
		if (!cnt[x]) vis[x]=0;
	}
	for (i=1;i<=n;i++) ans+=vis[i];
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main()
{
	vector<vector<int>> c(3, vector<int>(3));
	for (auto&& ci : c)
		for (auto&& cii : ci) cin >> cii;
	bool isValid = c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][1] - c[1][1] == c[0][2] - c[1][2]
		&& c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][1] - c[2][1] == c[1][2] - c[2][2]
		&& c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] - c[2][1]
		&& c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[1][1] - c[1][2] == c[2][1] - c[2][2];
	cout << (isValid ? "Yes" : "No") << endl;
	return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] l = cin.ArrayInt(n);

			Array.Sort(l);

			long ans = 0;
			for (int i = n - 1; i >= 0; i--) {
				for (int j = i - 1; j >= 0; j--) {
					int a = l[i];
					int b = l[j];
					int sub = a - b  + 1;
					int temp = BinarySearch(l, sub);
					ans += Math.Max(0, j - temp);
				}
			}

			Console.WriteLine(ans);
		}

		static int BinarySearch(int[] sl, int ai)
		{
			int left = -1;
			int right = sl.Count();

			while (right - left > 1) {
				int mid = left + (right - left) / 2;

				if (sl[mid] >= ai) {
					right = mid;
				} else {
					left = mid;
				}
			}

			return right;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, a[200001], q, i, b, c, sum=0, box[100001]={};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%lld", &a[i]);
        sum^=a[i];
        
    }
    
    for(i=1;i<=n;i++)
    {
        
        printf("%lld ", sum^a[i]);
    }
    
    
    return 0;
}

Measured memory_bytes: 5312
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod (1e9+7)

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#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--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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 string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    string S;
    cin >>S;
    int N=S.size();

    rep(i,N){
        S[i]='x';
    }    

    cout << S <<endl;


    return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.nextLine().toCharArray();
		char[] X = "CODEFESTIVAL2016".toCharArray();

		int count = 0;
		for (int i = 0; i < S.length; i++) {
			if (S[i] != X[i]) {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 9676
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int K;
  cin >> K;
  int odd = 0, even = 0;
  for(int i=1; i < K+1; i++){
    if(i % 2 == 0){
      odd++;
    } else {
      even++;
    }
  }

  cout << odd*even << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> x(n);
	for(int i = 0;i < n;i++)cin >> x[i];

	ll ans = 1e15;

	for(int i = 0;i < n;i++){
		if(i + k - 1 < n){
			ll dist = x[i+k-1] - x[i];
			dist += min(abs(x[i+k-1]),abs(x[i]));
			ans = min(ans,dist);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
S = input()

s_1 = int(S[0:2])
s_2 = int(S[2:])

YYMM = False
MMYY = False

if 1<=s_2<=12:
    YYMM = True
if 1<=s_1<=12:
    MMYY = True
    
if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int l = 0, r = n;
		int B = 1000000007;
		Map<Long, NavigableSet<Integer>> h = new HashMap<>();
		while (r - l > 1) {
			int m = (l + r) / 2;
			h.clear();
			boolean ok = false;
			long rh = 0;
			long t = 1;
			for (int i = 0; i < m; i++) {
				rh = rh * B + s[i];
				t *= B;
			}
			h.putIfAbsent(rh, new TreeSet<>());
			h.get(rh).add(m - 1);
			for (int i = 0; i + m < s.length; i++) {
				rh = rh * B + s[i + m] - t * s[i];
				if (h.containsKey(rh) && h.get(rh).floor(i) != null) {
					ok = true;
					break;
				}
				h.putIfAbsent(rh, new TreeSet<>());
				h.get(rh).add(i + m);
			}
			if (ok) l = m;
			else r = m;
		}

		System.out.println(l);
	}
}


Measured memory_bytes: 35264
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
 	}
	return res;
}


typedef struct _task {
	long day, mon;
}task;

bool comp_task(const task &a, const task &b) {
	printf("%d %d %d %d\n",a.day, a.mon, b.day, b.mon);
	bool res = true;
	if (a.day < b.day) res = true;
	else if (a.day > b.day) res = false;
	
	cout << res << endl;

	return res;
}

bool comp_task2(task a, task b) {
	return a.day < b.day;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N;
	cin >> N;

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

	int ans = A[0];
	for (int i = 1; i < A.size(); i++) {
		ans = gcd(ans, A[i]);
	}

	cout << ans << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 1272
/*---------------------------------------------
				Author:TanYz
---------------------------------------------*/
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <stack>
#include <ctime>
#include <set>
#include <vector>
#include <cstdlib>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mpii(a,b) make_pair(a,b)
const int INF=1<<30;
const int maxn=100000+2333;
const int mod=1000000007;

int n;
int a;
bool vis[maxn];

int main()
{
	//freopen("tan_in.txt","r",stdin);
	//freopen("tan_out.txt","w",stdout);
	scanf("%d",&n);
	int cnt=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(vis[a])cnt++;
		vis[a]=true;
	}
	if(cnt & 1)printf("%d\n",n-cnt-1);
	else printf("%d\n",n-cnt);
	return 0;
}





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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[505050];

ll mo=1000000007;
ll ret;
vector<int> id[1<<20];

template<class V, int ME> class BIT_r {
public:
	V bit[2][1<<ME];
	BIT_r(){clear();};
	void clear() {ZERO(bit);};
	
	void update(int entry, V val0, V val1) {
		entry++;
		while(entry <= 1<<ME) (bit[0][entry-1]+=val0)%=mo, (bit[1][entry-1]+=val1)%=mo, entry += entry & -entry;
	}
	V total(int entry) {
		int e=entry++;
		V v0=0,v1=0;
		while(entry>0) (v0+=bit[0][entry-1])%=mo, (v1+=bit[1][entry-1])%=mo, entry -= entry & -entry;
		return ((e*v0+v1)%mo+mo)%mo;
	}
	void add(int L, int R, V val) { // add val to L<=x<=R
		update(L,val,-val*(L-1)%mo);
		update(R+1,-val,val*R%mo);
	}
};
BIT_r<ll,21> bt;

ll dp[2];
ll V[505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int tot=0;
	id[0].push_back(0);
	FOR(i,N) {
		cin>>A[i];
		tot^=A[i];
		id[tot].push_back(i+1);
	}
	
	if(tot==0) {
		ll ret=1;
		FOR(i,id[0].size()-2) ret=ret*2%mo;
		bt.add(0,0,1);
		for(i=1;i<1<<20;i++) if(id[i].size()) {
			FORR(j,id[i]) {
				x=lower_bound(ALL(id[0]),j)-id[0].begin();
				V[j]=bt.total(x-1);
				bt.add(x,1<<20,V[j]);
			}
			ret+=bt.total(1<<20)-bt.total((1<<20)-1);
			FORR(j,id[i]) {
				x=lower_bound(ALL(id[0]),j)-id[0].begin();
				bt.add(x,1<<20,mo-V[j]);
			}
		}
		cout<<(ret%mo+mo)%mo<<endl;
	}
	else {
		dp[0]=1;
		x=0;
		FOR(i,N) {
			x^=A[i];
			if(x==tot) (dp[1]+=dp[0])%=mo;
			if(x==0) (dp[0]+=dp[1])%=mo;
		}
		cout<<dp[0]<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 73076
#include <bits/stdc++.h>
using namespace std;
long int h[200000];
int main(){
  long int n, k, ans = 0;
  cin >> n >> k;
  for(long int i = 0;i < n;i++){
    cin >> h[i];
  }
  sort(h, h + n);
  if(k >= n){
    cout << 0 << endl;
    return 0;
  }
  for(long int i = 0;i < (n - k);i++){
    ans += h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
n = gets.to_i
w = gets.chomp.split.map(&:to_i)
(1..n - 1).each do |i|
  w[i] += w[i - 1]
end
res = 10000
(0..n - 2).each do |i|
  res = [res, (w[i] - (w[n - 1] - w[i])).abs].min
end
puts res

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main () {
	long n, a, b;
	cin >> n >> a >> b;
	long passed=0;
	long passed2=0;
	string s; cin >> s;
	for (int i=0; i<(int)s.length(); i++) {
		if (s[i] == 'a' and passed<a+b) {
			cout << "Yes\n"; passed++;
		} else {
			if (s[i] == 'b' and passed<a+b and passed2<b) {
				cout << "Yes\n";
				passed++;
				passed2++;
			} else cout << "No\n";
		}
	}

} 

Measured memory_bytes: 3752
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

template<class T>T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a/gcd(a,b)*b;}

int MAX=1000000;
int N;
int A[1000000];

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

    vector<int> cnt(MAX+1);
    rep(i,N) cnt[A[i]]++;

    bool flag=true;
    for(int i=2;i<=MAX;i++){
        int sum=0;
        for(int j=i;j<=MAX;j+=i){
            sum+=cnt[j];
        }
        if(sum>1){
            flag=false;
            break;
        }
    }
    if(flag){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    
    int g=0;
    rep(i,N) g=gcd(g,A[i]);
    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 11140