akhauriyash/Code-Regression huggingface dataset:
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

ll n, p;
ll a[MAXN];

int main() {
	cin >> n >> p;
	for (int i = 0; i < MAXN; i++) {
		a[i] = 1;
	}
	for (int i = 2; i < MAXN; i++) {
		if (a[i]) {
			for (int j = 2 * i; j < MAXN; j += i) {
				a[j] = 0;
			}
		}
	}
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	ll ret = 1;
	for (ll i = 2; i * i <= p; i++) {
		if (!a[i]) {
			continue;
		}
		ll cur = 1;
		bool bad = false;
		for (int j = 0; j < n; j++) {
			cur *= i;
			if (cur > p) {
				bad = true;
				break;
			}
		}
		if (bad) {
			continue;
		}
		ll tp = p;
		while (tp % cur == 0) {
			tp /= cur;	
			ret *= i;
		}
	}
	cout << ret << endl;
	return 0;
}


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

namespace ConsoleApp1
{
    class TestCase
    {
        public int A { get; } = 0;
        public int B { get; } = 0;
        public TestCase(int a, int b)
        {
            A = a;
            B = b;
        }
    }

    class SampleTestCase
    {
        public TestCase TC { get; } = new TestCase(0, 0);
        public int ANS { get; } = 0;
        public SampleTestCase(TestCase tc, int ans)
        {
            TC = tc;
            ANS = ans;
        }
        public void EXPECT_EQ(int val)
        {
            if(ANS == val)
            {
                Console.WriteLine("Test OK");
            }
            else
            {
                Console.WriteLine("Test NG : ANS = " + ANS + ", SolveValue = " + val);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ExecuteProblem();
            //ExecuteSampleTest();
        }

        private static void ExecuteSampleTest()
        {
            var sampleTestCases = new SampleTestCase[] {
                  new SampleTestCase(new TestCase(5, 3), 9)
                , new SampleTestCase(new TestCase(3, 4), 7)
                , new SampleTestCase(new TestCase(6, 6), 12) };

            foreach (var stc in sampleTestCases)
            {
                stc.EXPECT_EQ(Solve(stc.TC));
            }
        }
        private static void ExecuteProblem()
        {
            string[] ab = Console.ReadLine().Split(' ');
            TestCase tc = new TestCase(int.Parse(ab[0]), int.Parse(ab[1]));
            Console.WriteLine(Solve(tc));
        }

        private static int Solve(TestCase tc)
        {
            int coinEqVal = tc.A == tc.B ? tc.A + tc.B : 0;
            int[] coins = new int[] {(tc.A + tc.A - 1), (tc.A + tc.B - 1), (tc.B + tc.B - 1), coinEqVal};
            return coins.Max();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b, a % b);
}
int main(){
    CIN(N);
    LL ans = 0;
    vector<int> vec;
    for(int a = 0;a < N;a++){
        CIN(b);vec.push_back(b);
    }
    ans = vec.front();
    for(int a = 0;a < N;a++)ans = gcd(ans,vec.at(a));
    COUT(ans);
}


Measured memory_bytes: 892
n = int(input())
li_a = []
for i in range(n):
  a = list(map(int, input().split()))
  li_a.append(a)
li = list(sorted(li_a))
ans = 0
b = li[0][0] + li[0][1]
for i in range(n-1):
  if li[i+1][0] - li[i+1][1] >= b:
    b = li[i+1][0] + li[i+1][1]
  else:
    b = min(b, li[i+1][0]+li[i+1][1])
    ans += 1
print(n-ans)

Measured memory_bytes: 29016
#include<stdio.h>
int main(void) {
	int a, b, c, tmp1, tmp2;

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

	tmp1 = a;
	a = b;
	b = tmp1;

	tmp2 = a;
	a = c;
	c = tmp2;

	printf("%d %d %d", a, b, c);

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;


template <typename T>
T gcd(T a, T b) {
	if (a < b) swap(a, b);
		while (b != 0) {
			T tmp = b;
			b = a % b;
			a = tmp;
		}
	return a;
}

int N;
int A[1000000];

bool is_prime[1000001];
bool used[1000001];
vector<int> facs[1000001];

void init(){
    for(int i = 2; i <= 1000000; i++){
        is_prime[i] = true;
    }
    for(int i = 2; i <= 1000000; i++){
        if(is_prime[i] = true){
            facs[i].push_back(i);
            for(int j = 2; i*j <= 1000000; j++){
                is_prime[i*j] = false;
                facs[i*j].push_back(i);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    int g;
    bool ok = true;
    init();
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(i == 0){
            g = A[i];
        }else{
            g = gcd<int>(A[i], g);
        }
        for(int f : facs[A[i]]){
            if(used[f]){
                ok = false;
            }
            used[f] = true;
        }
    }
    if(g ==1 ){
        if(ok){
            cout << "pairwise coprime" << endl;
        }else{
            cout << "setwise coprime" << endl;
        }
    }else{
        cout << "not coprime" << endl;
    }

}

Measured memory_bytes: 119908
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

count = 0
rem = 0	#余剰戦力
for i in range(N):
	if A[i]>=B[i]+rem:
		count += B[i]+rem
		rem = 0
	else:
		count += A[i]
		if (B[i]+rem-A[i])>A[i+1]:
			rem = A[i+1]
		else:
			rem = B[i]+rem-A[i]
count += rem #N+1番目の街

print(count)

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

#define F first
#define S second

using namespace std;

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

const int N = 16050, M = 8010;

int n, x, y;
set<int> fx[2], fy[2];
char s[M];
vector<int> dx, dy;

int main()
{
	scanf("%s%d%d", s, &x, &y);
	
	n = strlen(s);
	for (int i = 0, t = 0; i < n; i ++ )
	{
		int j = i, cnt = 0;
		while (j < n && s[j] == 'F') j ++ , cnt ++ ;
		
		if (!t) dx.push_back(cnt);
		else dy.push_back(cnt);
		
		i = j, t ^= 1;
	}
	
	int tx = 0;
	fx[tx].insert(M + dx[0]);
	for (int i = 1; i < dx.size(); i ++ )
	{
		tx ^= 1, fx[tx].clear();
		for (auto u : fx[tx ^ 1])
		{
			fx[tx].insert(u + dx[i]);
			fx[tx].insert(u - dx[i]);
		}
	}
	
	int ty = 0;
	fy[ty].insert(M);
	for (int i = 0; i < dy.size(); i ++ )
	{
		ty ^= 1, fy[ty].clear();
		for (auto u : fy[ty ^ 1])
		{
			fy[ty].insert(u + dy[i]);
			fy[ty].insert(u - dy[i]);
		}
	}
	
	if (fx[tx].count(x + M) && fy[ty].count(y + M)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
P = list(map(int, input().split()))
L = [(x+1)/2 for x in P]

ans = tmp = sum(L[:K])

for i in range (N-K):
    nxt = tmp + L[K+i] - L[i]
    ans = max(ans, nxt)
    tmp = nxt

print(ans)

Measured memory_bytes: 24804
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const long long MAX = 510000;
const long long MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  long long N, K;
  cin >> N >> K;
  long long sum[200001];
  sum[0] = 1;
  long long temp = min(K, N-1);
  rep(i, temp) {
    sum[i+1] = (COM(N, i+1) * COM(N-1, i+1)) % MOD;
  }
  rep(i, temp) {
    sum[i+1] += sum[i];
    sum[i+1] %= MOD;
  }
  cout << sum[temp] << endl;
  return 0;
}

Measured memory_bytes: 17148
from sys import stdin, stdout
from decimal import Decimal
from random import randint
PEPS = 1e-10
INF = float('inf')


def sqr(a):
    return a * a


def dist(a, b = (0, 0)):
    return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]))


def s_dist(a, b = (0, 0)):
    return (sqr(a[0] - b[0]) + sqr(a[1] - b[1]))


def dist3(a, b = (0, 0, 0)):
    return sqrt(sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2]))


def s_dist3(a, b = (0, 0, 0)):
    return (sqr(a[0] - b[0]) + sqr(a[1] - b[1]) + sqr(a[2] - b[2]))


def trans(p, al):
    return (p[0] * cos(al) + p[1] * sin(al), - p[0] * sin(al) + p[1] * cos(al))


def get_angle(a, b, c):
    cos_al = (sqr(a) + sqr(b) - sqr(c)) / (2 * a * b)
    return acos(cos_al)


def write_float(ans):
    stdout.write(str('%.13f' % ans) + '\n')


def get_hight(pt1, pt2, pt3):
    a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
    b = (pt3[0] - pt1[0], pt3[1] - pt1[1])
    return abs(a[0] * b[1] - a[1] * b[0]) / dist(pt1, pt2)


def get_square(pt1, pt2, pt3):
    a = (pt2[0] - pt1[0], pt2[1] - pt1[1])
    b = (pt3[0] - pt2[0], pt3[1] - pt2[1])
    return (a[0] * b[-1] - a[1] * b[0]) / 2


def sign(v):
    if v > 0:
        return 1
    elif v < 0:
        return -1
    else:
        return 0


def inn(pt, triangle):
    signs = set()
    signs.add(sign(get_square(triangle[0], triangle[1], pt)))
    signs.add(sign(get_square(triangle[1], triangle[2], pt)))
    signs.add(sign(get_square(triangle[2], triangle[0], pt)))
    return len(signs) == 1


def inter_in(a, b):
    return dist((a[0], a[1]), (b[0], b[1])) < a[-1] + b[-1]


def inter_in3(a, b):
    return dist3(a[:-1], b[:-1]) < a[-1] + b[-1]


def shift(what, wth):
    return (what[0] - wth[0], what[1] - wth[1])


n = int(stdin.readline())
vl = list(map(int, stdin.readline().split()))
ans = []

while len(vl):
    for i in range(len(vl) - 1, -1, -1):
        if vl[i] == i + 1:
            ans.append(i + 1)
            vl = vl[:i] + vl[i + 1:]
            break
    else:
        stdout.write('-1\n')
        break


if len(ans) == n:
    ans = ans[::-1]
    stdout.write('\n'.join(list(map(str, ans))))


Measured memory_bytes: 6220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  int k = 0;
  cin >> n;
  cin >> k;
  vector<int> price(n);
  for(int i = 0; i < n; i++) {
    cin >> price.at(i);
  }
  sort(price.begin(),price.end());
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans += price.at(i);
  }
  cout << ans << endl;
}


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

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

    int ans = 0;
    for(int i=0; i<n; ++i){
        set<char> s = {a[i], b[i], c[i]};
        ans += s.size() - 1;
    }
    cout << ans << endl;

    return 0;
}


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

