akhauriyash/Code-Regression huggingface dataset:
///
// File:  1368.cpp
// Author: ymiyamoto
//
// Created on Thu Nov 30 21:58:14 2017
//

#include <array>
#include <cstdint>
#include <iostream>

using namespace std;

uint32_t calc_e(array<uint32_t, 5> code, array<array<uint32_t, 10>, 10> matrix)
{
  uint32_t num = 0;
  for (uint32_t i = 0; i < code.size() - 1; i++) {
    num = matrix[num][code[i]];
  }
  return num;
}

bool check(array<uint32_t, 5> code, array<array<uint32_t, 10>, 10> matrix)
{
  uint32_t num = 0;
  for (uint32_t i = 0; i < code.size(); i++) {
    num = matrix[num][code[i]];
  }

  return num == 0;
}

int32_t main()
{
  array<array<uint32_t, 10>, 10> matrix;
  for (uint32_t i = 0; i < 10; i++) {
    for (uint32_t j = 0; j < 10; j++) {
      cin >> matrix[i][j];
    }
  }

  uint32_t count = 0;
  for (uint32_t i = 0; i < 10000; i++) {
    bool invalid = false;
    array<uint32_t, 5> code;
    code[0] = i / 1000;
    code[1] = (i - code[0] * 1000) / 100;
    code[2] = (i - code[0] * 1000 - code[1] * 100) / 10;
    code[3] = (i - code[0] * 1000 - code[1] * 100) % 10;
    code[4] = calc_e(code, matrix);

    for (uint32_t j = 0; j < 5; j++) {
      for (uint32_t k = 0; k < 10; k++) {
        array<uint32_t, 5> err(code);
        err[j] = k;
        if (err[j] != code[j]) {
          if (check(err, matrix)) {
            invalid = true;
          }
        }
      }
    }

    for (uint32_t j = 0; j < 5 - 1; j++) {
      array<uint32_t, 5> err(code);
      swap(err[j], err[j + 1]);
      if (err[j] != code[j] || err[j + 1] != code[j + 1]) {
        if (check(err, matrix)) {
          invalid = true;
        }
      }
    }

    if (invalid) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <sstream>
#include <queue>
using namespace std;
struct dot{
	long long int k,p,l,r;
};
int main(int argc, char** argv) {
	int n;
	while(cin>>n){
		int d[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				d[i][j]=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			a--;
			for(int j=0;j<b;j++){
				int c;
				cin>>c;
				d[a][c-1]=1;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<d[i][j];
				if(j<n-1)
					cout<<" ";
			}
			cout<<endl;
		}
			
				
	}
	return 0;
}


Measured memory_bytes: 3124
program main
	implicit none
	integer i,n
	integer(8) luc(0:86)
	luc(0)=2
	luc(1)=1
	read(*,*)n
	do i=2,n
		luc(i)=luc(i-1)+luc(i-2)
	enddo
	write(*,*)luc(n)
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
const ll cutoff = 10000000000000000;
int main(void) {
    ll n,m,p;
    cin>>n>>m>>p;
    ll d[n];
    const ll lim = 1LL<<60;
    ll a[m],b[m],c[m];
    bool mat[n][n]={};
    rep(i,n){
        d[i]=lim;
    }
    rep(i,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;c[i]-=p;c[i]*=-1;
        mat[a[i]][b[i]]=true;
    }
    d[0]=0;
    bool closed[n]={};
    queue<int> que;
    DEBUG{
        rep(i,n){
            rep(j,n){
                cout << mat[i][j] << " ";
            }
            cout << endl;
        }
    }
    rep(i,n+1){
        rep(j,m){
            if(d[a[j]]!=lim&&d[b[j]]>d[a[j]]+c[j]){
                d[b[j]] = d[a[j]]+c[j];
                if(i==n){
                    closed[b[j]]=true;
                    que.push(b[j]);
                }
            }
        }
    }
    DEBUG{
        rep(i,n){
            cout << closed[i]<<endl;
        }
    }
    while(!que.empty()){
        int cur = que.front();
        DEBUG{cout <<"front : "<< cur << endl;}

        rep(i,n){
            if(mat[cur][i]&&!closed[i]&&d[cur]<=cutoff){
                DEBUG{cout << i << endl;}
                que.push(i);
                closed[i]=true;
            }
        }
        que.pop();
    } 
    if(closed[n-1]==true){
        cout << -1 << endl;
    }else{
        cout << max(0LL,-d[n-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 6528
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

int main()
{
    int n;
    
    cin>>n;
    int a[n];
  
  
  for(int i=0;i<n;i++)
  {
   cin>>a[i]; 
  }
  
  int max1,max2;
  if(a[0]>a[1])
  {
      max1=0;
      max2=1;
  }
  else
  {
      max1=1;
      max2=0;
  }
  
  for(int i=2;i<n;i++)
  {
    if(a[i]>a[max1])
    {
        max2=max1;
        max1=i;
    }
    else if(a[i]>a[max2]) max2=i;
  }
    
   for(int i=0;i<n;i++)
   {
       if(i==max1)cout<<a[max2]<<endl;
       else cout<<a[max1]<<endl;
   }

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	char c;
	int deg = 90;
	P crt(0, 0);
	for (int x, y; cin >> x >> c >> y, (x | y) != 0; ) {
		P v = polar(1.0, deg * 3.141592 / 180);
		crt += v * (double)x;
		deg -= y;
	}
	cout << trunc(crt.real()) << endl << trunc(crt.imag()) << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, k;
	double maxSum = -INF;
	cin >> n >> k;
	vector<ll>p(n);
	vector<double>pp, sumAcc(n + 2, 0);
	rep(i, n)cin >> p[i];
	for (ll i = 0; i < n; i++) {
		pp.push_back((p[i] * (p[i] + 1)) / 2.0 / p[i]);
	}
	if (n == k)return cout << fixed << setprecision(10) << accumulate(all(pp), 0.0) << endl, 0;
	for (ll i = 1; i <= n; i++) {
		sumAcc[i] += pp[i - 1] + sumAcc[i-1];
	}
	auto getSum = [&](ll l ,ll r) {
		double rSum = sumAcc[r] - sumAcc[l];
		return rSum;
	};
	for (ll i = 1; i <= n - (k-1); i++) {
		maxSum = max(maxSum, getSum(i, i + k));
	}
	cout << fixed << setprecision(10) << maxSum << endl;
} 


Measured memory_bytes: 5492
S = [input() for _ in range(3)]

cnt = [0,0,0]
cp = 0

while True:
    cnt[cp] += 1
    if cnt[cp] == len(S[cp])+1:
        break
    
    if S[cp][cnt[cp]-1] == "a":
        cp = 0
    elif S[cp][cnt[cp]-1] == "b":
        cp = 1
    else:
        cp = 2

    
if cp == 0:
    print("A")
elif cp == 1:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int n;
    int c=0;
    scanf("%d",&n);
    int p[n];
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<i+2;j++){
            if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i+2]<p[i+1]&&p[i+1]<p[i])){
                c++;
            }
        }
    }
    printf("%d\n",c);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        List<Integer>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        
        // リストの作成
        for (int i = 0; i < n - 1; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            to[s].add(t);
            to[t].add(s); 
        }
        
        int[] first = new int[n];
        for (int i = 0; i < k; i++) {
            int p = sc.nextInt() - 1;
            int count = sc.nextInt();
            first[p] += count;
        }
        
        int[] last = new int[n];
        
        // visited[i][j]: 当該マスを既に通ったか否か
        boolean[] visited = new boolean[n];
        visited[0] = true;
        
        // steps = BFS((0, 0)→(h, w)までの最短経路の深さ)
        Queue<int[]> que = new ArrayDeque<int[]>();
        que.add(new int[]{0, 0});
        while (!que.isEmpty()) {
            int[] cur = que.poll();
            int p = cur[0];
            int count = cur[1] + first[p];
            last[p] = count;
            
            for (Integer q : to[p]) {
                if (!visited[q]) {
                    que.add(new int[]{q, count});
                    visited[q] = true;
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(last[i]);
            if (i != n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li h, w, m;

namespace std {
template<>
class hash<PI> {
public:
    size_t operator () ( const PI &p ) const { return p.F * 300300 + p.S;}
};
}

unordered_set<PI> st;

li cnt_x[300300];
li cnt_y[300300];

int main() {
    cin >> h >> w >> m;
    li mx = 0;
    li my = 0;
    rep(i, m) {
        li y, x;
        cin >> y >> x;
        st.insert({y, x});
        cnt_x[x]++;
        mx = max(mx, cnt_x[x]);
        cnt_y[y]++;
        my = max(my, cnt_y[y]);
    }
    li res = mx + my - 1;

    vector<li> xx;
    vector<li> yy;
    rep(i, h) {
        if (cnt_y[i + 1] == my) {
            yy.pb(i + 1);
        }
    }
    rep(i, w) {
        if (cnt_x[i + 1] == mx) {
            xx.pb(i + 1);
        }
    }

    for (auto && x : xx) {
        bool ok = false;
        for (auto && y : yy) {
            if (st.count({y, x}) == 0) {
                ok = true;
                res++;
                break;
            }
        }
        if (ok)break;
    }
    cout << res << endl;

    return 0;
}


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

int main() {
	int n; cin >> n;
	vector<set<int>> to(n);
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		to[a].insert(b);
		to[b].insert(a);
	}
	vector<int> c(n);
	rep(i, n) cin >> c[i];
	sort(c.rbegin(), c.rend());
	queue<int> que;
	rep(i, n) {
		if (to[i].size() == 1) que.push(i);
	}
	ll sum = 0;
	for (int i = 1; i < n; ++i)sum += c[i];
	vector<int> ans(n);
	while (que.size()) {
		if (!c.size()) break;
		int v = que.front();
		que.pop();
		ans[v] = c.back();
		c.pop_back();
		int nv = *to[v].begin();
		to[nv].erase(v);
		if (to[nv].size() == 1) {
			que.push(nv);
		}
	}
	cout << sum << endl;
	rep(i, n)cout << ans[i] << (i == n - 1 ? "\n" : " ");
	return 0;
}

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

int main()
{
  int n;
  for(;cin>>n;)
    {
      bool chack=true;
      int count=0;
      for(int i=0;i<n;i++)
	{
	  int p;
	  char x;
	  cin>>x>>p;
	  if(x=='(')
	    count+=p;
	  else
	    count-=p;
	  if(count<0)
	    chack=false;
	}
      if(count!=0)
	chack=false;
      if(chack)
	cout<<"YES"<<endl;
      else
	cout<<"NO"<<endl;
    }
}

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

int main() {
	long long n,a8,a9,a0;
	long long mod,ans;

	mod=1e9+7;

	cin >> n ;

	if (n<2) {
		cout << 0 << endl;
		return 0;
	}
	if (n<3) {
		cout << 2 << endl;
		return 0;
	}
	a8=1;
	a9=1;
	a0=1;
	rep(i,n){
		a0*=10;
		a8*=8;
		a9*=9;
		a0%=mod;
		a8%=mod;
		a9%=mod;
	}
	ans=a0+a8;
	ans%=mod;
	ans+=mod;
	ans-=a9;
	ans%=mod;
	ans+=mod;
	ans-=a9;
	ans%=mod;
	cout << ans  << endl;
	return 0;
}

Measured memory_bytes: 3600
a = int(input())
 
if a>=400 and a<600:print(8)
elif a>=600 and a<800:print(7)
elif a>=800 and a<1000:print(6)
elif a>=1000 and a<1200:print(5)
elif a>=1200 and a<1400:print(4)
elif a>=1400 and a<1600:print(3)
elif a>=1600 and a<1800:print(2)
elif a>=1800 and a<2000:print(1)

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

int main() {
	
	int n, m ,q;
	cin >>n>>m>>q;
	vector<vector<int>> a(n,vector<int>(n));
	for(int i=0; i<m; i++){
		int l,r;
		cin >> l >> r;
		a.at(--l).at(--r)++;
	}
	vector<vector<int>> dp(n,vector<int>(n));
	for(int w=0; w<n; w++){
		for(int i=0; i+w<n; i++){
			if(w==0) dp.at(i).at(i+w) = a.at(i).at(i+w);
			else dp.at(i).at(i+w) = dp.at(i+1).at(i+w) + dp.at(i).at(i+w-1) - dp.at(i+1).at(i+w-1) + a.at(i).at(i+w);
		}
	}
	for(int i=0; i<q; i++){
		int p1,q1;
		cin >> p1 >> q1;
		cout << dp.at(--p1).at(--q1) << endl;
	}
	
}

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

int main()
{
    ll n,y;
    cin >> n >> y;
    int X,Y,Z;
    bool flag = false;
    for( int x = 0; x <= n; x++ )
    {
        for( int y_ = 0; y_ <= n; y_++ )
        {
            if( y - ( 10000*x + 5000*y_ ) == 1000*( n - x - y_ ) && ( n - x - y_) >= 0 )
            {
                flag = true;
                X = x;
                Y = y_;
                Z = n - x - y_;
                break;
            }
        }
    }

    if( flag == false )
    {
        cout << "-1 -1 -1" << endl;
    }
    else if( flag == true )
    {
        cout << X << " " << Y << " " << Z << endl;
    }
    return 0;
}



Measured memory_bytes: 256
# after editorial

#
# PROP.
#   Subgraph of tree is forest.
#
# PROP.
#   For forest,
#     <num-verts> = <num-edges> + <num-components>
#   since for each component,
#     Vc = Ec + 1.
#
# PROP.
#   result = \sum_{i <= j} num_components(i, j)
#          = \sum num_verts(i, j) - num_edges(i, j)
#          = (\sum num_verts(i, j)) - (\sum num_edges(i, j))
#
#   \sum num_verts(i, j) = 1 + .. + (n-1) + n +
#                          1 + .. + (n-1) +
#                          ... +
#                          1
#                        = (tetrahedral number) = binom(n + 2, 3)
#
#   \sum num_edges(i, j) = \sum_e |{(i, j) | e in [i, j]}|
#                        = \sum_e (i0 * (n + 1 - j0))  (where e = (i0, j0))
#

def solve(ls, debug=0):
    n = len(ls) + 1
    term1 = ((n + 2) * (n + 1) * n) // 6  # 1st term in above PROP
    term2 = 0  # 2nd term in above PROP
    for i, j in ls:
        if i > j:
            i, j = j, i
        term2 += i * (n + 1 - j)

    return term1 - term2


def main(istr, ostr):
    n = int(istr.readline())
    ls = []
    for i in range(n - 1):
        v1, v2 = list(map(int, istr.readline().strip().split()))
        ls.append([v1, v2])
    result = solve(ls)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 39116
#include <iostream>
using namespace std;
const int N=55;
int n,a[N],h=0;//head
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(abs(a[i])>abs(a[h]))h=i;
    }
    cout<<2*n-1<<'\n';
    for(int i=0;i<n;i++){
        cout<<h+1<<' '<<i+1<<'\n';
    }
    if(a[h]>0){
        for(int i=0;i<n-1;i++){
            cout<<i+1<<' '<<i+2<<'\n';
        }
    }else{
        for(int i=n;i>1;i--){
            cout<<i<<' '<<i-1<<'\n';
        }
    }
}


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
int a[310][310];
int cc[310];
int en[310];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
            scanf("%d", &a[i][j]), --a[i][j];
        ++cc[a[i][0]];
    }
    int mx = 0;
    for (int i = 0; i < m; ++i)
        mx = max(mx, cc[i]);
    int ans = mx;
    for (int i = 0; i < m; ++i) {
        fill(cc, cc + m, 0);
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < m; ++k) {
                if (!en[a[j][k]]) {
                    ++cc[a[j][k]];
                    break;
                }
            }
        }
        int bst = -1;
        for (int j = 0; j < m; ++j) {
            if (en[j] == 0 && (bst == -1 || cc[bst] < cc[j]))
                bst = j;
        }
        ans = min(ans, cc[bst]);
        en[bst] = 1;
    }
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, X := ReadInt(), ReadInt()
	Ls := ReadInts(N)
	cnt := 1
	x := 0
	for _, l := range Ls {
		x += l
		if x <= X {
			cnt++
		} else {
			break
		}
	}
	fmt.Println(cnt)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
        a[i] -= i + 1;
    }

    sort(a, a + n);

    ll ans = 0;
    if (n % 2 == 1) {
        rep(i, 0, n) {
            ans += abs(a[i] - a[(1 + n / 2) - 1]);
        }
    } else {
        rep(i, 0, n) {
            ans += abs(a[i] - a[(n / 2) - 1]);
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    string s;
    cin >> s;
    LL ans=0;
    for(LL i=0; i<s.size(); i++){
        LL tmp=s[i]-'0';
        ans+=tmp;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1]) cout << a[2] << '\n';
    else cout << a[0] << '\n';
}

