akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int p[100000];
	for(int i=0;i<100000;i++){
		p[i]=0;
	}
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		int hoge;
		cin>>hoge;
		p[hoge-1]++;
	}
	for(int i=0;i<n;i++){
		if(p[i]+k-q>0){cout<<"Yes"<<endl;}
		else{cout<<"No"<<endl;}
	}
	return 0;
}

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

int main() {
	int N, M, i;
	cin >> N >> M;
	if (N == 1) cout << M;
	else if (M == 1) cout << 1;
	else {
		for (i = 2; i <= M / 2; ++i) {
			if (M % i == 0 && N <= i) break;
		}
		if (i == M / 2 + 1) cout << 1;
		else cout << M / i;
	}
}

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

ans = 0
res = 10**9
for i in range(x-100, x+101):
    if i in p:
        continue
    diff = abs(x-i)
    if diff < res:
        ans = i
        res = diff
print(ans)

Measured memory_bytes: 9188
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,h,w; cin >> n >> h >> w; ll cnt = 0;
  
  rep(i,n){
    ll x,y; cin >> x >> y;
    if(x >= h and y >= w) cnt++;
  }
  
  cout << cnt << endl;
  
  
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		System.out.println(n / 2 + n % 2 >= k ? "YES" : "NO");
		sc.close();
	}

}


Measured memory_bytes: 21332
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	static const int DATA_SET_MAX = 3000;
	static const int INPUT_X_MAX = 10000;
	static const int INPUT_Y_MAX = 10000;
	static const int INPUT_X_MIN = 0;
	static const int INPUT_Y_MIN = 0;
	int case_cnt = 1;
	int input_x = 0;
	int input_y = 0;

	do{
		cin >> input_x;
		cin >> input_y;

		assert (INPUT_X_MIN <= input_x && input_x <= INPUT_X_MAX); /* Precondition */
		assert (INPUT_Y_MIN <= input_y && input_y <= INPUT_Y_MAX); /* Precondition */

        /* Output */
		if((input_x == 0) && (input_y == 0)){
			break;
		}
		else{
			if (input_x <= input_y){
				cout << input_x << " " << input_y << endl;
			}
			else{
				cout << input_y << " " << input_x << endl;
			}
		}
		case_cnt++;
	}while(case_cnt < DATA_SET_MAX);
	return 0;
}




Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

int main()
{
    std::string S;
    std::cin >> S;
    int a = 0, b = 0;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '0') a++;
        else b++;
    }


    a = 2 * std::min(a, b);

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  map<int,int>M;
  for(int i=0;i<N;i++){
  int a;
    cin>>a;
    if(M.count(a))
      M.at(a)++;
    else
      M[a]=1;
  }int ans=0;
  for(auto p:M){
  auto k=p.first;
    auto v=p.second;
    if(k<=M.at(k))
      ans+=M.at(k)-k;
    else
      ans+=M.at(k);
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 4736
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si(),m = si();
			if(n==0) break;

			boolean[] ary = new boolean[n];
			int cnt = 0,pos = 0;
			while(cnt!=n){
				for (int i = 0; i < m ;) {
					if(ary[pos]) pos++;
					else{
						pos++;
						i++;
					}
					pos%=n;
				}
				pos=(pos-1+n)%n;
				cnt++;
				ary[pos]=true;
			}
			out.println(pos+1);
		}
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

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

#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define all(v) v.begin(),v.end()
#define mod %
#define pb push_back

const ll N = (ll)(100007);


int main()
{
	FIO
	int a, b, val;
	val = (1^2^3);
	cin >> a >> b;
	cout << (val^a^b) << "\n";
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b/c-(a-1)/c;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int P;
  int Q;
  int R;
  cin >> P >> Q >> R;
  int a=P+Q;
  int b=P+R;
  int c=Q+R;
  int d=min(min(a, b), c);
  cout << d << endl;
              }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[105];
