akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int a;
    int b;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第1条件
        if(riLeft.a != riRight.a){
            return riLeft.a > riRight.a;//<:昇順(小さい順)、>:降順(大きい順)
        }
        //第2条件
        return riLeft.b > riRight.b;
    }
};
bool operator< (const XX &riLeft, const XX &riRight){
    return riLeft.a < riRight.a;
};
bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};

int f(int n,int r){
    int si=1;
    int bo=1;
    for(int i=0;i<r;i++){
        si=si*(si-i);
    }
    for(int i=0;i<r;i++){
        bo=bo*(bo-i);
    }
    return si/bo;
}


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //ここから
    
    long long N,X;
    cin >>N >> X;
    
    long long ans=0;
    
    long long shou;
    long long amari=1;
    lldiv_t l;
    
    

        ans=N;
        long long tate=N-X;
        long long yoko=X;
        while(amari!=0){
            if(tate > yoko) swap(tate,yoko);
            
            l = lldiv(yoko,tate);
            shou=l.quot;
            amari=l.rem;
            if(shou==0 && amari==0){
                break;
            }else if(amari==0){
                ans=ans+(2*(shou-1)*tate+tate);
            }else{
                ans=ans+(amari+2*(shou)*tate+amari);
            }
            yoko=amari;
            tate=tate-yoko;
        }



    cout << ans << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 256
let N = stdin.ReadLine() |> int64

let rec resolver s n =
    match n with
    | i when i = N + 1L -> s
    | i when i % 3L > 0L && i % 5L > 0L -> resolver (s + n) (n + 1L)
    | _ -> resolver s (n + 1L)

resolver 0L 0L |> stdout.WriteLine


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

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        if(x >= k)  ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 1080: Everything Starts With Your Vote
// 2018.2.4 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ		200017
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

void insert(char *s, int w, int id)
{
	long long i;
	char *p;
	HASH *tp;
	int inc = *s + (*(s + 1) << 1);
	i = 0, p = s; while (*p) i = i*37 + *p++; i %= HASHSIZ;
	tp = hash + (int)i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return;
		tp += inc; if (tp >= hashend) tp -= HASHSIZ;
	}
	tp->s = s, tp->id = id;
}

int lookup(char *s, int w)
{
	long long i;
	char *p;
	HASH *tp;
	int inc = *s + (*(s + 1) << 1);
	i = 0, p = s; while (*p) i = i*37 + *p++; i %= HASHSIZ;
	tp = hash + (int)i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		tp += inc; if (tp >= hashend) tp -= HASHSIZ;
	}
	return -1;
}

typedef struct { char *nm; int x; char fav; } T;
T tbl[100002], *fav;
char name[100002][22];
int N, M, K, L;

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (a->fav - b->fav) return a->fav - b->fav;
	if (b->x - a->x) return b->x - a->x;
	return strcmp(a->nm, b->nm);
}

int check(int m)
{
	int i, f, x, base, sum;
	char *nm;

	base = K-m;
	if (base < 0) return 0;
	if (base >= N) return 1;
	sum = 0, nm = tbl[base].nm, base = tbl[base].x;
	for (i = 0; i < m; i++) {
		x = base - fav[i].x;
		if (x < 0) continue;
		f = (strcmp(fav[i].nm, nm) <= 0);
		if (!x && f) continue;
		sum += x; if (!f) sum++;
		if (sum > L) return 0;
	}
	return sum <= L;
}

int main()
{
	int i, lo, hi, mi;
	char buf[12], *p;

	while (N = in()) {
		M = in(), K = in(), L = in();
		memset(hash, 0, sizeof(hash));

		for (i = 0; i < N; i++) {
			fgets(name[i], 22, stdin);
			tbl[i].nm = p = name[i];
			while (*p > ' ') p++; *p = 0;
			insert(name[i], p-name[i], i);
			tbl[i].x = atoi(p+1), tbl[i].fav = 0;
		}
		for (i = 0; i < M; i++) {
			fgets(p=buf, 12, stdin);
			while (*p > ' ') p++; *p = 0;
			tbl[lookup(buf, p-buf)].fav = 1;
		}
		qsort(tbl, N, sizeof(T), cmp);
		fav = tbl + N - M, N -= M;

		lo = 0;
		hi = M; if (hi > K) hi = K; hi++;
		while (hi-lo > 1) {
			mi = (lo + hi) >> 1;
			if (check(mi)) lo = mi; else hi = mi;
		}
		printf("%d\n", lo);
	}
	return 0;
}


