akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];
  //reverse(s.begin(),s.end());

  Int ans=0;
  const Int INF = 1e8;
  for(Int x=0;x+1<w;x++){
    auto cost=make_v<Int>(h+2,h+2);
    fill_v(cost,INF);
    for(Int i=0;i<=h;i++){
      cost[i][0]=0;
      cost[0][i]=0;
      for(Int j=0;i+j<h;j++){
	chmin(cost[i+j+1][j+1],cost[i+j][j]+(s[i+j][x]==s[j][x+1]));
	chmin(cost[j+1][i+j+1],cost[j][i+j]+(s[j][x]==s[i+j][x+1]));
      }
    }
    auto dp=make_v<Int>(h+2,h+2);
    fill_v(dp,INF);
    dp[h][h]=0;
    for(Int i=h;i>=0;i--){
      for(Int j=h;j>=0;j--){
	chmin(dp[i][j],dp[i][j+1]+cost[i][j+1]);
	chmin(dp[i][j],dp[i+1][j]+cost[i+1][j]);
      }
    }
    ans+=dp[0][0];
  }

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


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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)




int n,m;

ll x[1000],y[1000],z[1000];

ll solve(ll a,ll b, ll c){
  ll dp[1001][1001];
  REP(i,1001)REP(j,1001) dp[i][j] = LLONG_MIN;
  REP(i,1001) dp[i][0] = 0;
  REP(i,n){
    ll q = a*x[i]+b*y[i]+c*z[i];
    REP(j,n){
      if(dp[i][j]!=LLONG_MIN){
        dp[i+1][j+1] = max(dp[i][j+1],dp[i][j]+q);
      }
    }
  }
  return dp[n][m];
}


int main(){
  cin >> n >> m;
  REP(i,n) cin >> x[i] >> y[i] >> z[i];
  ll ans = LLONG_MIN;
  FOR(i,-1,2)FOR(j,-1,2)FOR(k,-1,2){
    if(i==0||j==0||k==0) continue;
    ans = max(ans,solve(i,j,k));
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
a=sorted(list(map(int,input().split())))
x=0
i=(a[1]-a[0])//2
x+=i
a[1]-=i*2
a[2]-=i*2
i=(a[2]-a[1])
a[2]-=i
x+=i
print(x+sum(a)-a[0]*3)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        String x = in.next();
        String y = in.next();
        int cnt = 0;
        for (int i = 0; i < x.length(); i++) {
            
            if (x.charAt(i) == y.charAt(i)) {
                cnt++;
            }
            
        }
        System.out.println(cnt);
        
    }
    
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

vector<int> alpha(26,0);

for(int index = 0 ;index <s.size();index++)
{
    alpha[s[index]-'a']++;
}
for(int index =0;index<26;index++)
    if(alpha[index]%2)
{
    cout<<"No"<<endl;
    return 0;
}
cout<<"Yes"<<endl;
 return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;

const long long mod = 1e9+7;

struct rest{
    int number;
    string str;
    int point;
};

int main(){
	int n;
    rest* array;
    cin >> n;

    array = new rest[n];

    for(int i = 0; i < n; i++){
        cin >> array[i].str >> array[i].point;
        array[i].number = i + 1;
    }

    sort(array, array+n, [](const rest& x, const rest& y){
        if(strcmp(x.str.c_str(), y.str.c_str()) == 0) return x.point > y.point;
        else return strcmp(x.str.c_str(), y.str.c_str()) < 0;
    });

    for(int i = 0; i < n; i++){
        cout << array[i].number << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> S = new HashSet<String>();      
        for (int i=0; i<N; i++) {
        	S.add(sc.next());
        }        
		System.out.println(S.size());
	}
}

Measured memory_bytes: 71728
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String a = sc.next();
                String b = sc.next();
                String c = sc.next();
                sc.close();
                if(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) System.out.println("YES");
                else System.out.println("NO");
        }
}//0=48
 //a=97 a -> +26 = 123