double c,s;
int main()
{
    cin>>n>>m;
    for(register int i=1;i<=n;i++)
        cin>>a[i],s+=a[i];
    for(register int i=1;i<=n;i++)
        if(a[i]>=(s/(4*m)))
            c++;
    if(c>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string c_1, c_2, c_3, answer;
    cin >> c_1 >> c_2 >> c_3;
    answer += c_1[0];
    answer += c_2[1];
    answer += c_3[2];
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,j,r;
  char g;
  for(;;){
    scanf("%d %d %d",&i,&j,&r);
      if(i==-1&&j==-1&&r==-1){
        return 0;
      } else if(i==-1||j==-1){
        g='F';
      }
        else if(i+j>=80){
        g='A';
      } else if (i+j>=65){
        g='B';
      } else if (i+j>=50){
        g='C';
      } else if (i+j>=30&&r>=50){
        g='C';
      } else if (i+j>=30){
        g='D';
      } else {
        g='F';
      }
    printf("%C\n",g);
  }
}

Measured memory_bytes: 2664
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
k = ni()

lens = len(s)

subset = set()

for i in range(len(s)):
    for j in range(1,k+1):
        subset.add(s[i:i+j])
        
sublist = sorted(list(subset))
print(sublist[k-1])

Measured memory_bytes: 4592
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX 1e9+7
#define lim 1e5
using namespace std;

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

	int n=s.length();
	int m=t.length();

	int dp[n+1][m+1];

	

	memset(dp,0,sizeof(dp));

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
				dp[i][j] = dp[i-1][j-1]+1;	

			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	//cout<<dp[n][m]<<endl;



	int i=n , j=m , len=dp[n][m]+1;

	char ans[len];
		
	ans[len-1]='\0';
	len-=2;

	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans[len] = s[i-1];
			i--;
			j--;
			len--;
		}	

		
		else if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}

		else
		{
			j--;
		}	
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 35456
def 解():
    sx,sy,tx,ty = [int(_) for _ in input().split()]

    #スタート地点を{0,0}にする
    tx = tx - sx
    ty = ty - sy


    if tx != 0 and ty != 0:
        if 0 < ty  and  0 < tx :
            aV = ["U","R","D","L"]
            d1 = ty
            d2 = tx
        elif ty < 0 and 0 < tx :
            aV = ["R","D","L","U"]
            d1 = tx
            d2 = -ty
        elif ty < 0 and tx < 0:
            aV = ["D","L","U","R"]
            d1 = -ty
            d2 = -tx
        elif 0 < ty and tx < 0:
            aV = ["L","U","R","D"]
            d1 = -tx
            d2 = ty
        print("".join( [aV[0]*d1,aV[1]*d2,aV[2]*d1,aV[3]*(d2+1),aV[0]*(d1+1),aV[1]*(d2+1),aV[2],aV[1],aV[2]*(d1+1),aV[3] * (d2+1), aV[0]]))
    else:
        if 0 < ty and tx == 0:
            aV = ["U","R","D","L"]
            d1 = ty
            d2 = tx
        elif ty == 0 and 0 < tx :
            aV = ["R","D","L","D"]
            d1 = tx
            d2 = ty
        elif ty < 0 and tx == 0 :
            aV = ["D","L","D","R"]
            d1 = ty
            d2 = tx
        elif ty == 0 and tx < 0 :
            aV = ["L","D","R","D"]
            d1 = tx
            d2 = ty
        print("".join([ aV[0]*d1, aV[1], aV[2] * d1, aV[3] * 2, aV[0] * d1, aV[1], aV[0] , aV[1] * 2 , aV[2] * (d1+2),aV[3] * 2, aV[0]]))

解()

Measured memory_bytes: 3320
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] V = new int[N];
    for (int i = 0; i < N; i++) {
      V[i] = sc.nextInt();
    }
    
    int max = Integer.MIN_VALUE;
    for (int a = 0; a <= Math.min(N, K); a++) {
      for (int b = 0; a+b <= Math.min(N, K); b++) {
        int del = K-(a+b);
        int val = calc(V, a, b, del);
        max = Math.max(max, val);
      }
    }

    System.out.println(max);
  }
  
  private static int calc(int[] V, int a, int b, int del) {
    PriorityQueue<Integer> q = new PriorityQueue<>();
    int sum = 0;
    for (int i = 0; i < a; i++) {
      if (V[i] < 0) {
        q.offer(V[i]);
      }
      sum += V[i];
    }
    for (int i = 0; i < b; i++) {
      int v = V[V.length-1-i];
      if (v < 0) {
        q.offer(v);
      }
      sum += v;
    }
    while (!q.isEmpty() && del > 0) {
      int v = q.poll();
      sum -= v;
      del--;
    }
    return sum;
  }
}



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

