akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>                                                                               
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
#define FORE(v1, v2) for (v1 = 0; v1 <= v2; ++v1)
#define FORO(v1, v2) for (v1 = 1; v1 < v2; ++v1)
#define FOROE(v1, v2) for (v1 = 1; v1 <= v2; ++v1)
using ll = long long;
constexpr ll kMod = 1'000'000'007;
int main () {
  int n, k;
  int i;
  cin >> n >> k;
  vector<ll> h(n);
  FOR(i, n) {
    cin >> h[i];
  }


  if (k >= n) {
   cout << "0";
   return 0;
  }

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

  ll sum = 0;
  FOR(i, n-k) {
     sum += h[n-1-i-k];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*n
for i in range(n,0,-1):
    m,c = 2,0
    while i*m<=n:
        c+=x[i*m-1]
        m+=1
    x[i-1] = (a[i-1]+c%2)%2
print(sum(x))
for i in range(n):
    if x[i]: print(i+1)

Measured memory_bytes: 7276
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int h[]=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			h[i]=scan.nextInt();
		}
		h[0]=0;
		for(int i=1;i<=n;i++)
		{
			if(h[i]>h[i-1]) {
				h[i]--;
			}
		}
		for(int i=1;i<=n;i++)
		{
		if(h[i]>=h[i-1])
		{
			
		}else {
//			System.out.println(i);
			System.out.println("No");
			return;
		}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 48788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N],B[N];
    priority_queue<pair<ll,ll>> que;
    REP(i,N) cin >> A[i];
    REP(i,N){
        cin >> B[i];
        if(A[i] != B[i]) que.push({B[i],i});
        if(B[i] < A[i]){cout << -1 << endl;return 0;}
    }
    ll ans = 0,cnt = 0;
    while(!que.empty()){
        pair<ll,ll> p = que.top();que.pop();
        ll i = p.second -1,j = p.second +1;
        if(j == N) j = 0;if(i == -1) i = N-1;
        ll mid = p.second;
        if(B[mid] - A[mid] < B[i]+B[j]){cout << -1 << endl;return 0;}
        else if(B[mid] - A[mid] >= B[i] + B[j]){
            ll X = B[mid] - A[mid];
            ll Y = X / (B[i]+B[j]);
            ans += Y;
            B[mid] -= (B[i]+B[j])*Y;
            if(B[mid] != A[mid]) que.push({B[mid],mid});
        }
    }
    REP(i,N){
        if(A[i] != B[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

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



Measured memory_bytes: 256
s=input()[::-1]
alist=[0]*2019
num1=0
num2=1/10
lens=len(s)
for i in range(lens):
  num2=int(((num2)*10)%2019)
  num1=(num1+int(s[i])*(num2))%2019
  alist[num1]+=1
alist[0]+=1
ans=0
for i in range(2019):
  ans+=alist[i]*(alist[i]-1)//2
print(ans)

Measured memory_bytes: 9316
n,m=map(int,input().split())
ans1=[]
ans2=[]
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    ans1.append(b)
  if b==n:
    ans2.append(a)
    
ans=set(ans1)&set(ans2)
if len(ans)>0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 27456
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=200111;
int n,l,a[maxn],f[maxn],lv[maxn],rv[maxn];
LL ans;
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}

int main()
{
	scanf("%d%d",&n,&l);
	
	set<pii> st;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		st.insert(mp(a[i],i));
		f[i]=i;lv[i]=rv[i]=1;
	}
	f[n+1]=n+1;
	while(st.size())
	{
		int mn=st.begin()->ff,cur=st.begin()->ss,sum;
		vector<int> vs;
		while(cur<=n&&a[cur]==mn)
		{
			st.erase(mp(mn,cur));
			vs.pb(cur);
			cur=gf(cur+1);
		}
		
		if((int)vs.size()<l)continue;
		cur=0;sum=0;
		for(int i=0;i<(int)vs.size();i++)
		{
			while(cur<(int)vs.size()&&i-cur+1>=l)sum+=lv[vs[cur++]];
			ans+=(LL)sum*rv[vs[i]];
		}
		int sz=(int)vs.size()/l;
		vector<int> nl,nr;
		for(int i=1;i<=sz;i++)
		{
			int lb=i*l-1,rb=min((i+1)*l-1,(int)vs.size()),s=0;
			for(int j=lb;j<rb;j++)s+=rv[vs[j]];
			nr.pb(s);
		}
		reverse(vs.begin(),vs.end());
		for(int i=1;i<=sz;i++)
		{
			int lb=i*l-1,rb=min((i+1)*l-1,(int)vs.size()),s=0;
			for(int j=lb;j<rb;j++)s+=lv[vs[j]];
			nl.pb(s);
		}
		reverse(nl.begin(),nl.end());
		reverse(vs.begin(),vs.end());
		
		for(int i=0;i<sz;i++)
		{
			lv[vs[i]]=nl[i];
			rv[vs[i]]=nr[i];
		}
		for(int i=sz;i<(int)vs.size();i++)f[vs[i]]=vs[i]+1;
		vs.resize(sz);
		
		cur=0;sum=0;
		for(int i=0;i<(int)vs.size();i++)
		{
			while(cur<(int)vs.size()&&i-cur+1>=l)sum+=lv[vs[cur++]];
			ans-=(LL)sum*rv[vs[i]];
		}
		for(int i=0;i<(int)vs.size();i++)
		{
			a[vs[i]]++;
			st.insert(mp(a[vs[i]],vs[i]));
		}
	}
	printf("%lld\n",ans+n);
	return 0;
}

Measured memory_bytes: 12672
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

st = ns()
i = 0
n = len(st)
ans = 0
while i < n//2 :
    if st[i] != st[n-1-i]:
        ans += 1
    i += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 8100;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int sum['R' + 'G' + 'B'][N];
void solve(){
    int n;
    string s;
    cin >> n >> s;
    s = "#" + s;
    for(int i = 1; i <= n; ++i){
        sum['R'][i] = sum['R'][i - 1];
        sum['G'][i] = sum['G'][i - 1];
        sum['B'][i] = sum['B'][i - 1];
        sum[s[i]][i] ++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = i + 1; j <= n; ++j) {
            if(s[i] != s[j]) {
                int nd = 'R' + 'G' + 'B' - s[i] - s[j]; 
                int d = j - i; 
                ans += sum[nd][n] - sum[nd][j];
                if(j + d <= n && s[j + d] == nd) {
                    ans --;
                }
            }
        }
    }
    cout << ans;
    
} 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main(){
    int i = 0;
    int x;
    
    while(true){
        cin >> x;
        if(x == 0){
            break;
        } else {
            cout << "Case " << ++i << ": " << x << endl;
        }
    }
    
    return 0;
}



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

int main(){
    string s;
    cin>>s;
    int count =0;
    for(int i=0,j=s.length()-1;i<j;i++,j--){
        if(s[i]!=s[j]) count++;
    }
    cout << count;


    
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

l, r = map(int, input().split())

if r - l > 2019:
    print(0)
    quit()

minimum = 10**10
for i in range(l, r+1):
    for j in range(l, r+1):
        if(i != j):
            minimum = min(minimum, (i*j) % 2019)

print(minimum)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 105;
const int K = 1e5 + 5;

int dp[K];
ll n, k, a[N];

int solve(int rem) {
    if (rem < a[0]) return 0;
    int& ret = dp[rem];
    if (~ret) return ret;
    ret = 0;
    for (int j = 0; j < n; ++j)
        if (rem >= a[j])
            ret |= !solve(rem - a[j]);
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << (solve(k) ? "First" : "Second") << endl;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n){
			int sum=0,x;
			rep(j,5){
				cin>>x;
				sum+=x;
			}
			a[i]=sum;
		}
		cout<<*max_element(all(a))<<' '<<*min_element(all(a))<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
using System;

public class hello
{

    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map = new string[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                {
                    int t;
                    map[i, j] = int.TryParse(s[j].ToString(), out t) ? s[j].ToString() : "#";
                }
            }
            var dp = new string[h, w];
            goDp(map, h, w, dp);
        }
    }
    static void goDp(string[,] map, int h, int w, string[,] dp)
    {
        var ans = "0";
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (map[i, j] != "#")
                {
                    string t;
                    if ((i - 1 < 0) || (map[i - 1, j] == "#")) t = map[i, j];
                    else t = dp[i - 1, j] + map[i, j];
                    if (t[0] == '0') t = delete0(t);
                    string t2;
                    if ((j - 1 < 0) || (map[i, j - 1] == "#")) t2 = map[i, j];
                    else t2 = dp[i, j - 1] + map[i, j];
                    if (t2[0] == '0') t2 = delete0(t2);
                    dp[i, j] = checkAB(t, t2) ? t : t2;
                    if (((i + 1 >= h) || (map[i + 1, j] == "#")) && ((j + 1 >= w) || map[i, j + 1] == "#"))
                        ans = checkAB(ans, dp[i, j]) ? ans : dp[i, j];
                }
            }
        }
        Console.WriteLine(ans);
    }
    static string delete0(string s)
    {
        if (s.Replace("0", "").Length == 0) return "0";
        var p = 0;
        while (true)
        {
            if (s[p] != '0') break;
            p++;
        }
        return s.Substring(p);
    }
    static bool checkAB(string s, string t)
    {
        if (s == "") s = "0";
        if (t == "") t = "0";
        if (s.Length > t.Length) return true;
        else if (s.Length < t.Length) return false;
        return s.CompareTo(t) > 0;
    }
}