Measured memory_bytes: 256
q = int(input())
dict = {}
for i in range(q):
    a = input().split()
    if a[0] == "0":
        dict[a[1]] = a[2]
    elif a[0] == "1":
        if a[1] in dict:
            print(dict[a[1]])
        else:
            print(0)
    elif a[0] == "2":
        if a[1] in dict:
            del dict[a[1]]


Measured memory_bytes: 41864
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	p := scanInts(n)
	c := scanInts(n)

	ans := -1 << 60

	for i := 0; i < n; i++ {
		ss := make([]int, n)
		tt := make([]int, n)

		s := 0
		t := 0
		u := i

		for tt[p[u]-1] == 0 && p[u]-1 != i && t < k {
			u = p[u] - 1
			t++
			tt[u] = t
			s += c[u]
			ss[u] = s
			ans = max(ans, ss[u])
		}

		u = p[u] - 1
		if t != k {
			ans = max(ans, s+c[u])
		}
		cyc := t - tt[u] + 1
		tot := s - ss[u] + c[u]
		if tot > 0 {
			b := u
			ans = max(ans, ss[u]+tot*((k-tt[u])/cyc))

			for p[u]-1 != b {
				u = p[u] - 1
				ans = max(ans, ss[u]+tot*((k-tt[u])/cyc))
			}
		}
	}

	fmt.Fprintln(wr, ans)
}


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