//鶏になれ

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

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = 0;
    int x;
    int f;
    char c;
    string before;

    for(int i=0;i<q;i++){
        cin >> x;
        if(x==1){
            rev = !rev;
        }
        else{
            cin >> f >> c;
            if(f==1 and !rev){
                before += c;
            }
            else if(f==1 and rev){
                s += c;
            }
            else if(f==2 and !rev){
                s += c;
            }
            else{
                before += c;
            }
        }
    }

    reverse(before.begin(),before.end());
    before += s;
    auto itr=before.begin();
    auto end=before.end();
    if(!rev){
        cout << before << endl;
    }
    else{
        for(auto itr=before.rbegin();itr!=before.rend();itr++){
            cout << *itr;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1128
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
int f[maxn],g[maxn],num[maxn],a[maxn],h[maxn],go[maxn],nxt[maxn],d[maxn];
int bz[maxn];
int i,j,k,l,r,s,t,n,m,tot,ans;
bool czy;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
bool pd(int x){
	if (d[x]>1) return 0;
	bz[x]=1;
	if (!d[x]) return 1;
	int t=h[x];
	bool gjx=pd(go[t]);
	g[x]=g[go[t]]+1;
	return gjx;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&a[i]);
		d[a[i]]++;
		if (d[a[i]]>2){
			printf("0\n");
			return 0;
		}
		add(a[i],i);
	}
	ans=1;
	fo(i,1,n)
		if (!bz[i]){
			j=i;
			while (!bz[j]){
				bz[j]=1;
				j=a[j];
			}
			while (bz[j]==1){
				bz[j]=2;
				j=a[j];
			}
			k=j;
			czy=1;
			s=0;
			while (1){
				s++;
				if (d[j]>1){
					czy=0;
					t=h[j];
					while (t){
						if (bz[go[t]]!=2){
							l=go[t];
							break;
						}
						t=nxt[t];
					}
					if (!pd(l)){
						printf("0\n");
						return 0;
					}
					g[j]=g[l]+1;
				}
				j=a[j];
				if (j==k) break;
			}
			if (czy){
				num[s]++;
				continue;
			}
			while (d[j]==1) j=a[j];
			k=j;s=0;
			while (1){
				j=a[j];
				s++;
				if (d[j]>1){
					if (g[j]>s){
						printf("0\n");
						return 0;
					}
					else if (g[j]<s) ans=(ll)ans*2%mo;
					s=0;
				}
				if (j==k) break;
			}
		}
	fo(i,1,n){
		if (i==1) k=1;
		else if (i%2==1) k=2;
		else k=1;
		f[0]=1;
		fo(j,1,num[i]){
			f[j]=(ll)f[j-1]*k%mo;
			if (j>=2) (f[j]+=(ll)f[j-2]*(j-1)%mo*i%mo)%=mo;
		}
		ans=(ll)ans*f[num[i]]%mo;
	}
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 4480
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/



void proc() {
	LOAD(int, N);
	LOAD(int, K);
	cout << N + 1 - K << endl;
}


#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i < n; i++)
#define per(i,a,n) for (int i=n-1; i >= a; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> xplusy;
    vector<int> xminusy;
    rep(i,0,N){
        int x , y;
        cin >> x >> y;
        xplusy.pb(x+y);
        xminusy.pb(x-y);
    }
    sort(all(xplusy));
    sort(all(xminusy));
    cout << max(xplusy.back() - xplusy[0],xminusy.back() - xminusy[0] ) << endl;
}

Measured memory_bytes: 5032
#include<iostream>
#include<string>
using namespace std;
 
int main() {
  int N,M;
  int limit;
  int start;
  bool flag=false;
  cin>>N;
  cin>>M;
  if(M==0){
      if(N==1){
      cout<<"0";
  }else if(N==2){
      cout<<"10";
  }else{
      cout<<"100";
  } 
      exit(0);
  }
  int S[M];
  char C[M];
  for(int i=0;i<M;i++){
    cin>>S[i];        
    cin>>C[i];
  }
  if(N==1){
      start=0;
      limit=10;
  }else if(N==2){
      start=10;
      limit=100;
  }else{
      start=100;
      limit=1000;
  } 
  for(int i=start;i<limit;i++){
      string i_str;
      i_str = to_string(i);
      for(int j=0;j<M;j++){
        if(i_str[(S[j]-1)]!=C[j]){
            break;
        }
        if(j==M-1){
            cout<<i;
            exit(0);
        }
      }
  }
  cout<<"-1";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    const int maxn=1e5+10;
    int n,a[maxn];
    int m,s;
    bool check()
    {
    	for (int i=1;i<=n;i++)
    	    if (a[i]!=n-1) return 0;
    	return 1;
    }
    int main()
    {
    	cin>>n;
    	for (int i=1;i<=n;i++) scanf("%d",&a[i]),m=max(m,a[i]);
    	if (check())
    	{
    		cout<<"Yes";return 0;
    	}
    	for (int i=1;i<=n;i++)
    	    if (a[i]<m)
    	    {
    	    	if (a[i]==m-1) s++;
    	    	else
    	    	{
    	    		cout<<"No";return 0;
    			}
    		}
    	if (m<s||2*(m-s)>n-s||(n>s&&m-s<1)) cout<<"No";
    	else cout<<"Yes";
    	return 0;
    }

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

// const int mod = 1000000007;

// int main() {
//   int n;
//   cin >> n;
//   vector<ll> a(n);
//   rep(i, n) cin >> a[i];
//   ll ans = 0;
//   rep(i, 60) {
//     ll x = 0;
//     rep(j, n) if (a[j] >> i & 1)++ x;
//     ll now = x * (n - x) % mod;
//     rep(j, i) now = now * 2 % mod;
//     ans += now;
//     ans %= mod;
//   }
//   cout << ans << endl;
//   return 0;
// }

#include <bits/stdc++.h>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

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

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

  ll ans = 0, now = 0;
  ll x = 0;

  REP(i, 60) {
    x = 0;
    REP(j, N) {
      if (A[j] >> i & 1) {
        ++x;
      }
    }
    now = x * (N - x) % MOD;
    REP(j, i) { now = now * 2 % MOD; }
    ans = ans + now;
    ans = ans % MOD;
  }

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

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

namespace _0430_atcoder問題05
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            double c = (double)a / b;
            Console.WriteLine(c);
        }
    }
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;