bool aks(vector<int> &a)
{
  putchar('?');
  for(int i=0;i<a.size();i++){
    printf(" %d",a[i]+1);
  }
  putchar('\n');
  fflush(stdout);
  char s[10];
  scanf("%s",s);
  return s[0]=='R';
}

int main()
{
  int n;
  scanf("%d",&n);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=i;
  }
  bool X=aks(a);
  int L=0,R=n;
  while(L+1<R){
    int m=(L+R)/2;
    for(int i=0;i<m;i++){
      a[i]=i+n;
    }
    for(int i=m;i<n;i++){
      a[i]=i;
    }
    bool Y=aks(a);
    if(X==Y){
      L=m;
    }
    else{
      R=m;
    }
  }
  int t=L;
  vector<int> ans(2*n);
  ans[t]=X;
  ans[n+t]=!X;
  for(int i=0;i<t;i++){
    a[t]=i;
    ans[i]=aks(a);
  }
  for(int i=n+t+1;i<2*n;i++){
    a[t]=i;
    ans[i]=aks(a);
  }
  vector<int> b(n);
  for(int i=0;i<t;i++){
    b[i]=i;
  }
  for(int i=t;i<n-1;i++){
    b[i]=i+n+1;
  }
  for(int i=t+1;i<n+t;i++){
    b[n-1]=i;
    ans[i]=aks(b);
  }
  printf("! ");
  for(int i=0;i<2*n;i++){
    printf("%c",ans[i]?'R':'B');
  }
  putchar('\n');
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 724
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	if len(res)==0:
		res = [n]
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	#data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	#ans = data[:]
	return ans

n = readInt()
a = readInts()
a.sort()

#max_a = 10**6
max_a = a[-1]
ans = [0]*(max_a+1)

for i in a:
	if ans[i]!=2:
		ans[i]+=1
for i in set(a):
	if ans[i]<=2:
		for j in range(i*2,len(ans),i):
			ans[j]+=3

print(ans.count(1))

Measured memory_bytes: 40872
#include<cstdio>
#include<iostream>

using namespace std;
int N=100000;