using namespace std;

const int N = 1e5 + 3;
char a[N];
int n;

int main() {
	scanf("%s", a);
	n = int(strlen(a));
	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < n; ++i)
		if (a[i] == '0') cnt0++;
		else cnt1++;
	printf("%d", 2 * min(cnt0, cnt1));	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll A, B, H, M;
    cin >> A >> B >> H >> M;

    const double hh = static_cast<double>(H) + static_cast<double>(M) / 60.0;

    const double h = 2.0 * M_PI * (static_cast<double>(hh) / 12.0);
    const double m = 2.0 * M_PI * (static_cast<double>(M)  / 60.0);

    const double ax = static_cast<double>(A) * cos(h);
    const double ay = static_cast<double>(A) * sin(h);
    const double bx = static_cast<double>(B) * cos(m);
    const double by = static_cast<double>(B) * sin(m);

    const double dd = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
    printf("%.010f\n", sqrt(dd));

    return 0;
}


Measured memory_bytes: 3960
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n; rd(n);
  auto xs=new int[](n), ys=new int[](n);
  foreach(i; 0..n) rd(xs[i], ys[i]);

  foreach(i; 0..n){
    double[] theta;
    foreach(j; 0..n){
      if(i==j) continue;
      double dx=xs[j]-xs[i], dy=ys[j]-ys[i];
      theta~=atan2(dy, dx);
    }
    sort(theta);
    auto mxth=(theta[0]+PI*2)-theta[$-1];
    foreach(j; 1..(theta.length)) mxth=max(mxth, theta[j]-theta[j-1]);
    writefln("%.15f", max(0.0, mxth-PI)/(PI*2));
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 508
package main

import "fmt"

func main()  {
	var N uint64
	fmt.Scan(&N)

	var sum uint64
	sum = 0

	var i uint64

	for i = 1; i <= N; i++{
		if i % 3 !=0 && i % 5 != 0 {
			sum += i
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005,tt=1e9+7;
int n,c[maxn],las[maxn],f[maxn];
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&c[i]);
    f[0]=1;
    for (int i=1;i<=n;i++){
        f[i]=f[i-1];
        if (las[c[i]]!=i-1&&las[c[i]]) f[i]=(f[i]+f[las[c[i]]])%tt;
        las[c[i]]=i;
        //printf("%d %d\n",i,f[i]);
    }
    printf("%d\n",f[n]);
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n;
    cin >> n;
    char m;
    int x;
    char M[4]={'S','H','C','D'};
    int N[4][13];
    F(i,0,13){
        F(j,0,4){
            N[j][i]=i+1;
        }
    }
    F(i,0,n){
        cin >> m >> x;
        F(j,0,4) if(m==M[j]) N[j][x-1]=0;
    }
    F(i,0,4)
        F(j,0,13)
            if(N[i][j]>0) cout << M[i] << ' ' << N[i][j] << endl;
    return 0;
}


Measured memory_bytes: 3064
N,C,K=map(int,input().split())
T=[0]*N
for i in range(N):
    T[i]=int(input())
T.sort()

First_passengering=False
X=0
for k in range(N):
    t=T[k]

    if not First_passengering:
        X+=1
        First_passengering=True
        Dead_line=t+K
        Remain=C-1
    else:
        Remain-=1

    try:
        if T[k+1]>Dead_line:
            First_passengering=False
    except:
        pass

    if Remain==0:
        First_passengering=False

print(X)

Measured memory_bytes: 76360
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int counter;
	int a,b;
	long int total=0;
	cin>>counter;
	int i;
	for(i=0;i<counter;i++){
		cin>>a>>b;
		total=total+1+(b-a);
	}
	cout<<total<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // in
            int n = Integer.parseInt(sc.next());
            long[] l = new long[n];
            for (int i = 0; i < n; i++) {
                l[i] = Integer.parseInt(sc.next());
            }

            // calc
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    for (int k = j + 1; k < n; k++) {
                        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                        if (Math.abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j]) {
                            cnt++;
                        }
                    }
                }
            }
            System.out.println(cnt);
        }
    }
}