int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> homeworks(m);
    rep(i, m) cin >> homeworks[i];
    ll sum = accumulate(homeworks.begin(), homeworks.end(), 0ll);

    cout << max(n - sum, -1ll) << endl;
}



Measured memory_bytes: 3680
#!/usr/bin/env python3
# DPL_1_C: Combinatorial - Knapsack Problem

from operator import itemgetter


def max_value(total_weight, items):
    values = [0] * (total_weight+1)

    for v, w in sorted(items, key=itemgetter(1)):
        for i in range(w, total_weight+1):
            values[i] = max(values[i], values[i-w] + v)

    return values[-1]


def run():
    n, t = [int(i) for i in input().split()]
    vs = []

    for _ in range(n):
        v, w = [int(i) for i in input().split()]
        vs.append((v, w))

    print(max_value(t, vs))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5988
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define ll long long

const unsigned long long MAXN = (int)3e5 + 5;
const int MAXI = (int)2e9;
const ll INF = (1e18);
const int K = 3;

int main(){
    ll n,sz;cin >> n >> sz;
    vector<ll> dp(MAXN, INF);
    dp[0] = 0;
    vector<ll> w(MAXN), v(MAXN);
    ll v_sum = 0;
    for (int i = 1;i <= n;i ++) {
        cin >> w[i] >> v[i];
        v_sum += v[i];
    }
    for (int i = 1;i <= n;i ++) {
        for (ll have = v_sum - v[i];have >= 0;have --) {
            dp[have + v[i]] = min(dp[have + v[i]], dp[have] + w[i]);
        }
    }
    ll ans = 0;
    for (int i = 0;i <= v_sum;i ++) {
        if (dp[i] <= sz) {
            ans = max(ans, (ll) i);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

int main()
{
  	std::string s;
  	std::cin >> s;
  
  	std::vector<int> v(s.length() + 1, 0);
  
  	for (int i = 0; i < s.length(); ++i)
    {
    	if (s[i] == '<')
        	v[i+1] = v[i] + 1;
    }
  
  	for (int i = s.length(); i >= 0; --i)
    {
    	if (s[i] == '>')
        	v[i] = std::max(v[i], v[i+1] + 1);
    }
  
  	ll sum = 0;
  
  	for (int i = 0; i < s.length() + 1; ++i)
    	sum += v[i];
  
  	std::cout << sum << std::endl;
  
	return 0;
}

Measured memory_bytes: 2820
#include<cstdio>

int main(){
   int n,i,a,b,min,max;
   long long sum;
   scanf("%d %d",&n,&a);
   min = a;
   max = a;
   sum = a;
   for(int i = 2;n >= i;i++){
       scanf("%d",&b);
       if(min >= b){
           min = b;
       }
       else{
           min = min;
       }
       if(max <= b){
           max = b;
       }
       else{
           max = max;
       }
       sum = sum + b;
       }
       printf("%d %d %lld\n",min,max,sum);
       return 0;
       
}




Measured memory_bytes: 2736
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

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

int main() {
    int n, m, x,price = 0,p=1000000005,check=0;
    cin >> n >> m >> x;
    vector<int>c(n);
    vector<int>ans(m);
    rep(i, m)ans[i] = 0;
    vector<vector<int>>a(n,vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    //それぞれの本に対して買うor買わないのbit全探索
    rep(is, 1 << n) {
        price = 0;
        rep(i,n){
            if (is >> i & 1) {//bitが立っていたら、理解度を各アルゴリズムに対してプラス。また合計金額も記録
                rep(j, m) {
                    ans[j] += a[i][j];
                }
                price += c[i];
            }
        }
        int cnt = 0;
        rep(j, m) {
            if (ans[j] >= x)cnt++;
            ans[j] = 0;
        }
        if (cnt == m) {
            if (price < p)p = price;//最低価格の更新
            check = 1;
        }
    }
    if (check == 0)cout << -1 << endl;
    else cout << p << endl;

    return 0;
}

Measured memory_bytes: 3164
h, w = map(int, input().split())
ma = [ list(input()) for _ in range(h) ]
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
ans = 0

def bfs(sy, sx):
    if ma[sy][sx] == "#":
        return 0
    q = [[sy, sx, 0]]
    flag = [[0] * w for _ in range(h)]
    flag[sy][sx] = 1
    ans = 0
    while True:
        if len(q) == 0:
            break
        y, x, dist = q.pop(0)
        for dy, dx in d:
            if 0 <= y + dy < h and 0 <= x + dx < w and flag[y + dy][x + dx] == 0 and ma[y + dy][x + dx] == ".":
                flag[y + dy][x + dx] = 1
                q.append([y + dy, x + dx, dist + 1])
                ans = max(ans, dist + 1)

    return ans


for j in range(h):
    for i in range(w):
        ans = max(ans, bfs(j, i))

print(ans)

Measured memory_bytes: 9248
/*
 * 2503.cc: Project Management
 */

#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>
 
using namespace std;

/* constant */

const int MAX_N = 400;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct JP {
  int cp, sn, dn;
  vpii njps;
  JP(): cp(0), sn(0), dn(0) { njps.clear(); }
};

/* global variables */

JP jps[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;

    jps[a].njps.push_back(pii(b, c));
    jps[b].sn++;
  }

  queue<pii> q;
  q.push(pii(0, 0));

  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ud = u.first, &ui = u.second;

    if (jps[ui].cp < ud) jps[ui].cp = ud;

    if (++jps[ui].dn >= jps[ui].sn) {
      vpii &njps = jps[ui].njps;
      for (vpii::iterator vit = njps.begin(); vit != njps.end(); vit++) {
	int &vi = vit->first, vd = jps[ui].cp + vit->second;
	q.push(pii(vd, vi));
      }
    }
  }

  printf("%d\n", jps[n - 1].cp);
  
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;


int main(){
	int N;cin>>N;
	
	if(N%2==0)cout << N << endl;
	else cout << (N*2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
using namespace std;
int main()
{
	string s;
	int k,m=0;
	cin>>s>>k;
	vector <string> a;
	rep(i,s.size())
	{
		string tmp="";
		for(int j=i;j<s.size() and j<i+k;j++) tmp.push_back(s[j]),a.push_back(tmp),m++;
	}
	sort(a.begin(),a.end());
	//cout<<a.size()<<endl;
	rep(i,m-1) if(a[i]==a[i+1]) a.erase(a.begin()+i),i--;
	//if(a[0]==a[1]) a.erase(a.begin());
	//cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl<<a[3]<<endl<<a[4]<<endl<<a[5]<<endl;
	cout<<a[k-1];
    rt0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    bool s[105][105] = {false};
    int w, h, n;
    cin >> w >> h >> n;

    rep(i, h){
        rep(j, w){
            s[i][j] = true;
        }
    }

    rep(i, n){
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1){
            rep(j, h){
                rep(k, x){
                    s[j][k] = false;
                }
            }
        }   
        if(a == 2){
            rep(j, h){
                for (int k = x; k < w; ++k) {
                    s[j][k] = false;
                }
            }
        }
        if(a == 3) {
            rep(j, y){
                rep(k, w){
                    s[j][k] = false;
                }
            }
        }
        if(a == 4){
            for(int j = y; j < h; ++j){
                rep(k, w){
                    s[j][k] = false;
                }
            }
        }
    }

    ll ans = 0;
    rep(i, h){
        rep(j, w){
            //cout << s[i][j] << " ";
            if(s[i][j]){
                ans++;
            }
        }
        //cout  << endl;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i,k,s=0;
  cin>>n;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    k=a.at(i);
    if(i%2==1) k*=-1;
    s+=k;
  }
  cout<<s<<' ';
  for(i=1;i<n;i++){
    s=(s-a.at(i-1))*(-1)+a.at(i-1);
    cout<<s;
    if(i<n-1) cout<<' ';
    else cout<<endl;
  }
}

Measured memory_bytes: 1664
A, B, C = map(int, input().split())
K = int(input())

k = 0
while True:
    if A < B:
        break
    else:
        B *= 2
        k += 1

while True:
    if B < C:
        break
    else:
        C *= 2
        k += 1

if k <= K:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61788
import collections
n, q = map(int, input().split())
d = collections.defaultdict(list)
score = [0 for i in range(n)]
for _ in range(n-1):
    a,b = map(int, input().split())
    d[a].append(b)
for _ in range(q):
    p, x = map(int, input().split())
    score[p-1] += x
for node in range(1, n+1):
    child = d[node]
    for c in child:
        score[c-1] += score[node-1]
print(" ".join(map(str, score)))

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

int main(){
  int N;
  ll W;
  cin >> N >> W;
  vector<ll> w(110), v(110);
  rep(i,N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(110, vector<ll> (100100,0));
  //ll dp[110][100100]={0};
  rep(i,N){
    rep(j,W+1){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(j - w[i] < 0) continue;
      dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;

}


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

using namespace std;

using lint = long long;
using ldouble = long double;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> S(N);
    for (auto& s : S) cin >> s;

    int ans = 0;
    bool update = true;
    while (update) {
        update = false;
        for (int cx = 0; cx < N; ++cx) {
            for (int cy = 0; cy < M; ++cy) {
                if (S[cx][cy] != '.') continue;

                string app;
                for (int x = cx; x >= 0; --x) {
                    if (S[x][cy] != '.') {
                        app.push_back(S[x][cy]);
                        break;
                    }
                }
                for (int x = cx; x < N; ++x) {
                    if (S[x][cy] != '.') {
                        app.push_back(S[x][cy]);
                        break;
                    }
                }
                for (int y = cy; y >= 0; --y) {
                    if (S[cx][y] != '.') {
                        app.push_back(S[cx][y]);
                        break;
                    }
                }
                for (int y = cy; y < M; ++y) {
                    if (S[cx][y] != '.') {
                        app.push_back(S[cx][y]);
                        break;
                    }
                }

                sort(app.begin(), app.end());
                if (app.empty()) continue;

                for (int i = 0; i < app.size() - 1; ++i) {
                    if (app[i] == app[i + 1]) {
                        for (int x = 0; x < N; ++x) {
                            replace(S[x].begin(), S[x].end(), app[i], '.');
                        }
                        ans += 2;
                        update = true;
                    }
                }
            }
        }
    }

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



Measured memory_bytes: 3352
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):

    flag = False
    # 横
    for i in range(3):
        if A[i][0] in b and A[i][1] in b and A[i][2] in b:
            flag = True
            break
    # 縦
    for i in range(3):
        if A[0][i] in b and A[1][i] in b and A[2][i] in b:
            flag = True
            break
    # ななめ
    if A[0][0] in b and A[1][1] in b and A[2][2] in b:
        flag = True
    if A[0][2] in b and A[1][1] in b and A[2][0] in b:
        flag = True

    if flag:
        yes()
    else:
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == '__main__':
    main()


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

int main(void){
    int table[101][101];
    int i,j,r,c;

    scanf("%d %d",&c,&r);
    getchar();

    for(i=0;i<c;i++) table[i][r]=0;
    for(i=0;i<r;i++) table[c][i]=0;
    table[c][r]=0;

    for(i=0;i<c;i++){
        char buf[401];
        char *p_buf;
        int n;
        j=0;
        gets(buf);

        p_buf=strtok(buf," ");

        n=atoi(p_buf);
        table[i][j]=n;
        table[i][r]+=n;
        table[c][j]+=n;
        j++;

        while(p_buf!=NULL){
            p_buf=strtok(NULL," ");
            if(p_buf!=NULL){
                n=atoi(p_buf);
                table[i][j]=n;
                table[i][r]+=n;
                table[c][j]+=n;
            }
            j++;
        }
    }

    for(i=0;i<c;i++) table[c][r]+=table[i][r];

    for(i=0;i<=c;i++){
        printf("%d",table[i][0]);
        for(j=1;j<=r;j++){
            printf(" %d",table[i][j]);
        }
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	int ave = 0;
	int ans = 0;
	int Ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> X.at(i);
		ave = ave + X.at(i);
	}
	ave = (ave / N);
	for (int i = 0; i < N; i++) {
		ans = ans + pow((ave - X.at(i)), 2);
	}
	for (int i = 0; i < N; i++) {
		Ans = Ans + pow((ave+1 - X.at(i)), 2);
	}
	if (ans < Ans) {
		cout << ans << endl;
	}
	else {
		cout << Ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;

int c[110][110],h,w;
vector<int>a(10010);
void solve(int n){
    int x=0,y=0;
    bool dir = true;
    rep(l,0,n){
        int num = a[l];
        while(num){
            if(dir){
                c[x][y]=l+1;
                if(x<h-1){x++;}
                else{y++;dir=false;}
                }
            else{
                c[x][y]=l+1;
                if(x>0){x--;}
                else{y++;dir=true;}
            }
            num--;
        }
    }
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>h>>w>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    solve(n);
    rep(i,0,h){
        rep(j,0,w){
            cout<<c[i][j]<<' ';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 512
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            string[] s = Console.ReadLine().Split(' ');
            a[0] = int.Parse(s[0]);
            a[1] = int.Parse(s[1]);
            a[2] = int.Parse(s[2]);

            int sum = a[0] + a[1] + a[2];
            int max = Math.Max(Math.Max(a[0], a[1]), a[2]);
            int min = Math.Min(Math.Min(a[0], a[1]), a[2]);
            int mid = sum - max - min;
            Console.WriteLine(min + " " + mid + " " + max);

        }
    }
}

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int m,d;
  cin>>m>>d;
  int ans=0;
  rep(i,1,m+1)
    rep(j,1,d+1)
    {
      int x1=j%10,x2=j/10;
      int y=i;
      if(x1>=2 && x2>=2 && x1*x2==y) ans++;
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
def move(src, des, t, f, p, costs, r, c, a)
  if src == des
    return [t, a]
  end
  ret = [0, a]
  f[src[0]][src[1]] = '@'
  [[-1, 0], [0, -1], [0, 1], [1, 0]].each do |d|
    i, j = src[0] + d[0], src[1] + d[1]
    if i >= 0 && j >= 0 && i < r && j < c && f[i][j] == '.'
      ret = move([i, j], des, t + 1, f, p, costs, r, c, a)
      if ret[0] > 0
        cost = costs[1][i][j] + costs[2][i][j]
        ret[1] += cost
        if p[i][j]
          d = (t - p[i][j]) * costs[0][i][j] - cost
          ret[1] += d if d < 0
        end
        p[i][j] = t
        break
      end
    end
  end
  f[src[0]][src[1]] = '.'
  ret
end
def calc(f, costs, tasks, r, c, m)
  i0, j0 = tasks[0][0], tasks[0][1]
  p = Array.new(c){ [] }
  p[i0][j0] = 1
  t = 2
  a = costs[1][i0][j0] + costs[2][i0][j0]
  tasks.each_cons(2) do |task|
     t, a = move(*task, t, f, p, costs, r, c, a)
  end
  a
end
1.times do
  f = [], costs = [], tasks = []
  r, c, m = gets.split.map(&:to_i)
  r.times do |i|
    f[i] = gets.chomp.split('')
  end
  3.times do |k|
    costs[k] = []
    r.times do |i|
      costs[k][i] = gets.split.map(&:to_i)
    end
  end
  m.times do |i|
    tasks[i] = gets.split.map(&:to_i)
  end
  puts calc(f, costs, tasks, r, c, m)
end

Measured memory_bytes: 12456
#include <cstdio>
const long long MOD = 1000000007;
int N, M, A, B;
long long fc[2000001], fi[2000001], O;
inline long long W(int x, int y)
{
	return fc[x + y] * fi[x] % MOD * fi[y] % MOD;
}
int main()
{
	fc[0] = fi[0] = fi[1] = 1;
	for (int i = 2; i <= 200000; i++)
		fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
	for (int i = 1; i <= 200000; i++)
	{
		fc[i] = fc[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * fi[i] % MOD;
	}
	scanf("%d%d%d%d", &N, &M, &A, &B);
	for (int i = 1; i <= N - A; i++) // (1, 1) => (i, B) => (i, B + 1) => (N, M)
		O = (O + W(i - 1, B - 1) * W(N - i, M - B - 1)) % MOD;
	printf("%lld\n", O);
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

const double EPS = 1e-6;
const int MAX = 33;



int main()
{
    //freopen("in.txt", "r", stdin);
    string S;
    cin >> S;
    if (SZ(S) >= 4 && S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  ll x, k, d, times, ans;
  cin >> x >> k >> d;
  x = abs(x);
  times = x / d;
  if (k <= times)
  {
    ans = x - k * d;
  }
  else
  {
    k -= times;
    if (k % 2 == 0)
    {
      ans = x % d;
    }
    else
    {
      ans = min(abs(x % d + d), abs(x % d - d));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3572
while 1:
    n,l,r=map(int, input().split())
    if n==0:
        break
    a = []
    for i in range(n):
        a.append(int(input()))
    c = 0
    for j in range(l, r+1):
        for i in range(n):
            if j%a[i]==0:
                if i%2==1:
                    break
                else:
                    c += 1
                    break
            if i==n-1 and n%2==0:
                c += 1
    print(c)


Measured memory_bytes: 5600
#include<stdio.h>
int main(){
int h,w,a,b,c,d,ans;
scanf("%d %d\n%d %d",&h,&w,&a,&b);
c=h/a,d=w/b;
a=a*c,b=b*d;
ans=h*w-a*b;
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2148
read N
ma=0
mb=0
mai=0
mbi=0
i=0
for b in `dd`;do
	i=$[i+1]
	if [ $ma -lt $b ];then
		mb=$ma
		mbi=$mai
		ma=$b
		mai=$i
	elif [ $mb -lt $b ];then
		mb=$b
		mbi=$i
	fi
done
yes $ma|head -$[mai-1]
echo $mb
yes $ma|head -$[N-mai]

Measured memory_bytes: 23592
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<string, int> cnt;
  int n;
  cin >> n;
  vector<string> a;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(cnt[s] == 0) a.push_back(s);
    cnt[s]++;
  }
  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    string t;
    cin >> t;
    cnt[t]--;
  }
  int ans = 0;
  for(int i = 0; i < a.size(); i++)
    ans = max(cnt[a[i]], ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    tmp = input().split()
    #print(tmp)
    A = int(tmp[0])
    B = int(tmp[2])
    
    if tmp[1] == "+":
        print(A+B)
    else:
        print(A-B)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
ll n,s;
ll findsum(ll i)
{
    ll res=0,m=n;
    while(m>=i)
    {
        res+=m%i;
        m/=i;
    }
    res+=m;
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n>>s;
        ll l=1,r=n,ans=-1;
        for(ll i=2;i<=1e6;i++)
        {
            ll f1=findsum(i);
            if(f1==s)
            {
                ans=i;
                break;
            }
        }
        if(ans==-1&&n>s)
        {
            ll ma=INF;
            for(ll i=1;i<=min(1000000LL,s);i++)
            if((n-s+i)%i==0)
            {
                ll pr=(n-s+i)/i;
                if(pr>(s-i)&&(n/pr)==i)
                {
                    ma=min(pr,ma);
                    ans=ma;
                }
            }
        }
        if(ans==-1&&s==1)
        {
            cout<<n<<"\n";
            continue;
        }
        if(n==s&&ans==-1)
        ans=n+1;
        cout<<ans<<"\n";
    }
    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int ans = (1 << 28);
    for (int x = max({A, B, C}); x <= 100; x++) {
        int sum = (x - A) + (x - B) + (x - C);
        if (sum % 2 != 0) continue;
        ans = min(ans, sum / 2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

// positive only
int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return -1;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
// arr should be sorted
void *binary_search(const int key, const int *arr, const int N){
    int left = 0;
    int right = N;
    int mid;
    while(left < right) {
        mid = left + ((right - left) / 2);
        // found
        if(arr[mid] == key) return (void *)(arr + mid);
        // key should be more left
        else if(arr[mid] > key) right = mid;
        // key should be more right
        else left = mid + 1;
    }
    return NULL;
}
int main(int argc, char **argv) {
    int n = get_int();
    int s[100001];
    for(int i = 0; i < n; ++i) {
        s[i] = get_int();
    }
    int q = get_int();
    int cnt = 0;
    int t;
    while(q--) {
        // NULL ? nothing : cnt++
        binary_search(get_int(), s, n) && cnt++;
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2144
tmp = list(map(int, input().split(" ")))
N = tmp[0]
M = tmp[1]

data = [[i] for i in range(M)]

for i in range(M):
    tmp = list(map(int, input().split(" ")))
    data[i].extend(tmp)

data = sorted(data, key=lambda x:(x[1],x[2]), reverse=False)

before = -1
counter = 1
for i in range(M):
    if data[i][1] != before:
        counter = 1
        before = data[i][1]
    data[i].append(counter)
    counter += 1

data = sorted(data, key=lambda x:(x[0]), reverse=False)

for d in data:
    print('{0:06}'.format(d[1]), end="")
    print('{0:06}'.format(d[3]))


Measured memory_bytes: 40568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char x[9];
    int num=0,len,ans=0;
    cin>>x;
    len=strlen(x);
    for(int i=0;i<len;i++)
    num+=x[i]-'0';
    for(int i=0;i<len;i++)
    {
    	ans+=(x[i]-'0')*pow(10,len-1-i);
    }
    if(ans%num==0)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s;
  int a = 0 ,b = 0;
  while(scanf("%c",&s) == 1){
    if(s == '0'){
      a += 1;
    }else if(s == '1'){
      b += 1;
    }
  }
  if(a >= b){
    printf("%d",2*b);
  }else if (a < b){
    printf("%d",2*a);
  }
  return 0;
}

Measured memory_bytes: 128
x ? (a,b) = if x then a else b

readInt :: String -> Int
readInt = read

main = do
    s <- map readInt.tail.words<$>getContents
    print $ solve s

solve :: [Int] -> Int
solve = calc 0

calc i [] = 0
calc i (a:as) = (i>a)?(0,1) + calc (maximum[i,a]) as 


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int d; cin >> d;
    if(d == 25) OUT("Christmas");
    else if(d == 24) OUT("Christmas Eve");
    else if(d == 23) OUT("Christmas Eve Eve");
    else OUT("Christmas Eve Eve Eve");

    return 0;
}

Measured memory_bytes: 256
package main

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

func f(x, y int) int {
	if y == 0 {
		return x
	}
	if x >= y {
		m := x % y
		return f(y, m)
	}
	m := y % x
	return f(x, m)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	x, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	sc.Scan()
	y, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	a := f(x, y)
	fmt.Println(a)
}



Measured memory_bytes: 1084
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		int i, size, count = 0;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));

		for(i = 0; i < size; i++){
			if(isPrime(numbers.get(i)) == true) count++;
		}
		System.out.println(count);
		}
	
	private static boolean isPrime(int number){
		int i;
		int route = (int)Math.sqrt(number) + 1;

		if(number == 1) return false;

		for(i = 2; i < route; i++){
			if(number % i == 0) return false;
		}
		return true;	
	}
}

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

int main() {
	long long n,x,m,sum=0;
	cin >> n >> x >> m;
	long long a=x,b=0,totyu;
	for(long long i=0;i<n;i++){
		sum+=a;
		a=(a*a)%m;
		if(a==0){
			break;
		}else if(a==1){
			sum+=n-i-1;
			break;
		}else if(a==b){
			sum=totyu+(sum-totyu)*((n-101)/(i-100));
			i=100+(i-100)*((n-101)/(i-100));
		}
		if(i==100){
			b=a;
			totyu=sum;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3628
import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (foldl')
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [n, m] <- map read <$> words <$> getLine
  solve <$> replicateM (n-1) f <*> replicateM m f >>= print
  where f = readi B.readInt <$> B.getLine

solve :: [Int] -> [Int] -> Int
solve ds = snd . foldl' g (0,0)
  where g (p, ma) a = (p+a, (ma + abs ((dv ! p) - (dv ! (p+a)))) `mod` 100000)
        dv = V.unfoldr f (0, ds)
          where f ((-1), []) = Nothing
                f (x, []) = Just (x, (-1, []))
                f (x, (y:ys)) = Just (x, (x+y, ys))

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n



Measured memory_bytes: 67032
#include<stdio.h>

int main()
{
 int N;
 int a[100005];
 int div2=0;
 int div4=0;
 int i;
 int inc=0;

 scanf("%d",&N);
 for(i=0;i<N;i++) 
 { 
  scanf("%d",&a[i]);
  if ((a[i]%2 == 0)&&(a[i]%4 != 0)) div2++;
  if (a[i]%4 == 0) div4++;
 }
 if (div4>0) inc=1;

 if((2*div4 + inc + 2*(div2/2)) >= N)
 {
  printf("Yes\n");
 }else{
  printf("No\n");
 }

 return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> a(N+1), b(N);
    for (int i = 0; i <= N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    ll res = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] > a[i]){
            res += a[i];
            b[i] -= a[i];
            a[i] = 0;

            if (b[i] > a[i+1]) {
                res += a[i+1];
                a[i+1] = 0;
            } else {
                res += b[i];
                a[i+1] -= b[i];
            }
        }
        else{
            res += b[i];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 1024
MOD = 1_000_000_007
N, M = gets.split.map(&:to_i)

breaked_steps = M.times.map { gets.to_i }.group_by(&:itself)
step_costs = Array.new(N + 10)
step_costs[-1] = 0
step_costs[0] = 1

(1..N).each do |i|
  if breaked_steps[i]
    step_costs[i] = 0
  else
    step_costs[i] = step_costs[i - 1] + step_costs[i - 2]
  end
end

p step_costs[N] % MOD

Measured memory_bytes: 433020