akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<vector>
#include<map>
#include<sstream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb push_back

const int N = 100;
vector<int> edge[N];
bool vis[N];

vector<string> convert(string &in){
  vector<string> ret;
  string tmp;
  rep(i,(int)in.size()){
    if (in[i] == ':'||in[i] == ','||in[i] == '.')in[i]=' ';
  }
  stringstream sin(in);
  while(sin>>tmp)ret.pb(tmp);
  return ret;
}

int getindex(string &in,map<string,int> &M){
  int index = M.size();
  if (M.count(in)==0)M[in]=index;
  return M[in];
}

void dfs(int n,int now){
  if (vis[now])return;
  vis[now]=true;
  rep(i,(int)edge[now].size())dfs(now,edge[now][i]);
}

int solve(int n,vector<string> in){
  vector<string> out[n];
  vector<int> mem[n];
  map<string,int> M,name;
  rep(i,n){
    out[i]=convert(in[i]);
  }

  rep(i,n)M[out[i][0]]=i;
  
  rep(i,n){
    REP(j,1,(int)out[i].size()){
      if (M.count(out[i][j])){
	int tmp=M[out[i][j]];
	edge[i].pb(tmp);
      }else {
	int tmp=getindex(out[i][j],name);
	mem[i].pb(tmp);
      }
    }
  }

  rep(i,n)vis[i]=false;
  dfs(n,0);

  set<int> S;
  rep(i,n){
    if (vis[i]){
      rep(j,(int)mem[i].size())S.insert(mem[i][j]);
    }
  }
  return S.size();
}

main(){
  int n;
  while(cin>>n && n){
    vector<string> in(n);
    rep(i,n)cin>>in[i],edge[i].clear();
    cout << solve(n,in) << endl;
  }
  return false;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;




int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int N;
	cin >> N;
	vi freq(N + 1);

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

	vi freqFreq(N + 1);
	V<ll> ffSum(N + 1), ffSumi(N + 1);

	for (int i = 1; i <= N; ++i) {
		++freqFreq[freq[i]];
	}

	db(freq, freqFreq);

	for (int i = 1; i <= N; ++i) {
		ffSum[i] = ffSum[i - 1] + freqFreq[i];
		ffSumi[i] = ffSumi[i - 1] + freqFreq[i] * 1LL * i;
	}

	vi f(N + 1);

	for (int x = 1; x <= N; ++x) {
		f[x] = (ffSumi[x] + x * (ffSum[N] - ffSum[x])) / x;
	}


	f[0] = N + 1;

	db(f);

	for (int K = 1; K <= N; ++K) {
		int lo = 0, hi = N;
		while (lo < hi) {
			int mid = (lo + hi + 1) / 2;
			if (f[mid] >= K)
				lo = mid;
			else
				hi = mid - 1;
		}
		cout << lo << '\n';
	}

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 9088
import copy
n = int(input())

al = ['a', 'b', 'c' , 'd', 'e', 'f', 'g', 'h', 'i', 'j']
list = []
for i in range(n):
    new = []
    if i ==0:
        new.append(al[0])
    else:
        lis = copy.deepcopy(list)
        for x in lis:
            flag = False
            for y in al[:i+1]:
                if y in x:
                    new.append(x+y)
                else:
                    if flag == False:
                        new.append(x+y)
                        flag = True
    list = new

for x in new:
    print(x)

Measured memory_bytes: 14684
#include<iostream>
#include<string>
using namespace std;
string map[1050];
int dp[1050][1050]={};
int main(){
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
            cin>>map[i];
    }
    for(int i=0;i<=h;i++){
    }
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i==1&&j==1)continue;
            if(map[i][j-1]!='#'){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=dp[i][j]%1000000007;
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<long, int> P;
 
void dj(long *dist, int s, int n, vector<P> *g) {
	bool used[100001];
	for(int i=1;i<=n;i++){
		dist[i]=9223372036854775807;
		used[i]=false;
	}
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, s));
	while(!q.empty()){
		P tmp = q.top();q.pop();
		int i = tmp.second;
		if(used[i])continue;
		used[i]=true;
		dist[i]=tmp.first;
		for(P e:g[i]){
			long d=tmp.first+e.first;
			if(dist[e.second]<=d)continue;
			q.push(P(d,e.second));
		}
	}
}
 