const int maxn = 1e5 + 20;

bool visited[maxn];
int n, m, a, b, outDegree[maxn], dis[maxn];
vector<int> graph[maxn];

void dfs(int i) {
    visited[i] = 1;
    for (int x : graph[i]) {
        if (!visited[x]){
            dis[x] = dis[i] + 1; 
            dfs(x);
        }
        if (dis[x] > dis[i]) {
            if (outDegree[x] % 2 == 0){
                outDegree[i]++;
                cout << i << " " << x << endl;
            }
            else{
                outDegree[x] ++;
                cout << x << ' '  << i << endl;
            }
        }
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    if (m % 2 == 1)
        return cout << -1 << endl, 0;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(1);    
}

Measured memory_bytes: 15616
#include<stdio.h>
#define N 100000

int main(){
  int T[N],S[N],i,q,c=0,n,left,right,mid;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(S[mid]==T[i]){
        c++;
	break;
      }
      else if(T[i]<S[mid])
	right=mid;
      else
	left=mid+1;
    } 
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
	int n,q;
	cin>>n>>q;
	UnionFind in(n);
	while(q--){
		int a,b,c;
		cin>>a>>b>>c;
		if(a==0)in.unionSet(b,c);
		else cout<<in.findSet(b,c)<<endl;
	}
}