Measured memory_bytes: 36480
W, H, N = [int(x) for x in input().strip().split()]
x_min = 0
y_min = 0

for i in range(N):
    x, y, a = [int(x) for x in input().strip().split()]
    if a == 1 and x_min < x:
        x_min = x
    elif a == 2 and W > x:
        W = x
    elif a == 3 and y_min < y:
        y_min = y
    elif a == 4 and H > y:
        H = y
    
if x_min > W or y_min > H:
    print('0')
else:
    print((W - x_min)*(H - y_min))

Measured memory_bytes: 3064
n = int(raw_input())
l = [int(raw_input()) for _ in range(n)]
s = sum(l)
if s % 10 != 0:
    print s
else:
    l.sort()
    for m in l:
        if m % 10 != 0:
            print s - m
            break
    else:
        print 0


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],x,ans;
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        if(x>n)ans++;
        else a[x]++;
    }
    for(int i=1; i<=n; i++)
    {
        if(a[i]==0)continue;
        if(a[i]<i)ans+=a[i];
        else 
		if(a[i]>i)ans+=a[i]-i;
    }
    cout<<ans;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<string> check = {"SS", "SW", "WS", "WW"};
  string ans;
  for (string lst : check){
    ans = lst;
    for (int i=2; i<N; i++){
      if (ans[i-1] == 'S'){
        if (s[i-1] == 'o'){
          if (ans[i-2] == 'S') ans += 'S';
          else ans += 'W';
        }
        else {
          if (ans[i-2] == 'S') ans += 'W';
          else ans += 'S';
        }
      }
      else {
        if (s[i-1] == 'o'){
          if (ans[i-2] == 'S') ans += 'W';
          else ans += 'S';
        }
        else {
          if (ans[i-2] == 'S') ans += 'S';
          else ans += 'W';
        }
      }
    }
    bool flag1 = false, flag2 = false;
    if (ans[N-1] == 'S'){
      if (s[N-1] == 'o'){
        if (ans[0] == ans[N-2]) flag1 = true;
      }
      else {
        if (ans[0] != ans[N-2]) flag1 = true;
      }
    }
    else {
      if (s[N-1] == 'o'){
        if (ans[0] != ans[N-2]) flag1 = true;
      }
      else {
        if (ans[0] == ans[N-2]) flag1 = true;
      }
    }
    if (ans[0] == 'S'){
      if (s[0] == 'o'){
        if (ans[1] == ans[N-1]) flag2 = true;
      }
      else {
        if (ans[1] != ans[N-1]) flag2 = true;
      }
    }
    else {
      if (s[0] == 'o'){
        if (ans[1] != ans[N-1]) flag2 = true;
      }
      else {
        if (ans[1] == ans[N-1]) flag2 = true;
      }
    }
    if (flag1 && flag2){
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <stdlib.h>
 
long long int compare(const void *a, const void *b){
  return (*(long long int *)a)- (*(long long int *)b);
}
 
int main(){
  int n;
  scanf("%d",&n);
  long long int a[n];
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  qsort(a,n,sizeof(long long int),compare);
  
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      printf("NO");
      return 0;
    }
  }
  
  printf("YES");
  return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
	if (a>0) puts("Positive"); else
    if (a==0||(a<0&&b>0)) puts("Zero"); else
    if ((abs(b)-abs(a))%2!=0) puts("Positive");
	else puts("Negative");
	return 0;
}