int main() {
  int n;
  int A[N], B[N];
  scanf("%d", &n);
  //printf("%d\n",n);
  for(int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  
  for(int i=1; i<n; i++){
    B[i-1]= A[i] - A[i-1];
  }
  int cnt = 0;
  int b = B[0];
  int kou=0, bon=0, yama=0, mine=0, kubo=0;

  for(int i=1; i<n-1; i++){
    if(B[i]==0){
      cnt += 1;
    }
    else if(B[i]<0){
      if(b>0 && cnt>0){
	kou+=1;
      }
      else if(b>0 && cnt==0){
	mine+=1;
      }
      else if(b<0 && cnt>0){
	yama+=1;
      }
      b=B[i];
      cnt=0;
    }
    else{
      if(b<0 && cnt==0){
	kubo+=1;
      }
      else if(b<0 && cnt>0){
	bon+=1;
      }
      else if(b>0 && cnt>0){
	yama+=1;
      }
      b=B[i];
      cnt=0;
    }
  }

  
  cout<<kou<<" "<<bon<<" "<<yama<<" "<<mine<<" "<<kubo<<endl;
	
	return 0;
	
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;

void bfs(string s, char mc)
{
	if (N == s.size())
	{
		std::cout << s << std::endl;
		return;
	}

	for (char c = 'a'; c <= mc+1; ++c)
	{
		bfs(s + c, max(c, mc));
	}
}

int main(int argc, char **argv)
{
	cin >> N;
	bfs("a", 'a');
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
	

	int A, B, H, W;
	cin >> H >> W >> A >> B;

	for (int i = 0; i < H; i++) {

		for (int j = 0; j < W; j++) {

			if (i < B && j < A) {
				cout << 1;
			}
			else if (i < B && j >= A) {
				cout << 0;
			}
			else if (i >= B && j < A) {
				cout << 0;
			}
			else {
				cout << 1;
			}

		}

		cout << endl;

	}







}

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

int main()
{
  int H, W;

  cin >> H >> W;

  while( H != 0 or W != 0 ) {

    for( int i = 0; i < H; i++ ) {
      for( int j = 0; j < W; j++ ) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;

    cin >> H >> W;
  }

  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int TwicePreviousValue = 1;
int PreviousValue = 1;

int Fibonacci(const int& n)
{
	if(n == 0) return TwicePreviousValue;
	if(n == 1) return PreviousValue;
	int CurrentValue = TwicePreviousValue + PreviousValue;
	for(int i = 2; i < n; i++){
		int TemporaryValue = PreviousValue;
		CurrentValue  += PreviousValue;
		PreviousValue += TwicePreviousValue;
		TwicePreviousValue = TemporaryValue;
	}
	return CurrentValue;
}
 
int main()
{
	int n;
	cin >> n;
	cout << Fibonacci(n) << endl;
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int n; cin >> n;
	rep(d, 1, n + 1) {
		char g[8][8];
		rep(y, 0, 8)rep(x, 0, 8)cin >> g[x][y];
		int X, Y; cin >> X >> Y; X--; Y--;
		queue<pii> q;
		q.push(pii(X, Y));
		rep(i, -3, 4) q.push(pii(X + i, Y));
		rep(i, -3, 4) q.push(pii(X, Y + i));
		while (!q.empty()) {
			pii c = q.front(); q.pop();
			if (g[c.first][c.second] == '0')continue;
			if (c.first < 0 || c.second < 0 || c.first >= 8 || c.second >= 8)continue;
			g[c.first][c.second] = '0';
			rep(i, -3, 4) q.push(pii(c.first + i, c.second));
			rep(i, -3, 4) q.push(pii(c.first, c.second + i));
		}
		cout << "Data " << d << ":" << endl;
		rep(y, 0, 8) { rep(x, 0, 8)cout << g[x][y]; cout << endl; }
	}
	return 0;
}

Measured memory_bytes: 3012
#include <stdio.h>
#include <stdlib.h>

int desc(const void *a, const void *b) {
	return *(int *)b - *(int *)a;
}

int main() {
	int num[3], i;

	for (i = 0; i < 3; i++) {
		scanf("%d", &num[i]);
	}

	qsort(num, 3, sizeof(int), desc);
	printf("%d", num[0] * 10 + num[1] + num[2]);

	return 0;
}

Measured memory_bytes: 128
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int d;
	while (cin >> d)
	{
		int sum = 0;
		for (size_t i = 0; i < 600/d; i++)
		{
			sum += i*d*i*d*d;
		}
		cout << sum << endl;
	}
	return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int a,b,h;
  scanf("%d %d %d",&a,&b,&h);
  printf("%d\n",((a + b) * h )/ 2);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int P[N], Q[N];
  for (int i = 0; i < N; i++) { cin >> P[i]; }
  for (int i = 0; i < N; i++) { cin >> Q[i]; }
  int a, b;
  int arr[N];
  for (int i = 0; i < N; i++) { arr[i] = i+1; }
  int cnt = 1;
  do {
    int p = 1;
    int q = 1;
    for (int i = 0; i < N; i++) {
      if (P[i] != arr[i]) {
        p = 0;
        break;
      }
    }
    for (int i = 0; i < N; i++) {
      if (Q[i] != arr[i]) {
        q = 0;
        break;
      }
    }
    if (p == 1) {
      a = cnt;
      //cout << cnt << endl;
    }
    if (q == 1) {
      b = cnt;
      //cout << cnt << endl;
    }
    cnt++;
  } while (next_permutation(arr, arr+N));
  cout << abs(a - b) << endl;
  return 0;
}

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

#include <algorithm>
#include <vector>
using namespace std;

using coord_t = double;
using coord2_t = double;

struct Point {
  coord_t x, y;

  Point() {}
  Point(coord_t x, coord_t y) : x(x), y(y) {}

  bool operator<(const Point &p) const {
    return x < p.x || (x == p.x && y < p.y);
  }
};

coord2_t cross(const Point &O, const Point &A, const Point &B) {
  return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

vector<Point> convex_hull(vector<Point> P) {
  int n = P.size(), k = 0;
  if (n == 1) return P;
  vector<Point> H(2 * n);

  sort(P.begin(), P.end());

  for (int i = 0; i < n; ++i) {
    while (k >= 2 && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
    H[k++] = P[i];
  }

  for (int i = n - 2, t = k + 1; i >= 0; i--) {
    while (k >= t && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
    H[k++] = P[i];
  }

  // cout << "P" << endl;
  // for (int i = 0; i < P.size(); ++i) {
  //   cout << fixed << setprecision(5) << P[i].x << " " << P[i].y << endl;
  // }
  // cout << "H" << endl;
  // for (int i = 0; i < H.size(); ++i) {
  //   cout << fixed << setprecision(5) << H[i].x << " " << H[i].y << endl;
  // }

  H.resize(k - 1);
  return H;
}

int main() {
  int n;
  while (cin >> n, n) {
    vector<Point> v;
    for (int i = 0; i < n; ++i) {
      double x, y;
      scanf("%lf,%lf", &x, &y);
      // cout << x << " " << y << endl;
      v.push_back(Point(x, y));
    }

    vector<Point> ConvexHull = convex_hull(v);
    cout << n - ConvexHull.size() << endl;

    // for (int i = 0; i < ConvexHull.size(); ++i) {
    //   cout << fixed << setprecision(10) << ConvexHull[i].x << " " << ConvexHull[i].y << endl;
    // }
  }
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  switch(N%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}

Measured memory_bytes: 3580
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=1e5+5;
int main()
{
      int arr[3];

      scn(arr[0]);
      scn(arr[1]);
      scn(arr[2]);

      sort(arr,arr+3);

      if(arr[0]==5 && arr[1]==5 && arr[2]==7)
      {
          cout<<"YES";
      }
      else
      {
          cout<<"NO";
      }
}



Measured memory_bytes: 3764
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
k = input[2].to_i

if k - (a + b) >= 0
    a = 0
    b = 0
elsif k - a >= 0
    b -= (k - a)
    a = 0
else
    a -= k
end

puts a.to_s + " " + b.to_s

Measured memory_bytes: 1788
let () =
  Scanf.scanf "%d %s" @@ fun n s ->
  let a = Array.init (n+1) (fun i -> if i > 0 && s.[i-1] = '#' then 1 else 0) in
  for i = 1 to n do a.(i) <- a.(i) + a.(i-1) done;
  Array.init (n+1) (fun i -> a.(i) + (n - i) - (a.(n) - a.(i)))
  |> Array.fold_left min n |> Printf.printf "%d\n"



Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int A=26, N=1e6+6;
struct node{
    int32_t go[A];
    int32_t hav[A];
    // map<char, int32_t> go;
    bool term;
    int32_t down;
    node(){
        memset(go,0,sizeof go);
        memset(hav,0,sizeof hav);
        term=0;
        down=0;
    }
} trie[N];
int ffr=2; // 0 is nullptr,1 is root
void insert(const string & s){
    int v=1;
    int cnt[A]={0};
    for(char c:s){
        cnt[c-'a']++;
    }
    forn(i,A){
        trie[v].hav[i]+=!!cnt[i];
        // dbg(v,cnt[i],!!cnt[i],trie[v].hav[i]);
    }
    for(char c:s){
        if(!trie[v].go[c-'a']){
            trie[v].go[c-'a']=ffr++; 
        }
        v=trie[v].go[c-'a']; 
        cnt[c-'a']--;
        forn(i,A)trie[v].hav[i]+=!!cnt[i];
    }
    trie[v].term=1;
}
int ans=0;
void dfs(int v,int p=0,int kak=0){
    trie[v].down=trie[v].term;
    forn(i,A){
        int to=trie[v].go[i];
        if(to){
            dfs(to,v,i);
            trie[v].down+=trie[to].down;
        }
    }
    // dbg(v,p,kak,trie[v].term,trie[v].down,trie[v].hav[0],trie[v].hav[1],trie[v].hav[2],trie[v].hav[3]);
    if(trie[v].term){
        // dbg("was",ans);
        ans+=trie[v].down-1;
        // dbg("sub",ans);
        ans+=trie[p].hav[kak]-trie[v].down;
        // dbg(ans);
    }
}

int32_t main(){
    int n;
    cin>>n;
    forn(i,n){
        string s;
        cin>>s;
        reverse(s.begin(), s.end());
        insert(s);
    }
    dfs(1);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 290544
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;cin>>n;
	int a[n],i,sum=0;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	int v1,v2;
	if(sum%n)
	{
	    v1=sum/n;
	    v2=v1+1;
	}
	else
	{
	    v1=sum/n;
	    v2=v1;
	}
	int ans1=0,ans2=0;
	for(i=0;i<n;i++)
	{
	    ans1+=pow(a[i]-v1,2);
	    ans2+=pow(a[i]-v2,2);
	}
	//cout<<sum<<" "<<ans1<<" "<<ans2<<endl;
	cout<<min(ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    int A, B = 0;
    cin >> A >> B;

    int count = 0;
    int sum = 1;
    while (sum < B)
    {
        sum += A - 1;

        count++;
    }
    cout << count;
}


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

const int MAX = 10;
int main() {
	int N, L;
	cin >> N >> L;
	int big = L, sum = L;
	for (int i = 1;i < N;++ i) {
		cin >> L;
		big = max(big, L);
		sum += L;
	}
	cout << (big * 2 < sum ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

なんで問題文中に解き方書いてんのこれ
*/

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
 
int main()
{
  string s;
  cin >> s;
  cout << s[0] << s.length() - 2 << s[s.length()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    ls <- List.sort . map read . words <$> getContents
    putStrLn $ if ls !! 0 + ls !! 1 == ls !! 2 then "Yes" else "No"

Measured memory_bytes: 508
N = int(input())
h = []
for _ in range(N) :
    A, B = map(int, input().split())
    h.append((A + B, A, B))
    
h.sort(reverse=True)
print(sum([h[i][1] for i in range(0, N, 2)]) - sum([h[i][2] for i in range(1, N, 2)]))

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

const int N = 8e5 + 100;

#define L (x<<1)
#define R (x<<1|1)

template <class T> void Max (T &x, T y) { if (x < y) x = y; }
template <class T> void Min (T &x, T y) { if (x > y) x = y; }
typedef long long ll;
ll ans = 2e18;

struct Sgt {
	
	ll a[N], b[N], ta[N];
	
	void update (int x) {
		a[x] = min(a[L], a[R]);
		b[x] = min(b[L], b[R]);
	}
	
	void set_tag (int x, ll t) {
		a[x] += t;
		b[x] += t;
		ta[x] += t;
	}
	
	void pushdown (int x) {
		if (ta[x]) {
			set_tag(L, ta[x]);
			set_tag(R, ta[x]);
			ta[x] = 0;
		}
	}
	
	void Modify (int x, int l, int r, int z, ll t) {
		int mid;
		while (l != r) {
			mid = (l + r) >> 1; pushdown(x);
			if (z <= mid) r = mid, x = L;
			else l = mid + 1, x = R;
		}
		Min(a[x], t - z);
		Min(b[x], t + z);
		for (x >>= 1; x; x >>= 1) update(x);
	}
	
	ll Query (int x, int l, int r, int ql, int qr, bool o) {
		if (l == ql && r == qr) return o ? b[x] : a[x];
		int mid = (l + r) >> 1; pushdown(x);
		if (qr <= mid) return Query(L, l, mid, ql, qr, o);
		if (ql > mid) return Query(R, mid + 1, r, ql, qr, o);
		return min(Query(L, l, mid, ql, mid, o), Query(R, mid + 1, r, mid + 1, qr, o));
	}
	
	void Get (int x, int l, int r) {
		if (l == r) return Min(ans, a[x] + l);
		int mid = (l + r) >> 1; pushdown(x);
		Get(L, l, mid);
		Get(R, mid + 1, r);
	}
	
	Sgt () { 
		memset(a, 0x3f, sizeof a);
		memset(b, 0x3f, sizeof b);
	}
}f, g;

int n, q, a, b;

int main () {
	scanf("%d%d%d%d", &n, &q, &a, &b);
	for (int i = 1, x, la; i <= q; ++i) {
		scanf("%d", &x);
		if (i == 1) {
			f.Modify(1, 1, n, b, abs(x - a));
			g.Modify(1, 1, n, a, abs(x - b));
		} else {
			ll u = min(g.Query(1, 1, n, 1, x, 0) + x, g.Query(1, 1, n, x, n, 1) - x), v = min(f.Query(1, 1, n, 1, x, 0) + x, f.Query(1, 1, n, x, n, 1) - x);
			f.set_tag(1, abs(la - x));
			g.set_tag(1, abs(la - x));
			f.Modify(1, 1, n, la, u);
			g.Modify(1, 1, n, la, v);
		}
		la = x;
	}
	f.Get(1, 1, n);
	g.Get(1, 1, n);
	printf("%lld", ans);
	return 0;
}
/*
8 2 1 8
3 5 
*/

Measured memory_bytes: 37120
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;




int main() {
 long long a;
 cin>>a;
 vector<long long> vec(a);
 rep(i,a){
   cin>>vec.at(i);
 }
 vector <long long> sum(a);
 sum.at(0)=vec.at(0);
 for(int i=1;i<a;i++){
   sum.at(i)=sum.at(i-1)+vec.at(i);
 }
 long long lengt=sum.at(a-1);
 long long min=INF;
 int minnum;
 rep(i,a-1){
   if(abs(lengt-2*sum.at(i))<min){
     minnum=i;
     min=lengt-2*sum.at(i);
   }
 }
 cout<<abs(min)<<endl;
}


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

int main() {
	int n ;
	cin >> n ;
	int a[n][3] , h[n][3] ;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2] ;
	h[0][0] = a[0][0];
	h[0][1] = a[0][1];
	h[0][2] = a[0][2];
	for(int i = 1; i < n ; i++)
	{
		h[i][0] = max(h[i-1][1],h[i-1][2])+a[i][0];
		h[i][1] = max(h[i-1][0],h[i-1][2])+a[i][1];
		h[i][2] = max(h[i-1][0],h[i-1][1])+a[i][2];
	}
	cout << max({h[n-1][0],h[n-1][1],h[n-1][2]});
	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i,N) {
        int a;
        cin >> a;
        A[i] = a;
    }
    map<ll,ll> S,T;

    rep(i,N) {
        ll a,b;
        a = i+1+A[i];
        b = i+1-A[i];
        S[a]++;
        T[b]++;
    }

    ll ans = 0;

    for (auto tmp:S) {
        ll a = tmp.first;
        ll num = tmp.second;

        ans += T[a]*num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 38704
#include<iostream>
using namespace std;
long long c=0;

void Merge(long int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    long int L[n1+1];
    long int R[n2+1];
    for(int i=0;i<n1;i++)
        {L[i]=A[left+i];}
    for(int i=0;i<n2;i++)
        {R[i]=A[mid+i];}
    L[n1]=5000000000;
    R[n2]=5000000000;
    int i=0;
    int j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j])
            A[k]=L[i++];
        else
            A[k]=R[j++];
        c++;
    }
}

void MergeSort(long int A[],int left,int right){
    if(left + 1< right){
        int mid=(left+right)/2;
        MergeSort(A,left,mid);
        MergeSort(A,mid,right);
        Merge(A,left,mid,right);
    }
}

int main(){
    int N;
    cin>>N;
    long int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    MergeSort(A,0,N);

    for(int i=0;i<N-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[N-1]<<endl<<c<<endl;
    return 0;
}



Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,m;
  cin>>n>>m;
  vector<vector<int>> dist(n, vector<int>(n, 10'000'000));
  REP(i,n){
    dist[i][i] = 0;
  }
  int a[m],b[m],c[m];
  REP(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  REP(k,n){
    REP(i,n){
      REP(j,n){
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  
  int ans=0;
  bool flag;
  REP(i,m){
    flag = false;
    REP(s,n){
      REP(t,n){
        if(dist[s][t]==dist[s][a[i]]+c[i]+dist[b[i]][t] || dist[s][t]==dist[s][b[i]]+c[i]+dist[a[i]][t]){
          flag = true;
          break;
        }
      }
      if(flag)break;
    }
    if(flag)ans++;
  }
  
  ans = m-ans;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int K = keyboard.nextInt();
		int A = keyboard.nextInt();
		int B = keyboard.nextInt();
		
		String ans ="NG"; 
		for(int x=A; x<=B; x++) {
			if(x%K == 0)
			ans = "OK";
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100010
int prog;
int n;
LL dp[MAXSIZE];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>prog;
	REP(i,n){
		int w;
		LL v;
		cin>>w>>v;
		FORD(j,prog,w)
			dp[j]=max(dp[j-w]+v,dp[j]);
	}
	
	cout<<dp[prog];
	
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    string s;
    vector<string> S(N);
    vector<psi> Sp;
    string previous = "";
    int count = 1;

    rep(i, N)
    {
        cin >> S[i];
    }

    sort(S.begin(), S.end());

    int maxVal = 0;

    for (int i = 0; i < N; i++)
    {
        s = S[i];
        if (i == 0)
        {
            previous = s;
        }
        else if (i == N - 1)
        {
            if (previous == s)
            {
                Sp.push_back(make_pair(previous, ++count));
                if (maxVal < count)
                    maxVal = count;
            }
            else
            {
                Sp.push_back(make_pair(previous, count));
                Sp.push_back(make_pair(s, 1));
                if (maxVal < count)
                    maxVal = count;
            }
        }
        else if (previous == s)
        {
            count++;
        }
        else
        {
            Sp.push_back(make_pair(previous, count));
            if (maxVal < count)
                maxVal = count;
            previous = s;
            count = 1;
        }
    }

    int max = 0;

    rep(i, Sp.size())
    {
        if (Sp[i].second == maxVal)
        {
            cout << Sp[i].first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 18676
n,a = map(int,input().split())
if n == 1:
  print(1)
  exit()
if n <= a:
  print(n)
  exit()
#n <= x**(k-i)*(x-1)**iのk-iを返す
def border(x,k):
  L = 0
  R = k
  while L+1 < R:
    M = (L+R)//2
    if x**(k-M)*(x-1)**(M) < n:
      R = M
    else:
      L = M
  return k-L
def sec(k):
  y = int(n**(1/k))+1
  if (y-1)**k < n <= y**k:
    x = y
  elif y**k < n <= (y+1)**k:
    x = y+1
  elif (y-2)**k < n <= (y-1)**k:
    x = y-1
  b = border(x,k)
  return (x+a)*k-(k-b)
ansls = []
for i in range(1,51):
  ansls.append(sec(i))
print(min(ansls)-a)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
struct Node
{
    int a,b;
}s[maxn];
bool cmp(Node a,Node b)
{
    return a.a<b.a;
}
int main()
{

    int m,n;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    scanf("%d%d",&s[i].a,&s[i].b);
        sort(s,s+n,cmp);
      ll sum=0;
        for(int i=0;i<n&&m;i++)
        {
               if(m>=s[i].b)
              {
                  m-=s[i].b;
                  sum+=(ll )s[i].a*s[i].b;
              }
              else
              {

                  sum+=(ll)s[i].a*m;
                  m=0;
              }
        }
        printf("%lld\n",sum);


    return 0;
}


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

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

  vector<int> fruits(N);
  
  for (int i=0; i < N; ++i) {
    cin >> fruits[i];
  }
  sort(fruits.begin(), fruits.end());

  int result = 0;
  for (int i=0; i < K; ++i) {
    result += fruits[i];
  }
  cout << result << "\n";
}

Measured memory_bytes: 3624
#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;

#define N 200020
lli cnt[N];

int main()
{
    int n;
    cin >> n;
    lli a[n];
    for(auto &x: a) cin >> x;

    for(auto x: a){
        cnt[x]++;
    }
    lli ans = 0;
    for(auto x: cnt){
        ans += (x*(x-1))/2;
    }
    for(auto x: a){
        lli y = ans;
        y -= (cnt[x]*(cnt[x]-1))/2;
        y += ((cnt[x]-1)*(cnt[x]-2)) / 2;
        cout << y << "\n";
    }

//    cout << 200000 << "\n";
//    for(int i=0; i<200000; i++){
//        cout << 4 << " ";
//    }
//    cout << endl;

    return 0;
}


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

int main() {
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >>a.at(i);
  
  int x=0;
  for(int i=N-1; i>=0; i--){
    for(int j=0; j<i; j++){
      if(a.at(j)<a.at(j+1)){
        x=a.at(j);
        a.at(j)=a.at(j+1);
        a.at(j+1)=x;
        x=0;
      }
    }
  }
  
  int A,B;
  for(int i=0; i<N; i+=2) A +=a.at(i);
  for(int i=1; i<N; i+=2) B +=a.at(i);
  
  cout <<A-B<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s,t;
	cin >> n;
	cin >> s;
	cin >> t;
	for(int i=0;i<n;i++){
		int x=0;
		for(int j=i;j<n;j++){
			if(s[j]==t[x]){
				x++;
			}
		}
		if(x==n-i){
			cout << n+i << endl;
			return 0;
		}
	}
	cout << n*2 << endl;
	return 0;
}

Measured memory_bytes: 256
t[3600];w,h,c,z;f(x,i){for(t[x]=0;i;t[z=x+"<>xyz\1\2"[--i]-61]&&f(z,8));}main(i){for(;scanf("%d%d",&w,&h)*h;printf("%d\n",c)){for(i=++h;c=--i;)for(z=w;z;)scanf("%d",i*60+z--+t);for(;!i?i=w,--h:1;)t[z=h*60+i--]&&++c-f(z,8);}}

Measured memory_bytes: 0