Measured memory_bytes: 1236
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;

char func(char prev, char ox, char beast) {
	bool flag = true;
	if (prev == 'W') flag = !flag;
	if (ox == 'x') flag = !flag;
	if (beast == 'W') flag = !flag;
	if (flag) return 'S';
	else return 'W';
}

char tmp[100000];
int main() {
	string s;
	cin >> s;
	int g_cnt = 0, p_cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'g') g_cnt++;
		else p_cnt++;
	}
	int mg_cnt = (s.size() + 1) / 2, mp_cnt = s.size() / 2;
	cout << mp_cnt - p_cnt;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;

int main(){
  int n;
  cin >> n;
  ll V =0, E=0;
  for(int i=1;i<=n;++i) V+= ll(i)*(n-i+1);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    if(a>b) swap(a,b);
    E+= ll(a)*(n-b+1);
  }
  ll ans=V-E;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
const int N=200005;
const int maxn = 1e5 + 10;
ll pos[maxn],fac[maxn],facm[maxn];
ll quick_pow(ll a,ll n,ll p)
{
    ll x = a;
    ll res = 1;
    while(n){
        if(n & 1){
            res = ((ll)res * (ll)x) % p;
        }
        n >>= 1;
        x = ((ll)x*(ll)x) % p;
    }
    return res;
}
ll C(ll n,ll k){
    if(k > n) return 0ll;
    ll ans = fac[k]*fac[n-k]%MOD;
    ans = (fac[n]*quick_pow(ans,MOD-2ll,MOD))%MOD;
    return ans;
}
int main()
{
    fac[0] = 1;
    for(int i = 1;i < maxn;i++)
        fac[i] = (fac[i-1]*i)%MOD;
    ll n;
    scanf("%lld", &n);
    n++;
    ll m, x;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &x);
        if (pos[x]){
            m = n - (i - pos[x] + 1);
            break;
        }
        pos[x] = i;
    }
    for(int i = 1;i <= n;i++)
        printf("%lld\n", (C(n, i) - C(m, i-1)+MOD) % MOD);
    return 0;
}


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