Measured memory_bytes: 10328
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        for (int i = 0; i<S.length(); i++ )
        {

            char ch = S.charAt(i);
            if(ch !='z')
            {  ch++;
                System.out.println(ch);
            }



        }






        }







    }
















Measured memory_bytes: 35492
def calc_digits(n):
    cnt = 0
    while n > 0:
        n //= 10
        cnt += 1
    
    return cnt


N = int(input())

ans = 10**11
for i in range(1,int(N**0.5)+1):
    if N%i == 0:
        B = N//i
        
        tmp = max(calc_digits(i),calc_digits(B))
        
        ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 67024
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	LL X, A, B;
	cin >> X >> A >> B;
	string ans;
	if (B <= A)
		ans = "delicious";
	else if (B - A > X)
		ans = "dangerous";
	else
		ans = "safe";
	cout << ans << endl;


	return 0;
}

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

n, m, x = map(int,input().split())
C = [list(map(int,input().split())) for i in range(n)]
ans = float("inf")
for i in range(2**n):
    R = [0] * m
    ib = format(i, "b").zfill(n)
    v = 0
    for j in range(n):
        if ib[j] == "1":
            for k in range(m):
                R[k] += C[j][k+1]
            v += C[j][0]
    
    if min(R) >= x:
        ans = min(ans, v)

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

Measured memory_bytes: 68492
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

#define rep(i,a,b) for(unsigned (i)=(a);(i)<(b);(i)++)
#define ull unsigned long long
#define sharp '#'
#define ZERO 'a'
#define ZET 'z'
#define ALPHA_NUM 26

string correct;
vector<string> answer;
bool flag[ALPHA_NUM+1];

//void fix_step(void){
//	string tmp = test;
//	bool flag[ALPHA_NUM] = { true };
//	rep(i, 0, correct.length())
//		if (!flag[(unsigned)test[i] - ZERO]){
//			flag[(unsigned)test[i] - ZERO] = true;
//		test[i]--;
//
//	}
//		if (correct.compare(test) == 0)answer.push_back(tmp);
//
//}

void func(const char* str, unsigned pt){
	string test = string(str);
	//cout << test << endl;
	if (pt == correct.length()){
		answer.push_back(test);
		return;
	}
	if (flag[correct[pt] - ZERO]){
		string tmp = test + correct[pt];
		func(tmp.c_str(), pt + 1);
	}
	if (!flag[correct[pt] - ZERO + 1]){
		string tmp = test + (++correct[pt]);
		--correct[pt];
		flag[correct[pt] - ZERO + 1] = true;
		func(tmp.c_str(), pt + 1);
		flag[correct[pt] - ZERO + 1] = false;
	}
}

int main(void){
	flag[0] = flag[ALPHA_NUM] = true;
	while (true){
		cin >> correct;
		if (correct[0] == sharp)return(0);
		answer.clear();
		rep(i, 1, ALPHA_NUM)flag[i] = false;
		func("", 0);
		cout << answer.size() << endl;
		if (answer.size() <= 10)rep(i, 0, answer.size())cout << answer[i] << endl;
		else{
			rep(i, 0, 5)cout << answer[i] << endl;
			rep(i, answer.size() - 5, answer.size())cout << answer[i] << endl;
		}
	}
	return(0);



}

Measured memory_bytes: 2344
public class Main {