Measured memory_bytes: 3144
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]

l = 0
r = max(H)
T = 1
while r > l+1:
    T = (l+r)//2
    c = 0
    for h in H:
        if h > B*T:
            c += (h-B*T)//(A-B)
            if (h-B*T)%(A-B) != 0:
                c += 1
    if c <= T:
        r = T
    else:
        l = T

if l == T:
    print(T+1)
else:
    print(T)

Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s, t;

bool check(string p, string q)
{
    map<char, int> mp;
    for (int i = 0; i < p.size(); i++)
    {
        mp[p[i]]++;
    }
    for (int i = 0; i < q.size(); i++)
    {
        if (mp[q[i]] == 0)
            return false;
    }
    return true;
}

int main()
{
    cin >> s >> t;
    vector<vector<ll>> moji(30);
    for (ll i = 0; i < s.size(); i++)
    {
        moji[s[i] - 'a'].push_back(i);
    }

    ll ans = 0;
    int M = s.size(), N = t.size();

    if (check(s, t) == false)
    {
        cout << -1 << endl;
        return 0;
    }

    int nowlen = 0, now = moji[t[0] - 'a'][0];
    for (int i = 1; i < N; i++)
    {
        int d;
        auto itr = lower_bound(moji[t[i] - 'a'].begin(), moji[t[i] - 'a'].end(), now + 1);
        if (itr == moji[t[i] - 'a'].end())
        {
            nowlen++;
            d = moji[t[i] - 'a'][0];
        }
        else
        {
            d = *itr;
        }
        now = d;
        //cout << t[i] << " " << *itr << endl;
    }

    ans = now + 1 + (ll)nowlen * (ll)M;

    cout << ans << endl;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    double num=0;
    for(int i=0; i<N; i++){
        double A;
        cin >> A;
        num+=1/A;
    }
    cout << 1/num;
}