int main() {

  int i,j;
  int n;
  int *A;
  int *B;
  int C[10001];
  scanf("%d",&n);
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }

  for(i=0;i<=10001;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=10001;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i==n) break;
    printf(" ");
  }
 
  printf("\n");
  

  return 0;
}

Measured memory_bytes: 16276
#include <iostream>

using namespace std;

int K[10][10];
typedef long long ll;
ll ans;
int h,w;
int main() {
  cin >> h >> w;
  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> K[i][j];
    }
  }

  for(int k = 0; k < 10; k++) {
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
	K[i][j] = min(K[i][j],K[i][k] + K[k][j]);
      }
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int a;
      cin >> a;
      if(a != -1) ans += K[a][1];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 
 

 
int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> n >> k;
    vi v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    sort(all(v));
    a=0;
    for(int i=0; i<k; i++){
        a+=v[i];
    }
    cout << a << el;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

int a[200000];
signed main(){
    int n;
    cin >> n;
    int now = 1;
    REP(i,n){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i,n){
        if(now > 1000000000000000000/a[i]){
            cout << -1 << endl;
            return 0;
        }
        now *= a[i];   
    }
    if(now>1000000000000000000){
        cout << -1 << endl;
            return 0;
    }

    cout << now << endl;

    return 0;
}

Measured memory_bytes: 4376
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = col.deque(sinput().split())
q = iinput()
cnt = 0
for i in range(q):
    try: t,f,c = sarr()
    except: cnt += 1; cnt %= 2; continue
    if cnt: #反転の状態
        if f == "1": s.append(c)
        if f == "2": s.appendleft(c)
    else: #ノーマル状態
        if f == "1": s.appendleft(c)
        if f == "2": s.append(c)
    #print(s)

s = "".join(s)
s = s[::-1] if cnt else s
print(s)



Measured memory_bytes: 28972
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

