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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  if((b - a) % 2) cout << "Borys" << endl;
  else cout << "Alice" << endl;
}


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

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int sugar, water, sugar_ans, water_ans;
    double p;
    double max_p = 0.0;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            for (int k = 0; k <= 3000; k++) {
                for (int l = 0; l <= 3000; l++) {
                    water = 100*a*i + 100*b*j;
                    sugar = c*k + d*l;
                    if (water + sugar > f) break;
                    if (water * e / 100.0 < sugar) break;
                    p = 100 * (double)(sugar) / (water + sugar);
                    if (p >= max_p) {
                        max_p = p;
                        sugar_ans = sugar;
                        water_ans = water;
                    }
                }
            }
        }
    }
    cout << sugar_ans + water_ans << " " << sugar_ans << endl;

    return 0;
}

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

int main()
{
    ll n, m; cin >> n >> m;
    
    vector<pair<ll, ll>> pa;

    for (ll i = 0; i < n; i++) {
        ll a;
        cin >> a;
        pa.push_back({ a,1LL });
    }

    for (ll i = 0; i < m; i++) {
        ll b, c;
        cin >> b >> c;
        pa.push_back({ c,b });
    }
    
    sort(pa.begin(), pa.end(),greater<pair<ll,ll>>());

    ll ans = 0;
    ll cnt = 0;
    ll paCnt = 0;
    while (cnt < n) {

        for (ll i = 0; i < pa[paCnt].second; i++) {
            ans += pa[paCnt].first;
            cnt++;
            if (cnt == n) {
                break;
            }
        }
        paCnt++;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n > k)
    {
        n -= k;
        int ans = k * x;
        ans += n * y;
        cout << ans << endl;
    }
    else
    {
        cout << n * x << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main(){
	int n,a,b;
 	scanf("%d%d%d",&n,&a,&b);
  	printf("%d %d",min(a,b),max(a+b-n,0));
  	return 0;
}


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

typedef ostringstream OSS;
typedef istringstream ISS;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

struct Cake {
    Cake (int w_, int h_, int c_) :
        w(w_), h(h_), area(w_ * h_), cuti(c_) {}
    int w, h, area, cuti;

    bool operator < (const Cake &c) const {
        if (cuti != c.cuti) return cuti < c.cuti;
        return area < c.area;
    }
};

int main(void) {
    int N, W, H;

    while (cin >> N >> W >> H, W) {
        VPII qs(N);
        for (auto &q : qs) {
            cin >> q.fst >> q.snd;
            --q.fst;
        }

        vector<Cake> cakes;
        cakes.EB(W, H, -1);

        for (int i = 0; i < N; i++) {
            PII q = qs[i];
            int p = q.fst;
            int s = q.snd;

            Cake cake = cakes[p];
            int w = cake.w;
            int h = cake.h;
            cakes.erase(cakes.begin() + p);
            
            s %= w + h;
            
            if (s < w) {
                cakes.EB(s, h, i);
                cakes.EB(w - s, h, i);
            } else {
                s -= w;
                cakes.EB(w, s, i);
                cakes.EB(w, h - s, i);
            }

            sort(ALL(cakes));
        }

        VI areas;
        for (auto cake : cakes) {
            areas.PB(cake.area);
        }

        sort(ALL(areas));

        for (int i = 0; i < (int)areas.size(); i++) {
            cout << areas[i] << (i + 1 == (int)areas.size() ? '\n' : ' ');
        }
    }

	return 0;
}

Measured memory_bytes: 1224
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.length() % 2 == 1) {
			int b = s.length() / 2;
			s = s.substring(0,b) + s.substring(b+1,s.length());
		}
		System.out.println(isKaibun(s) ?"Yes" : "No");
	}
	static boolean isKaibun(String s) {
		if(s.equals(Hanten(s))) {
			return true;
		} else {
			return false;
		}
	}
	static String Hanten(String s) {
		StringBuffer sb = new StringBuffer(s);
		s = sb.reverse().toString();
		return s;
	}
}


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

