akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int, int>> edges;
	k -= (n - 1) * (n - 2) / 2;
	for (int i = 2; i <= n; ++i) {
		edges.push_back(make_pair(1, i));
	}
	for (int q = 2; q <= n; ++q) {
		for (int j = q + 1; j <= n; ++j) {
			if (k < 0) {
				k++;
				edges.push_back(make_pair(q, j));
			}
		}
	}
	cout << edges.size() << endl;
	REP(i, edges.size()) {
		cout << edges[i].first << " " << edges[i].second << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int latte = 0, malta = 0;
  for(int i = 0; i < M; i++) {
    int x;
    cin >> x;
    if(x > X) ++latte;
    else ++malta;
  }
  cout << min(latte, malta) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#define myLOOP(i,n) for (int i=0;i<(n);i++)
using namespace std;

/**
* refered to yaya1026
*/
int main(){
	int N, M;
	string a[51],b[51];
	cin >> N >> M;
	myLOOP(i,N) cin >>a[i];
	myLOOP(i,M) cin >>b[i];

	bool judge = false;

	myLOOP(i,N){
		myLOOP(j,N){
				bool match = true;
				if(i+M-1>N || j+M-1>N)
          continue;
				for(int y=0;y<M;y++){
					for(int x=0;x<M;x++){
						if(a[i+y][j+x]!=b[y][x])
              match=false;
						continue;
					}
				}
				if(match)
          judge=true;
		}
	}

	cout << ((judge) ? "Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    ans = 0
    for i in range(n - 1):
        if a[i] & 1 and a[i + 1]:
            ans += 1
            a[i + 1] -= 1
        ans += a[i] >> 1
    ans += a[-1] >> 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 45276
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;


int main(){


    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    REP(i,n){
        cin >> a[i];
        b[i]=a[i];
        a[i] -= (i+1);
    }
    VSORT(a);

    ll median = 0;
    ll sum = 0;

    median = a[a.size()/2];

    REP(i,n){
        sum+= abs(a[i]-median);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

int dp[maxn],n,mx=0,k,c,l[maxn],r[maxn];
string s;

int main(){
	cin>>n>>k>>c>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='o'){
			if(i-c>0) dp[i]=dp[i]+mx+1;
			else dp[i]=1; 
		}
		if(i-c>=0) mx=max(mx,dp[i-c]);
	}
//	for(int i=0;i<n;i++) cout<<dp[i]<<" ";
//	cout<<endl;
	for(int i=0;i<maxn;i++) l[i]=inf;
	for(int i=0;i<n;i++) if(s[i]=='o'&&dp[i]<=k){
		l[dp[i]]=min(i,l[dp[i]]);
	}
	for(int i=0;i<maxn;i++) dp[i]=0;
	mx=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'){
			if(i+c<n-1) dp[i]=dp[i]+mx+1;
			else dp[i]=1;
		}
		if(i+c<=n-1) mx=max(mx,dp[i+c]);
	}
	for(int i=0;i<n;i++) if(dp[i]<=k&&dp[i]>=1){
		dp[i]=k-dp[i]+1;
	}
//	for(int i=0;i<n;i++) cout<<dp[i]<<" ";
//	cout<<endl;	
	for(int i=0;i<maxn;i++) r[i]=0;
	for(int i=0;i<n;i++) if(s[i]=='o'&&dp[i]<=k){
		r[dp[i]]=max(i,r[dp[i]]);
	}
//	for(int i=1;i<=k;i++) cout<<l[i]<<" "; cout<<endl;
//	for(int i=1;i<=k;i++) cout<<r[i]<<" "; cout<<endl;
	for(int i=1;i<=k;i++) if(l[i]==r[i]){
		cout<<l[i]+1<<endl;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    const int I = 64;
    const int D = 10;
    const char Y = 'Y';
    //const char N = 'N';
    const int N = 9; 

    auto qout = [](ll x){cout << "? " << to_string(x) << endl; cout.flush();return;};
    auto aout = [](ll x){cout << "! " << to_string(x) << endl; cout.flush();return;};
    auto qin = []{char c; cin >> c; return c == Y;};

    int n = N;
    int i = 0;
    vector<bool> visit(D);
    vector<bool> yn(D);

    ll ans = 1e9;
    bool one = false;
    while(true) {
        qout(ans);
        i++;
        if (qin()) {
            if (n == N) one = true;
            break;
        } 
        ans /= 10;
        n--;
    }

    if (one) {
        while(n > 0) {
            qout(ans-1);
            i++;
            if (!qin()) {
                aout(ans);
                return 0;
            }
            ans /= 10;
            n--;
        }
        aout(ans);
        return 0;
    }

    bool nl = false;
    int x = 1;
    int d = 8;
    ans = 0;
    while(i < I) {
        if(nl) {
            visit = vector<bool>(D);
            yn = vector<bool>(D);
            x = 0;
            d = 9;
            nl = false;
        }
        visit[x] = true;
        if (n == 0) {
            qout(ans*100 + x*10);
        } else {
            qout(ans*10 + x);
        }
        bool b = qin();
        yn[x] = b;
        if (b) {
            if (n == 0) {
                aout(ans*10+x);
                return 0;
            } else if (x == 9) {
                ans = ans * 10 + x;
                n--;
                nl = true;
            } else if (visit[x+1] && !yn[x+1]) {
                ans = ans * 10 + x;
                n--;
                nl = true;
            } else {
                x += d;
            }
        } else {
            if (n == 0) {
                x++;
            } else if (visit[x-1] && yn[x-1]) {
                ans = ans * 10 + x-1;
                n--;
                nl = true;
            } else {
                x -= d;
            }
        }

        d /= 2; if (d == 0) d = 1;
        i++;
    }
 
    return 0;
}


Measured memory_bytes: 596
N,X=map(int,input().split())

def f(x,y):
  if x%y==0:
    return y*(2*x//y-1)
  else:
    res=0
    res=y*2*(x//y)+f(y,x%y)
    return res

print(f(N-X,X)+N)
    
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N];
int main(){
	int k,n,ans=1e9;scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=0;i<n;i++)ans=min(ans,k-a[i+1]+a[i]);
	ans=min(ans,a[n-1]-a[0]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String args[]){
    	Scanner scan = new Scanner(System.in);
      	int num = scan.nextInt();
      	int cnt = 0;
        boolean a = num > 99;
      	if(a){
          	cnt++;
        	num = num - 100;
        }
      	boolean b = num > 9;
	    if(b){
      		num = num - 10;
        	cnt++;
      	}
      	boolean c = num == 1;
      	if(c){ cnt ++;}
        System.out.println(cnt);
    }
}

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (a[j] < a[i]) {
          ans++;
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll moddividing(ll x,ll y){
    vector<ll> vec(30);
    rep(i,30){
        vec[i] = y;
        y = y * y % 1000000007;
    }
    ll c = x;
    c = c * vec[0] % 1000000007;
    c = c * vec[2] % 1000000007;
    c = c * vec[9] % 1000000007;
    c = c * vec[11] % 1000000007;
    c = c * vec[14] % 1000000007;
    c = c * vec[15] % 1000000007;
    c = c * vec[17] % 1000000007;
    c = c * vec[19] % 1000000007;
    c = c * vec[20] % 1000000007;
    c = c * vec[23] % 1000000007;
    c = c * vec[24] % 1000000007;
    c = c * vec[25] % 1000000007;
    c = c * vec[27] % 1000000007;
    c = c * vec[28] % 1000000007;
    c = c * vec[29] % 1000000007;
    return c;
}

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<ll> factorial(N);
    factorial[0] = 1;
    factorial[1] = 1;
    for (ll i = 2; i <= N - 1; i++){
        factorial[i] = (factorial[i - 1] * i) % 1000000007;
    }
    ll max_x = 0;
    for (ll i = K; i <= N; i++){
        ll comb = moddividing(factorial[i - 1], (factorial[i - K] * factorial[K - 1]) % 1000000007);
        if (vec[i - 1] >= 0) max_x = (max_x + (vec[i - 1] * comb) % 1000000007) % 1000000007;
        else max_x = (max_x + ((vec[i - 1] + 1000000007) * comb) % 1000000007) % 1000000007;
    }
    ll min_x = 0;
    for (ll i = K; i <= N; i++){
        ll comb = moddividing(factorial[i - 1], (factorial[i - K] * factorial[K - 1]) % 1000000007);
        if (vec[N - i] >= 0) min_x = (min_x + (vec[N - i] * comb) % 1000000007) % 1000000007;
        else min_x = (min_x + ((vec[N - i] + 1000000007) * comb) % 1000000007) % 1000000007;
    }
    if (max_x - min_x >= 0) cout << max_x - min_x << endl;
    else cout << max_x - min_x + 1000000007 << endl;
}

Measured memory_bytes: 4716
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << ((a+b-1)/b)<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int n;
	cin >> n;
	int ans = 0;
	ff(i, 0, n) {
		ans += 800;
		if (i % 15 == 14) {
			ans -= 200;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int A[100005], P[100005];
set<int> S;

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        cin >> A[i];
        P[ A[i] ] = i;
    }

    long long ans = 0;

    S.insert(P[N]);

    for(int i=N-1; i>=1; i--)
    {
        S.insert(P[i]);
        auto it = S.find(P[i]);

        int L1 = 0, R1 = N+1;
        int L2 = 0, R2 = N+1;

        if(it != S.begin())
        {
            it--;
            L1 = *it;

            if(it != S.begin())
            {
                it--;
                L2 = *it;
                it++;
            }

            it++;
        }

        it++;

        if(it != S.end())
        {
            R1 = *it;
            it++;

            if(it != S.end())
                R2 = *it;
        }

        if(L1 != 0)
            ans += 1LL * (R1 - P[i]) * (L1 - L2) * i;
        if(R1 != N+1)
            ans += 1LL * (P[i] - L1) * (R2 - R1) * i;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5760
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    
    let whxy:Vec<u32> = read_vec::<u32>();
    let w = whxy[0];
    let h = whxy[1];
    let x = whxy[2];
    let y = whxy[3];

    let area :f64= f64::from(w) * f64::from(h) * 0.5;

    let mut q = 0;
    if w % 2 == 0 && h % 2 ==0 &&
       x == (w/2) && y == (h/2) {
           q = 1;
       }

    println!("{:.6} {}", area, q);
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int[][] d0y = new int[M][3];
        for(int i=0; i<M; i++){
            d0y[i][1] = in.nextInt();
            d0y[i][0] = in.nextInt();
            d0y[i][2] = i;
        }
        String[] ans = new String[M];
        int[] k = new int[N+1];
        Arrays.fill(k, 1);
        Arrays.sort(d0y, Comparator.comparing((int[] a) -> a[0]));
        for(int i=0; i<M; i++){
            StringBuilder temp = new StringBuilder();
            String ken = Integer.toString(d0y[i][1]);
            String num = Integer.toString(k[d0y[i][1]]);
            for(int j=0; j<6-ken.length(); j++) temp.append(0);
            temp.append(ken);
            for(int j=0; j<6-num.length(); j++) temp.append(0);
            temp.append(num);
            ans[d0y[i][2]] = temp.toString();
            k[d0y[i][1]]++;
        }
        for(String a : ans) out.println(a);
    }

}
}



Measured memory_bytes: 102772
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);
int main() {
    cin>>N>>M;
    mat G(N, vec(0));
    vec ans(N, -1);
    ans[0] = 0;
    rep(i,M) {
        cin>>A>>B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    queue<P> que;
    que.emplace(0, 0);
    while(!que.empty()){
        P p = que.front();
        que.pop();
        ll v = p.fi, d = p.se;
        //if(ans[v] != -1) continue;
        //cout<<v<<endl;
        for(ll to : G[v]){
            if(ans[to] == -1){
                //cout<<to<<' '<<d<<endl;
                ans[to] = v;
                que.emplace(to, d + 1);
            }
        }
    }
    rep(i,N){
        if(ans[i] == -1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    reps(i,1,N){
        cout<<ans[i] + 1<<endl;
    }
}

Measured memory_bytes: 13632
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int a,b;
	cin >> a >> b;

	if(a <= b) rep(i,0,b) cout << a;
	if(b < a) rep(i,0,a) cout << b;
	cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;



struct edge{
    ll to;
    ll cost;
};

void dijkstra(ll s, vector<vector<edge>> G, vector<ll> &d){
    //first : 最短距離、second : 頂点番号
    priority_queue< llll, vector<llll>, greater<llll>> que;
    fill(ALL(d), INF);

    d[s] = 0;
    que.push(make_pair(0, s));

    while(!que.empty()){
        llll q = que.top(); que.pop();
        ll v = q.second;

        if(q.first > d[v]) continue;

        for (edge e : G[v]) {
            if(q.first + e.cost >= d[e.to]) continue;
            d[e.to] = q.first + e.cost;
            que.push(make_pair(d[e.to], e.to));
        }
    }
}

int main(){
    ll n, m, s, t; cin >> n >> m >> s >> t;
    vector<vector<edge>> Gy(n+1);
    vector<vector<edge>> Gs(n+1);
    vector<ll> ds(n+1);
    vector<ll> dt(n+1);



    ll tmp1, tmp2, tmp3, tmp4;
    for (int i = 0; i < m; i++) {
        cin >> tmp1 >> tmp2 >> tmp3 >> tmp4;
        Gy[tmp1].push_back(edge{tmp2, tmp3});
        Gs[tmp1].push_back(edge{tmp2, tmp4});
        Gy[tmp2].push_back(edge{tmp1, tmp3});
        Gs[tmp2].push_back(edge{tmp1, tmp4});
    }

    dijkstra(s, Gy, ds);
    dijkstra(t, Gs, dt);

    vector<ll> ans(n);
    ans[n-1] = ds[n] + dt[n];
    for (ll i = n-2; i >= 0; i--) {
        ans[i] = min(ans[i+1], ds[i+1] + dt[i+1]);
    }

    ll moto = 1000000000000000;
    for (ll i = 0; i < n; i++) {
        printf("%lld\n", moto - ans[i]);
    }


}


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

// using namespace std;



// const int N = 100000, MAXI = 10000;

// int getRandom(int l, int r) {
//     return l + rand() % (r - l + 1);
// }



// // Driver code to test above functions
// int main() 
// {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
   
//     srand(time(nullptr));
   
//     int tc = 30;
//     cout << tc << "\n";
//     //int n = 2;
//     while (tc--)
//     {
//         int n = getRandom(99900, 100000);
//         cout << n << "\n";
//         int a[n+1];
//         for(int i=1;i<=n;i++)
//         {
//             if(i==1)
//                 a[1] = getRandom(2, n);
//             else if(i==n)
//                 a[n] = getRandom(1, n-1);
//             else
//             {
//                 int x = getRandom(1, i-1);
//                 int y = getRandom(i+1, n);

//                 int flag = rand()%2;

//                 if(flag==0)
//                     x = y;

//                 a[i] = x;
//             }
//             cout << a[i] << " ";
//         }
//         cout << "\n~\n";
//     }

//     return 0;
// }








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


 

// #include <bits/stdc++.h>
// using namespace std;
// #define N 100005



// int main()
// {
//     freopen("input.txt","r", stdin);
//     freopen("output.txt","w", stdout);

//     ios_base::sync_with_stdio(0);
//     cin.tie(NULL);
//     cout.tie(NULL);

//     int t;
//     cin >> t;
//     while(t--)
//     {
        
//     }
   
//     return 0;
// }














//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 

// Driver code to test above functions
int32_t main()
{
         
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    //cout << 26*26 << endl;
 
    string s = "";
    int n;
    cin >> n;

    while(n>0)
    {
        n--;
        s += (char)('a' + n%26);
        n/=26;
    }

    reverse(s.begin(), s.end());

    cout << s;
    
    return 0; 
}



Measured memory_bytes: 3648
import sys
class Node:
    parent = -1
    left = -1
    right = -1

    def __init__(self, key):
        self.key = key

    def __repr__(self):
        return "key:{},parent:{},left:{},right:{}".format(self.key, self.parent, self.left, self.right)

root_node_no = -1

def insert(nodes :dict, in_node :Node):
    global root_node_no

    cur_node_no = root_node_no
    parent_node_no = -1
    while cur_node_no != -1:
        parent_node_no = cur_node_no
        if in_node.key < cur_node_no:
            cur_node_no = nodes[cur_node_no].left
        else:
            cur_node_no = nodes[cur_node_no].right

    in_node.parent = parent_node_no

    if root_node_no == -1:
        root_node_no = in_node.key
    elif in_node.key < parent_node_no:
        nodes[parent_node_no].left = in_node.key
    else:
        nodes[parent_node_no].right = in_node.key

    nodes[in_node.key] = in_node

def inorder_tree_walk(nodes, node_no ,inorder):
    if node_no == -1:
        return
    inorder_tree_walk(nodes, nodes[node_no].left, inorder)
    inorder.append(node_no)
    inorder_tree_walk(nodes, nodes[node_no].right, inorder)

def preorder_tree_walk(nodes, node_no, preorder):
    if node_no == -1:
        return
    preorder.append(node_no)
    preorder_tree_walk(nodes, nodes[node_no].left, preorder)
    preorder_tree_walk(nodes, nodes[node_no].right, preorder)
    pass

def main():
    num_com = int(input())
    commands = sys.stdin.readlines()
    nodes = {}
    for i in range(num_com):
        if commands[i][0] == 'i':
            insert(nodes, Node(int(commands[i][7:])))
        elif commands[i][0] == 'p':
            # inorder
            inorder = []
            inorder_tree_walk(nodes, root_node_no, inorder)
            print(" " + " ".join(map(str, inorder)))
            # preorder
            preorder = []
            preorder_tree_walk(nodes, root_node_no, preorder)
            print(" " + " ".join(map(str, preorder)))


main()


Measured memory_bytes: 267748
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXQ 200005
#define MAXM 200005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int Q, T[MAXQ], F[MAXQ], cnt = 0, curR = 0, curL = 0;
char tmp, C[MAXQ];
string S, ans="";
deque<char> l, r;

void solve(){
    rep(i, Q){
        if(T[i]==1){
            cnt--;
        } else {
            if(F[i]==1){
                if(cnt%2==0)
                    l.push_back(C[i]);
                else
                   r.push_back(C[i]);
                curL++;
            } else {
                if(cnt%2==0)
                   r.push_back(C[i]);
                else
                   l.push_back(C[i]);
            }
        }
    }


    while(!l.empty()){
        tmp = l.back();
        ans += tmp;
        l.pop_back();
    }

    ans += S;

    while(!r.empty()){
        tmp = r.front();
        ans += tmp;
        r.pop_front();
    }

    cout << ans << endl;
}

int main(){
    cin >> S >> Q;

    rep(i ,Q){
        cin >> T[i];
        if(T[i]==2){
            cin >> F[i] >> C[i]; 
        } else {
            cnt++;
        }
    }

    if(cnt % 2 != 0)
        reverse(S.begin(), S.end());

    // cout << S << endl;

    solve();
}


Measured memory_bytes: 3040
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
void dfs(vector<int>adj[],int u,int visited[]) {
       visited[u] = 1;
       for (int i = 0; i < adj[u].size(); i++) {
       int v = adj[u][i];
       if (!visited[v]) 
       dfs(adj,v,visited);
      }
      
      }
void addedge(vector<int>adj[],int a,int b){
    adj[a].pb(b);
    adj[b].pb(a);
}
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=k+1;i<=n;i++){
        if(a[i]>a[i-k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 4436
N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0] * 6000 for _ in range(N + 1) ] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(5000):
            if dp[i][j][k] == 0:
                continue
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]
C = 0
for i in range(N + 1):
    C += dp[N][i][i * A]
print(C - 1)

Measured memory_bytes: 140152
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
char s[55];
int a[55];
int main(){
	scanf("%s",s+1);
	for(int i=1;i<=4;i++)a[i]=s[i]-'0';
	for(int i=0;i<1<<3;i++){
		int x=a[1],t=i;
		for(int j=1;j<=3;j++){
			if(t&1)x+=a[j+1];
			else x-=a[j+1];
			t>>=1;
		}
		if(x==7){
			x=a[1],t=i;
			printf("%d",x);
			for(int j=1;j<=3;j++){
				if(t&1)printf("+");
				else printf("-");
				printf("%d",a[j+1]);
				t>>=1;
			}
			printf("=7");
			exit(0);
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long dp[101][25];
int main(){
      int n,tmp;
      cin >> n >> tmp;
      dp[0][tmp] = 1;
      for(int i = 1;i<=n-2;i++){
            cin >> tmp;
            for(int j = 0;j <= 20;j++){
                  if(j+tmp<=20)dp[i][j]+=dp[i-1][j+tmp];
                  if(j>=tmp)dp[i][j]+=dp[i-1][j-tmp];
            }
      }
      cin >> tmp;
      cout << dp[n-2][tmp]<<endl;
}

Measured memory_bytes: 1176
#include<iostream>
using namespace std;
#define MAX 1000000
bool prime[MAX];
void isPrime(){
  fill(prime,prime+sizeof(prime),true);
  prime[0] = prime[1] = false;
  for(int i = 2 ; i * i < MAX ; i++){
    if(!prime[i])continue;
    for(int j = i + i ; j < MAX ; j += i){
      prime[j] = false;
    }
  }
} 
int main(void){
  isPrime();
  int N;
  while(cin>>N,N){
    int cnt = 0;
    for(int i = 2 ; i <= N/2 ; i ++){
      if(prime[i] && prime[N-i]){
        cnt ++;
      }
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 2136
x = int(input())

a = [500, 5, 100, 50, 1]
b = [0, 0, 0, 0, 0]

for i in range(5):
    b[i] = x // a[i]
    x = x % a[i]

print(b[0] * 1000 + b[1]*5)


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = sc.nextInt();
		Trans t = new Trans(str);
		String command="";
		for(int i = 0 ; i < n ; i ++){
			command=sc.next();
			if(command.equals("print"))
				t.print(sc.nextInt(), sc.nextInt());
			else if(command.equals("replace"))
				t.rePlace(sc.nextInt(), sc.nextInt(), sc.next());
			else if(command.equals("reverse"))
				t.reverse(sc.nextInt(), sc.nextInt());
		}
	}

}
class Trans{
	private String str;
	Trans(String s){
		str = s;
	}
	void print(int a,int b){
		System.out.println(str.substring(a, b+1));
	}
	void rePlace(int a, int b, String s){
		str = str.substring(0, a)+s+str.substring(b+1, str.length());
	}
	void reverse(int a, int b){
		String before = str.substring(0, a);
		String after = str.substring(b+1, str.length());
		String remid="";
		for(int i = b ; i >= a ; i --){
			remid+=str.charAt(i);
		}
		str=before+remid+after;
		//System.out.println(str);
	}
}

Measured memory_bytes: 41072
/*input
10 100
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll mod=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#include<iostream>
using namespace std;
ll dp[64][2][2];
ll L,R;
int main()
{
    cin>>L>>R;
    long ans=0;
    for(int k=1;k<=62;k++)
    {
        dp[62-k][L<=1L<<k-1][(1L<<k)-1<=R]=1L<<k>L&&R>=1L<<k-1;
    }
    for(int i=0;i<=60;i++)
    {
        int x=L>>60-i&1;
        int y=R>>60-i&1;
        for(int xl=0;xl<2;xl++)for(int yl=0;yl<2;yl++)
        {
            int limx=xl?0:x;
            int limy=yl?1:y;
            for(int yy=0;yy<=limy;yy++)for(int xx=limx;xx<=yy;xx++)
            {
                (dp[i+1][xl||xx>limx][yl||yy<limy]+=dp[i][xl][yl])%=mod;
            }
        }
    }
    for(int i=0;i<4;i++)(ans+=dp[61][i/2][i%2])%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,x;
    cin>>a>>b>>c>>d;

    if(a<c) a=c;
    if(b>d) b=d;
    x=max(0,b-a);
    cout<<x<<endl;
return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25

int main()
{	
	int i, j, k;
	int n;
	cin >> n;
	int A[n];
	int B[n];
	int C[n];
	rep(i, n) cin >> A[i];
	rep(i, n) cin >> B[i];
	rep(i, n) cin >> C[i];
	sort(A, A + n);
	sort(B, B + n);
	sort(C, C + n);
	long long count = 0;
	rep(i, n) {
		count += (lower_bound(A, A + n, B[i]) - A) * (C + n - upper_bound(C, C + n, B[i]));
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1408
//https://atcoder.jp/contests/keyence2020/tasks/keyence2020_d

#include<bits/stdc++.h>
const int inf = 1e9;
using namespace std;

int n, ans = inf, a[18], b[18], dp[1 << 18][18];

int val(int i, int j){
    j &= 1;
    return (j ? b[i] : a[i]);
}

void up(int&a, int b){
    if (a > b) a = b;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) if (i&1) swap(a[i], b[i]);

    for (int i = 0; i < (1 << n); i++) for (int j = 0; j < n; j++) dp[i][j] = inf;
    for (int i = 0; i < n; i++) dp[1 << i][i] = i;

    for (int i = 1; i < (1 << n); i++) if (i & (i - 1)){
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (((i >> j)&1)){
                int num = __builtin_popcount(i);
                for (int k = 0; k < n; k++) if (k != j && val(k, num-2) <= val(j, num-1)){
                    up(dp[i][j], dp[i^(1 << j)][k] + cnt);
                }
            }
            else cnt++;
        }
    }
    for (int i = 0; i < n; i++) up(ans, dp[(1 << n)-1][i]);
    if (ans == inf) ans = -1;
    cout << ans;
}


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

int main() {
    string s;
    cin >> s;
    map<char, int> cnt;
    for (char c : s) cnt[c]++;

    if (cnt.size() == 1) {
        if (s.size() == 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    } else if (cnt.size() == 2) {
        if (s.size() < 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    } else {
        if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

string S;

int main(void) {
  cin >> S;

  ll a = 0, b = 0, c = 0;
  REP(i, 0, S.length()) {
    if(S[i] == 'a') a++;
    if(S[i] == 'b') b++;
    if(S[i] == 'c') c++;
  }

  if(abs(a - b) <= 1 && abs(b - c) <= 1 && abs(c - a) <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
// Compute C(N, K): choose the last ball in each bin
#include <iostream>
using namespace std;
int C[1001][1001];
int M = 1e9 + 7;
int main() {
  int N, K;
  cin >> N >> K;
  C[0][0] = 1;
  for (int k = 1; k <= K; ++k)
    for (int n = k; n <= N; ++n)
      C[n][k] = (C[n - 1][k - 1] + C[n - 1][k]) % M;
  cout << C[N][K] << endl;
}


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

int main() {
  int a[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  cout << ((a[x] == a[y]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  string s;
  cin >> s;
  int len = s.size() - 8;
  for(int i = 0; i < len; i++) cout << s[i];
  cout << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using namespace  std;

void fnInput(int &rnMaxSiz, vector<int> &rvnSort)
{
  cin >> rnMaxSiz;

  rvnSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int> &rvnSort, int &rnSortCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vLeft, vRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;

  vLeft.resize(nLeftSiz + 1);
  vRight.resize(nRightSiz + 1);

  for (int i = 0; i < nLeftSiz; i++)
    vLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vRight[i] = rvnSort[nMid + i];

  vLeft[nLeftSiz] = INT_MAX;
  vRight[nRightSiz] = INT_MAX;
  int i = 0, j = 0;

  for (int n = nLeft; n < nRight; n++)
    if (vLeft[i] <= vRight[j])
    {
      rvnSort[n] = vLeft[i++];
      rnSortCnt++;
    }
    else
    {
      rvnSort[n] = vRight[j++];
      rnSortCnt++;
    }
}

void fnMergeSort(vector<int> &rvnSort, int &rnSortCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnSortCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnSortCnt, nMid, nRight);
    fnMerge(rvnSort, rnSortCnt, nLeft, nMid, nRight);
  }
}

void fnResult(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i != 0)  cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}

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

  int nMaxSiz;
  vector<int> vnSort;

  fnInput(nMaxSiz, vnSort);

  int nLeft = 0;
  int nRight = nMaxSiz;
  int nSortCnt = 0;
  fnMergeSort(vnSort, nSortCnt, nLeft, nRight);

  fnResult(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 5068
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 200010;

int n, res, m;
int w[N], d[N], cnt[20], sxr[N];

int main()
{
    scanf("%d", &n);

    for (int i = 1; i < n; i++) 
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c); 
        w[a] ^= c;
        w[b] ^= c; 
    }

    for (int i = 0; i < n; i++)  cnt[w[i]]++; 

    for (int i = 1; i <= 15; i++)
    {
        res += cnt[i] / 2;
        m |= (cnt[i] & 1) << (i - 1);
    }

    for (int i = 1; i < (1 << 15); i++) d[i] = d[i >> 1] + (i & 1);
    for (int i = 1; i < (1 << 15); i++) d[i] -= 1;
    for (int i = 1; i < (1 << 15); i++)
    {
        for (int j = 0; j < 15; j++)
        {
            if ((i >> j) & 1)sxr[i] ^= (j + 1);
        }
    }
    
    for (int i = 1; i < (1 << 15); i++)
    {
        if (sxr[i] != 0)continue;
        for (int k = (i - 1) & i; k; k = (k - 1) & i)
        {
            if (sxr[k] == 0)d[i] = min(d[i], d[k] + d[i ^ k]);
        }
    }

    printf("%d", res + d[m]);
}

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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()


signed main(){
    int a,b;
    cin>>a>>b;
    vector<string> vec;
    for(int i=0;i<a;i++){
        string t;
        cin>>t;
        vec.pb(t);
    }
    cout<<string(b+2,'#')<<endl;
    for(int i=0;i<a;i++){
        cout<<"#"<<vec[i]<<"#"<<endl;
    }
    cout<<string(b+2,'#')<<endl;
    return 0;
}

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

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100100];

int main() 
{

    int N;
    string S;
    cin >> N;
    cin >> S;
    int count = 0;
    int result = 1;
    while (count < N - 1)
    {
        if (S[count] != S[count + 1]) {
            result = result + 1;
        }
        count = count + 1;
    }
    cout << result << endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
int count =0;
int count2 = 0;
Node treeMinimum(Node x){
   while (x->left != NIL){
    x = x->left;
}
return x;
}



Node IterativetreeSearch(Node u, int k){
  while(u !=NIL && k !=u->key){
    if(k < u->key){
      u = u->left;

    }

    else u = u->right;
  }
  return u;

}


/*
Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key) 
  return treeSearch(u->left,k);
  
  else return treeSearch(u->right,k);
  
  }*/

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
      }
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }

  if(y->left != NIL){
    x = y->left;
  } 
  else {
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y-> parent ->left){
    y->parent->left =x;
  }
  else y-> parent -> right = x;

  
  if(y != z){
    z->key = y->key;
  } 

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right; 
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if (z->key < y->key){
    y->left = z;
  }
  
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
 
}




void preorder(Node u){
  
  
    if (u != NIL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
    
 
    
    }
}

int main(){
  int n, i, x;
  //int ,num[500000];
  char com[20];
  scanf("%d", &n);
  //for ( i = 0; i < n; i++ ){num[i] = 0;}//???
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = IterativetreeSearch(root, x);
      if ( t != NIL ){
	printf("yes\n"); 
	/*num[count] = 1;
	count++;
	*/
      }
      else {
	printf("no\n");
	/*num[count] = 2;
	  count++;*/
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    

    else if ( com[0] == 'p' ){
      /*if(count2 == 0){
	for(j=0;j<n;j++){
	  if(num[j]==1)printf("yes\n");
	  else if(num[j]==2)printf("no\n");
	  else printf("");
	  count2 = 1;
	}
	}*/
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
	count = 0;
	
      }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(IterativetreeSearch(root, x));
    }
  }

  return 0;
  }

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

int main(){
	string s;
	cin >> s;
	int sum = 0;
	for(int i = 0; i < s.size(); i++){
		sum += s[i] - '0';
	}
	int ok = 0;
	for(int i = 0; i < s.size(); i++){
		if(i == 0 && s[i] != '1')break;
		if(i > 0 && s[i] != '0')break;

		if(i == s.size() - 1){
			ok = 1;
		}
	}
	if(ok)cout << 10 << endl;
	else cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k,G,tmp,ma;
inline int gcd(int a,int b){
	while(a){
		b%=a;
		swap(a,b);
	}
	return b;
}
int main(){
	scanf("%d%d",&n,&k);
	while(n--){
		scanf("%d",&tmp);
		ma=max(ma,tmp);
		if(G>tmp)swap(G,tmp);
		G=gcd(G,tmp);
	}
	if(ma>=k&&(k%G==0))printf("POSSIBLE");
	else printf("IMPOSSIBLE");
}


Measured memory_bytes: 128