void solve(){
	double d, t, s;
	cin >> d >> t >> s;
	 
	if(d / s <= t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main(){
	int t = 1;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 1e7+2;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n;
	cin >> n;

	int rt = sqrt(N)+1;

	loop(i,1,n+1)
	{
		for(int j = i; j < n+1; j += i)
		{
			A[j]++;
		}
	}


	int sum = 0;

	// loop(i,1,100)cout << A[i] << " ";
	// return;

	for(int i = 1 ; i <= n; i++)
	{
		sum += (i*A[i]);
	}

	cout << sum;

}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define ll  long long
#define ld	long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"

const ll MOD2 = 998244353;
const ll MOD = 1000*1000*1000 + 7;	
const ll N  = 1000*1000+5;
const double PI  = 3.14159265;

int main()
{
	int n,l;
	cin>>n>>l;
	std::vector<pii> v;
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		int dum = l+i;
		ans+=dum;
		v.pb(mp(abs(dum),i));
	}
	sort(all(v));
	ans-=(v[0].ss+l);
	cout<<ans;
	
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d" ,&n);
  vector <int> A(n);
  for(int i=0;i<n;i++){
    cin >> A.at(i);
  }
  int s = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      s += A.at(i)*A.at(j);
    }
  }
  printf("%d\n",s);
}
      
    

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i=0;i<N;++i){
		cin >> A[i];
	}
	vector<int> B(N, 0);
	bool flag = true;
	for (int i = N; i > 0; --i) {
		int cnt = 0;
		for (int j = i + i; j <= N; j += i) {
			int index = j - 1;
			cnt += B[index];
		}
		cnt %= 2;
		if (cnt == A[i - 1]) {
			
		}
		else {
			B[i - 1] = 1;
		}
	}
	int M = 0;
	for (int i = 0; i < N; ++i) {
		M += B[i];
	}
	cout << M << endl;
	for (int i = 0; i < N; ++i) {
		if (B[i]) {
			cout << i + 1 << endl;
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
  char c;
  cin>>c;
  if('A'<=c&&c<='Z'){
    cout<<'A'<<endl;
  }else{
    cout<<'a'<<endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,k;
  cin>>a>>b>>k;
  long long l=k-a;
  a=max((long long)0,a-k);
  k=max((long long)0,l);
  l=k-b;
  b=max((long long)0,b-k);
  cout<<a<<' '<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int n,k;
      cin >> n >> k;
      double ans = 0;
      for(int i=1;i<=n;i++){
            double tmp = 1.0;
            for(int j=i;j<k;j*=2){
                  tmp /= 2.0;
            }
            ans += tmp;
      }
      ans /= n;
      printf("%.12f",ans);      
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
#define mod 1000000007
#define INT 2100000000

vector<vector<int> > tree;
vector<int> weight;
vector<vector<int> >ret;

void foo(int root)
{
	ret[root].resize(2);
	int mi = -INT, ma = INT;
	int tmp;
	for (int i = 0; i < tree[root].size(); ++i) {
		tmp = tree[root][i];
		//cout << "   foo " << tmp << '\n';
		foo(tmp);
		if (ret[tmp][0] > ret[tmp][1]) {
			ret[root] = ret[tmp];
			return;
		}
		mi = max(mi, ret[tmp][0] - 1);
		ma = min(ma, ret[tmp][1] + 1);
	}
	ret[root][0] = mi; ret[root][1] = ma;
	if (weight[root] != INT) {
		if (!(mi <= weight[root] && weight[root] <= ma)) {
			ret[root][0] = 0; ret[root][1] = -1;
		} else {
			ret[root][0] = ret[root][1] = weight[root];
		}
	}
	//cout << "ret " << ret[root][0] << ' ' << ret[root][1] << '\n';
}

void result(int root, int prev)
{
	weight[root] = (prev == -INT ? 1 : prev);
	for (int i = 0; i < tree[root].size(); ++i) {
		int tmp = tree[root][i];
		int mi = prev - 1, ma = prev + 1;
		mi = max(mi, ret[tmp][0]);
		ma = min(ma, ret[tmp][1]);
		result(tmp, mi);
	}
}

int main()
{
	//freopen("test", "r", stdin);
	int n, t; cin >> n >> t;
	vector<int> v(n, 0); cin >> v[0];
	int mmm = -1; int c = 0, prev = v[0];
	for (int i = 1; i < n; ++i) {
		cin >> v[i];
		if (v[i] > prev) {
			if (v[i] - prev > mmm) {
				mmm = v[i] - prev;
				c = 1;
			} else if (v[i] - prev == mmm) {
				++c;
			}
		} else {
			prev = v[i];
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 640
import sys

n = int(input())
a = [int(input()) for i in range(n)]

already_nums = set()
push_count = 0
i = 0
while i != 1:
    if i not in already_nums:
        already_nums.add(i)
        i = a[i]-1
        push_count += 1
    else:
        print(-1)
        sys.exit()
print(push_count)

Measured memory_bytes: 15904
#include <iostream>
#include <stdio.h>
#include <string.h>
#define int long long

using namespace std;

int n,m;

signed main()
{
	scanf("%lld%lld",&n,&m);
	if(n==1 && m==1) printf("1\n");
	else if(n==1) printf("%lld\n",m-2);
	else if(m==1) printf("%lld\n",n-2);
	else printf("%lld\n",(n-2)*(m-2));
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
mod = 10**9+7

if N < M:
    N, M = M, N

if N == M:
	answer = 2
	for i in range(2, N+1):
		answer = answer * i * i
		answer = answer % mod
	print (answer)

elif N == M+1:
	answer = 1
	for i in range(2, N):
		answer = answer * i * i
		answer = answer % mod
	answer = answer * N % mod
	print(answer)

else:
	print(0)

Measured memory_bytes: 3064
#include <iostream>

int main(void){
  int n,k,i;
  int count = 0;
  std::cin >> n >> k;
  for(i=0; i<n; i++){
    int h;
    std::cin >> h;
    if(h>=k){count++;}
  }
  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;
using ll = long long;

const ll mod = 1'000'000'007;

auto main (void) -> int {
  int n;
  cin >> n;

  vector<int> a (n);
  for (auto i = 0; i < n; i++) cin >> a[i];

  ll tmp_0 = 0;
  ll tmp_1 = 0;

  for (auto i = 0; i < n; i++) {
    ll c  = static_cast<ll> (a[i]);
    tmp_0 = (tmp_0 + c) % mod;
    tmp_1 = (tmp_1 + c * c) % mod;
  }
  tmp_0 = (tmp_0 * tmp_0) % mod;

  ll b = tmp_0 < tmp_1 ? tmp_0 - tmp_1 + mod : tmp_0 - tmp_1;

  cout << (b + (b % 2) * mod) / 2 << endl;

  return 0;
}


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

n,k=map(int,input().split())
sushi=[list(map(int,input().split())) for _ in range(n)]
sushi.sort(key=lambda x:x[1],reverse=True)

from collections import Counter
sel=Counter()
ans=0
sta=[]

for t,d in sushi[:k]:
    ans+=d
    sel[t]+=1
    sta.append([t,d])

ans+=len(sel)**2
tmp=ans
for t,d in sushi[k:]:
    if t in sel:continue
    while sta:
        tt,dd=sta.pop()
        if sel[tt]>1:
            tmp+=d-dd+2*len(sel)+1
            ans=max(ans,tmp)
            sel[tt]-=1
            sel[t]+=1
            break
print(ans)


Measured memory_bytes: 76636
#include <cstdio>
#include <algorithm>

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	for (int i = 1; i <= 20000; ++i)
	{
		int aa = i * 8 / 100;
		int bb = i * 10 / 100;
		if (aa == a && bb == b)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 128
// =====================================================================================
//
//       Filename:  cp.cpp
//
//        Version:  1.0
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Priyank Kumar Singh ()
//   Organization:  RVCE Bangalore
//
// =====================================================================================


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
vector<int> s[10];
/*
void dfs(int i, int j){
    int c=s[i][j];
    if(i==n-1 && j==m-1 ){
        ans = min(ans, c);
        return;
    }
    
    if(j+1<m) dfs(i,j+1);
    c+=s[i][j];
    if(i+1<n) dfs(i+1,j);
    c+=s[i][j];
}
int c1=0;
*/

void answer(){
    ll n,m,x,y=0;
    cin>>n;
    vector<ll> v(n+1);
    for(int i=0;i<n;i++){
        cin>>v[i];
        y^=v[i];
    }
    for(int i=0;i<n;i++){
        m = y^v[i];
        cout<<m<<" ";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


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


typedef long long ll;
using namespace std;
const int maxn = 1e6+5;
int v[maxn];
vector<int> w;
void gen()
{
    for(int i = 2; i < maxn; i++) {
        if(!v[i]) {
            w.push_back(i);
            for(int j = i*2; j < maxn; j+=i) v[j] = 1;
        }
    }
}

int main()
{
    gen();
    int a;
    cin >> a;
    auto it = lower_bound(w.begin(), w.end(), a);
    cout << *it << endl;
}


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

class B {
    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        var t = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var total = t.Sum();
        var m = int.Parse(Console.ReadLine());
        for (int i = 0; i < m; ++i) {
            var line = Console.ReadLine().Split();
            var p = int.Parse(line[0]) - 1;
            var x = int.Parse(line[1]);
            Console.WriteLine(total - t[p] + x);
        }
    }
}


Measured memory_bytes: 13268
n = int(input())
s = input()

over = 0
ans_f = 0
ans_e = 0
for c in s:
    if c == "(":
        over += 1
    else:  # )
        if over > 0:
            over -= 1
        else:
            ans_f += 1

ans_e = over

ans = ""
for i in range(0, ans_f):
    ans += "("

ans += s

for i in range(0, ans_e):
    ans += ")"

print(ans)


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
N = len(S)

# nxt[i][c] := i文字目以降で最初に文字cが登場するindex(存在しないときはN)
nxt = list2d(N+1, 26, N)
for i in range(N-1, -1, -1):
    for c in range(26):
        nxt[i][c] = nxt[i+1][c]
    c = ord(S[i]) - 97
    nxt[i][c] = i

# dp[i] := i文字目以降について「部分文字列とならない」最短の文字列長
dp = [INF] * (N+1)
# rest[i][(c, j)] := 位置iから見て、最小達成に用いた文字cと、次に使う文字のindexj
rest = [None] * (N+1)
dp[N] = 1
# 常に自分より後ろでの最小が必要になるので、後ろから埋めていく
for i in range(N-1, -1, -1):
    # iから見て先頭として使う文字を26通り全部試す
    # abcを昇順で回して、最小更新条件を等号なしにすることで、辞書順で小さい方を優先できる
    for c in range(26):
        # 次の文字がない時
        if nxt[i][c] == N:
            if dp[i] > 1:
                dp[i] = 1
                rest[i] = (c, N)
        # 次の文字がある時
        else:
            # i以降に文字cが出現するindex+1の位置での最短文字列長 + 1
            # 例えばaについてなら、a****となるので、****での最小とaの分で+1
            if dp[i] > dp[nxt[i][c]+1] + 1:
                dp[i] = dp[nxt[i][c]+1] + 1
                rest[i] = (c, nxt[i][c]+1)

# 復元
i = 0
ans = []
while i < N:
    c, idx = rest[i]
    ans.append(chr(c+97))
    i = idx
print(''.join(ans))


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

int main() {
  int num;
  cin >> num;
  
  if (num >= 0 && num < 1200) {
  	cout << "ABC" << endl;
  } else if (num < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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

bool good(string n){
  if(n[0]==n[1]&&n[1]==n[2]) return true;
  if(n[1]==n[2]&&n[2]==n[3]) return true;
  return false;
}

int main(){
  string n;cin >> n;
  if(good(n)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions
N, M = map(int, input().split())
X = list(map(int, input().split()))

Y=[0]*N

for i in range(N):
    Y[i]=abs(X[i]-M)

tmp=Y[0]
for i in range(N-1):
    tmp=fractions.gcd(tmp,Y[i+1])

print(tmp)


Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
int main(){
char b;
  cin>>b;
  if(b=='A')
    cout<<'T'<<endl;
  if(b=='T')
    cout<<'A'<<endl;
    if(b=='C')
    cout<<'G'<<endl;
  if(b=='G')
    cout<<'C'<<endl;
  
  
return 0;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long max = Math.max(a, b);
			long min = Math.min(a, b);
			max = Math.max(max, c);
			min = Math.min(min, c);

			System.out.println(min+" "+max);
		}
	}
}



Measured memory_bytes: 26300
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int H, W;
    scanf("%d %d", &H, &W);

    char **a = (char**)malloc(H * sizeof(char**));
    int h, w;
    for(h=0; h<H; h++) {
        a[h] = (char*)malloc(W * sizeof(char));
    }
    for(h=0; h<H; h++) {
        scanf("%s", a[h]);
    }
    
    for(w=0; w<W+2; w++) {
        printf("#");
    }
    printf("\n");
    for(h=0; h<H; h++) {
        printf("#");
        printf("%s", a[h]);
        printf("#\n");
    }
    for(w=0; w<W+2; w++) {
        printf("#");
    }
    printf("\n");

    for(h=0; h<H; h++) {
        free(a[h]);
    }
    free(a);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int int64_t
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A== C) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];
  int ans[102][102];
  int now_a_index = 0;
  REP(i,H){
    REP(j,W){
      int tmp_j;
      if(i & 1){
        tmp_j = W - 1 - j;
      }else{
        tmp_j = j;
      }
      ans[i][tmp_j] = now_a_index + 1;
      if(--a[now_a_index] == 0){
        now_a_index++;
      }
    }
  }
  REP(i,H){
    REP(j,W){
      if(j)cout << ' ';
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define SIZE 256

int main(void){
	char str[SIZE];
	int a, b;
	char op = '\0';

	while (1) {
		fgets(str, SIZE, stdin);
		sscanf(str, "%d %c %d", &a, &op, &b);
		if (op == '?') break;
		else if (op == '+') printf("%d\n", (a + b));
		else if (op == '-') printf("%d\n", (a - b));
		else if (op == '*') printf("%d\n", (a * b));
		else printf("%d\n", (a / b));
	}

	return 0;
}

Measured memory_bytes: 612
//Decision's template
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
using namespace std;

#define maxn 100000
#define INF 10000007
#define MOD 1000000007
#define mst(s,k) memset(s,k,sizeof(s))

typedef long long ll;

struct Edge{
    int from,to,dist;
    Edge(int u,int v,int d):from(u),to(v),dist(d){}
};

/*-------------------------------template End--------------------------------*/

int A,B,Q,pos1,pos2,pos3;
ll s[100007],t[100007],tmp,ans;

int main(){
	cin>>A>>B>>Q;
	s[0] = t[0] = -5e11;
	s[A+1] = t[B+1] = 5e11;
	for(int i = 1;i<=A;i++) cin>>s[i];
	for(int i = 1;i<=B;i++) cin>>t[i];
	for(int i = 1;i<=Q;i++){
		cin>>tmp;
		ans = ~(1LL<<63);
		pos1 = lower_bound(s+1,s+A+1,tmp) - s;
		pos2 = lower_bound(t+1,t+B+1,s[pos1]) - t;
		pos3 = lower_bound(t+1,t+B+1,s[pos1 - 1]) - t;
		ans = min(ans,s[pos1] - tmp + min(t[pos2] - s[pos1],s[pos1] - t[pos2 - 1]));
		ans = min(ans,tmp - s[pos1 - 1] + min(t[pos3] - s[pos1 - 1],s[pos1 - 1] - t[pos3 - 1]));
		pos1 = lower_bound(t+1,t+B+1,tmp) - t;
		pos2 = lower_bound(s+1,s+A+1,t[pos1]) - s;
		pos3 = lower_bound(s+1,s+A+1,t[pos1 - 1]) - s;
		ans = min(ans,t[pos1] - tmp + min(s[pos2] - t[pos1],t[pos1] - s[pos2 - 1]));
		ans = min(ans,tmp - t[pos1 - 1] + min(s[pos3] - t[pos1 - 1],t[pos1 - 1] - s[pos3 - 1]));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int a,b,c,d,e,k;
	
	cin >> a >> b >> c >> d >> e >> k;
	
	if(e - a > k){
	    cout << ":(" << endl;
	}else{
	    cout << "Yay!" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int a=stoi(s.substr(0,4));
    int b=stoi(s.substr(5,2));
    int c=stoi(s.substr(8,2));
    if(a<2019||(a==2019&&b<4)||(a==2019&&b==4&&c<=30)){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var X = int.Parse(Console.ReadLine());
            Console.WriteLine(X < 1200 ? "ABC" : "ARC");
        }
    }
}


Measured memory_bytes: 27316