  private static void solve() {
    int n = ni();
    if (n < 1200) {
      System.out.println("ABC");
    } else if (n < 2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23380
#include <stdio.h>

int aa(int b) {
    int i, out = 0;
    for (i=1; b / i != 0 ;i*=10) {
        out = out * 10 + (b / i) % 10;
    }
    return out;
}

int main() {
    int i, a, b, out=0;
    scanf("%d%d", &a, &b);

    for (i=a; i <= b ;i++) {
        if (i == aa(i)) {
            out += 1;
        }
    }

    printf("%d\n", out);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

	
	
int main(int argc, char *argv[]) {
	
	int N; cin >> N;

	int M = 0;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int h; cin >> h;
		if (h >= M) {
			cnt++;
		}
		M = max(M, h);
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
l=[list(map(int,input().split()))for i in range(N)]
l.sort(key=lambda x: x[0])
ans=0
for i in l:
    if K==0:
        break
    K-=min(K,i[1])
    ans=i[0]
print(ans)

Measured memory_bytes: 93644
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    ll n, k;
    cin >> n >> k;
    
    vector<vector<ll>> imos(2 * k + 1, vector<ll>(2 * k + 1, 0));
    REP(i, n){
        ll x, y;
        char c;
        cin >> x >> y >> c;
        
        if(c == 'B'){
            x += k;
        }
        x %= 2 * k;
        y %= 2 * k;
        
        
        imos[x + 1][y + 1]++;
        imos[(x + k) % (2 * k) + 1][(y + k) % (2 * k) + 1]++;
    }
    
    for(int i = 1; i <= 2 * k; i++){
        for(int j = 1; j <= 2 * k; j++){
            imos[i][j] += imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1];
        }
    }

    ll ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            ll t = imos[i][j] - imos[i + k][j] - imos[i][j + k] + imos[i + k][j + k];
            ans = max({ans, t, n - t});
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 31616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def g(n,b):
    r = 0
    while n > 0:
        r += n % b
        n //= b
    return r

def f():
    n = int(input())
    s = int(input())
    if s == n:
        return n + 1
    sq = int(math.sqrt(n))
    for i in range(2,sq+1):
        if g(n, i) == s:
            return i
    if n % s == 0 and n//s > s:
        return n//s
    ns = n - s * 1.0
    for i in range(sq+1,0,-1):
        b = ns / i + 1
        if b != int(b) or b < 2:
            continue
        b = int(b)
        if g(n, b) == s:
            return b
    return -1

print(f())


Measured memory_bytes: 7836
#include<cstdio>
#include<cstring>
#include<cassert>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[111];
int i,j,k,n,m,b[211][2];
int av(int x){
	return (x>=0)?x:-x;
}
void add(int x,int y){
	b[++m][0]=x;b[m][1]=y;a[y]+=a[x];
}
int main(){
	scanf("%d",&n);m=0;
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (i=1,k=1;i<=n;i++)
	 if (av(a[k])<av(a[i])) k=i;
	if (!a[k]){
		puts("0");return 0;
	}
	if (a[k]>0){
		while (a[n]<a[k]) add(k,n);
		for (i=2;i<n;i++){
			while (a[i]+a[n]<a[i-1]) add(n,n);
			if (a[i]<a[i-1]) add(n,i);
		}
		while (a[n]<a[n-1]) add(n,n);
	}else{
		while (a[1]>a[k]) add(k,1);
		for (i=n-1;i>1;i--){
			while (a[i]+a[1]>a[i+1]) add(1,1);
			if (a[i]>a[i+1]) add(1,i);
		}
		while (a[1]>a[2]) add(1,1);
	}
	assert(m<=2*n);
	printf("%d\n",m);
	for (i=1;i<=m;i++) printf("%d %d\n",b[i][0],b[i][1]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Inf = 1e9 + 7;
const int maxn = 1e5 + 7;
queue <int> qua;
map <int, int> mp;
int n;

int main() {
	cin >> n;
	int minT = Inf;
	if(n % 10 == 0) minT = 10;
	else {
		for(int i = 1; i <= n; i++) {
			int t = i, p = n - i;
			int s1 = 0, s2 = 0;
			while(t) {
				s1 += t % 10;
				t /= 10;
			}
			while(p) {
				s2 += p % 10;
				p /= 10;
			}
			minT = min(minT, s1 + s2);
		}
	}
	cout << minT << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(void)
{
   int D;
   cin >> D;
   if(D == 25)
   {
       cout << "Christmas" << endl;
   }
   else if(D == 24)
   {
        cout << "Christmas Eve" << endl;
   }
   else if(D == 23)
   {
        cout << "Christmas Eve Eve" << endl;
   }
   else if(D == 22)
   {
        cout << "Christmas Eve Eve Eve" << endl;
   }
    
    return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
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); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << 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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,d,x;cin>>n>>d>>x;
  vector<int>a(n);
  int cnt=0;
  rep(i,n){
    cin>>a[i];
    int ans=1-a[i];
    while(1){
      ans+=a[i];
      if(ans>d)break;
      cnt++;
    }
  }
  cout<<cnt+x<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n, m;

  map<string, int> mp;

  cin >> n;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    mp[s]++;
  }

  cin >> m;
  for(int i=0; i<m; i++){
    string s; cin >> s;
    mp[s]--;
  }

  int ans=0;
  for(auto itr = mp.begin(); itr!=mp.end(); itr++){
    ans = max(ans, itr->second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
dp = [0] * N
for i in range(1, N):
    tmp = []
    for j in range(1, K+1):
        if (i-j<0): continue
        tmp.append(dp[i-j]+abs(H[i]-H[i-j]))
    dp[i] = min(tmp)
print(dp[N-1])


Measured memory_bytes: 52576
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String op;
    int a, b;
    while(true){
      a = sc.nextInt();
      op = sc.next();
      b = sc.nextInt();
      if(op.equals("+"))System.out.println(a+b);
      else if(op.equals("-"))System.out.println(a-b);
      else if(op.equals("/"))System.out.println(a/b);
      else if(op.equals("*"))System.out.println(a*b);
      else if(op.equals("?"))break;
    }
  }
}

Measured memory_bytes: 26380
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>

#include <vector>

using namespace std;


typedef long long LL;


typedef pair <int, int> pr;


const int N = 2e5 + 10;

const int INF = 2e9;


const LL mod = 1e9 + 7;


inline LL power(LL a, LL n, LL mod)
{
	LL Ans = 1;
	while (n)
	{
		if (n & 1) Ans = Ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return Ans;
}


namespace ufs
{
	int parent[N];

	void init(int n) { for (int i = 1; i <= n; i++) parent[i] = i; }

	inline int findrt(int x) { return parent[x] == x ? x : parent[x] = findrt(parent[x]); }

	void merge(int x, int y)
	{
		x = findrt(x), y = findrt(y);
		parent[x] = y;
	}
}


int col[N], w[N];
int n, X, Y;

pr minv[N];
vector <int> vec[N];
int cnt[N];


LL fac[N], ifac[N];

inline LL calc(int n, int m) { return n < m ? 0 : fac[n] * ifac[m] % mod * ifac[n-m] % mod; }


int main()
{
	cin >> n >> X >> Y;
	
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = fac[i-1] * i % mod;
	ifac[n] = power(fac[n], mod-2, mod);
	for (int i = n-1; i >= 0; i--) ifac[i] = ifac[i+1] * (i+1) % mod;
	
	int maxc = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &col[i], &w[i]);
		maxc = max(maxc, col[i]);
	}
	for (int i = 1; i <= maxc; i++) minv[i] = make_pair(INF, INF);
	
	for (int i = 1; i <= n; i++)
	{
		minv[col[i]] = min(minv[col[i]], make_pair(w[i], i));
		vec[col[i]].push_back(i);
	}
	
	ufs::init(n);
	
	for (int i = 1; i <= maxc; i++)
	{
		for (auto id : vec[i])
			if (w[id] + minv[i].first <= X)
				ufs::merge(id, minv[i].second);
	}
	
	pr mn = make_pair(INF, INF), mn2 = make_pair(INF, INF);
	for (int i = 1; i <= n; i++)
	{
		pr tmp = make_pair(w[i], i);
		mn = min(mn, tmp);
	}
	for (int i = 1; i <= n; i++)
	{
		pr tmp = make_pair(w[i], i);
		if (col[i] != col[mn.second])
			mn2 = min(mn2, tmp);
	}
	
	for (int i = 1; i <= n; i++)
		if (col[mn.second] != col[i] && mn.first + w[i] <= Y)
			ufs::merge(mn.second, i);
		else if (mn2.first != INF && col[mn2.second] != col[i] && mn2.first + w[i] <= Y)
			ufs::merge(mn2.second, i);
	
	for (int i = 1; i <= n; i++)
		if (ufs::findrt(i) == ufs::findrt(mn.second))
			cnt[col[i]]++;
	
	int all = 0;
	for (int i = 1; i <= maxc; i++)
		all += cnt[i];
	
	LL Ans = 1;
	for (int i = 1; i <= maxc; i++)
		if (cnt[i])
		{
			Ans = Ans * calc(all, cnt[i]) % mod;
			all -= cnt[i];
		}
	
	printf("%lld\n", Ans);
	
	return 0;
}

Measured memory_bytes: 17664
import sys

def reconst(pre, ino):
    if len(pre) == 0:
        return
    elif len(pre) == 1:
        print pre[0],
        return

    root = ino.index(pre[0])
    preLeft, preRight = pre[1:root + 1], pre[root + 1:]
    inLeft, inRight = ino[:root], ino[root + 1:]

    reconst(preLeft, inLeft)
    reconst(preRight, inRight)
    print pre[0],

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    pre = map(int, lines[1].split())
    ino = map(int, lines[2].split())
    reconst(pre, ino)

Measured memory_bytes: 6456
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b;

	cin>>a>>b;

	cout<<yn(a%2==1&&b%2==1)<<endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
	string s, t; cin >> s >> t;
	if (len(s) != len(t))
	{
		cout << "No";
		return;
	}
	bool ok = true;
	for (int i = 0; i < s.length(); ++i)
	{
		ok = true;
		for (int j = i; j < i + t.length(); ++j)
		{
			if (s[j - i] != t[(j) % len(t)]) ok = false;
		}
		if (ok) 
		{
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}

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

int main(void){
    ll N;
    const ll mod =1000000007;
    cin >> N;
    string S = "AGCT";
    
    ll dp[4][4][4][N];
    
    rep(i,4)rep(j,4)rep(k,4)if(!((i ==0 && j == 1 && k == 2) || (i==0 && j == 2 && k == 1) || (i==1 && j == 0 && k == 2)))dp[i][j][k][2] = 1 ;else dp[i][j][k][2]=0;
    
    for(int i = 3; i<N ;i++){
        rep(j,4)rep(k,4)rep(l,4){
            dp[j][k][l][i] =0;
            rep(m,4){
                if(!((j ==0 && k == 1 && l == 2) || (j==0 && k == 2 && l == 1) || (j==1 && k == 0 && l == 2) || (m==0 && j == 1 && l == 2) || (m==0 && k == 1 && l == 2))) dp[j][k][l][i] += dp[m][j][k][i-1]%mod;
            }
         // cout << S[j] << " " << S[k] << " " << S[l] << " " << dp[j][k][l][i] << endl;
        }
    }
    
    ll ans=0;
    rep(i,4)rep(j,4)rep(k,4)ans= (ans + dp[i][j][k][N-1])%mod;
    cout << ans << endl;
}


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

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;

    int M = 0x01 << N;

    int ans = INF;
    REP(i, M) {
        int p = i;
        int x = 1;
        REP(j, N) {
            if (p & 0x01) x *= 2;
            else x += K;
            p >>= 1;
        }
        ans = min(ans, x);
    }

    cout << ans << endl;

    return 0;
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<double, int> Pi;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int N;
  cin >> N;
  vector<P> p;
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    if (x || y) p.push_back(P(x, y)); // 0は弾く
  }
  function<double(P)> dist = [&](P a) {
    return sqrt((double)a.first * a.first + (double)a.second * a.second);
  };
  function<Pd(P)> norm = [&](P a) {
    Pd b;
    double l = dist(a);
    b.first = (double)a.first / l;
    b.second = (double)a.second / l;
    return b;
  };
  function<double(Pd, Pd)> dot = [&](Pd a, Pd b) {
    return a.first * b.first + a.second * b.second;
  };
  function<double(Pd, Pd)> cross = [&](Pd a, Pd b) {
    return a.first * b.second - a.second * b.first;
  };
  function<double(P)> deg = [&](P a) {
    return atan2((double)a.second, (double)a.first) * 180 / M_PI;
  };
  dump(p);
  // 角度を計算
  vector<Pi> d;
  rep(i, p.size()) d.push_back(Pi(deg(p[i]), i));
  sort(d.begin(), d.end());
  dump(d);
  double ans = 0.0;
  rep(l, p.size()) {
    int r = l;
    P a = { 0, 0 };
    rep(i, p.size()) {
      a.first += p[d[r].second].first;
      a.second += p[d[r].second].second;
      ans = max(ans, dist(a));
      r = (r + 1) % p.size();
    }
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
import Foundation

let input = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let N = input[0]
let K = input[1]
var pointArray = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let evaluationNum = N - K

for j in 0...evaluationNum - 1 {
    if pointArray[j] < pointArray[j + K] {
        print("Yes")
    } else if pointArray[j] >= pointArray[j + K]{
        print("No")
    }
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n/2) {
        if(s[i] != s[n-1-i]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
def can_put(nowCard, hanakoCard, taroCard, turn)
  if turn == "taro"
    if nowCard < hanakoCard.max
      turn = "hanako"
      i = hanakoCard.index{|m| nowCard < m}
      nowCard = hanakoCard[i]
      hanakoCard.delete(nowCard)
    else nowCard > hanakoCard.max
      nowCard = taroCard.shift 
    end
  else turn == "hanako"
    if nowCard < taroCard.max
      turn = "taro"
      i = taroCard.index{|m| nowCard < m}
      nowCard = taroCard[i]
      taroCard.delete(nowCard)
    else nowCard > taroCard.max
      nowCard = hanakoCard.shift  
    end
  end
  return nowCard, hanakoCard, taroCard, turn
end

loop do
  n = gets.chomp.to_i
  break if n == 0
  allCard = []
  (1..2*n).each do |i|
    allCard << i
  end
  taroCard = []
  hanakoCard = []
  n.times do |num|
    taroCard << gets.chomp.to_i
  end
  taroCard = taroCard.sort{|a,b| a<=>b}
  hanakoCard = allCard.reject{|val| taroCard.include?(val)}.sort{|a,b| a<=>b} 
  nowCard = taroCard.shift

  turn = "taro"
  loop do
    break if taroCard.length == 0 || hanakoCard.length == 0
    nowCard, hanakoCard, taroCard, turn = can_put(nowCard, hanakoCard, taroCard, turn)
  end

  puts hanakoCard.length
  puts taroCard.length
end



Measured memory_bytes: 6880
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)
	x := math.Ceil(c / b)
	y := math.Ceil(a / d)
	if x <= y {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1820
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int getmin(bitset<100001>& a) {
	for (int i = 1;; i++) {
		if (!a[i])return i;
	}
}
void dfs(int pos, int prev, vector<vector<pair<int, int>>>& T, vector<int>& col) {
	vector<bitset<100001>> e(1);
	for (int i = 0; i < T[pos].size(); i++) {
		if (col[T[pos][i].second] != INF)e[0][col[T[pos][i].second]] = true;
	}
	for (int i = 0; i < T[pos].size(); i++) {
		if (T[pos][i].first == prev)continue;
		int c;
		for (int i = 1;; i++) {
			if (!e[0][i]) {
				c = i;
				break;
			}
		}
		col[T[pos][i].second] = c;
		e[0].set(c);
		dfs(T[pos][i].first, pos, T, col);
	}
}
int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> T(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		T[a].push_back({ b,i });
		T[b].push_back({ a,i });
	}
	vector<int> col(N - 1, INF);
	dfs(0, -1, T, col);
	cout << *max_element(col.begin(), col.end()) << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << col[i] << endl;
	}
}

Measured memory_bytes: 720768
using System;
using System.Collections.Generic;
using static System.Console;

class Program
{
	static void Main(string[] args)
	{
		string[] s1 = ReadLine().Split(' ');
		string[] s2 = ReadLine().Split(' ');
		Dictionary<string, long> dic = new Dictionary<string, long>()
		{
			{s1[0],long.Parse(s2[0]) },
			{s1[1],long.Parse(s2[1]) },
		};
		string s = ReadLine();
		dic[s] -= 1;
		Write($"{ dic[s1[0]]} {dic[s1[1]]}");
		ReadKey();
	}
}

Measured memory_bytes: 13152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int pcnt(int x)
{
    return __builtin_popcount(x);
}

int f(int x)
{
    if (x == 0)
        return 0;
    return f(x % pcnt(x)) + 1;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi x(n);
    rep(i, n)
    {
        x[i] = s[i] - '0';
    }
    int pc = 0;
    rep(i, n)
    {
        pc += x[i];
    }
    vi ans(n);
    rep(bit, 2)
    {
        int npc = pc;
        if (bit == 0)
        {
            npc++;
        }
        else
        {
            npc--;
        }
        if (npc <= 0)
            continue;
        int r0 = 0;
        rep(i, n)
        {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n - 1; i >= 0; i--)
        {
            int r = r0;
            if (x[i] == bit)
            {
                if (bit == 0)
                {
                    r = (r + k) % npc;
                }
                else
                {
                    r = (r - k + npc) % npc;
                }
                ans[i] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }
    }
    rep(i, n)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5192
#include<cstdio>
#include<algorithm>
using namespace std;
int books[128];
int m,n;
bool check(int mid){
	int now = 0;//現在の添字
	int d = 0;//現在の棚
	int l = 0;//現在の棚の幅
	while(now < n && d < m){
		if(l + books[now] <= mid){
			l += books[now++];
		}
		else{
			d++;
			l = 0;
		}
	}
	if(d > m-1)return false;
	else return true;
}
int main(){
	while(scanf("%d%d",&m,&n),(m|n)){
		int sum = 0;
		int ma = -1000;
		for(int i = 0; i < n; i++){
			scanf("%d",&books[i]);
			sum += books[i];
			ma = max(ma,books[i]);
		}
		
		int l = ma,r = sum;
		int mid=0;
		for(int i = 0;i < 100; i++){
			mid = (l+r)/2;
			if( check(mid) ){
				r = mid;
			}
			else l = mid;
		}
		printf("%d\n",r);
	}
	return 0;
}
		

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int a, b, c;
        cin >> a >> b >> c;

        cout <<max(0LL, c - (a-b)) << '\n';

        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#define MAXN 105
int a[MAXN];
int N,cnt;
void swap(int x,int y) {
    int t=a[x];
    a[x]=a[y];
    a[y]=t;
}
void get_input() {
    scanf("%d",&N);
    for(int i=0;i<N;i++) {
        scanf("%d",&a[i]);
    }
}

void solve() {
    int flag=1;
    for(int j=0;flag;j++) {
        flag=0;
        for(int i=N-1;i>j;i--) {
            if(a[i]<a[i-1]) {
                swap(i,i-1);
                cnt++;
                flag=1;
            } 
        }
    }

}

void display_output() {
    printf("%d",a[0]);
    for(int i=1;i<N;i++) {
        printf(" %d",a[i]);
    }
    printf("\n%d\n",cnt);
}

int main() {
#ifdef debug
    freopen("in.txt","r",stdin);
#endif
    get_input();
    solve();
    display_output();
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> A, M;

void read() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int m;
    cin >> m;
    M.push_back(m);
  }
}

bool f(int m, size_t i = 0, int sum = 0) {
  if (i == A.size()) return sum == m;
  return f(m, i + 1, sum) || f(m, i + 1, sum + A.at(i));
}

int main() {
  read();
  for (int m : M) cout << (f(m) ? "yes"s : "no"s) << endl;
}



Measured memory_bytes: 3184
import math
# import numpy as np
import sys

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]


n = NextInt()
s = input()
if len(s) > n:
    s = s[:n] + "..."
print(s)

Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<stack>
#include<cstdlib>
 
using namespace std;
 
int main ()
{
    string word;
    stack<int> S;
    while(cin>>word){
        if(word=="+"){
            int sum=0;
            sum+=S.top();
            S.pop();
            sum+=S.top();
            S.pop();
            S.push(sum);
        }
        else if(word=="-"){
            int sub=0;
            sub-=S.top();
            S.pop();
            sub+=S.top();
            S.pop();
            S.push(sub);
 
        }
        else if (word=="*"){
            int product=1;
            product*=S.top();
            S.pop();
            product*=S.top();
            S.pop();
            S.push(product);
        }
        else{
            int num=atoi(word.c_str());
            S.push(num);
        }
    }
 
    cout<<S.top()<<endl;
    return 0;
}

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

using namespace std;

/// {{{
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

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

int main(void){
  while (true){
    int x, y;
    cin >> x >> y;

    if (x == 0 && y == 0) break;

    int cnt = 0;
    int a;
    cin >> a;
    int dp[20][20] = {0};

    REP(i, a){
      int b, c;
      cin >> b >> c;
      dp[c][b] = -1;
    }

    dp[1][1] = 1;
    FOR(i, 1, y + 1){
      FOR(j, 1, x + 1){
        if (dp[i][j] != -1){
          if (i != 1 && dp[i - 1][j] != -1) dp[i][j] += dp[i - 1][j];
          if (j != 1 && dp[i][j - 1] != -1) dp[i][j] += dp[i][j - 1];
        }
      }
    }
    cout << dp[y][x] << endl;
  }
  return (0);
}

Measured memory_bytes: 3008
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()


    // k
    var ans =Long.MAX_VALUE

    for(i in 0..100000){

        var t = c * 2 * i + Math.max(0, x - i) * a + Math.max(0, y- i) * b
        ans = Math.min(ans, t.toLong())

    }

    println(ans)

}


Measured memory_bytes: 31388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int n,x,t,ans = 0;
    cin>>n>>x>>t;
    if(n%x != 0)ans++;
    ans += n/x;
    cout<<ans * t<<endl;


}



Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>

long solve(long n) {
    long m = 1 + n;
    int cl = ceil(sqrt(n));

    long d,r;
    long double tmp;
    for (int i = 1; i <= cl; ++i) {
        // comp?
        d = n/i;
        r = n%i;
        tmp = i + d;
        if (r == 0 && m > tmp) {
            m = tmp;
        }
    }

    return m;
}


int main () {
    long n;
    scanf("%ld", &n);
    long m = solve(n);

    printf("%ld\n", m - 2);
}

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

const int MAX_N = 1e4 + 1;

string S[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0, a = 0, b = 0, ba = 0;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        for (int j = 0; j < S[i].length() - 1; j++) {
            if (S[i][j] == 'A' && S[i][j + 1] == 'B') ans++;
        }
        if (S[i][0] == 'B' && S[i][S[i].length() - 1] == 'A') ba++;
        else if (S[i][0] == 'B') b++;
        else if (S[i][S[i].length() - 1] == 'A') a++;
    }
    ans += max(0, ba - 1);
    if (ba > 0 && a > 0) ans++, a--;
    if (ba > 0 && b > 0) ans++, b--;
    ans += min(a, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  string s;
  vector<int> alph(26,0);
  cin >> s;
  for(int i = 0; i < s.size(); i++) alph[(int)(s[i] - 'a')]++;
  for(int i = 0; i < 26; i++){
    if(alph[i] == 0){
      cout << (char)( i + 'a') << endl;
      return 0;
    }

  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
bool Solve(){
	int n,m;
	cin>>n>>m;
	int ans=n*n+m*m;
	for(int i=0;i*i<ans;i++){
		for(int j=i;i*i+j*j<ans;j++){
			if(i==0&&j==0||i==0&&j==1){
				continue;
			}
			if(ans%(i*i+j*j)==0){
				return false;
			}
		}
	}
	return true;
}
int main(){
	int test;
	cin>>test;
	while(test--){
		if(Solve()){
			cout<<"P"<<endl;
		}
		else{
			cout<<"C"<<endl;
		}
	}
	return 0;
}

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

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

  vector<int> a(n), cp_a(n);

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

  sort(cp_a.begin(), cp_a.end(), greater<int>());

  int mx, mx1;
  mx = cp_a[0];
  bool flag = false;

  for(int i=0; i<cp_a.size(); ++i){
    if(cp_a[0] == cp_a[1]){
      mx1 = mx;
      break;
    }
    if(cp_a[0] > cp_a[i]){
      mx1 = cp_a[i];
      flag = true;
      break;
    }
  }
  for(int i=0; i<n; ++i){
    if(mx != a[i]) cout << mx << endl;
    if(mx == a[i]) cout << mx1 << endl;
  }

  
  return 0;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
vector<LL> a,b,suf,sor;
int sufnum=0,sornum=0;

int main(){
  cin>>n;
  LL tmp;
  REP(i,n){
    cin>>tmp;
    a.push_back(tmp);
  }
  REP(i,n){
    cin>>tmp;
    b.push_back(tmp);
  }
  REP(i,n){
    if(a[i]<b[i]){
      sufnum++;
      suf.push_back(b[i]-a[i]);
      sor.push_back(0);
    }else{
      sor.push_back(a[i]-b[i]);
      suf.push_back(0);
    }
  }

  
  sort(suf.begin(),suf.end());
  LL sum=0;
  REP(i,n){
    sum+=suf[i];
  }
  sort(sor.begin(),sor.end());
  REP(i,n){
    if(sum<=0)break;
    sum-=sor[n-1-i];
    sornum++;
  }
  if(sum>0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<sufnum+sornum<<endl;
  return 0;
}


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

ll n, ans;

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		if((i % 3 != 0 && i % 5 != 0) && i % 3 != 0 && i % 5 != 0){
			//cout << i << endl;
			ans+=i;

		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3620