Measured memory_bytes: 256
#include <stdio.h>

int isPrimeNum(int);

int main(){
  int n,x,i;
  int count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isPrimeNum(x)) count++;
    }

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

  return 0;
}

int isPrimeNum(int x){
  int i;

  if(x<2) return 0;
  else if (x==2) return 1;
  if (x%2==0) return 0;
  for(i=3;i*i<=x;i+=2){
    if(x%i==0) return 0;
  }
  return 1;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
int n,m,vis[100010],x,y,z;
vector<int> g[100010];
void dfs(int now){
	vis[now]=1;
	for(auto to:g[now]){
		if(!vis[to]){
			dfs(to);
		}
	}
	return ;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			ans++;
			dfs(i);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9216
from fractions import gcd
from functools import reduce
N = int(input())
a_lis = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a_lis)

result = 0
for i in range(N):
    result += (lcm - 1) % a_lis[i]
print(result)

Measured memory_bytes: 5372
#include <iostream>

using namespace std;

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

    bool flag = false;
    for (char c = 'a'; c <= 'z'; c++) {
        string tmp = s;
        tmp.push_back(c);

        if (tmp == t) flag = true;
    }
    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  int n, sum=0; cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
    sum+=v[i];
  }
  int a=sum/n;
  int l=0;
  rep(i,n){
    l+=pow(v[i]-a,2);
  }
  int r=0;
  rep(i,n){
    r+=pow(v[i]-a-1,2);
  }
  cout<<min(l,r);
}