int main() {
	int n,m,s,t;
	vector<P> yen[100001],snuke[100001];
	cin>>n>>m>>s>>t;
	for(int i=0;i<m;i++){
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		yen[u].push_back(P(a,v));
		yen[v].push_back(P(a,u));
		snuke[u].push_back(P(b,v));
		snuke[v].push_back(P(b,u));
	}
 
	long dist1[100001];
	dj(dist1, s, n, yen);
 
	long dist2[100001];
	dj(dist2, t, n, snuke);
 
	for(int i=1;i<=n;i++)dist1[i]+=dist2[i];
	for(int i=n-1;i>=0;i--)dist1[i]=min(dist1[i],dist1[i+1]);
	for(int i=1;i<=n;i++){
		cout<<1000000000000000-dist1[i]<<endl;
	}
}


Measured memory_bytes: 18916
#include<iostream>
#include<cstdio>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define ll long long
void read(__int128 &x)
{
    x = 0;
    char ch;
    int flag = 1;
    while ((ch = getchar()))
    {
        if (ch == '-') flag = -1;
        if (ch >= '0' && ch <= '9') break;
    }
    x = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
    {
        x = x * 10 + ch - '0';
    }
    x *= flag;
}

void out(__int128 x)
{
    if (x < 0)
    {
        x = -x;
        putchar('-');
    }
    if (x >= 10) out(x / 10);
    putchar(x % 10 + '0');
}
ll quick(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

map<int, ll>vis;
int x[200005];
int y[200005];
int main()
{


    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int xx;
        scanf("%d", &xx);
        x[i] = i + xx;
        vis[i - xx]++;
    }

    ll sum = 0;

    for(int i = 1; i <= n; i++)
    {
        sum += vis[x[i]];
    }
    printf("%lld\n", sum );
}




Measured memory_bytes: 27136
H, W = map(int, input().split())
a=[]
for i in range(H):
    x = input()
    if "#" in x:
        a.append(list(x))
b=[i for i in zip(*a)]
c=[]
for i in range(W):
    if "#" in b[i]:
        c.append(b[i])
c=[i for i in zip(*c)]
for i in c:
    print(*i, sep="")

Measured memory_bytes: 4724
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N, K;
    cin >> N >> K;

    cout << CEIL(N - 1, K - 1) << "\n";
    return 0;
}



Measured memory_bytes: 256
// Only 54 RE
#include <cstdio>
#include <cstring>

#include <set>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long i64;

#define NMAX 300000
#define MOD 998244353

static int n;
static int A[NMAX * 2 + 10], l[NMAX + 10], r[NMAX + 10], c[NMAX + 10];
static vector<int> op[NMAX + 10];

inline int nxt(int i) {
    return i < n ? i + 1 : 1;
}

inline int pre(int i) {
    return i > 1 ? i - 1 : n;
}

inline int pos(int i) {
    return i < 1 ? i + n : (i > n ? i - n : i);
}