int main(){
    int N,C; cin >> N >> C;
    int s[N],t[N],c[N];
    for(int i=0;i<N;i++){
        cin >> s[i] >> t[i] >> c[i];
    }
    int tmax=200002;
    int time[tmax]={0};
    for(int i=1;i<=C;i++){
        int imos[tmax]={0};
        for(int j=0;j<N;j++){
            if(c[j]==i){
                imos[2*s[j]-1]++;
                imos[2*t[j]]--;
            }
        }
        for(int j=1;j<tmax;j++){
            imos[j]+=imos[j-1];
        }
        for(int j=0;j<tmax;j++){
            if(imos[j]>0){
                time[j]++;
            }
        }
    }
    int ans=0;
    for(int i=0;i<tmax;i++){
        ans=max(ans,time[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3072
S = input()[::-1]

words = list(map(lambda s: s[::-1], ['dreamer', 'eraser', 'erase', 'dream']))

while True:
    for w in words:
        if S[:len(w)] == w:
            S = S[len(w):]
            break
    else:
        break

print('YES' if len(S) == 0 else 'NO')

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, D = map(int, input().split())
    graph[L].append((R, D))
    graph[R].append((L, -D))

d = [None] * (N + 1)

def calc(start): #startからの連結成分をチェックする
    d[start] = 0
    stack = [start]
    while len(stack) != 0:
        tmp = stack.pop()
        for next_, diff in graph[tmp]:
            if d[next_] == None:
                d[next_] = d[tmp] + diff
                stack.append(next_)
            else:
                if d[next_] == d[tmp] + diff:
                    pass
                else:
                    print ('No')
                    exit()
    return 

# for i in graph:
#     print (i)

for i in range(1, N):
    if d[i] == None:
        calc(i)
print ('Yes')


Measured memory_bytes: 65944
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[60], b[60], c[60], d[60];
  for(int i=1; i<=n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i=1; i<=m; i++){
    cin >> c[i] >> d[i];
  }
  for(int i=1; i<=n; i++){
    int sum=0;
    int minn = 10000000000000000;
    int min_j;
    for(int j=1; j<=m; j++){
      sum = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(sum<minn){
        minn = sum;
        min_j = j;
      }
    }
    cout << min_j << endl;
  }
}

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

using namespace std;
typedef long long ll;

int main(){
    int N;cin >> N;
    map<string,int> sorted_map;
    int max = 0;
    rep(i,N){
        string tmp;cin >> tmp;
        if (sorted_map[tmp]  > 0){
            sorted_map[tmp]++;
        }
        else {
            sorted_map[tmp] = 1;
        }
        if (sorted_map[tmp] > max){
            max = sorted_map[tmp];
        }
    }

    for(auto x: sorted_map){
        if (x.second == max){
            cout << x.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 19232
import math
a, b, h, m = list(map(int, input().split()))
th = abs(30 * h + 0.5 * m - 6 * m)
if th > 180:
    th -= 360
    th = abs(th)
rad = math.radians(th)
d = pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(rad)
d = pow(d, 0.5)
print(d)

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

int main (void){
  long long int n = 0;

  cin >> n;
  vector<long long int> a(n,0);
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }

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

  for(int i = 0;i < n - 1;i++){
    if(a[i] == a[i + 1]){
      cout << "NO\n";
      return 0;
    }
  }

  cout << "YES\n";

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
	ll n, m;
	cin >> n >> m;

	vector<ll> l, r;

	for (ll i = 0; i < m; i++)
	{
		ll temp;
		cin >> temp;
		l.push_back(temp);
		cin >> temp;
		r.push_back(temp);
	}

	ll ans = *min_element(r.begin(), r.end()) - *max_element(l.begin(), l.end());

	if(ans < 0){
		ans = 0;
	}
	else{
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

double dxy(vector<int> &x, vector<int> &y, int p){
    long long sum=0;
    for(int i=0; i<x.size(); ++i){
        sum += pow(abs(x[i]-y[i]),p);
    }
    return (pow(sum,1.0/p));
}
double dmax(vector<int> &x, vector<int> &y){
    int d_max=0;
    for(int i=0; i<x.size(); ++i){
        d_max = max(d_max,abs(x[i]-y[i]));
    }
    return d_max;
}


int main()
{

    int n;
    cin >> n;
    vector<int> x(n,0);
    vector<int> y(n,0);

    for(auto&& a: x){
        cin >> a;
    }

    for(auto&& a: y){
        cin >> a;
    }
    cout << fixed;
    cout << dxy( x, y, 1) << endl;
    cout << dxy( x, y, 2) << endl;
    cout << dxy( x, y, 3) << endl;
    cout << dmax( x, y) << endl;
    return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    string s;
    // cin >> t;
    cin >> s;
    if ((s.length() == 6) && (s[2] == s[3]) && (s[4] == s[5]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    // vector<lli> v;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut q = std::collections::BinaryHeap::new();
    for &a in &A { q.push(a); }
    for _ in 0..M {
        let x = q.pop().unwrap();
        q.push(x / 2);
    }
    let ans = q.iter().sum::<i64>();

    println!("{}", ans);
}


Measured memory_bytes: 8444
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
bool is_prime(int num) {
    for(int i=2; i*i <= num; i++) {
        if (num%i == 0) return false;
    }
    return true;
}
#endif


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

    int N; cin >> N;

    const int PMAX = 55555;

    vi ans;
    FOR(i,2,PMAX+1) {
        if (ans.size() >= N) break;
        if (is_prime(i) && i % 5 == 1) ans.push_back(i);
    }

    cout << ans[0];
    FOR(i,1,ans.size()){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,i,a,b,c,f=0;
	
	scanf("%d",&n);
	
	for(;n>0;n--){
		
		b=c=f=0;
		
		for(i=0;i<10;i++){
			scanf(" %d",&a);
			if(b<a)b=a;
			else if(c<a)c=a;
			else{
				f=1;
			}
		}
		
		if(f==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
		
	

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    string s;cin>>s;
    rep(i,3){
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3624
a, b, c = map(int, input().split())
if a % 2 and b % 2 and c % 2:
    d = sorted([a, b, c])[0]
    e = sorted([a, b, c])[1]
    f = sorted([a, b, c])[2]
    print(d*e)
else:
    print(0)

Measured memory_bytes: 3060
def main():
#1. input
    s = input()

#2. list and sort
    s_list = []
    for char in s:
        s_list.append(char)
        
    s_list.sort(reverse=False)

#3. judge
    if ''.join(s_list) == 'abc':
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++

def main():
	n = int(input())
	ll=list(map(int, input().split()))
	
	ll.sort()
	#print(ll)
	h=n//2
	
	return ll[h]-ll[h-1]

	

if __name__ == "__main__":
	print(main())
	
	

Measured memory_bytes: 14008
import math

def input_num():
	ls = input().strip().split(" ")
	return [int(e) for e in ls]

n,m,x = input_num()
c_ls = []
a_ls = []
for i in range(n):
	ls = input_num()
	c = ls[0]
	c_ls.append(c)
	a_ls.append(ls[1:])

# 部分和問題(NP完全)かつM<=12から、愚直法で解く

def judge(tx):
	for i in range(len(tx)):
		if tx[i] < x: return False
	return True

tc_ls = []
for i in range(2**n):
	raw_s = bin(i)[2:]
	s = "0"*(n-len(raw_s)) + raw_s
	f_ls = [e == "1" for e in s]
	tc = 0
	tx = [0 for _ in range(m)]
	for book_idx, f in enumerate(f_ls):
		if f is False: continue
		tc += c_ls[book_idx]
		tx = [tx[j]+a_ls[book_idx][j] for j in range(m)]
	if judge(tx) is True:
		tc_ls.append(tc)

if len(tc_ls) == 0:
	print(-1)
else:
	print(min(tc_ls))

Measured memory_bytes: 9260
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, z, w;
	cin >> n >> z >> w;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << abs(a[0] - w) << endl;
	} else {
		cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;


int main() {
 int n,k,ans,tmp;
 cin >> n >> k;
  ans=0;
  for(int i=0;i<n;i++){
    cin >> tmp;
    ans=ans+min(2*tmp,2*abs(k-tmp));
  }
  cout << ans << endl;
}
    

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  ll Asum=0,Bsum=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    Asum+=A[i];
  }
  for(int i=0;i<N;i++){
    cin >> B[i];
    Bsum+=B[i];
  }
  if(Asum<Bsum){
    cout << -1 << endl;
    return 0;
  }
  vector<int> dif(N);
  for(int i=0;i<N;i++){
    dif[i]=A[i]-B[i];
  }
  sort(dif.begin(),dif.end());
  ll count=0;
  ll ans=0;
  for(int i=0;i<N;i++){
    if(dif[i]<0){
      count+=dif[i];
      ans++;
    }
    else{
      break;
    }
  }
  if(ans==0){
    cout << 0 << endl;
    return 0;
  }
  for(int i=N-1;i>=0;i--){
    ans++;
    count+=dif[i];
    if(count>=0){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4296
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	sort(H, H + N);

	long long ans = 0;
	for (int i = 0; i < N-K; i++)
	{
		ans += H[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
  cin>>n;
	int ans = 0;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string ss;
		cin >> ss;
		s.insert(ss);
	}
	ans = s.size();
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 19204
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
nums=[]
for i in range(n):
    nums.append(int(input()))
nms=sorted(nums,reverse=True)
for i in range(n):
    if nums[i]==nms[0]:
        print(nms[1])
    else:
        print(nms[0])

Measured memory_bytes: 14448
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

    long double ans = 0;
    REP(i, N) ans += (long double) 1 / A[i];

    print((long double) (1) / ans);


    
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

int main()
{
    while(1)
    {
        int w,d;
        cin >>w >>d;
        if(w*d==0) break;

        vector<int> hw(w),hd(d);
        rep(i,w) cin >>hw[i];
        rep(i,d) cin >>hd[i];

        vector<vi> f(d,vi(w,0));

        //i???????????¨???
        rep(i,d)
        {
            int now=hd[i];
            int idx=-1;

            rep(j,w)
            {
                if(now==hw[j])
                {
                    //j??????????????§??????now????????´??????????????°?????????
                    int m=0;
                    rep(k,d) m=max(m,f[k][j]);

                    if(m!=now)
                    {
                        idx=j;
                        break;
                    }
                }
            }

            //not found
            if(idx==-1)
            {
                rep(j,w)
                {
                    if(hw[j]>=now)
                    {
                        idx=j;
                        break;
                    }
                }
            }
            f[i][idx]=now;
        }

        /*
        for(int i=d-1; i>=0; --i)
        {
            rep(j,w) printf("%3d",f[i][j]);
            printf("\n");
        }
        */

        rep(i,w)
        {
            int m=0;
            rep(j,d) m=max(m,f[j][i]);

            if(m!=hw[i])
            {
                rep(j,d)
                {
                    if(hd[j]>=hw[i])
                    {
                        f[j][i]=hw[i];
                        break;
                    }
                }
            }
        }

        /*
        for(int i=d-1; i>=0; --i)
        {
            rep(j,w) printf("%3d",f[i][j]);
            printf("\n");
        }
        */
        
        int ans=0;
        rep(i,d)rep(j,w) ans+=f[i][j];
        std::cout << ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#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 mod 1000000007
//#define mod 998244353

int N,K;
int A[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    int left=0;
    int right=0;
    rep(i,N){
        scanf("%lld",&A[i]);
        right=max(A[i],right);
    }
    while(left+1<right){
        int cut=0;
        int middle=(left+right)/2;
        rep(i,N){
            cut+=max((int)0,(A[i]+middle-1)/middle-1);
        }
        if(cut<=K){
            right=middle;
        }else{
            left=middle;
        }
    }
    printf("%lld\n",right);
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll x,k,d;cin>>x>>k>>d;
  if(x<0)x=-x;
  ll need = x/d;

  // xから可能な限り0に近づく、
  if(k<need){
    // 必要回数よりもkの方が小さかったらそこまでなのでそれ出して終わり。
    cout<<(x-k*d)<<endl;
    return 0;
  }

  // k>=need
  // 0にd以下まで近づける
  k -= need;
  ll now = x%d;
//cout<<now<<' '<<need<<' '<<k<<endl;
  if(k%2){
    cout<<d-now<<endl;
  }else{
    cout<<now<<endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct P {int x, y;};

int main() {
	const int d[4][4] = {{0, 0, 1, 0}, {0, -1, 0, -2}, {-1, 0, -1, 0}, {0, 1, 0, 2}};
	array<array<int, 6>, 11> m{};
	for (int i = 1; i <= 9; i++) {
		for (int j = 1, e = 5 - i % 2; j <= e; j ++)
			m[i][j] = gcu() - '0';
		gcu();
	}
	P p = {1, 1};
	int r = 0;
	do {
		for (r = (r + 1) % 4;; r = (r + 3) % 4)
			if (m[p.y + d[r][1]][p.x + d[r][0]]) {
				p.x += d[r][2], p.y += d[r][3];
				break;
			}
		out("RULD"[r]);
	} while(!(p.x == 1 && p.y == 1));
	outl();
}


Measured memory_bytes: 2508
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n; cin >> n;
    vl a(n),sum(n+1,0);
    rep(i,n) cin >> a[i];
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
    }
    ll d = linf;
    REP(i,1,n){
        ll rev = sum[n] - sum[i];
        chmin(d, abs(sum[i]-rev));
    }
    cout << d << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include <algorithm> 
#include <vector>

using namespace std;
int main()
{
    int N;
    string S_i;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i<N ; i++){
        cin>>S_i;
        S[i] = S_i;
    }
    
    sort(S.begin(), S.end());
    S.erase( unique(S.begin(), S.end()), S.end() );
    
    cout << S.size() << endl;
    return 0;
} 

Measured memory_bytes: 9588
#include <iostream>
#define ll long long
using namespace std;

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

int main(){
    ll n, s = 0, m, d;
    cin >> n;
    for(ll i = 1;i<=n;i++){
        for(ll j = i;j<=n;j++){
            d = gcd(i, j);
            for(ll k = j;k<=n;k++){
               // cout << i  << " " << j  << " " << k << "\n";
                if(i == j && j == k)
                    s += i;
                else if((i == j && j != k) || (j == k && j != i) || (i == k && j != k)){
                    m = gcd(d, k);
                    s += (3*m);
                }
                else{
                    m = gcd(d, k);
                    s += 6*m;
                }
            }
        }
    }
    cout << s;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

int main(){
    Fast;
    long long n;
    cin>>n;
    string ans="";
    if(n<=26){
        n--;
        cout<<char(n+'a')<<endl;
        return 0;
    }
    while(1){
        int m=n%26;
        m--;m+=26;
        m%=26;
        char ch=char (m+'a');
        ans+=ch;
        if(m==25){
            n-=26;
        }
        n/=26;
        if(n<=0){
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

class Cumu {
 private:
  vector<ll> _sum;

 public:
  Cumu(vector<ll> &source) {
    _sum = vector<ll>(source.size() + 1);
    for (ll i = 1; i < source.size() + 1; i++) {
      _sum[i] = _sum[i - 1] + source[i - 1];
    }
  }
  ll sum(ll left, ll right) {
    //
    return _sum[right + 1] - _sum[left];
  }
};

int main() {
  ll N;
  scanf("%lld", &N);

  vector<ll> list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);
  }

  auto cumu = Cumu(list);

  ll ans = 0;

  for (ll i = 0; i < N - 1; i++) {
    ll plus = (list[i] * (cumu.sum(i + 1, N - 1) % MOD)) % MOD;
    ans += plus;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6388
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	r := readInt()
	fmt.Println(3 * r * r)
}


Measured memory_bytes: 1776
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/

int main(){
    int n,y;
    int x;
    scanf("%d %d",&n,&y);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(n-i-j<0){
                //printf("check > %d - %d - %d = %d\n",n,i,j,n-i-j);
                break;
            }
            x=10000*i+5000*j+1000*(n-i-j);
            //printf("%d %d %d = %d\n",i,j,n-i-j,x);
            if(x==y){
                printf("%d %d %d\n",i,j,n-i-j);
                return 0;
            }else if(x>y){
                break;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    int ans = 0;
    for(int p=1;p<=9;p++){
        for(int i=1;i<pow(3, p);i++){
            int rank = 1;
            int num = 0;
            int bits = i;
            for(int j=0;j<p;j++){
                num += (3 + 2 * (bits %3)) * rank;
                bits /= 3;
                rank *= 10;
            }
            bool flag3 = false, flag5 = false, flag7 = false;
            int cp = num;
            while(cp > 0){
                if(cp %10 == 3) flag3 = true;
                if(cp %10 == 5) flag5 = true;
                if(cp %10 == 7) flag7 = true;
                cp /= 10;
            }
            if(flag3 && flag5 && flag7){
                if(num <= n) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

const int INFTY=1000000001;
int C;

void Marge(int A[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	
	int* L=new int[n1+1];
	int* R=new int[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]=INFTY;
	R[n2]=INFTY;
	
	for(int i=0,j=0,k=left;k<right;k++){
		if(C++,L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
		}
	}
	
	delete[] L;
	delete[] R;
}


void MargeSort(int A[],int left,int right){
	if(left+1>=right)
		return;
		
	int mid=(left+right)/2;
	MargeSort(A,left,mid);
	MargeSort(A,mid,right);
	Marge(A,left,mid,right);
}

int main(){
	int N;
	cin>>N;
	
	int A[500000];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	C=0;
	
	MargeSort(A,0,N);
	
	for(int i=0;i<N;i++){
		cout<<A[i];
		
		if(i<N-1){
			cout<<' ';
		}
		else{
			cout<<endl;
		}
	}
	
	cout<<C<<endl;
	
	return 0;
}

Measured memory_bytes: 6796
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int l1,l2;
int dp[3005][3005];
int pos[3005][3005]={};
int func(int i,int j)
{
	int d1,d2;
	if(i==l1||j==l2)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(s1[i]==s2[j])
		dp[i][j]=func(i+1,j+1)+1;
	else
	{
		d1=func(i+1,j);
		d2=func(i,j+1);
		if(d1>d2)
		{
			dp[i][j]=d1;
			pos[i][j]=1;
		}
		else
		{
			pos[i][j]=2;
			dp[i][j]=d2;
		}
	}
	return dp[i][j];
}
void func1(int i,int j)
{
	if(i==l1||j==l2)
		return;
	if(s1[i]==s2[j])
	{
		cout<<s1[i];
		func1(i+1,j+1);
	}
	else
	{
		if(pos[i][j]==1)
			func1(i+1,j);
		else if(pos[i][j]==2)
			func1(i,j+1);
	}
}
int main()
{
	int i,j,d;
	cin>>s1>>s2;
	l1=s1.length();
	l2=s2.length();
	for(i=0;i<=l1;i++)
	{
		for(j=0;j<=l2;j++)
			dp[i][j]=-1;
	}
	d=func(0,0);
	func1(0,0);
}

Measured memory_bytes: 71040
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    int n = 2;
    int ans = 0;
    while (n <= k)
    {
        int odd = 1;
        while (odd <= k)
        {
            ans++;
            odd += 2;
        }
        n += 2;
    }
    cout << ans;
}

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

int main() {
	int n;
	cin >> n;
	--n;
	int c[n], s[n], f[n];
	for (int i = 0; i < n; ++i) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n; ++i) {
		int time = 0;
		for (int j = i; j < n; ++j) {
			if (time <= s[j]) {
				time = s[j];
			} else {
				time += (f[j] - (time - s[j]) % f[j]) % f[j];
			}
			time += c[j];
		}
		cout << time << endl;
	}
	cout << 0;
	return 0;
}

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

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n) {
    for (int i = 0; i < n; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    if (root(x) == root(y)) return;
    par[root(x)] = root(y);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  
  UnionFind tree(n);
  
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (tree.same(i, p[i]-1)) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#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>
#endif

using namespace std;
typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};
ll dp1[5010];
ll dp2[30000000];
int main(void){
  ll N, ga, sa, ba, gb, sb, bb;
  cin >> N >> ga >> sa >> ba >> gb >> sb >> bb;
  rep(i, N+1){
    dp1[i] = i;
    if(i >= ga) dp1[i] = max(dp1[i], dp1[i-ga]+gb);
    if(i >= sa) dp1[i] = max(dp1[i], dp1[i-sa]+sb);
    if(i >= ba) dp1[i] = max(dp1[i], dp1[i-ba]+bb);
  }
  ll M = dp1[N];
  rep(i, M+1){
    dp2[i] = i;
    if(i >= gb) dp2[i] = max(dp2[i], dp2[i-gb]+ga);
    if(i >= sb) dp2[i] = max(dp2[i], dp2[i-sb]+sa);
    if(i >= bb) dp2[i] = max(dp2[i], dp2[i-bb]+ba);
  }
  cout << dp2[M] << endl;
}


Measured memory_bytes: 196864
#include <iostream>

using namespace std;

int main(){
    int n;
    int t, x, y;
    int pt=0, px=0, py=0;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>t>>x>>y;
        if((t-pt) < (abs(x-px)+abs(y-py)) || ((t-pt) - (abs(x-px)+abs(y-py))) % 2 != 0 ){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

const long long MOD = 1e9 + 7;

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<int> oks(N+1, true);
  for ( int i = 0; i < M; i++ ) {
    int a;
    std::cin >> a;
    oks[a] = false;
  }

  std::vector<long long> dp(N+1);
  dp[0] = 1;

  for ( int now = 0; now < N; now++ ) {
    for ( int next = now + 1; next <= std::min(N, now + 2); next++ ) {
      if (oks[next]) {
        dp[next] += dp[now];
        dp[next] %= MOD;
      }
    }
  }
  std::cout << dp[N] << std::endl;
  return 0;
}


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

int main(){
  string s; cin >> s;
  for(int i = 'a';i <= 'z';i++){
    if(find(s.begin(),s.end(),i) == s.end()){
      cout << (char)i << endl;
      return 0;
    }
  }

  cout << "None" << endl;
}

Measured memory_bytes: 512
import sys
#input = sys.stdin.readline
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(M)]
ans=min(a)+min(b)
for i in range(M):
    ans=min((a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]),ans)
print(ans)

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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	double p[n+1];
	rep(i, 1, n+1){
		cin >> p[i];
	}
	
	double dp[2][n+1][n+1];
	dp[0][0][0] = 1;
	rep(i, 1, n+1){
		for(ll k = 0; k <= i; k++){
			dp[i%2][k][i-k] = 0;
			if(k > 0){
				dp[i%2][k][i-k] += dp[(i-1)%2][k-1][i-k]*p[i];
			}
			if(k < i){
				dp[i%2][k][i-k] += dp[(i-1)%2][k][i-k-1]*(1-p[i]);
			}
		}
	}
	
	double ans = 0;
	for(ll k = 0; k <= n; k++){
		if(k > n-k){
			ans += dp[n%2][k][n-k];
		}
	}
	cout << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 140928