Measured memory_bytes: 26300
n = int(input())
d = sorted(map(int, input().split()))
m = int(input())
t = sorted(map(int, input().split()))
if n < m:
    print("NO")
    exit()

p = 0
ans = True

for i in range(m):
    while p < n and d[p] < t[i]:
        p += 1
    if p >= n or d[p] > t[i]:
        ans = False
    p += 1
print(["NO", "YES"][ans])


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


long long ans;
char str[100];
int l;

long long toInt(int s, int t) {
    char substr[100];
    strncpy(substr, str + s, t-s+1);
    substr[t-s+1] = '\0';
//    printf("%s\n",substr);
    long res = atol(substr);
    return (long long)res;
    
}
long long solve(int s, int t, long long sum) {

    if( t == l-1 ) {
	return sum + toInt(s,t);
    }
    return solve(t+1,t+1,sum+toInt(s,t)) + solve(s,t+1,sum);
}


int main() {

    scanf("%s",str);
    l = (int)strlen(str);

    printf("%ld\n",solve(0,0,0));
    
}


Measured memory_bytes: 128
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]

A = []
for _ in range(H):
    A += list(map(int, input().split()))

for i in range(10):
    for j in range(10):
        for k in range(10):
            C[j][k] = min(C[j][k], C[j][i]+C[i][k])