inline i64 fac(int x) {
    i64 r = 1;
    for (; x; x--) r = r * x % MOD;
    return r;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", A + i);
    memcpy(A + n + 1, A + 1, sizeof(int) * n);
    if (all_of(A + 1, A + n + 1, [](int x) { return x == A[1]; }))
        printf("%lld\n",
            all_of(A + 1, A + n + 1, [](int x) { return x == 1; }) ? fac(n) : 0);
    else {
        int d = 0, s = 1;
        i64 ans = 1, cnt = 0;
        for (int i = 1; i <= n; i++) {
            if (i == 1 && A[1] == A[n]) {
                while (A[i + 1] == A[1]) i++;
                s = i + 1;
                continue;
            }
            if (l[A[i]]) ans = 0;
            l[A[i]] = i;
            for (r[A[i]] = i; A[r[A[i]] + 1] == A[i]; r[A[i]]++) ;
            if (A[i] == 1) d = r[A[i]] - l[A[i]] + 1;
            i = r[A[i]];
        }

        for (int i = 1; i <= n; i++) {
            if (!l[i]) continue;
            int pl = l[i] - d + 1;
            if (pl < 1) {
                op[1].push_back(i);
                op[pos(r[i]) + 1].push_back(-i);
                op[pos(pl)].push_back(i);
            } else if (r[i] > n) {
                op[1].push_back(i);
                op[pos(r[i]) + 1].push_back(-i);
                op[pos(pl)].push_back(i);
            } else {
                op[pos(pl)].push_back(i);
                op[pos(r[i]) + 1].push_back(-i);
            }
        }
        set<int> q;
        for (int i = 1; i <= n; i++) {
            for (int v : op[i]) {
                if (v > 0) q.insert(v);
                else q.erase(q.find(-v));
            }
            if (!q.empty()) c[*q.rbegin()]++;
        }

        for (int i = n; i >= 1; i--) {
            if (!l[i]) {
                cnt++;
                continue;
            }
            int len = r[i] - l[i] + 1;
            if (r[i] > n) r[i] -= n;
            if (len > d) ans = 0;
            if (A[pre(l[i])] < i && A[nxt(r[i])] < i)
                ans = ans * (d - len + 1) % MOD;
            for (int j = 0; j < c[i] - 1; j++, cnt--) ans = ans * cnt % MOD;
        }
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 23680
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	t_hp, t_at, a_hp, a_at = IN()
	#s = input()
	i=0
	while t_hp > 0 and a_hp>0:
		if i % 2 == 0:
			a_hp-=t_at
		else:
			t_hp -= a_at
		i+=1
	ret = 'Yes' if t_hp > 0 else 'No'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;


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

    int ans = k;
    rep(i,n-1){
        ans *= k-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
S=input()
Q=int(input())
Rev=True
front=''
back=''
for i in range(Q):
    a=input()
    if a=='1':
        Rev=not(Rev)
    else:
        b,c,x=a.split()
        if c == '1':
            if Rev:
                front += x
            else:
                back += x
        else:
            if Rev:
                back += x
            else:
                front += x
if Rev:
    print(front[::-1] + S + back)
else:
    print(back[::-1]+S[::-1]+front)


Measured memory_bytes: 4468
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i = i + 1
            tmp = A[j]
            A[j] = A[i]
            A[i] = tmp
        else:
            continue
    A[r] = A[i+1]
    A[i+1] = x
    return i+1

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    x = partition(a, 0, n-1) 
    A = [str(a[i]) for i in range(n)]
    A[x] = '[' + A[x] + ']'
    for i in range(n):
        if i == n-1:
            print(A[i])
        else:
            print(A[i], end=' ')
main()


Measured memory_bytes: 16372
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    long n = readln.chomp.to!long;
    long s = readln.chomp.to!long;

    if (n == s) {
        (n+1).writeln;
        return;
    }
    long t = n.to!double.sqrt.to!long+2;
    foreach(b; 2..t) {
        if (check(b, n, s)) {
            b.writeln;
            return;
        }
    }
    foreach(p; iota(1, t).retro) {
        long b = (n-s)/p + 1;
        if (check(b, n, s)) {
            b.writeln;
            return;
        }
    }

    (-1).writeln;
}

bool check(long b, long n, long s) {
    long f(long b, long n) {
        return n%b + (n<b ? 0 : f(b, n/b));
    }
    return b>1 && f(b, n) == s;
}


Measured memory_bytes: 256
n=int(input())
a = list(map(int,input().split()))
q=int(input())
bc = [list(map(int, input().split())) for l in range(q)]
cnt=[0]*100001
Sum=0
for i in range(n):
  cnt[a[i]]+=1
  Sum+=a[i]
for i in range(q):
  Sum+=(bc[i][1]-bc[i][0])*cnt[bc[i][0]]                           
  cnt[bc[i][1]]+=cnt[bc[i][0]]
  cnt[bc[i][0]]=0
  print(Sum)

Measured memory_bytes: 32040
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

	

	int x, n;
	cin >> x >> n;
	int s = 0;
	for(int i = 0; i < n; i++){
		int ip;
		cin >> ip;
		s += ip;
	}
	if(s >= x){
		cout << "Yes\n";
	}
	else cout << "No\n";
	
 
return 0;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
ans = 1
r = 1
AA = A[0]
for i in range(1,N):
#  print( AA & A[i], AA ,A[i], end="")
  r+=1
  if ( AA & A[i] == 0 ):
    AA |= A[i]
  else:
    for l in range(i-r+1,i):
      r -= 1
      AA ^= A[l]
#      print( " - ", AA & A[i], AA ,A[i],A[l], end="")
      if ( AA & A[i] == 0 ):
        break
    AA |= A[i]
  ans += r
#  print( " -- ", r,ans )
print(ans)


Measured memory_bytes: 24712
#include<cstdio>

using namespace std;

typedef long long LL;
const int N = 200005;
LL a[N], ans;
int n, l, r, cnt[25];

bool add(LL x){
	LL t = x;
	for(int i = 1; i; i++){
		if(cnt[i] && (x & 1))
			return false;
		x >>= 1;
		if(!x)	break;
	}
	for(int i = 1; i; i++){
		if(t & 1)
			cnt[i]++;
		t >>= 1;
		if(!t)	break;
	}
	return true;
}

void del(LL x){
	for(int i = 1; i; i++){
		if(x & 1)
			cnt[i]--;
		x >>= 1;
		if(!x)	break;
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	r = 1;
	for(l = 1; l <= n; l++){
		if(r < l)	r = l;
		if(r <= n)
			while(add(a[r])){
				ans += r - l + 1;
				r++;
				if(r > n)	break;
			}
		del(a[l]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1664
#![allow(unused_imports)]
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;
use std::str::FromStr;
use std::cmp::Reverse;

type Error = Box<dyn std::error::Error>;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct Scanner {
    buff: Vec<String>,
    pos: usize,
}


impl Scanner {
    pub fn new() -> Self {
        Scanner {
            buff: Vec::new(),
            pos: 0,
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        while self.buff.len() <= self.pos {
            self.pos = 0;
            self.buff = read_line().split_whitespace().map(|s| s.to_owned()).collect();
        }

        let result = self.buff[self.pos].parse::<T>();
        self.pos += 1;
        result.ok().unwrap()
    }

    pub fn next_line(&mut self) -> String {
        let result  = read_line().trim().to_owned();
        self.buff.clear();
        self.pos = 0;

        result
    }

    pub fn next_vec<T: FromStr>(&mut self) -> Vec<T> {
        self.buff.clear();
        self.pos = 0;
        read_line().trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect()
    }
    
    pub fn next_line_chars(&mut self) -> Vec<char> {
        let result  = read_line().trim().chars().collect();
        self.buff.clear();
        self.pos = 0;

        result
    }
}


fn main() {
    let mut sc = Scanner::new();
    let n:usize = sc.next();
    let m:usize = sc.next();
    let mut baito = Vec::with_capacity(n);

    for _i in 0..n {
        let a: usize = sc.next();
        let b: u64 = sc.next();
        baito.push((a, b));
    }
    baito.sort_by(|a, b| a.0.cmp(&b.0));

    let mut pos = 0;
    let mut que = BinaryHeap::new();
    let mut ans = 0;
    for i in 0..m {
        while pos < n {
            if baito[pos].0 > i+1 {
                break;
            }
            que.push(baito[pos].1);
            pos += 1;
        }
        if !que.is_empty() {
            ans += que.pop().unwrap();
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4644
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int K = NM[0];
		String S = readLine()[0];
		if(S.length()<=K) {
			print(S);
		}else {
			print(S.substring(0,K)+"...");
		}
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


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

using namespace std;

template< typename Semigroup >
struct Node {
  Node *l, *r, *p;
  int idx;
  Semigroup key, sum;
  bool rev;
  int sz;

  Node() {}

  Node(int idx, const Semigroup &v) {
    init_node(idx, v);
  }

  void init_node(int idx, const Semigroup &v) {
    this->idx = idx;
    this->key = this->sum = v;
    this->l = this->r = this->p = nullptr;
    rev = false;
    sz = 1;
  }

  void push() {
    /*
    if(rev) {
      swap(l, r);
      if(l) l->rev ^= true;
      if(r) r->rev ^= true;
    }
     */
  }

  bool is_root() {
    return !p || (p->l != this && p->r != this);
  }

  void update() {
    sz = 1;
    sum = key;
    if(l) sz += l->sz, sum = l->sum + sum;
    if(r) sz += r->sz, sum = sum + r->sum;
  }

  void rotr() { // 右回転
    auto *x = p, *y = x->p;
    if((x->l = r)) r->p = x;
    r = x, x->p = this;
    x->update(), update();
    if((p = y)) {
      if(y->l == x) y->l = this;
      if(y->r == x) y->r = this;
      y->update();
    }
  }

  void rotl() { // 左回転
    auto *x = p, *y = x->p;
    if((x->r = l)) l->p = x;
    l = x, x->p = this;
    x->update(), update();
    if((p = y)) {
      if(y->l == x) y->l = this;
      if(y->r == x) y->r = this;
      y->update();
    }
  }

  void splay() {
    push();
    while(!is_root()) {
      auto *q = p;
      if(q->is_root()) {
        q->push(), push();
        if(q->l == this) rotr();
        else rotl();
      } else {
        auto *r = q->p;
        r->push(), q->push(), push();
        if(r->l == q) {
          if(q->l == this) q->rotr(), rotr();
          else rotl(), rotr();
        } else {
          if(q->r == this) q->rotl(), rotl();
          else rotr(), rotl();
        }
      }
    }
  }

  Node *expose() {
    Node *rp = nullptr;
    for(Node *cur = this; cur; cur = cur->p) {
      cur->splay();
      cur->r = rp;
      cur->update();
      rp = cur;
    }
    splay();
    return rp;
  }

  void link(Node *parent) {
    expose();
    parent->expose();
    p = parent;
    parent->r = this;
  }

  void cut() {
    expose();
    auto *parent = l;
    l = nullptr;
    parent->p = nullptr;
  }

  void evert() {
    expose();
    rev ^= true;
    push();
  }
};


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

  Node< int > uku[100000];
  for(int i = 0; i < N; i++) {
    uku[i].init_node(i, 0);
  }

  for(int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    while(K--) {
      int T;
      scanf("%d", &T);
      uku[T].link(&uku[i]);
    }
  }
  int Q;
  scanf("%d", &Q);
  while(Q--) {
    int U, V;
    scanf("%d %d", &U, &V);
    uku[U].expose();
    printf("%d\n", uku[V].expose()->idx);
  }
}


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

using namespace std;

int main(){
  int N;
  vector<int> a;
  cin >> N;
  int b;
  for(int i=0;i<N;i++){
    cin >> b;
    a.push_back(b);
  }
  sort(a.begin(),a.end());
  int c=-1;
  int count;
  int ans=0;
  for(int i=0;i<N;i++){
    count=0;
    if(c!=a[i]){
      c=a[i];
      for(int j=i;c+2>=a[j]&&j<N;j++){
        count++;
      }
      ans=max(ans,count);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int cnt(int n, vi &sosu){
  int ans = 0;
  for(int i : sosu){
    if(i >= n - 1) ans++;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  vi sosu(n + 1, 0);
  for(int i = 2; i <= n; i++){
    int num = i;
    for(int j = 2; j <= n; j++){
      while(num % j == 0){
        num /= j;
        sosu[j]++;
      }
    }
  }
  int v5 = cnt(5, sosu), v3 = cnt(3, sosu) - 1;
  int ans = cnt(75, sosu);
  ans += cnt(25, sosu) * v3;
  ans += cnt(15, sosu) * (v5 - 1); 
  ans += v5 * (v5 - 1) / 2 * (v3 - 1);
  cout << ans << endl;
}

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

using namespace std;

const int N = 101000;

int a[N], b[N];
int deg[N], fat[N];
int paint[N];

vector <int> adj[N];

void dfs(int u, int l = -1) {
	for (int x: adj[u]) {
		if(l == x)continue;
		fat[x] = u;
		dfs(x, u);
	}
}

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


	for (int i = 0; i < n-1; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		deg[a[i]]++; deg[b[i]]++;
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}

	dfs(1);
	fat[1] = 0;
	paint[0] = 1;
	queue <int> q;

	for (int i = 2; i <= n; ++i) {
		if(deg[i] <= 1) {
			q.push(i);
		}
	}
	if(n == 1) {
		q.push(1);
	}
	int ok = 1;
	while(!q.empty()) {
		int at = q.front();
		//printf("%d\n", at);
		q.pop();
		if(paint[at] == 0) {
			paint[at] = 1;
			if(paint[fat[at]] == 0) {
				paint[fat[at]] = 1;
				if(fat[fat[at]] != 0) {
					deg[fat[fat[at]]]--;
					if(deg[fat[fat[at]]] <= 1 && paint[fat[fat[at]]] != 1) {
						q.push(fat[fat[at]]);
					}
				}
			} else {
				//printf("enter\n");
				ok = 0;
				break;
			}
		} else {
			//printf("enter\n");
			ok = 0;
			break;
		}
	}
	if (ok) puts("Second");
	else puts("First");
	
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ans=0;
    double x;
    cin>>n;
    if(n%2==0)
    {
        printf("0.5000000000\n");
    }
    else
    {
        x=(n+1)/2.0/n;
        printf("%.10lf\n",x);
    }
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 109 C / Link: http://abc109.contest.atcoder.jp/tasks/abc109_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

LL ans = 0LL;

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

	LL N, X;
	cin >> N >> X;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	a.push_back(X);
	N = SZ(a);
	SORT(a);
	VL b(N - 1);
	FOR(i, 0, N - 1) {
		b[i] = a[i + 1] - a[i];
	}
	LL g = b.front();
	FOR(i, 1, N - 1) {
		g = gcd(g, b[i]);
	}
	ans = g;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int n;
LL ta,ans,k=2;

int main(){
	scanf("%d",&n);
	scanf("%d",&ta);
	ans+=ta-1;
	while(--n){
		scanf("%d",&ta);
		if(ta==k)k++;
		else if(ta%k==0)ans+=ta/k-1;
		else ans+=ta/k;
	}
	printf("%lld\n",ans);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int D;
  cin >> D;
  switch(D){
    case 22: cout << "Christmas Eve Eve Eve"; break;
    case 23: cout << "Christmas Eve Eve"; break;
    case 24: cout << "Christmas Eve"; break;
    case 25: cout << "Christmas"; break;
      
  }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c = c-b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a = a-d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include "iostream"
#include "vector"
using namespace std;
int main() {
    int N;
    cin >> N;
    int count = 0;
    vector<int> H(N, 0);
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        H[i] = h;
        bool r = true;
        for (int j = 0; j < i; j++) {
            if(H[j] > h) {
                r = false;
            }
        }
        if (r) count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[200000];
int cnt[200000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
		cnt[a[i]]++;
	}
	
	int ans = 0;
	rep(i, n) { ans += cnt[i] * (cnt[i] - 1); }
	
	rep(i, n) {
		int prev = cnt[a[i]] * (cnt[a[i]] - 1);
		int now = (cnt[a[i]] - 1) * (cnt[a[i]] - 2);
		cout << (ans + now - prev) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n;cin >> n;
    vl v(n);
    rep(i,n)cin >> v[i];
    bool e=false;
    ll sum=0;
    ll pcnt=0;
    ll mini = inf;
    rep(i,n){
        if(v[i]==0)e=true;
        if(v[i]>0)pcnt++;
        sum+=abs(v[i]);
        mini = min(abs(v[i]),mini);
    }
    if(e){
        cout << sum << endl;
        return 0;
    }
    if(pcnt%2==n%2){
        cout << sum << endl;
    }
    else{
        cout << sum-mini*2 <<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    
    long long A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]==0){
            cout << 0;
            return 0;
        }
    }
 
    long long result = 1;
    //long long limit = pow(10.0,18.0);
    
    //bool can = true;
    for(int i=0;i<N;++i) {
            if(A[i]>1000000000000000000/result){
            result = -1;
            //can = false;
            break;
            }
        result = result *A[i];
    }
 
    
    cout << result;
}

Measured memory_bytes: 4376
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main(){
    input!{
        a:usize,
    }
    let result = if a%2 != 0 {a/2 + 1} else {a/2};
    println!("{}", result);
}

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

int main(){
    string s, t = "CODEFESTIVAL2016";
    int ans = 0;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout <<ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

ll find5(ll in){
    if(in<5) return in;
    else return in+find5(in/5);
}

int main(void){
    ll N, div;
    cin>>N;
    if(N%2==1) cout<<0<<endl;
    else{
        div=N/10;
        cout<<find5(div)<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
using namespace std;
const int MO = 1000000007; 
int n, f;
LL tot;
char s1[60], s2[60];
void clean() {}
void solve() {
	clean();
	scanf("%s", s1 + 1), scanf("%s", s2 + 1);
	if (s1[1] == s2[1]) tot = 3, f = 2; else if (s1[1] == s1[2]) tot = 6, f = 3;
	while (f <= n) {
		if (s1[f] == s2[f]) {
			if (s1[f - 1] == s2[f - 1]) tot = (tot * 2) % MO;
			//else if (s1[f - 1] == s1[f - 2]) tot = tot % MO;
			f++;
		} else if (s1[f] == s1[f + 1]) {
			if (s1[f - 1] == s2[f - 1]) tot = (tot * 2) % MO;
			else if (s1[f - 1] == s1[f - 2]) tot = (tot * 3) % MO;
			f += 2;
		}
	}
	printf("%lld\n", tot);
}
int main() {
	scanf("%d", &n), solve();
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int a,b,c,k,ans(0);
    cin >> a >> b >> c >> k;
    if(k<=a)    ans += k;
    else    ans += a;

    if((a+b)<k){
        ans -= k-(a+b);
    }

    put(ans);

    return 0;
}

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


int main()
{
    vector<int> array;
    int a;
    cin >> a;

    int i = 1;

    while(true)
    {
        if(i==1){
            array.push_back(a);
            i++;
            continue;
        }
        else if(array[i-2]%2 == 0)
        {
            array.push_back(array[i-2]/2);
        }
        else
        {
            array.push_back(3*array[i-2] + 1);
        }
        
        for(int j = 0;j < i-1;j++)
        {
            if(array[j] == array[i-1])
            {
                cout << i << endl;
                return 0;
            }
        }
        i++;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long count = 0;
		boolean isEv = (k % 2 == 0);
		long nom = n / k;
		count += nom;
		count += nom * (nom - 1) * 3;
		count += nom * (nom - 1) * (nom - 2);
		if (k % 2 == 0) {
		    long ev = (n + k / 2) / k;
    		count += ev;
    		count += ev * (ev - 1) * 3;
    		count += ev * (ev - 1) * (ev - 2);
		}
        System.out.println(count);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 998244353;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

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

  rep(i, 1, 10100) {
    int x = i * 0.08, y = i * 0.1;
    if(x == a && y == b) return cout << i << endl, 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

macro_rules! ifv {
    ($cond:expr, $a:expr, $b:expr) => {
        if $cond {
            $a
        } else {
            $b
        }
    }
}

fn main() {
  input! {
    s: chars,
    t: chars
  };

  let n = s.len();
  let m = t.len();

  // debug!(s,t);
  // debug!(n,m);

  let mut dp = vec![vec![-1; m+1]; n+1];
  let mut dp_from = vec![vec![-1; m+1]; n+1];

  dp[0][0] = 0;
  for i in 0..n+1 {
    for j in 0..m+1 {
      if dp[i][j] == -1 {
        continue
      }

      let base = dp[i][j];
      if i < n && dp[i+1][j] < base {
        dp[i+1][j] = base;
        dp_from[i+1][j] = 0;
      }
      if j < m && dp[i][j+1] < base {
        dp[i][j+1] = base;
        dp_from[i][j+1] = 1;
      }
      if i < n && j < m {
        let to = ifv!(s[i] == t[j], base+1, base);
        if dp[i+1][j+1] < to {
          dp[i+1][j+1] = to;
          dp_from[i+1][j+1] = 2;
        }
      }
    }
  }

  let mut lcs = dp[n][m] as usize;
  let mut answer = vec!['~'; lcs];
  let mut ni = n;
  let mut mi = m;
  while ni > 0 || mi > 0 {
    match dp_from[ni][mi] {
      0 => { ni -= 1; },
      1 => { mi -= 1; },
      2 => {
        ni -= 1;
        mi -= 1;
        if s[ni] == t[mi] {
          lcs -= 1;
          answer[lcs] = s[ni];
        }
      },
      _ => { panic!("that cant be") }
    }
  }

  let ans: String = answer.into_iter().collect();
  println!("{}", ans);
}

Measured memory_bytes: 78076
#include <stdio.h>

int main(void)
{
        int n,l,s,i;

        scanf("%d%d",&n,&l);

        int d[n],e[n];

        for(i=0;i<n;i++){
                d[i]=l+i;
        }

        s=0;
        for(i=0;i<n;i++)
                s+=d[i];
        if(l+n-1>0){
               if(l<=0) printf("%d\n",s);
               else printf("%d\n",s-d[0]);
        }
        else printf("%d\n",s-d[n-1]);
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>


using namespace std;

int main()
{
	string str;
	cin >> str;
	
	for(int i = 0;i < 4;i++)
	{
		cout << str[i] ;
	}
	cout << ' ' ;
	for(int i = 4;i < str.size();i++)
	{
		cout << str[i];
	}
	cout << endl;
	
	return 0;
}
	

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

int Partition(int *A, int p, int r);
void PrintData(int *A, int n, int r);

int main(){

  int i;
  int n;
  int *A;
  int p,q,r;
  scanf("%d", &n);

  A = (int *)malloc(n * sizeof(int));

  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  q = Partition(A, 0, n);

  PrintData(A, n, q);
  
  return 0;
}

int Partition(int *A, int p, int r){

  int x;
  int i,j;
  int temp;
  
  x = A[r-1];
  i = p-1;

  for(j=p; j<r-1; j++){
    if(A[j] <= x){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  
  temp = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = temp;

  return i+1;
}

void PrintData(int *A, int n, int r){

  int i;

  for(i=0; i<n; i++){
    if(i == r) printf("[%d] ", A[i]);
    else if(i == n-1) printf("%d\n", A[i]);
    else printf("%d ", A[i]);
  }
}



Measured memory_bytes: 2124
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<usize>();
    let b=read::<usize>();
    let v=vec![-1,0,2,0,1,0,1,0,0,1,0,1,0];
    println!("{}",if v[a]==v[b]{"Yes"}else{"No"})
}

Measured memory_bytes: 4352