akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int isprime[55600];
int ans [60];
int primes (void)
{

        memset(isprime,1,sizeof(isprime));
        isprime[1]=0;
        for(int i=2;i<=55555;i++)
        {
                if(isprime[i])
                {
                        //cout<<i<<endl;
                        for(int j=i+i;j<=55555;j+=i)
                        {
                                isprime[j]=0;
                        }
                }
        }
}
int main ()
{
        primes();
        int N,count;
        cin>>N;
        count=1;
        for(int i=3;count<=N;i+=10)
        {
                if(isprime[i])
                {
                        ans[count++]=i;
                }
        }
        for(int i=1;i<=N;i++)
        {
                cout<<ans[i]<<" ";
        }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int n; cin >> n;
    string s, t; cin >> s >> t;

    for (size_t i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
}

signed main() {
    solve();
    return 0;
}

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

using pint = pair<ll, ll>;
int N;
vector<pint> v;

int main() {
  cin >> N;
  v.resize(N);
  for (int i = 0; i<N; i++){
    cin >> v[i].first >> v[i].second;
  }
  int P[N];
  for (int i = 1; i < N+1; i++) P[i-1] = i;
  ll total = 0;
  ll cnt = 0;
  do {
    for (int i = 0; i < N-1; i++){
      total += sqrt((v[P[i]-1].first - v[P[i + 1]-1].first) * (v[P[i]-1].first - v[P[i + 1]-1].first)+(v[P[i]-1].second - v[P[i + 1]-1].second)*(v[P[i]-1].second - v[P[i+1]-1].second));
    }
    cnt++;
  } while (next_permutation(P, P + N));
  //cout << total << ' ' << cnt <<endl;
  cout << fixed<<setprecision(6)<<total / cnt << endl;
  return 0;
}

Measured memory_bytes: 3876
# import sys
# sys.setrecursionlimit
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

N, M, X = geta(int)
b = []
for _ in range(N):
    b.append(geta(int))

inf = 10**7

ans = inf

for c in range(0, 2**N):
    tmp = c
    cost = 0
    bi = 0
    sk = [0] * M
    while tmp > 0:
        if tmp & 1 == 1:
            cost += b[bi][0]
            for i in range(M):
                sk[i] += b[bi][i + 1]

        tmp = tmp >> 1
        bi += 1

    if min(sk) >= X and ans > cost:
        ans = cost

print(ans if ans < inf else -1)


Measured memory_bytes: 73968
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.buffer.readline

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.root = [-1] * (n + 1)
            self.rnk = [0] * (n + 1)

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

        def unite(self, x, y):
            x = self.find_root(x)
            y = self.find_root(y)
            if x == y:
                return
            elif self.rnk[x] > self.rnk[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rnk[x] == self.rnk[y]:
                    self.rnk[y] += 1

        def isSameGroup(self, x, y):
            return self.find_root(x) == self.find_root(y)

        def size(self, x):
            return -self.root[self.find_root(x)]

    N, M, K = map(int, input().split())
    UF = UnionFind(N+1)
    fr_num = [0] * (N+1)
    for _ in range(M):
        a, b = map(int, input().split())
        UF.unite(a, b)
        fr_num[a] += 1
        fr_num[b] += 1

    ans = [0] * (N+1)
    for i in range(1, N+1):
        ans[i] = UF.size(i) - 1 - fr_num[i]

    for _ in range(K):
        c, d = map(int, input().split())
        if UF.isSameGroup(c, d):
            ans[c] -= 1
            ans[d] -= 1
    print(*ans[1:])


if __name__ == '__main__':
    main()


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++)
        cin >> t[i];

    vector<int> v(N - 1);
    for (int i = 0; i < N - 1; i++)
        v[i] = t[i + 1] - t[i];

    int res = 0;
    for (int i = 0; i < N - 1; i++) {
        if (v[i] <= T)
            res += v[i];
        else
            res += T;
    }
    res += T;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
using namespace std ;
int main()
{
    int l=0,r=1,temp=0;
    char s[100010];
    scanf("%s",s);
    while(s[r]!='\0')
    {
        if((s[l]=='0' && s[r]=='1') || (s[l]=='1' && s[r]=='0'))
        {
            temp+=2;
            s[l]='a';
            s[r]='a';
            while(s[l]=='a')
            {
                l++;
            }
            if(l==r){r++;}
        }
        else
        {
            r++;
        }
    }
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num[] = new int[3];
        for (int i = 0; i < 3; ++i) num[i] = sc.nextInt();
        sc.close();
        Arrays.sort(num);
        System.out.print(num[0] + num[1] + num[2] * 10);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    cout << setprecision(10);
    ll n, m, d;
    cin >> n >> m >> d;
    double a = 0;
    if (d == 0) {
        a += n;
    } else {
        a += n * 2 - d * 2;
    }
    a = a / (n * n);
    a *= (m - 1);
    cout << a << endl;
}


Measured memory_bytes: 256
#pragma GCC oplmize(2)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
const double eps = 1e-8;
ll n,k,ma=-0x3f3f3f3f,ww,cc,ans[5005],s;
struct node{
    ll nex,val;
}a[5005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(n),sc(k);
    for(int i=1;i<=n;i++) sc(a[i].nex);
    for(int i=1;i<=n;i++) sc(a[i].val);
    for(int i=1;i<=n;i++){
        cc=0;
        ww=a[i].nex;
        memset(ans,0,sizeof(ans));
        while(ww!=i && cc<k){
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
            ww=a[ww].nex;
        }
        if(cc<k) {
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
        }
        if(ans[cc]>0 && k>cc){
            s=k/cc*ans[cc];
            ma=max(ma,s);
            for(int i=1;i<=k%cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
            s=(k/cc-1)*ans[cc];
            for(int i=1;i<=cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
        }
    }
    pr(ma);
    return 0;
}


Measured memory_bytes: 3968
//
//  main.cpp
//  AtCoderAGC013-D
//
//  Created by 巻田光起 on 2017/06/01.
//  Copyright © 2017年 KMConner. All rights reserved.
//

#include <iostream>
#include <math.h>


using namespace std;

int main(int argc, const char * argv[]) {
    
    unsigned long A,B,C;
    cin>>A>>B>>C;
    

    
    int i = 0;
    unsigned long a,b,c;
    while (A%2==0&&B%2==0&&C%2==0) {
        a=(B+C)/2;
        b=(C+A)/2;
        c=(A+B)/2;
        A=a;
        B=b;
        C=c;
        i++;
        if(A==B&&B==C){
            cout<<-1<<endl;
            return 0;
        }
        //printf("%d, %d, %d\n",(int)A,(int)B,(int)C);
    }
    
    cout<<i<<endl;
    return 0;
}


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

int main() {
  int n, K;
   cin >> n >> K;
  K--;
  string S;
  cin >> S;
  if(S.at(K) == 'A'){
    S.at(K) = 'a';
  }
  else if(S.at(K) == 'B'){
    S.at(K) = 'b';
  }
  else if(S.at(K) = 'C'){
    S.at(K) = 'c';
  }
  cout << S << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			if (a.at(i) != (1 + (i / 2) * 2)) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a.at(i) != ((i + 1) / 2) * 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	long long ans = 1;
	for (int i = 0; i < (n/2); i++) {
		ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

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

int main() {
    int N;
    long L[128] = {0};
    
    cin >> N;
    L[0] = 2;
    L[1] = 1;
    
    for(int i=2; i<N+1; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
const double eps = 1e-6;

vector<string> v;
string ss;
int n;
void solve(int idx,int cnt){
	if (idx>=n){
		v.push_back(ss);
		return;
	}
	for(int i=0;i<=cnt;i++){
        ss+='a'+i;
	    solve(idx+1,cnt+(i==cnt));
        ss.pop_back();
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	

	scanf("%d",&n);
	solve(0,0);
    	sort(v.begin(),v.end());
    	for(auto &x:v)
        	printf("%s\n",x.c_str());
}		


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

string sw(string s, char x, char y){
	for(char& a : s){
		if(a == x){
			a = y;
		} else if(a == y){
			a = x;
		}
	}
	return s;
}

int count(string s, char x){
	int num = 0;
	for(char a : s){
		if(a == x) num += 1;
	}
	return num;
}

string f(string s, vector<bool>& keep){
	string t;
	for(int i = 0; i < (int)s.size(); i++){
		if(keep[i]) t += s[i];
	}
	keep.assign(s.size(), true);
	return t;
}

string solve(string s){
	vector<bool> keep(s.size(), true);
	int na = 0, nb = 0, nc = 0;
	for(char x : s){
		if(x == 'A') na += 1;
		if(x == 'B') nb += 1;
		if(x == 'C') nc += 1;
	}
	for(int i = 0; i < (int)s.size(); i++){
		if(na > nb && s[i] == 'A'){
			if(i > 0 && i < (int)s.size() - 1 && s[i-1] == s[i+1]) continue;
			na -= 1;
			keep[i] = false;
		}
	}
	s = f(s, keep);
	for(int i = 0; i + 2 < (int)s.size(); i++){
		if(na > nb && s.substr(i, 3) == "CAC"){
			keep[i] = keep[i+1] = false;
			na -= 1; nc -= 1;
		}
	}
	s = f(s, keep);
	assert(na == nb);
	char last_keep = 'X';
	for(int i = 0; i + 1 < (int)s.size(); i++){
		if(keep[i] && na > nc && (s.substr(i, 2) == "AB" || s.substr(i, 2) == "BA")){
			if(i + 1 < (int)s.size() - 1 && last_keep == s[i+2]) continue;
			keep[i] = keep[i+1] = false;
			na -= 1; nb -= 1;
		}
		if(keep[i]) last_keep = s[i];
	}
	s = f(s, keep);
	assert(na == nc && nb == nc);
	return s;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string _s;
	cin >> _s;
	string s;
	for(char r : _s){
		if(!s.empty() && s.back() == r) continue;
		s += r;
	}

	// a >= b >= c
	bool r0 = false, r1 = false, r2 = false;
	if(count(s, 'A') < count(s, 'B')){
		r0 = true; s = sw(s, 'A', 'B');
	}
	if(count(s, 'A') < count(s, 'C')){
		r1 = true; s = sw(s, 'A', 'C');
	}
	if(count(s, 'B') < count(s, 'C')){
		r2 = true; s = sw(s, 'B', 'C');
	}

	string ans = solve(s);

	if(r2) ans = sw(ans, 'B', 'C');
	if(r1) ans = sw(ans, 'A', 'C');
	if(r0) ans = sw(ans, 'A', 'B');
	cout << ans << '\n';
}

Measured memory_bytes: 7596
#include<iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n];
	int max=0;
    int t;
	for (t = 0; t < n; t++){
		cin >> a[t];
		if (max<a[t]){
			max = a[t];
		}
	}
	int ab = max;
	int ans;
	for (t = 0; t < n; t++){
		if (ab>abs(a[t] - (max / 2))){
			ab = abs(a[t] - (max / 2));
			ans = a[t];
		}
        if(ans == max){
          ans = 0;
        }
	}
	cout << max << " " <<ans << endl;

	return 0;
}


Measured memory_bytes: 640
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
	double EPS = 1.0e-08;
	int [][] a;
	int ymin, ymax, n;
	
	class L implements Comparable<L>{
		int left, right;

		public L(int left, int right) {
			this.left = left;
			this.right = right;
		}

		public int compareTo(L o) {
			if(this.left < o.left) return -1;
			if(this.left > o.left) return 1;
			if(this.right < o.right) return -1;
			if(this.right > o.right) return 1;
			return 0;
		}
		
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0)break;
			Point2D [] data = new Point2D[n];
			ymin = 1 << 24;
			ymax = 0;
			a = new int[n][2];
			for(int i =0; i < n; i++){
				int x = sc.nextInt(), y = sc.nextInt();
				data[i] = new Point2D.Double(x, y);
				ymin = Math.min(ymin, y);
				ymax = Math.max(ymax, y);
				a[i][0] = x;
				a[i][1] = y;
			}
			
			int area = 0;
			for(int y = ymin; y < ymax; y++){
				
				ArrayList<L> list = new ArrayList<L>();
				for(int i = 0 ;i < n; i++){
					int nextind = (i + 1) % n;
					if((a[i][1] <= y && a[nextind][1] <= y) || (a[i][1] >= y+1 && a[nextind][1] >= y+1)){
						continue;
					}
					int [] resa = computeX(i, y);
					int [] resb = computeX(i, y+1);
					list.add(new L(Math.min(resa[0], resb[0]), Math.max(resa[1], resb[1])));
				}
				
				Collections.sort(list);
				int k = list.size();
				int prev = -2000;
				for(int i = 0 ; i < k; i+= 2){
					area += list.get(i+1).right - Math.max(list.get(i).left, prev);
					prev = list.get(i+1).right;
				}
			}
			System.out.println(area);
			
		}
	}

	private int[] computeX(int i, int y) {
		int [] res = new int[2];
		int den, num, w;
		int nextind = (i + 1) % n;
		den = a[nextind][1] - a[i][1];
		num = (y - a[i][1]) * (a[nextind][0] - a[i][0]);
		w = a[i][0] + num / den;
		if(num % den == 0){
			res[0] = w;
			res[1] = w;
		}
		else if((num % den) * den < 0){
			res[0] = w-1;
			res[1] = w;
		}
		else{
			res[0] = w;
			res[1] = w + 1;
		}
		return res;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

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

int main(){
  int N;
  cin>>N;
  map<char,int> m;
  for(int i=0;i<N;i++){
    char s;
    cin>>s;
    m[s]=1;
  }
  int sum=0;
  for(auto x : m){
    sum+=x.second;
  }
  if(sum==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}


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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 1e5 + 1;
const ll NN = 1e18;
int n;
ll a[N];
ll pro = 1;
int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#else
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif
    cin >> n;
    rep(i, 1, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }
    rep(i, 1, n)
    {
        ll mx = NN / pro;
        DB(mx);
        if (a[i] > mx)
        {
            cout << -1;
            return 0;
        }
        pro = pro * a[i];
    }
    cout << pro;
    return 0;
}


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

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

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }


bool isPrime(int num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num == 3) return true;
    else if(num % 2 == 0) return false;
    else if(num % 3 == 0) return false;
    
    double sqrtnum = sqrt(num);
    
    for (int i = 3; i <= sqrtnum; i += 2) {
        if(num % i == 0){
            return false;
        }
    }
    
    return true;
    
}


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    for (int i = n; i <= 100003; i++) {
        if(isPrime(i)) {
            cout << i << endl;
            break;
        }
    }
    
    
    
}



signed main() {
    solve();
    return 0;
}



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

int main(){
	
	while(1){
		string x;
		int sum = 0;

		getline(cin, x);
		if(x == "0") break;

		for(int i=0;i<x.length();i++){
			sum += x[i] - 48;
		}

		cout<<sum<<endl;
	}

	return 0;
}

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

#define ll long long
#define ar array

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

	int n;
	cin >> n;
	vector<int> cnt(4, 0);
	while(n--) {
		string s;
		cin >> s;
		if (s=="AC") ++cnt[0];
		if (s=="WA") ++cnt[1];
		if (s=="TLE") ++cnt[2];
		if (s=="RE") ++cnt[3];
	}
	cout << "AC x " << cnt[0] << '\n';
	cout << "WA x " << cnt[1] << '\n';
	cout << "TLE x " << cnt[2] << '\n';
	cout << "RE x " << cnt[3];
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    if(a+b==c || a==b+c || a+c==b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
/*
Author:Fuad Ashraful Mehmet
University of Asia Pacific
AtCoder Beginner Contest 155
Date:16 Feb 2020
*/
#include<bits/stdc++.h>
using namespace std;


int n,m,q,len;
const int N=1e6+5;


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b&&b!=c)
    {
        cout<<"Yes"<<endl;
    }
    else if(b==c&&c!=a)
    {
        cout<<"Yes"<<endl;
    }
    else if(c==a&&a!=b)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int head[N],nxt[N],to[N],w[N],n,G,d=1<<30;
LL ans;
inline int dfs(int k,int fa) {
	int s=1,t,mx=0;
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa) {
			s+=t=dfs(to[i],k);
			mx=max(mx,t);
			ans+=2LL*w[i]*min(t,n-t);
			if (t*2==n) d=w[i];
		}
	mx=max(mx,n-s);
	if (mx*2<n)
		for (int i=head[k];i;i=nxt[i])
			d=min(d,w[i]);
	return s;
}
int main()
{
	int i,a,b,tot=0;n=gi();
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
		w[tot-1]=w[tot]=gi();
	}
	dfs(1,0);
	printf("%lld\n",ans-d);
	return 0;
}


Measured memory_bytes: 5888
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}