from collections import Counter
Co = Counter(A)
ans = 0
for a, c in Co.most_common():
    if a==-1 or a==1:
        continue
    ans += C[a][1]*c
print(ans)

Measured memory_bytes: 41308
#include <stdio.h>

int main()
{
	int in[5], i, j, swap;
	for (i = 0; i < 5; i++) {
		scanf("%d", &in[i]);
	}
	for (i = 0; i < 5; i++) {
		for (j = 0; j < 5; j++) {
			if (in[i] > in[j]) {
				swap = in[i];
				in[i] = in[j];
				in[j] = swap;
			}
		}
	}
	for (i = 0; i < 4; i++) {
		printf("%d ", in[i]);
	}
	printf("%d\n", in[4]);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll n,k;
	cin >> n >> k;
	ll a = n % k;
	cout << min(a, k-a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
using namespace std;
struct CityData {
    std::string ken;
    std::string num;
    void calc(size_t ken_p, size_t num_p) {

        ken = "000000";
        size_t ken_pp = ken_p + 1;
        std::string ken_str = std::to_string(ken_pp);
        size_t size =  ken_str.size();
        ken.replace(6 - size, size, ken_str);

        num = "000000";
        std::string num_str = std::to_string(num_p);
        size =  num_str.size();
        num.replace(6 - size, size, num_str);
    }
};

int main() {
    size_t N, M;
    cin >> N >> M; 

    std::map<size_t, size_t> huga[N];
    size_t p, y;
    for (unsigned int i = 0; i < M; i++) {
        cin >> p >> y;
        huga[p - 1][y] = i;
    }

    CityData cities[M];
    for (unsigned int i = 0; i < N; i++ ) {
        unsigned int num = 1;
        if (!huga[i].empty()) {
            auto end = huga[i].end();
            for (auto ite = huga[i].begin(); ite != end; ite++) {
                unsigned int const idx = (*ite).second;
                cities[idx].calc(i, num);
                num++;
            }
        }
    }

    for (unsigned int i = 0; i < M; i++) {
        cout << cities[i].ken << cities[i].num << endl;
    }

    return 0;
}


Measured memory_bytes: 24448
import sys
input = sys.stdin.readlines()
nums = []
[[nums.append(num) for num in row.strip().split(" ")] for row in input[:3]]
bs = [i.strip() for i in input[4:]]
mat = [num in bs for num in nums]
patterns = [[0, 1, 2],
            [0, 4, 8],
            [0, 3, 6],
            [1, 4, 7],
            [2, 4, 6],
            [2, 5, 8],
            [3, 4, 5],
            [6, 7, 8]]
for pat in patterns:
    if mat[pat[0]] and mat[pat[1]] and mat[pat[2]]:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3064
n = int(input())
monster = list(map(int, input().split()))
knight = list(map(int, input().split()))
result = 0

for i in range(n):
    if knight[i] <= monster[i]:
        result += knight[i]
    elif knight[i] <= (monster[i] + monster[i+1]):
        monster[i+1] -= (knight[i] - monster[i])
        result += knight[i]
    else:
        result += (monster[i] + monster[i+1])
        monster[i+1] = 0

print(result)


Measured memory_bytes: 18476
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

  long long N;
  cin >> N;

  long long ans = 0;
  for (long long i = 1; i <= N; i++) {
    ans += (N - 1) / i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"

int main() {

    int N, L;
    std::cin >> N >> L;
    int sum = 0;
    int min = INT_MAX;
    for (int i = 0; i < N; ++i) {
        sum += L + i;
        if (std::abs(L + i) < std::abs(min))min = L + i;
    }
    int ans = sum - min;
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
c_lst = [0]*n
a_lst = [0]*n 
for i in range(n):
    lst = list(map(int,input().split()))
    c_lst[i] = lst[0]
    a_lst[i] = lst[1:]

ryoukin = float("inf")

for i in range(2**n):
    temporary = 0
    rikaido = [0]*m
    for j in range(n):
        if i&(1<<j):
            temporary += c_lst[j]
            for k in range(m):
                rikaido[k] += a_lst[j][k]
    
    for j in rikaido:
        if j >= x:
            continue
        else:
            break #この段階でrikaidoがxを超えないものがあれば次へ（？）
    else:#breakでループ抜けなかった場合
        if temporary < ryoukin:
            ryoukin = temporary

if ryoukin != float("inf"):
    print(ryoukin)
else:
    print("-1")

Measured memory_bytes: 9224
function main(argString) {
  var count = 0;
  var split = argString.split(' ');
  var N = Number(split[0]), A = Number(split[1]), B = Number(split[2]);
  for (var i = 1; i <= N; i++) {
    var num = ('' + i).split('').reduce((a, b) => Number(a) + Number(b));
    if (A <= num && num <= B) count += i;
  }
  console.log(count);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9488
IDENTIFICATION DIVISION.
PROGRAM-ID. 164C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(20).
01 N          PIC 9(6).
01 I          PIC 9(6).
01 TBL.
   03 S       PIC X(10) OCCURS 200000 DEPENDING ON N.
01 CNT        PIC 9(6).
01 OUT        PIC Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    ACCEPT S(I)
  END-PERFORM.
*>
  SORT S ASCENDING KEY S.
  MOVE 1 TO CNT.
  PERFORM VARYING I FROM 2 BY 1 UNTIL I > N
    IF S(I) NOT = S(I - 1)
      ADD 1 TO CNT
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 7232
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = long long;
using ii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;



int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);
    

    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n % 2 == 1){
        cout<<"No"<<endl;
    }
    else{
        //cout<<s.substr(0,n/2)<<" "<<s.substr((n/2),n)<<endl;
        if(s.substr(0,n/2) == s.substr((n/2),n)){
            
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/*
by.YXH_XianYu
   2018.6.16
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 2010
#define MX 15

int n,k,q,
	a[MXN],
	b[MXN],
	c[MXN],
	d[MXN],
	ans=1000000000;


int main(){
	//freopen("mothergoose.in","r",stdin);
	//freopen("mothergoose.out","w",stdout);

	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),b[i]=a[i];
	std::sort(b+1,b+n+1);
	//按照元素大小从小到大排序
	for(int y=1;y<=n;y++){
		//选出d[0]元素
		for(int i=1;i<=n;i++)
			//分段
			if(a[i]>=b[y])
				//将同一段选中
				c[++c[0]]=a[i];
			else{
				//若此段大小<k,则寻找下一段
				if(c[0]<k){
					c[0]=0;
					continue;
				}
				//选出c[0]-k+1个元素
				std::sort(c+1,c+c[0]+1);
				for(int j=1,lim=c[0]-k+1;j<=lim;j++)
					d[++d[0]]=c[j];
				c[0]=0;
				continue;
			}
		//处理最后一段
		if(c[0]>0){
			std::sort(c+1,c+c[0]+1);
			for(int j=1,lim=c[0]-k+1;j<=lim;j++)
				d[++d[0]]=c[j];
			c[0]=0;
		}
		//计算X-Y
		if(d[0]>=q){
			std::sort(d+1,d+d[0]+1);
			ans=std::min(ans,d[q]-b[y]);
			d[0]=0;
		}
		else{
			break;
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
string st;
signed main(){
	bool f1=false,f2=false;
	cin>>st;
	int len=st.size();
	for(register int i=0;i<len;i++){
			if(!f1){
				if(st[i]=='C') f1=true;
			}
			if(st[i]=='F'&&f1){
					f2=true;
					cout<<"Yes";
					return 0;
			}
	}
	cout<<"No";
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    long long int A[N];
    long long int C[N];
    long long int box[N]; 
    int i;
    long long int ans=0;
    long long int sa;
    for(i=0;i<N;i++){
        cin >> A[i];
        C[i]=0;
    }
    for(i=0;i<N;i++)C[A[i]-1]++;
    for(i=0;i<N;i++){
        box[i]=C[i]*(C[i]-1)/2;
        ans += box[i];
    }
    for(i=0;i<N;i++){
        sa = C[A[i]-1]-1;
        cout << ans - sa << endl;
    }
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


struct edge{ll to,cost;};
struct dijkstra
{
  using P=pair<ll,ll>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<edge>>ed;
  vector<ll>dist;
  ll sz;
  dijkstra(ll size){
    sz=size;
    ed.resize(size);
  }
  void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(ll from,ll to,ll cost){
    ed[from].push_back({to,cost});
  }
  ll cal(ll start,ll end=0){
    reset();
    q.push({0,start});
    while(!q.empty()){
      P tp=q.top();q.pop();
      if(dist[tp.second]!=-1)continue;
      dist[tp.second]=tp.first;
      for(auto nn:ed[tp.second]){
        if(dist[nn.to]!=-1)continue;
        q.push({nn.cost+tp.first,nn.to});
      }
    }
    return dist[end];
  }
  ll getd(ll end){
    return dist[end];
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  dijkstra di(n);
  rep(i,n-1)
  {
    ll a,b,c;
    cin>>a>>b>>c;
    di.ae(a-1,b-1,c);
    di.ae(b-1,a-1,c);
  }
  ll q,k;cin>>q>>k;
  k--;
  di.cal(k);
  rep(i,q)
  {
    ll x,y;
    cin>>x>>y;
    x--;y--;
    cout<<di.getd(x)+di.getd(y)<<"\n";
  }
  cout<<endl;

  return 0;

}


Measured memory_bytes: 11120
import math
p = [2]
NM = 10000
c = 3
while len(p) < NM:
    m = int(math.sqrt(c))
    r = True
    for i in p:
        if i > m:
            break
        if c % i == 0:
            r = False
            break
    if r:
        p.append(c)
    c += 2
 
while True:
    n = int(raw_input())
    if n == 0:
        break
    print sum(p[:n])
        

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        to[s].push_back(t);
    }

    vector<double> dp(n);
    for (int v = n - 2; v >= 0; v--) {
        double now = 0;
        for (int u : to[v]) {
            now += dp[u];
        }
        now /= to[v].size();
        now += 1;
        dp[v] = now;
    }

    double ans = dp[0];
    for (int nv = 0; nv < n - 1; nv++) {
        if (to[nv].size() == 1) continue;

        int nu = to[nv][0];
        for (int u : to[nv]) {
            if (dp[nu] < dp[u]) nu = u;
        }

        double now = [&] {
            vector<double> dp(n);
            for (int v = n - 2; v >= 0; v--) {
                double now = 0;
                for (int u : to[v]) {
                    if (v == nv && u == nu) continue;
                    now += dp[u];
                }
                int deg = to[v].size();
                if (v == nv) deg--;
                now /= deg;
                now += 1;
                dp[v] = now;
            }
            return dp[0];
        }();
        ans = min(ans, now);
    }

    printf("%.10f\n", ans);
}

Measured memory_bytes: 1408
import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, R = map(int, readline().split())
    city = [int(s) - 1 for s in readline().split()]
    ABC = map(int, read().split())

    G = [[INF] * N for _ in range(N)]
    for a, b, c in zip(*[iter(ABC)] * 3):
        G[a - 1][b - 1] = G[b - 1][a - 1] = c

    for i in range(N):
        G[i][i] = 0

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if G[i][j] > G[i][k] + G[k][j]:
                    G[i][j] = G[i][k] + G[k][j]

    ans = INF
    for plan in permutations(city):
        res = 0
        for i in range(R - 1):
            res += G[plan[i]][plan[i + 1]]
        if ans > res:
            ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14060
import java.util.*;
public class Main{
    public static void main(String[] args){
	Scanner kbd = new Scanner(System.in);
	int[] x = new int[3];
	x[0] = kbd.nextInt();
	x[1] = kbd.nextInt();
	x[2] = kbd.nextInt();
	Arrays.sort(x);
	System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}

Measured memory_bytes: 17336
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, i; cin >> n >> i;
  cout << n - i + 1 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	
	ll n; cin >> n;
	vector<int> digit;

	while (n) {
		ll q = (n % 2 == 0) ? n / (-2) : (n - 1) / (-2);
		digit.push_back(n + 2 * q);
		n = q;
	}
	if (digit.empty())digit.push_back(0);
	reverse(digit.begin(), digit.end());

	for (auto itr = digit.begin(); itr < digit.end(); itr++) {
		cout << *itr;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B = MAP()

mx = min(A, B)
mn = max(A + B - N, 0)

print(mx, mn)


Measured memory_bytes: 5476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int x = 800*N;
  int y = 200 * (N/15);
  cout << x-y << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int t(int a, int b, int d){
  int tmp = a-b;
  if(tmp<0)tmp = -tmp;
  if(tmp <= d){
    return 1;
  }
  else{
    return 0;
  }
}

int main(){
  int a, b,c, d;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);

  int ab = 0;
  int ac = 0;
  int bc = 0;

  if(t(a,b,d)==1) ab = 1;
  if(t(a,c,d)==1) ac = 1;
  if(t(b,c,d)==1) bc = 1;

  if(ac){
    printf("Yes\n");
    return 0;
  }
  else{
    if(ab && bc){
      printf("Yes\n");
      return 0;
    }
    else{
      printf("No\n");
      return 0;      
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (N > K)cout << K*X + (N - K)*Y;
	else cout << N*X;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;


int main()
{
	int h, w;
	cin >> h >> w;
	vecst st;
	string t(w, '.');
	for (int i = 0;i < h;i++) {
		string s;
		cin >> s;
		if (s != t) st.push_back(s);
	}
	char ans[110][110];
	int wp = 0;
	for (int j = 0;j < w;j++) {
		bool che = false;
		for (int i = 0;i < st.size();i++) {
			if (st[i][j] == '#') {
				che = true;
				break;
			}
		}
		if (che) {
			for (int i = 0;i < st.size();i++) {
				ans[i][wp] = st[i][j];
			}
			wp++;
		}
	}
	for (int i = 0;i < st.size();i++) {
		for (int j = 0;j < wp;j++) {
			cout << ans[i][j];
		}
		ent;
	}
}


Measured memory_bytes: 256
#!python3

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

# input
N = int(input())
AB = [LI() for _ in range(N)]

MOD = 10 ** 9 + 7


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def create_pairs():
    z = 0
    d = {}
    for a, b in AB:
        # irre
        if a == 0 and b == 0:
            z += 1
            continue
        if a == 0:
            b = 1
        elif b == 0:
            a = 1
        else:
            m = abs(gcd(a, b))
            a, b = a // m, b // m
        
        # 180
        if b < 0:
            a, b = -a, -b

        if a > 0:
            t = (a, b)
            i = 0
        else:
            t = (b, -a)
            i = 1
        if t in d:
            d[t][i] += 1
        else:
            d[t] = [0, 0]
            d[t][i] += 1
    
    return d, z


def main():
    p2 = [None] * (N + 1)
    p2[0] = 1
    for i in range(1, N + 1):
        p2[i] = p2[i - 1] * 2 % MOD
    
    d, z = create_pairs()
    ans = 1
    for x, y in d.values():
        v = p2[x] + p2[y] - 1
        ans = ans * v % MOD

    ans += z - 1
    ans %= MOD
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 104748
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_N 2000001
int pr[MAX_N];

map<int,int> prime_factor(int m){
  map<int,int> rtn;
  for(int i=2;i*i<=m;i++) while(!(m%i)){
    ++rtn[i];
    m/=i;
  }
  if(m!=1) rtn[m]=1;
  return rtn;
}

int main(){
  int n;cin>>n;
  REP(i,n){
    int tmp;cin>>tmp;
    map<int,int> mp=prime_factor(tmp);
    for(auto p:mp) pr[p.first]++;
  }
  REP(i,MAX_N) if(pr[i]==n){
    cout<<"not coprime";
    return 0;
  }
  REP(i,MAX_N) if(pr[i]>1){
    cout<<"setwise coprime";
    return 0;
  }
  cout<<"pairwise coprime";
}

Measured memory_bytes: 7524
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n;
vector<pair<int,int> >ans;
int main(){
	SF("%d",&n);
	if(n%2==1){
		for(int i=1;i<n;i++)
			ans.push_back(make_pair(i,n));	
		n--;
	}
	if(n>2){
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				if(i+j!=n+1)
					ans.push_back(make_pair(i,j));
	}
	PF("%d\n",ans.size());
	for(int i=0;i<int(ans.size());i++)
		PF("%d %d\n",ans[i].first,ans[i].second);
}

Measured memory_bytes: 384
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;

bool isValid(vector<int> xs, vector<int> ys, int n) {

    int d = 0;

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

        d += (xs[i] - ys[i]) * (xs[i] - ys[i]);

    }

    bool ok = false;

    for (int i = 1; i <= d; i++) {

        if (i * i == d) {
            ok = true;
        }

    }

    return ok;

}


int main() {

    int N, D;
    cin >> N >> D;

    vector<vector<int>> vs;

    for (int i = 0; i < N; i++) {
        vector<int> v;
        for (int j = 0; j < D; j++) {
            int x;
            cin >> x;
            v.push_back(x);
        }
        vs.push_back(v);
    }

    int result = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {


            if (isValid(vs[i], vs[j], D)) {
                result += 1;
            }

        }
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

int main() {
	ll N, K;
	string S;
	cin >> N >> K >> S;

	S[K-1] = tolower(S[K - 1]);
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    v = inl()
    ev = collections.Counter()
    od = collections.Counter()
    for i in range(n):
        if i % 2 == 0:
            ev[v[i]] += 1
        else:
            od[v[i]] += 1
    ex = ev.most_common(2)
    ox = od.most_common(2)
    if ex[0][0] != ox[0][0]:
        ans = n - ex[0][1] - ox[0][1]
    elif len(ex) == 1 and len(ox) == 1:
        ans = n - ex[0][1]
    elif len(ex) == 1:
        ans = n - ex[0][1] - ox[1][1]
    elif len(ox) == 1:
        ans = n - ex[1][1] - ox[0][1]
    else:
        ans = min(n - ex[0][1] - ox[1][1], n - ex[1][1] - ox[0][1])
    return ans


print(solve())


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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;



signed main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){cin>>a[i];}
  sort(a.begin(),a.end());
  map<ll,ll> M;
  for(int i=0;i<n;i++){M[a[i]]=i;}
  vector<vector<ll>> dp(n,vector<ll>(n,1));
  ll mx=2;
  for(int i=0;i<n;i++){
    for(int t=0;t<i;t++){
      dp[i][t]=2;
      ll A=a[i]-a[t];
      if(M.count(a[t]-A)){
	dp[i][t]=1+dp[t][M[a[t]-A]];
	mx=max(mx,dp[i][t]);
      }
    }
  }
  cout<<mx<<endl;
  
  return 0;
}


Measured memory_bytes: 198760
S[2001*2002];
m[4][2001*2002],H,W,z,d[4]={1,-1},k,i;

f(i){
	return m[k][i]=S[i]+47?0:m[k][i]?:1+f(i+d[k]);
}

main(t){
	scanf("%d%d ",&H,&W);
	for(d[2]-=d[3]=~W;S[i-~W]=~getchar();++i);
	for(;i--;z=fmax(z,t))for(t=k=0;k<4;++k)t+=f(i-~W);
	printf("%d",z-3);
}


Measured memory_bytes: 78464
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[200001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, X[200001], x[200001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &(X[i]));
		x[i] = X[i];
	}

	merge_sort(x, N);
	int small = x[N/2 - 1], large = x[N/2];
	for (i = 0; i < N; i++) printf("%d\n", (X[i] <= small)? large: small);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <string>

using namespace std;

int main(){
    char c;
    int flag = 0;
    cin >> c;

    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') flag++;

    cout << ((flag == 1) ? "vowel" : "consonant") << endl;

    return 0;
}

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

int main() {
        int N, K;
        int count = 0;
        cin >> N;
        cin >> K;

        rep(k, K) {
                int x, y, a;
                cin >> x >> y;
                if (x > (N/2)) {
                        x = (x * -1) + N+1;
                }
                if (y > (N/2)) {
                        y = (y * -1) + N+1;
                }
                a = min(x, y) % 3;
                if (a == 0) a = 3;
                cout << a << endl;
        }
        return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

ll int f_shikaku(ll int A,ll int B){
    ll int a=max(A,B);
    ll int b=min(A,B);
    if(a%b==0)return 2*(ll int)(a/b)*b-b;
    return f_shikaku(a%b,b)+2*(ll int)(a/b)*b;
}
int main(void){
    ll int N,X;
    scanf("%lld %lld",&N,&X);
    ll int ans;
    ans=f_shikaku(X,N-X)+N;
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(void){
  char s[100010];
  int i,ans=0;
  scanf("%s",s);
  for(i=0;i<strlen(s)-1;i++){
    if(s[i]!=s[i+1]) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    string s;
    cin >> s;

    if(s[5] == '0' && s[6] <= '4'){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def next_runrun(n)
    if n < 10
        return n + 1
    end

    digit_1  = n % 10
    digit_10 = (n / 10) % 10

    if digit_1 == digit_10 - 1
        return n + 1
    elsif digit_1 == digit_10
        if digit_1 == 9
            m = next_runrun(n / 10)
            if m % 10 == 0
                return 10 * m
            else
                return 10 * m + m % 10 - 1
            end
        else
            return n + 1
        end
    elsif digit_1 == digit_10 + 1
        m = next_runrun(n / 10)
        if m % 10 == 0
            return 10 * m
        else
            return 10 * m + m % 10 - 1
        end
    end
end

k = gets.to_i

i = 1
n = 1
while i < k
    n = next_runrun(n)
    i = i + 1
end
puts n


Measured memory_bytes: 3836
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int K = sc.nextInt();

		char replace = S[K - 1];

		for(int i = 0; i < N; i++) {
			if(S[i] != replace) {
				S[i] = '*';
			}
		}

		System.out.println(String.valueOf(S));
	}
}

Measured memory_bytes: 23636
use proconio::*;
use std::collections::BinaryHeap;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 8;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    for &(_, j) in cands.iter().take(2) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

const ll MOD = 1e9+7;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll t1 = 0;
    ll t2 = 0;
    for(i = 0;i < n;++i){
        rep(j,n){
            if(i < j && a.at(i) > a.at(j)) ++t1;
            else if(a.at(i) > a.at(j)) ++t2;
        }
    }
    ll ans = k*(k+1)/2%MOD*t1%MOD + k*(k-1)/2%MOD*t2%MOD;
    cout << ans%MOD << endl;

    return 0;
}

Measured memory_bytes: 3648
import java.io.*;

public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            int x = Integer.parseInt(br.readLine());
            System.out.println(x * x * x);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 17008
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;

    long long ans = 0;
    if(a % 2 != 0 && b % 2 != 0 && c % 2 != 0)
        ans = min({a * b, b * c, c * a});
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256