Measured memory_bytes: 3664
import math
k=int(input())
m = list(map(int,input().split()))
a=m[0]
b=m[1]
c=0
for i in range(1000):
  j=i+1
  n=k*j
  if a<=n and n<=b:
    c=c+1
if c>0:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9192
import java.util.Scanner;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<String> dict = new HashSet<>();
		StringBuilder out = new StringBuilder();
		for (int i = 0; i < n; ++i) {
			String cmd = (String)sc.next();
			if (cmd.equals("insert")) {
				String str = (String)sc.next();
				dict.add(str);
			}
			if (cmd.equals("find")) {
				String str = (String)sc.next();
				out.append(dict.contains(str) ? "yes" : "no");
				out.append("\n");
			}
		}
		System.out.print(out);
	}
}


Measured memory_bytes: 234936
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
    
    else
    cout << "No" << endl;
}


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

#define ll long long
#define vt vector
#define pb push_back
#define sz(x) (int)(x).size()

int main(){
  int n;cin>>n;
  vt<int> H(n),dp(n);
  for(int i=0;i<n;i++) cin>>H[i];
  dp[0]=0,dp[1]=abs(H[1]-H[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2])); 
  }
  
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4008
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B; cin >> A >> B;
	int count = 0;
	rep(i, A, B + 1) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])
		{
			count++;;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>  
#include <math.h>
using namespace std;
 
int main(void){

  long long L;
  long long R;
  cin >> L >> R;
  int tmp=2019;
 
  if (R-L >= 2019){
  tmp =0;
  }  

  else{
    for (long long i = L;i <= R;++i){
      for (long long j = i+1;j <= R;++j){
        int diff =(i*j)%2019;
        if (tmp > diff && diff >=0){
          tmp = diff;
        }
      }
    }
  }  
  cout << tmp;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int change = 0;
		String s = scan.next();
		for(int i=0;i<s.length()/2;i++){
			if(!(s.charAt(i)==s.charAt(s.length()-1-i))){
				change++;
			}

		}
		System.out.println(change);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}
main(){
    int cnt[100000] = {},N,A;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        if((N%2) ^ (A%2)){
            cnt[A]++;
            if(cnt[A] <= 2)continue;
        }
        cout << 0 << endl;
        return 0;
    }
    if(cnt[0] > 1){
        cout << 0 << endl;
        return 0;
    }
    cout << powmod(2,N/2) << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int count = 0;
    for (auto c : s) {
        if (c == '1') {
            count++;
        }
    }
    cout << count << "\n";
}

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