use std::cmp;
use std::iter::Iterator;

fn main() {
    input! {
        x:usize,
        a:usize,
    }


    if x < a {
        println!("0");
    }else{
        println!("{}", 10);
    }

}



Measured memory_bytes: 4352
import numpy as np

def ii():
    return int(input())


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


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def next_pair(lst):
    n = len(lst)
    for i in range(n-1):
        yield lst[i], lst[i+1]


class UnionFind(object):

    def __init__(self, n):
        # 親のnodeを表す
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            # 経路圧縮
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        self.par[x] = y


class UnionFindRank(UnionFind):

    def __init__(self, n):
        UnionFind.__init__(self, n)

        self.rank = [0 for _ in range(n)]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.rank[x] += 1
        else:
            self.par[y] = x
            self.rank[y] += 1


class UnionFindRankCount(UnionFind):

    def __init__(self, n):
        UnionFind.__init__(self, n)

        self.rank = [0 for _ in range(n)]
        self.count = [1 for _ in range(n)]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def kruskal(n, edges):
    """
    :param n: int node数
    :param edges: list(tuple(int)) edge
        ex.) edges = [(0, 1, 10), (1, 0, 50), (2, 0, 30)]  (from, to, weight)
    :return: 最小全域木に含まれるエッジ（edgesの部分集合）
    """
    edges = sorted(edges, key=lambda x: x[2])
    u = UnionFindRankCount(n)

    k = []
    cnt = 0
    for e in edges:
        i, j, w = e
        if not u.same(i, j):
            u.union(i, j)
            k.append(e)
            cnt += 1

        if cnt == n-1: break

    return k



