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

int main() {
  string S;
  cin >> S;
  int b = 0;
  int N = S.size();
  if (S.substr(0,7) == "keyence" || S.substr(N-7) == "keyence") b = 1;
  if (S.substr(0,6) == "keyenc" && S.substr(N-1) == "e") b = 1;
  if (S.substr(0,5) == "keyen" && S.substr(N-2) == "ce") b = 1;
  if (S.substr(0,4) == "keye" && S.substr(N-3) == "nce") b = 1;
  if (S.substr(0,3) == "key" && S.substr(N-4) == "ence") b = 1;
  if (S.substr(0,2) == "ke" && S.substr(N-5) == "yence") b = 1;
  if (S.substr(0,1) == "k" && S.substr(N-6) == "eyence") b = 1;
  
  if (b) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Illumination
public class Main{

	int[][] d0 = {{-1,0},{-1,1},{0,-1},{0,1},{1,0},{1,1}}, d1 = {{-1,-1},{-1,0},{0,-1},{0,1},{1,-1},{1,0}};
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt(), h = sc.nextInt();
		boolean[][] u = new boolean[h+2][w+2], v = new boolean[h+2][w+2];
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)u[i][j]=sc.nextInt()==1;
		v[0][0] = true;
		List<int[]> l = new ArrayList<int[]>();
		l.add(new int[]{0, 0});
		while(!l.isEmpty()){
			List<int[]> next = new ArrayList<int[]>();
			for(int[]a:l){
				int pi = a[0], pj = a[1];
				for(int k=0;k<6;k++){
					int ni = pi + (pi%2==1?d0[k][0]:d1[k][0]), nj = pj + (pi%2==1?d0[k][1]:d1[k][1]);
					if(0<=ni&&ni<=h+1&&0<=nj&&nj<=w+1&&!u[ni][nj]&&!v[ni][nj]){
						v[ni][nj] = true; next.add(new int[]{ni, nj});
					}
				}
			}
			l = next;
		}
		int res = 0;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(u[i][j]){
			for(int k=0;k<6;k++){
				int ni = i + (i%2==1?d0[k][0]:d1[k][0]), nj = j + (i%2==1?d0[k][1]:d1[k][1]);
				if(v[ni][nj])res++;
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
using System;
using System.Linq;



public class Test
{
	public static void Main( )
	{
		var n = int.Parse( Console.ReadLine() );
		var A = Console.ReadLine().Trim().Split().Select( x => int.Parse(x)).ToArray();
		
		int cnt　=　0;
		for( var i=0; i <= n-1; i++ ) {
			var mini = i;
			for( var j=i; j <= n-1; j++ ) {
				if( A[j] < A[mini] ) {
					mini = j;
				}
			}
			if( i != mini ) {
				swap<int>( ref A[i], ref A[mini] );
				cnt++;
			}
		}
		
		Console.WriteLine( String.Join( " ", A ) );
		Console.WriteLine( cnt );
		
		return;
	}
	public static void swap<T>( ref T a, ref T b )
	{
		var t = a;
		a = b;
		b = t;
		return;
	}
}


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

using namespace std;

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

    int n;
    cin >> n;

    long long a = 0, b = 0, c = 0, p, q, r;
    for(int i = 0; i < n; ++i){
        cin >> p >> q >> r;
        p += max(b, c);
        q += max(a, c);
        r += max(a, b);
        a = p;
        b = q;
        c = r;
    }

    cout << max(max(a, b), c) << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 256
#include <cstdio>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 2 && b == 2){
        printf("Yes");
    } else if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) {
        if (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) {
            printf("Yes");
        } else {
            printf("No");
        }
    } else if (a != 2 && (b == 4 || b == 6 || b == 9 || b == 11)) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#B
import numpy as np
a0=np.array(list(map(int,input().split())))
a1=np.array(list(map(int,input().split())))
a2=np.array(list(map(int,input().split())))
A=np.array([a0,a1,a2])
#print(A)
C=np.zeros((3, 3))
n=int(input())
B=[]
for i in range(n):
    b=int(input())
    B.append(b)

for i in range(3):
    for j in range(3):
        if int(A[i][j]) in B:
            C[i][j]=1
#print(C)
if int(C[0][0]*C[0][1]*C[0][2])==1 or\
int(C[1][0]*C[1][1]*C[1][2])==1 or\
int(C[2][0]*C[2][1]*C[2][2]) ==1 or\
int(C[0][0]*C[1][0]*C[2][0])==1 or\
int(C[0][1]*C[1][1]*C[2][1])==1 or\
int(C[0][2]*C[1][2]*C[2][2])==1 or\
int(C[0][0]*C[1][1]*C[2][2])==1 or\
int(C[0][2]*C[1][1]*C[2][0])==1 :
    print('Yes')
else:
    print('No')
            
    

Measured memory_bytes: 13332
import java.util.*;
import java.io.*;
 
public class Main{
  
  static public void main(String args[]){
    
    Scanner sc = new Scanner(System.in);
    ArrayList<String> inputStr = new ArrayList<String>();
    String tmpStr;
    
    do{
      tmpStr = sc.next();
      inputStr.add(tmpStr);
    }while(sc.hasNext());
    
    int N = Integer.parseInt(inputStr.get(0));
    
    inputStr.remove(0);
    inputStr.remove(0);
    
    String words[] = new String[N];
    for(int i=0; i<N; i++){
      words[i] = inputStr.get(i);
    }
    
    Arrays.sort(words);
    
    for(int j=0; j<N; j++){
      System.out.printf("%s", words[j]);
    }
    
  }
}

Measured memory_bytes: 23508
_, k = map(int, input().split())
A = [*map(int, input().split())]
ng, ok = 0, 1<<30
while ok - ng > 1:
    m = (ng + ok) // 2
    if k < sum([(a-1)//m for a in A]): ng = m
    else: ok = m
print(ok)


Measured memory_bytes: 30812
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e8;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
vl dp(MAXN, -1);

signed main() {

	fast
	string s, t;
	cin >> s >> t;
	bool ok = 1;
	if (t.length() != s.length() + 1)
		ok = 0;
	else
	{
		loop(i, s.length())
		{
			if (s[i] != t[i])
			{
				ok = 0;
				break;
			}
		}
	}
	if (ok)
		cout << "Yes\n";
	else
		cout << "No\n";



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 10988
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    a = list(LI())
    res = [0]*len(a)
    res[0] = a[n-1]
    ans = 0
    for i in range(len(a)-1):
        res[i+1] = res[i] + a[n-i-2]
    for i in range(len(a)-1):
        ans += a[i] * res[n-i-2]
    print(ans % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46128
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    string x,y;
    cin>>x>>y;
    int c=0;
    for(int i=0; i<x.size(); i++){
        if(x[i]!=y[i]) c++;
    }
    cout<<c<<"\n";
    return 0;
}


Measured memory_bytes: 3916
// 2013/07/12 Tazoe

#include <iostream>
using namespace std;

struct sweet{
	int i;
	int p;
	int q;
	int r;
};

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

		if(n==0)
			break;

		struct sweet S[1000];
		for(int j=0; j<n; j++){
			cin >> S[j].i >> S[j].p >> S[j].q >> S[j].r;
		}

		int P, Q, R, C;
		cin >> P >> Q >> R >> C;

		bool flg = false;

		for(int j=0; j<n; j++){
			if(S[j].p<=P && S[j].q<=Q && S[j].r<=R && 4*S[j].p+9*S[j].q+4*S[j].r<=C){
				cout << S[j].i << endl;
				flg = true;
			}
		}

		if(!flg){
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    ll N, K, S;
    cin >> N >> K >> S;
    vector<ll> res;

    for(int i = 0; i < K; i++){
        res.push_back(S);
    }
    if(S == (ll)1e9){
        for(int i = 0; i < N-K; i++){
            res.push_back(1);
        }
    }
    else{
        for(int i = 0; i < N-K; i++){
            res.push_back(S+1);
        }
    }

    for(auto x: res){
        cout << x << " ";
    }
    cout << endl;




    return 0;
}


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;

lli mod = 1e9+7;

lli bigmod(lli a, lli b, lli m)
{
    lli gg = a%m;
    lli ret = 1;
    while(b){
        if(b%2){
            ret = (ret*gg) % m;
        }
        gg = (gg*gg) % m;
        b/=2;
    }
    return ret;
}

lli ncr(lli n, lli r)
{
    lli tr = r;
    lli up = 1;
    while(tr--){
        up = (up*n)%mod;
        n--;
    }
    n = 1;
    tr = r;
    lli down = 1;
    while(tr--){
        down = (down*n)%mod;
        n++;
    }

    lli ret = up;
    ret = (ret * bigmod(down, mod-2, mod)) % mod;
    return ret;
}

int main()
{
    lli n, a, b;
    cin >> n >> a >> b;
    lli ans = bigmod(2, n, mod) - 1;
    ans =  ans + mod + mod + mod + mod;
    ans -= ncr(n, a);
    ans -= ncr(n, b);
    ans %= mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
unsigned long long quick_pow(unsigned long long A,unsigned long long B,unsigned long long C)
{
	unsigned long long ans=1;
	while(B)
	{
		if(B&1)
			ans=(ans*A)%C;
		B>>=1;
		A=(A*A)%C;
	}
	return ans;
}
int main(){
	unsigned long long n;
	cin>>n;
	unsigned long long x=quick_pow(10,n,mod);
	unsigned long long y=quick_pow(9,n,mod);
	unsigned long long z=quick_pow(8,n,mod);
	unsigned long long ans=x+z-y-y;
	ans+=mod;
	ans+=mod;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3620
function Main(input) {
    input = input.split("\n");
  	var a = input[0]-0;
  	var aa = ~~(a/500);
  	var ans = 0;
  	ans += aa*1000;
  	var bb = ~~((a-aa*500)/5);
  	ans += bb*5;
  	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
T mult(T n,T m){
	if(m==0) return 1;
	if(m==1){
		return n%mod;
	}else if(m%2==0){
		T t=mult(n,m/2);
		return (t*t)%mod;
	}else{
		T t=mult(n,m-1);
		return (t*n)%mod;
	}
}

vector<ll> d1(200000),d2(200000);
template <class T>
void make_table(T N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			d1[i]=1;
			d2[i]=1;
		}else{
			d1[i]=(i*d1[i-1])%mod;
			d2[i]=mult(d1[i],mod-2);
		}
	}
}

template <class T>
T comb_mod_2(T n,T k){
	if(n<k) return 0;
	return (((d1[n]*d2[n-k])%mod)*d2[k])%mod;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  make_table(200000);
  ll ans=0;
  FOR(j,b+1,w+1){
    ans+=comb_mod_2(h-a-1+j-1,j-1)*comb_mod_2(a-1+w-j,a-1);
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    string s;
    cin >> s;
    for (char c : s) {
        if (c == '7') {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )

int N;
int A[20001];
int main() {
    cin >> N;
    if (N == 3) {
        std::cout << 2 << " " << 5 << " " << 63 << std::endl;
        return 0;
    }
    if (N == 4) {
        std::cout << 2 << " " << 5 << " "<< 20 << " " << 63 << std::endl;
        return 0;
    }
    if (N == 5) {
        std::cout << 2 << " " << 5 << " " << 20 << " " << 30 << " " << 63 << std::endl;
        return 0;
    }
    int cnt = 0;
    REP(i, 2, 30000) {
        if ((i % 2 == 0) || (i % 3 == 0)) {
            A[cnt] = i;
            ++cnt;
        }
        if (cnt == N) {
            break;
        }
    }
    ll sum = std::accumulate(A, A+N, 0);
    ll mod = sum % 6;
    switch (mod) {
        case 2:
            rep(i, 0, N) {
                if (A[i] == 8) {
                    continue;
                }
                if (i) std::cout << " ";
                std::cout << A[i];
            }
            REP(i, A[N-1]+1, 30000) {
                if (i%6 == 0) {
                    std::cout << " " << i << std::endl;
                    break;
                }
            }
            break;
        case 3:
            rep(i, 0, N) {
                if (A[i] == 9) {
                    continue;
                }
                if (i) std::cout << " ";
                std::cout << A[i];
            }
            REP(i, A[N-1]+1, 30000) {
                if (i%6 == 0) {
                    std::cout << " " << i << std::endl;
                    break;
                }
            }
            break;
        case 5:
            rep(i, 0, N) {
                if (A[i] == 9) {
                    continue;
                }
                if (i) std::cout << " ";
                std::cout << A[i];
            }
            rep(i, A[N-1]+1, 30000) {
                if (i%6 == 4) {
                    std::cout << " " << i << std::endl;
                    break;
                }
            }
            break;
        default:
            rep(i, 0, N) {
                if (i) std::cout << " ";
                std::cout << A[i];
            }
            break;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define rep(i, n) for (int i{ 0 }; i < n; ++i)

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for ( auto& r_a : a) cin >> r_a;
    int cnt{ 0 };
    for (int i{ 0 }; i < N; ++++i)
        if (a.at(i) % 2 == 1) cnt++;

    cout << cnt;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, double> lpair;
typedef pair<double, ll> lpair2;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    double xs, ys, xt, yt;
    ll N;
    double x[1010], y[1010], r[1010];
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    rep(i,1,N+1) cin >> x[i] >> y[i] >> r[i];
    x[0] = xs; y[0] = ys, r[0] = 0;
    x[N+1] = xt; y[N+1] = yt; r[N+1] = 0;
    vector<lpair> tree[1010];
    rep(i,0,N+2){
        rep(j,0,N+2){
            if(i == j) continue;
            double dist = sqrt(pow(x[i] - x[j],2) + pow(y[i] - y[j], 2));
            double hankei = r[i] + r[j];
            dist = max(0.0, dist - hankei);
            tree[i].push_back(make_pair(j, dist));
        }
    }

    priority_queue<lpair2, vector<lpair2> ,greater<lpair2> > pq;
    double dist[1010] = {};
    rep(i,1,N+2) dist[i] = INF;
    rep(i,0,N+2) pq.push(make_pair(dist[i], i));
    ll is_visit[1010] = {};
    while(!pq.empty()){
        lpair2 l1 = pq.top();
        pq.pop();
        is_visit[l1.second] = 1;
        for(auto &e: tree[l1.second]){
            if(dist[e.first] > dist[l1.second] + e.second){
                if(!is_visit[e.first]){
                    dist[e.first] = dist[l1.second] + e.second;
                    pq.push(make_pair(dist[e.first], e.first));
                }
            }
        }
    }
    // printa(dist, N+2);
    cout << setprecision(12) << dist[N+1] << endl;
}


Measured memory_bytes: 22256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
int n,a[111111],mx[111111],cnt[111111];
map<int,int> num[111111];
vector<int> g[111111];
void dfs(int i)
{
	for (int j=0;j<g[i].size();j++)
	{
		int to=g[i][j];
		dfs(to);
		num[i][cnt[to]]++;
	}
	for (map<int,int>::iterator it=num[i].begin();it!=num[i].end();it++)
	{
		cnt[i]=max(cnt[i],it->first);
		cnt[i]+=it->second;
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		g[a[i]].push_back(i); 
	}
	dfs(1);
	printf("%d\n",cnt[1]);
	return 0;
}

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

const int M = 1001;
int n,m,k,a[M],d[M],vis[M],ver[M],s0,s1,w0[M],w1[M],t;
vector<int> v[M];

bool check(int x)
{
	x=max(x,-x);
	if(x==1) return 0;
	int k=sqrt(x);
	for(int i=2;i<=k;i++) if(x%i==0) return 0;
	return 1;
}

void ins(int k)
{
	if(k%2) w1[++s1]=k;
	else w0[++s0]=k;
}

int dfs(int x)
{
	for(int i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==t) continue; vis[v[x][i]]=t;
		if(!ver[v[x][i]] || dfs(ver[v[x][i]])) 
		{
			ver[v[x][i]]=x; 
			return 1;
		}
	}
	return 0;
}

int main()
{
	scanf("%d",&n); a[0]=-1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i-1]+1) ins(a[i]);
		if(a[i+1]!=a[i]+1) ins(a[i]+1);
	}
	for(int i=1;i<=s1;i++)
		for(int j=1;j<=s0;j++)
			if(check(w1[i]-w0[j])) v[i].push_back(j);
	for(t=1;t<=s1;t++) k+=dfs(t);
	printf("%d",s1+s0-k+(s1-k)%2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner scan = new Scanner(System.in);
		
		int i,j;
		
		while(true){
			
			int h = scan.nextInt();
			int w = scan.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(i=1; i<=h; i++){
				for(j=1; j<=w; j++){
					if((i+j)%2==0){
						System.out.print('#');
					}else{
						System.out.print('.');
					}
					
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 28864
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int d, n; cin >> d >> n;
    int val = 1;
    if (n == 100) n++;
    if (d == 1) {
        val = 100;
    } else if (d == 2) {
        val = 10000;
    }
    cout << val * n << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int main() {
  int a, b;
  cin >> a >> b;
  int n = 0;
  int o = 0;
  for (int i = 1; i < 1000; ++i) {
    n += i;
    if (n - o == b - a) {
      cout << n - b << endl;
      return 0;
    }
    o = n;
  }
  return 0;
}


Measured memory_bytes: 256
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
char s[N];
int main()
{
	ll n;
	while(cin>>n)
	{
		for(int i = n;;i++)
		{
			int a = i%10;
			int b = i/10%10;
			int c = i/100;
			if(a == b && b == c)
			{
				printf("%d\n",i);
				return 0;
			}
		}
	}
}

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int x, a, b; cin >> x >> a >> b;
    if(b-a <= 0) cout << "delicious" << endl;
    else if(b-a <=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}


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


int main()
{
	int n,k;  
	char s[20];
	 
	 cin>>n>>s>>k;
	 k--;
	 for(int i=0;i<n;i++){
		 
		 if(s[i]==s[k]){
			 cout<<s[i];
	      }
	      else {
			  cout<<"*";
	      
	 }
	 	
   }

}


Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] += 32;

  ps(s); br();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 6, MAXH = 12;
char tile[MAXW + 2][MAXH + 2];
int checked[MAXW + 2][MAXH + 2];
char c;

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
int countt(int x, int y)
{
    if(tile[x][y] != c) return 0;
    checked[x][y] = 1;
    int ans = 1;
    REP(4)if(!checked[x + dx[i]][y + dy[i]]) ans += countt(x + dx[i], y + dy[i]);
    return ans;
}
void van(int x, int y)
{
    if(tile[x][y] == 'O') { tile[x][y] = 'v'; return ;}
    if(tile[x][y] != c) return ;
    tile[x][y] = 'v';
    REP(4) van(x + dx[i], y + dy[i]);
    return;
}
void test()
{
    rep(j, MAXH){rep(i, MAXW) cout << tile[i+1][j+1]; cout << endl;}

}

int main()
{
    int t; cin >> t;
    while(t--)
    {
        memset(tile, '.', sizeof(tile));
        rep(j,MAXH)rep(i,MAXW)cin >> tile[i + 1][j + 1];
        int vaned = 0;
        for(int ans = 0; 1; ans++)
        {
            vaned = 0;
            memset(checked, 0, sizeof(checked));
            for(int i = 1; i <= MAXW; i++)for(int j= 1; j<= MAXH; j++)if(tile[i][j] != 'O' && tile[i][j] != '.' && tile[i][j] != 'v')
            {
                int cnt = 0;
                c = tile[i][j];
                cnt = countt(i, j);// cout << "count " << i << " "<< j << " :" << cnt << endl;
                if(cnt >= 4) { van(i, j); vaned = 1;}
            }
            //test();

            if(!vaned) { cout << ans << endl; break;}
        
            rep(l,12)for(int i = 1; i <= MAXW; i++)for(int j = MAXH; j > 0; j--)if(tile[i][j] == 'v')
            {
                for(int k = j; k > 0; k--)tile[i][k] = tile[i][k - 1];
                /*
                for(int k = 1 ;k <= MAXH; k++)if(tile[i][j - k] != 'v')
                    for(int l = j; l >= j - k; l--)
                    {
                        if(l - k >= 0) tile[i][l - k] = tile[i][l - k];
                        else tile[i][l - k] = '.';
                    }*/
            }
            //cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//loop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
  //input
  ll n;
  cin >> n;

  //process
  if(n==1) {
    cout << "0" << endl;
    exit (0);
  }
  if(n==2) {
    cout << "2" << endl;
    exit (0);
  }
  
  ll mp = modpow(10,n,1000000007) - modpow(9,n,1000000007) - modpow(9,n,1000000007) + modpow(8,n,1000000007);
  if(mp < 0) mp+= 1000000007;
  if(mp < 0) mp+= 1000000007;
  if(mp < 0) mp+= 1000000007;
  if(mp < 0) mp+= 1000000007;
  if(mp < 0) mp+= 1000000007;
  mp %= 1000000007;
  //output
  cout << mp << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s, t;cin >> s >> t >> s;
    cout << 'A' << t[0] << 'C' << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
//#define int long long
#include<algorithm>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
#define F first
#define S second
#define pb push_back
#define mk make_pair
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define rep(i,a,b) for(int i = a; i<= b; i++)
#define all(c) c.begin(), c.end()
#define ws " "
#define ln "\n"
#define get(x) int x; cin >> x;
#define prt printf("hello world\n")
#define MOD 1e16 + 7;

int main()
{   
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        float rad;
        cin >> rad;
        float twopi = atan(1)*8;
        cout << twopi*rad << ln;
       return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    map<string, int> mp;
    REP(i, N){
        cin >> S[i];
        mp[S[i]] += 1;
    }

    int res = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        res = max(res, itr->second);
    }

    vector<string> ans;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        string s;
        if (itr->second == res){
            cout << itr->first << endl;
        }
    }
}

Measured memory_bytes: 25152
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
N,X = map(int,input().split())
x = list(map(int,input().split()))
x = x+[X]
x.sort()
d = [x[i+1]-x[i] for i in range(N)]
D = d[0]
for i in range(1,N):
    D = gcd(D,d[i])
print(D)

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



int main() {
   long long n;
   cin >> n;
   vector<long long> a(n);
   for (int i=0; i<n; i++) {
      cin >> a[i];
   }
   for (int i=0; i<n; i++) {
      if (a[i] == 0) {
         cout << 0 << endl;
         return 0;
      }
   }
   long long ans = 1;
   for (int i=0; i<n; i++) {
      ans = ans * a[i];
      if ((ans > 0) && (ans <= 1000000000000000000)) {
         continue;
      }
      else {
         cout << -1 << endl;
         return 0;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4000
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//ぜんぜんわからん
ll gcd(ll A, ll B) {
	if (A == 0) return B;
	return gcd(B % A, A);
}

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


	int N, M;
	cin >> N >> M;

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

	ll lcm = A[0];

	bool dame = 0;
	rep1(i, N - 1) {
		ll g = gcd(lcm, ll(A[i]));
		lcm = lcm / g * A[i];
		if (lcm > 2e9) {
			dame = 1;
			break;
		}
	}

	if (dame) co(0);
	else {
		bool guusuu = 0;
		rep(i, N) {
			if (lcm / A[i] % 2 == 0) guusuu = 1;
		}
		if (guusuu) co(0);
		else {
			ll kotae = (lcm / 2 + M) / lcm;
			co(kotae);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

    priority_queue<ll> aft;
    priority_queue<ll, vector<ll>, greater<ll>> bef;
    ll num[3 * N];
    vector<ll> top(N + 1, 0), end(N + 1, 0);

    rep(i, 3 * N)
    {
        cin >> num[i];
        if (i >= 0 && i < N)
        {
            bef.push(num[i]);
            top[0] += num[i];
        }
        else if (i >= 2 * N && i < 3 * N)
        {
            aft.push(num[i]);
            end[N] += num[i];
        }
    }

    repd(k, N, 2 * N)
    {
        ll back = 3 * N - k - 1;
        if (num[k] > bef.top())
        {
            top[k - N + 1] = top[k - N] + (num[k] - bef.top());
            bef.pop();
            bef.push(num[k]);
        }
        else
        {
            top[k - N + 1] = top[k - N];
        }
        if (num[back] < aft.top())
        {
            end[back - N] = end[back - N + 1] + (num[back] - aft.top());
            aft.pop();
            aft.push(num[back]);
        }
        else
        {
            end[back - N] = end[back - N + 1];
        }
    }

    ll ans = top[0] - end[0];
    repd(i, 1, N + 1)
    {
        ans = max(ans, top[i] - end[i]);
    }

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


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//    if(n==1)return false;
//    T i = 2;
//    while(i*i<=n){
//       if(n%i==0)return false;
//       i+=1;
//    }
//    return true;
//}

// bool prime[100005];
// void seive()
// {
//     memset(prime,true,sizeof(prime));
//     prime[0]=0;
//     prime[1]=0;
//     for(ll p=2;p*p<=100000;p++)
//     {
//         if(prime[p]==true)
//         {
//             for(ll i=p*2;i<=100000;i+=p)
//             prime[i]=false;
//         }
//     }    
// }

// ll power(ll n,ll k, ll mod){
//     if(k==0)
//         return 1;
//     if(k==1)
//         return n%mod;

//     ll get=power(n,k/2,mod);
//     ll ret = ((get%mod)*(get%mod))%mod;

//     if(k%2)
//         ret = ((ret%mod)*(n%mod))%mod;

//     return ret%mod;
// }

int main(){
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    FAST;
    
    int n; cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    vll dp(n);
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    repp(i,2,n){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    p(dp[n-1]);
}

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

 int main(){
          ios::sync_with_stdio(false);
  	  cin.tie(0); 
	  int N; 
	  cin>>N; 
	  vector<int> x(N); 
	  for(int i=0;i<N;i++){ 
		  cin>>x[i]; 
	  }  
	  vector<int> copy=x; 
	  sort(x.begin(),x.end()); 
	  int mid=N/2; 
	  int xmid=x[mid]; 
	  int xm=x[mid-1];

	  for(int i=0;i<N;i++){ 
		if (copy[i]<x[mid]){ 
			cout<<xmid<<" "; 
		}else{ 
			cout<<xm<<" "; 
		} 


	  }

    
    return 0; 
}


Measured memory_bytes: 3840
// AOJ 1086 Live Schedule
// 2018.2.4 bal4u

#include <stdio.h>
#include <string.h>

int E[31][16], F[31][16];
int dp[31][51][6];
int se[32], sf[32];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
    int C, D, W, X, c, d, w, x, k, ans;
	int nw, nx, t;

	while (C = in()) {
		D = in(), W = in(), X = in();

		for (c = 0; c < C; c++) for (d = 0; d < D; d++) E[d][c] = in();
		for (c = 0; c < C; c++) for (d = 0; d < D; d++) F[d][c] = in();

		memset(dp, 0, sizeof(dp));
		for (d = 0; d < D; d++) {
			for (c = 0; c < C; c++) se[c+1] = se[c] + E[d][c], sf[c+1] = sf[c] + F[d][c];

			for (w = 0; w <= W; w++) for (x = 0; x <= X; x++) {
				if (dp[d+1][w][x] < dp[d][w][x]) dp[d+1][w][x] = dp[d][w][x];
				for (c = 0; c < C; c++) for (k = c+1; k <= C; k++) {
					if (!E[d][k-1]) break;
					nw = w + sf[k]-sf[c], nx = x + (k-c>1);
	                if (nw <= W && nx <= X && dp[d+1][nw][nx] < (t=dp[d][w][x]+se[k]-se[c]))
						dp[d+1][nw][nx] = t;
				}
			}
		}

		ans = 0;
		for (w = 0; w <= W; w++) for (x = 0; x <= X; x++)
			if (ans < dp[D][w][x]) ans = dp[D][w][x];
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2040
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    {
      let mut v = Vec::new();
      for _ in 0..$i {
        v.push($e.get::<$t>());
      }
      v
    }
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let n = scan!(sc; i32);
  let mut s = scan!(sc => n; i32);
  let q = scan!(sc; i32);
  let t = scan!(sc => q; i32);
  s.sort();
  s.dedup();
  let mut v = s.iter().chain(t.iter()).map(|&v| v).collect::<Vec<i32>>();
  let mut ans = v.len();
  v.sort();
  v.dedup();
  ans -= v.len();
  println!("{}", ans);
}



Measured memory_bytes: 5048
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    if(n%2==1){
        FOR(i,1,m+1){
            cout<<i<<" "<<n+1-i<<endl;
        }
    }
    else{
        FOR(i,1,m/2+1){
            cout<<i<<" "<<m+1-i<<endl;
        }
        FOR(i,1,m/2+1+m%2){
            cout<<i+m<<" "<<(m+m+2)-i<<endl;
        }
    }
}

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

int main(){
  int a,b,sum=0;
  cin >>a>>b;
  
  for(a;a<=b;a++){
    int o,p,q,r,s;
    o=a/10000;
    p=(a-o*10000)/1000;
    q=(a-o*10000-p*1000)/100;
    r=(a-o*10000-p*1000-q*100)/10;
    s=a-o*10000-p*1000-q*100-r*10;

    
    if(o==s && p==r)
      sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int a, b;


int main() {
	
	cin >> a >> b;

	if (a > 9 || b > 9)
		cout << -1;
	else
		cout << a * b;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
ll poww(ll a,int b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1)
		{
			ans=ans*base%MOD;
		}
		base=base*base%MOD;
		b>>=1;
	}
	return ans%MOD;
}
int n,a,b;
ll c=1,ans;
int main(){
	n=read(),a=read(),b=read();
	ans=poww(2,n);
	//cout<<ans<<endl;
	FUP(i,1,b)
	{
		c=c*poww(i,MOD-2)%MOD*(n-(i-1))%MOD;
		//printf("%lld\n",c);
		if(i==a||i==b)
		{
			//cout<<c<<endl;
			ans=(ans+MOD-c)%MOD;
		}
	}
	printf("%lld",ans-1);
    return 0;
}

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

class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};

class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y):id(id),x(x),y(y){}
  bool operator < (const Point &p) const{
    return id < p.id;
  }

  void print(){
    printf("%d\n",id);
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x < p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y < p2.y;}


int makeKDTree(int l,int r,int depth){
  if( !(l<r) ) return NIL;

  int mid = (l+r)/2;
  int t = np++;
  if(depth % 2 == 0){
    sort(P+l,P+r,lessX);
  }else{
    sort(P+l,P+r,lessY);
  }
  T[t].location = mid;
  T[t].l = makeKDTree(l,mid,depth+1);
  T[t].r = makeKDTree(mid+1,r,depth+1);

  return t;
}


void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if(sx <= x && x <= tx && sy <= y && y <= ty){
    ans.push_back(P[T[v].location]);
  }

  if(depth % 2 == 0){
    if(T[v].l != NIL){
      if(sx <= x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r != NIL){
      if(x <= tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }else{
    if(T[v].l != NIL){
      if(sy <= y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r != NIL){
      if(y <= ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }
}



int main(){
  int x,y;
  scanf("%d",&N);

  for(int i=0;i<N;i++){
    scanf("%d %d",&x,&y);
    P[i] = Point(i,x,y);
    T[i].l = T[i].r = T[i].p = NIL;
  }

  np = 0;

  int root = makeKDTree(0,N,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<Point> ans;
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<ans.size();j++){
      ans[j].print();
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 15872