string str1,str2;
int main()
{
	cin>>str1>>str2;

	int len1 = str1.length();
	int len2 = str2.length();

	if (len1 < len2)cout<<"LESS"<<endl;
	else
	if (len1 > len2)cout<<"GREATER"<<endl;
	else
	{
		for (int i = 0 ; i < len1; i++)
		{
			if (str1[i] > str2[i]) {cout<<"GREATER"<<endl; return 0 ;}
			else
			if (str1[i] < str2[i])
			{
				cout<<"LESS"<<endl;
				return 0;
			}

		}
		cout<<"EQUAL"<<endl;
	}


return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int x;
    cin>>x;
    int res = 100, cnt = 0;
    while (res<x)
    {
        res*=1.01;
        res=floor(res);
        cnt++;
    }
    cout<<cnt;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

int main()
{
    int a, b, i, k;
    cin>>a>>b>>k;

    vector<int> v;
    int z = max(a, b);

    for(i=0; i<=z; i++){
        if( (fmod(a,i) == 0) && (fmod(b, i) == 0) )
            v.push_back(i);
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    cout<<v[k-1];
}


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

int main() {
	int N;
	cin >> N;
	switch (N % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

void trace(int A[], int N){

  int i;
  for( i = 0; i < N; i++){
  if( i > 0) printf(" ");
  printf("%d", A[i]);
  }
 printf("\n");
}

void insertionsort(int A[], int N){
  int i, j, v;
  for( i = 1; i < N; i++){
   v = A[i];
   j = i - 1;
  while( j >= 0 && A[j] > v){
   A[j+1] =A[j];
   j--;
  }
  A[j+1] = v;
  trace(A, N);
 }
}

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for( i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionsort(A, N);

  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    int n; cin >> n;
    int l[2 * n]; rep(i, 2 * n) cin >> l[i];
    sort(l, l + 2 * n);
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split()))
#res = {}
res = 0
for i in range(len(ls)):
    for j in range(i+1,len(ls)):
        for k in range(j+1, len(ls)):
            a,b,c = ls[i],ls[j],ls[k]
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                #print((a,b,c))
                #if tuple(sorted((a,b,c))) not in res:
                    #res[tuple(sorted((a,b,c)))] = 0
                res += 1
#print(len(res))
print(res)

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

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

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    int cnt = 0;
    for (char x = 'a'; x <= 'z'; x ++) {
      bool left = false, right = false;

      for (int j = 0; j < i; j ++) {
        if (s.at(j) == x) {
          left = true;
        }
      }
      for (int j = i; j < n; j ++) {
        if (s.at(j) == x) {
          right = true;
        }
      }
      if (left && right) {
        cnt ++;
      }
    }
    if (ans < cnt) {
      ans = cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    k = read_int()
    n = 50
    q, r = divmod(k, n)
    a = [q + (n - 1)] * n
    for i in range(r):
        a[i] += n - r + 1
    for i in range(r, n):
        a[i] -= r
    print(n)
    print(*a)


main()


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

int maxcnt;
bool vis[100];
int graph_lens[100];
int graph[100][100];

void search(int i, int cnt, int ub) {
  if(maxcnt<cnt) maxcnt=cnt;
  vis[i] = true;
  int len = graph_lens[i];
  int *edg = graph[i];
  ub++;
  for(int j = 0; j < len; j++) {
    if(!vis[edg[j]])ub--;
  }
  if(maxcnt < ub) {
    cnt++;
    for(int j = 0; j < len; j++) {
      int to = edg[j];
      if(!vis[to]) search(to, cnt, ub);
    }
  }
  vis[i] = false;
}

int main() {
  while(true) {
    int n; scanf("%d", &n);
    if(n==0) break;
    fill(vis, vis+100, false);
    fill(graph_lens, graph_lens+100, 0);
    for(int i = 0; i < n; i++) {
      int a,b; scanf("%d%d", &a, &b); a--; b--;
      graph[a][graph_lens[a]++] = b;
      graph[b][graph_lens[b]++] = a;
    }
    maxcnt = 0;
    for(int i = 0; i < 100; i++) {
      search(i,1,n+1);
    }
    printf("%d\n", maxcnt);
  }
  return 0;
}

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

int main(void){
  char C;
  cin >> C;
  string alp = "abcdefghijklmnopqrstuvwxyza";
  char ans;
for (int h = 0; h < 26; h++){
  if (C == alp[h]){
    ans = alp[h+1];
  }
}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<float,float>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	vector<ll> a1(n);
	vector<ll> b1(n);
	vector<ll> c1(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	rep(i,n){
		ll temp=upper_bound(b.begin(),b.end(),a[i])-b.begin();
		a1[i]=temp;
	}
	rep(i,n){
		ll temp=upper_bound(c.begin(),c.end(),b[i])-c.begin();
		b1[i]=temp;
	}
	ll cnt=0;
	for(ll i=n-1;i>=0;i--){
		cnt+=n-b1[i];
		c1[i]=cnt;
	}
	ll ans=0;
	rep(i,n){
		if (a1[i]<=n-1){
				ans+=c1[a1[i]];
			//	cout<<j<<' '<<b1[j]<<endl;
			//	cout<<ans<<endl;
			}

	}

cout<<ans;




}


Measured memory_bytes: 4992
s = input()
t = input()


if len(s) > 10:
    print("No")
    exit()

if s != t[:-1] :
    print("No")
    exit()

alp = list('abcdefghijklmnopqrstuvwxyz')
for i in t:
    if i not in alp:
        print("No")
        exit()

print("Yes")




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

int main() {
	int x, y;

	for(int i=0; i<10000; i++) {
		cin >> x >> y;
		if(x==0 && y==0) {
			break;
		}
		if(x < y) {
			cout << x << " " << y << endl;
		}else if(x > y) {
			cout << y << " " << x << endl;
		}else {
			cout << x << " " << y << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i;
	char c[4];
	int p[4]={0};
	scanf("%s",c);
	for(i=0;i<3;i++)
	{
		if(c[i]=='a')
			p[0]=1;
		if(c[i]=='b')
			p[1]=1;
		if(c[i]=='c')
			p[2]=1;
	}
	if(p[0]==1&&p[1]==1&&p[2]==1)
		printf("Yes");
	else
		printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int cnta=0,cntb=0;
    for (int i=0;i<n;i++){
        if(s[i]=='A')
            cnta++;
        if(s[i]=='B')
            cntb++;
    }
    if (cnta >=2 && cntb>0)
        cout<<"Yes";
    else if (cntb>=2 && cnta>0)
        cout<<"Yes";
    else
        cout<<"No";



    return 0;
}


Measured memory_bytes: 256