def main():
    N = ii()
    coord = []
    for n in range(N):
        x, y = lii()
        coord.append((x, y, n))

    c_sortx = sorted(coord, key=lambda x: x[0])
    c_sorty = sorted(coord, key=lambda x: x[1])

    edges = []
    for p1, p2 in next_pair(c_sortx):
        w = min(abs(p1[0] - p2[0]), abs(p1[1] - p2[1]))
        edges.append([p1[2], p2[2], w])

    for p1, p2 in next_pair(c_sorty):
        w = min(abs(p1[0] - p2[0]), abs(p1[1] - p2[1]))
        edges.append([p1[2], p2[2], w])

    min_tree = kruskal(N, edges)
    return sum(map(lambda x: x[2], min_tree))


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

Measured memory_bytes: 74512
#include<stdio.h>
#include<algorithm>
using namespace std;
const long long mod=1e9+7;
long long a[200010];
long long a1[200010];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    sort(a,a+n);
    long long ans=1;
    if(a[0]>=0)for(int i=1;i<=k;i++)ans=(ans*a[n-i])%mod;
    else if(a[n-1]<=0&&(k%2)==0)for(int i=0;i<k;i+=2)ans=a[i]*a[i+1]%mod*ans%mod;
    else if(a[n-1]<=0&&(k%2)==1)
    {
    	ans=(a[n-1]+mod)%mod;
    	for(int i=1;i<k;i+=2)ans=a[n-1-i]*a[n-2-i]%mod*ans%mod;
	}
	else if(n==k)for(int i=0;i<n;i++)
	{
		if(a[i]<0)a[i]+=mod;
		ans=ans*a[i]%mod;
	}
    else
    {
    	int n0=0,n1=0,n2=0;
    	for(int i=0;i<n;i++)
    	{
    		if(a[i]<0)n2++;
    		else if(a[i]==0)n0++;
    		else if(a[i]>0)n1++;
		}
		if(n1+n2<k)ans=0;
		else if((n2%2)==1&&n1+n2==k&&n0)ans=0;
		else
		{
			for(int i=0;i<n1;i++)a1[i]=a[n-i-1];
			int na1=0,na2=0;
			if(k<=n1)na1=k;
			else
			{
				na1=n1;
				if(((k-n1)%2)==1)na1--;
				na2=k-na1;
			}
			while(na1>1&&na2+1<n2&&(a1[na1-1]*a1[na1-2])<((a[na2])*(a[na2+1])))na1-=2,na2+=2;
			for(int i=0;i<na1;i++)ans=ans*a1[i]%mod;
			for(int i=0;i<na2;i++)ans=ans*(a[i]+mod)%mod;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4836
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = LONG_LONG_MAX;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll N;
  ll kmax = 61;
  cin >> N;
  vvll kbuf(N, vll(kmax));
  vll ocnt(kmax, 0);

  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    for (ll j = kmax - 1; j >= 0; j--) {
      ll tmp = (x >> j) & 1;
      kbuf[i][j] = tmp;
      ocnt[j] += tmp;
    }
  }

  ll ans = 0;
  for (ll j = 0; j < kmax; j++) {
    ll addv = mul(ocnt[j], N-ocnt[j]);
    ll pc = pow(2LL, j);
    addv = mul(addv, pc);
    ans = add(ans, addv);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int l = s.size();
  string ans = "AC";
  if(s[0] != 'A')
    ans = "WA";

  int cnt = 0;
  for(int i = 1; i < l; i++){
    if(isupper(s[i])){
      if(i == 1 || i == l -1 || s[i] != 'C'){
        ans = "WA";
      }
      cnt++;
    }
  }

  if(cnt != 1)
    ans = "WA";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,m,temp,x=0;
    char a[101];
    int b[100]= {0};
    cin>>n;
    if((n>=1)&&(n<=100))
        for(int i=0; i<n; i++)
            {
                cin>>a[i];
                if(a[i]=='I')
                    {
                        ++x;
                        b[i]=x;
                    }
                else if(a[i]=='D')
                    {
                        --x;
                        b[i]=x;
                    }
                else
                    m=x;
            }

    for(int c=0; c<n-1; c++)
        {
            if(b[c]>b[c+1]){
                temp=b[c];
            b[c]=b[c+1];
            b[c+1]=temp;}
        }

if(b[n-1] >0)
    cout<<b[n-1];
    else
        cout<<"0";
        return 0;
    }

Measured memory_bytes: 256
#include<iostream>

using namespace std;
static const int N=100;
int main(){
    int n,u,k,v;
    
    int M[N][N];
    cin>>n;

    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            M[i][j]=0;
        }
    }

    for (int i=0 ;i<n;i++){
        cin>>u>>k;u--;
        for (int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }

    for (int i=0; i<n;i++){
        for (int j=0;j<n;j++){
            if(j) cout<<" ";
            cout<<M[i][j];

        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3096
# n = 42

# while n < 130_000_000
#   n *= 2
# end

# puts n

n, m = gets.split.map(&:to_i)
ary = []
m.times {ary << gets.split(" ").map(&:to_i)}
ary_flag = Array.new(n).map{Array.new(2,1)}

ary_flag[0][0] = n+1

ary.each {|x|
  if ary_flag[x[0]-1][0] == n+1
    ary_flag[x[1]-1][0] = n+1
  end
  ary_flag[x[0]-1][1] -= 1
  ary_flag[x[1]-1][1] += 1
  if ary_flag[x[0]-1][1] == 0
    ary_flag[x[0]-1][0] = 1
  end
}

cnt = 0
ary_flag.each {|x|
  if x[0] == n+1 && x[1] > 0
    cnt += 1
  end
}

puts cnt


Measured memory_bytes: 12796
def bit_DP(N,Adj):
    dp=[[0]*N for i in range(1<<N)]
    dp[1][0]=1
    for S in range(1<<N):
        for v in range(N):
            if (S&(1<<v))==0:
                continue
            sub=S^(1<<v)
            
            for u in range(N):
                if (sub&(1<<u)) and (Adj[u][v]):
                    dp[S][v]+=dp[sub][u]
    ans=sum(dp[(1<<N)-1][u] for u in range(1,N))
    return ans
def main():
    N,M=map(int,input().split())
    Adj=[[0]*N for i in range(N)]
    for _ in range(M):
        a,b=map(int,input().split())
        Adj[a-1][b-1]=1
        Adj[b-1][a-1]=1
    ans=bit_DP(N,Adj)
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int abs(int n) {
    if (n >= 0) return n;
    return -n;
}

int mid_dis(int a1, int a2, int K) {
    int dis1 = abs(a1 - a2);
    int dis2 = K - dis1;
    return (dis1 < dis2) ? dis1 : dis2;
}

int main() {
    int K, N, i, j;
    cin >> K >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    int tmp_max = -1;

    for (i = 0; i < N; i++) {
        if (i == N - 1) {
            int tmp = A[0] + (K - A[N - 1]);
            if (tmp > tmp_max) {
                tmp_max = tmp;
            }
            break;
        }
        int tmp = A[i + 1] - A[i];
        if (tmp > tmp_max) {
            tmp_max = tmp;
        }
    }

    cout << K - tmp_max << endl;

    return 0;
}

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

int N, M;
int a[10];

pair<vector<int>,int> run() {
  vector<int> v(N), h(N, 0);
  for(int i = 0; i < N; ++i) v[i] = i;
  for(int i = 0; i < M; ++i) {
    swap(v[a[i]], v[a[i]+1]);
    int nh = max(h[a[i]], h[a[i]+1]) + 1;
    h[a[i]] = h[a[i]+1] = nh;
  }
  return make_pair(v, *max_element(h.begin(), h.end()));
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    cin >> a[i];
    --a[i];
  }
  pair<vector<int>,int> ans = run();
  sort(a, a+M);
  do {
    pair<vector<int>, int> p = run();
    if(p.first == ans.first) {
      ans.second = min(ans.second, p.second);
    }
  } while(next_permutation(a, a+M));
  cout << ans.second << endl;
  return 0;
}

Measured memory_bytes: 1224
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):    
      dp[i+1][j]=dp[i][j]*2%MOD
      if ls[i]<=j:
        dp[i+1][j]=(dp[i+1][j]+dp[i][j-ls[i]])%MOD
print(dp[N][S])

Measured memory_bytes: 148620
import java.util.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws java.io.IOException {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int p[] = new int[n];
            for (int i = 0; i < n; i++)
                p[i] = sc.nextInt();
            StringBuilder sb = new StringBuilder();
            int start = p[0];
            int end = start;
            for (int i = 0; i < n; i++) {
                if (i == n - 1) {
                    sb.append(start);
                    if (end != start) {
                        sb.append("-" + end);
                    }
                } else if (p[i + 1] - p[i] == 1) {
                    end++;
                } else {
                    sb.append(start);
                    if (end != start) {
                        sb.append("-" + end);
                    }
                    sb.append(" ");
                    start = p[i + 1];
                    end = start;
                }
            }
            System.out.println(sb.toString());
        }

    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vector<P> G[200005];
int main() {
  int n,m;
  cin >> n >> m;
  vi x(m),y(m),z(m),check(n,0);
  rep(i,m){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--;y[i]--;

    G[x[i]].emplace_back(y[i],z[i]);
    G[y[i]].emplace_back(x[i],z[i]);
  }
  queue<int> q;
  int ans = 0;
  rep(i,n){
    if(!check[i]){
      q.push(i);
      int size = 0, zz = 0;
      while(!q.empty()){
        int u = q.front();
        q.pop();
        check[u] = 1;
        size++;
        for(auto v:G[u]){
          if(check[v.first])continue;
          q.push(v.first);
          zz+=v.second;
        }
      }
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 13544
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    db ans = a[0] / db(pow(2ll, n - 1));
    for (int i = 1; i < n; ++i) {
        ans += a[i] / db(pow(2ll, n - i));
    }
    cout << ans << "\n";
}


Measured memory_bytes: 512
open System
open System.Collections.Generic


let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N=R int
    let T=RS int
    let M=R int
    let sum=Array.sum T
    for i in [0..M-1] do
        let px=RS int
        printfn "%d" (sum-T.[px.[0]-1]+px.[1])
    0


Measured memory_bytes: 14044
#include <stdio.h>
int main()
{
  int m,f,r,sum=0;
  while(1)
    {
      scanf("%d%d%d",&m,&f,&r);
      if(m==-1 && f==-1 && r==-1)break;
      sum=m+f;
      if(m==-1 || f==-1)printf("F\n");
      else if(sum>=80)printf("A\n");
      else if(sum>=65)printf("B\n");
      else if(sum>=50)printf("C\n");
      else if(sum>=30)
	{
	  if(r>=50)printf("C\n");
	  else printf("D\n");
	}
      else printf("F\n");
    }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <algorithm>
// #include <vector>
// #include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int lA[N+10];
    for (int i=0; i<N; i++) cin >> lA[i];
    sort(lA, lA + N, greater<int>());
    int sum = 0;
    for (int i=0; i<K; i++) sum+=lA[i];
    cout << sum << endl;

}

Measured memory_bytes: 256
def modpow(a,b,mod):
    ans=1
    a=a%mod
    while b>0:
        if b%2==1:
            ans=(ans*a)%mod
        a=(a**2)%mod
        b=b//2
    return ans

N,A,B=map(int,input().split())

ans=modpow(2,N,10**9+7)-1
c=1
d=1
for i in range(A):
  c=(c*(N-i))%(10**9+7)
for i in range(A):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
c=1
d=1
for i in range(B):
  c=(c*(N-i))%(10**9+7)
for i in range(B):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
while ans<0:
  ans+=10**9+7
print(ans)

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

int main() {
int A,B,C,K;
  int D;
  cin >> A >> B >> C >> K;
  if(A + B >= K){
    if(A >= K){
     cout << K << endl;
    }
    else
  	cout << A << endl;
  }
  else {
  	D = K-A-B;
    cout << A - D << endl;
  }
  
}

Measured memory_bytes: 3624
"""
マージソートを実装する
"""
count = 0

def merge(A, left, mid, right):
    global count

    n1 = mid-left
    n2 = right-mid

    L = [0]*(n1+1)
    for i in range(n1):
        L[i] = A[left+i]
    
    R = [0]*(n2+1)
    for i in range(n2):
        R[i] = A[mid+i]
    
    L[n1] = 10000000000
    R[n2] = 10000000000

    i, j = 0, 0 
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        else:
            A[k] = R[j]
            j = j+1
    return count
    
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        #sortする
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        #統合する
        merge(A, left, mid ,right)


n = int(input())
s = list(map(int, input().split()))
mergeSort(s, 0, n)
s = map(str, s)
print(' '.join(s))
print(count)
    


Measured memory_bytes: 61836
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
   
    int N;
    cin>>N;
    long long A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int T;
    T=0;
    while(1){
        T=T+1;
        for(int i=0;i<N;i++){
            if(A[i]%2==0){
                A[i]=A[i]/2;
            
            }else{
                cout<<T-1<<endl;
                return 0;
                
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256