akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

//解説AC(Union Find使った後がわからなかった)

class UnionFindTree {
public:
	int treeCnt; //ツリーの数
	vi rank, p; //rank => 根の高さ, p => 親
	vi num; //木の要素数
	UnionFindTree() {}
	UnionFindTree(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.assign(size, 1);
		treeCnt = 0;
		REP(i, size) {
			makeset(i);
		}
	}

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
		treeCnt++;
	}

	//同じ木に属しているか判定
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	//xとyが属している木をつなぐ
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	//木と木を繋ぐ処理をする。
	void link(int x, int y) {
		if (!same(x, y)) {
			if (rank[x] > rank[y]) {
				p[y] = x;
				num[x] += num[y];
			}
			else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
				num[y] += num[x];
			}
			treeCnt--;
		}
	}


	//xが属している木の根を探る
	int findSet(int x) {
		if (p[x] == x) return x;
		else return p[x] = findSet(p[x]);
	}

	//このUnionFindTreeにいくつの木があるか調べる
	int countTree() {
		return treeCnt;
	}

	//aが像くしている木の要素数を調べる。
	int getNum(int a) {
		return num[findSet(a)];
	}
};

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, L;
	cin >> N >> K >> L;
	UnionFindTree Road(N);
	UnionFindTree Train(N);
	REP(i, K) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		Road.unite(p, q);
	}
	REP(i, L) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		Train.unite(r, s);
	}
	vector<PP> VP(N);
	REP(i, N) {
		VP[i] = PP(P(Road.findSet(i), Train.findSet(i)),i);
	}
	so(VP);
	int ind = 0;
	vi Ans(N);
	while (ind < N) {
		int fir = ind;
		PP curp = VP[ind];
		P cur = curp.first;
		int cnt = 1;
		ind++;
		while (ind < N && VP[ind].first == cur) {
			ind++;
			cnt++;
		}
		FOR(i, fir, ind) {
			Ans[VP[i].second] = cnt;
		}
	}
	REP(i, N) {
		if (i != 0)cout << " ";
		cout << Ans[i];
	}
	cout << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 8692
def main():
    n, m = map(int, input().split(' '))
    a = list(map(int, input().split(' ')))
    b = [0,2,5,5,4,5,6,3,7,6]
    c = [[b[i], -i] for i in a]
    c.sort()
    result = [[] for _ in range(n+1)]
    dp = [-1]*(n+1)
    dp[0] = 0
    for i in range(1, n+1):
        for j in c:
            if i-j[0] >= 0:
                if dp[i-j[0]] >= 0:
                    dp[i] = dp[i-j[0]] +1
                    break
    c = [[-x[1], x[0]] for x in c]
    c.sort(reverse = True)
    result = []
    i = n
    while i > 0:
        j = 0
        while j < len(c):
            if i-c[j][1] >= 0:
                if dp[i-c[j][1]] + 1 == dp[i]:
                    result.append(c[j][0])
                    i -= c[j][1]
                    j = len(c)
                else:
                    j += 1
            else:
                j += 1
    print(''.join(map(str, result)))
if __name__ =='__main__':
    main()

Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h1, h2, m1, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int minn = h2 * 60 + m2 - h1 * 60 - m1;
    cout << (1440 + minn - k) % 1440 << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,now,i,x,m,a[500010],f[500010],g[500010];
int main(){
	scanf("%d%d",&n,&now);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	f[n+1]=1;
	for(i=n;i;i--)f[i]=(f[i+1]<=a[i]/2)?f[i+1]:f[i+1]+a[i];
	for(i=1;i<=n;i++)g[i]=f[i+1]<=now,now=min(now,abs(now-a[i]));
	scanf("%d",&m);
	for(i=1;i<=m;i++){
		scanf("%d",&x);
		if(g[x])puts("YES");
		 else puts("NO");
	}
}

Measured memory_bytes: 7808
n, y = map(int, input().split())
judge = "no value"

for i in range(n+1):
    if judge == "Found it!":
        break
    for j in range(n+1):
        z = n - i - j
        value = z * 10000 + i * 5000 + j *1000
        if value == y and z >= 0:
            print(z, i , j)
            judge = "Found it!"
            break

if judge == "no value":
    print(-1, -1, -1)


Measured memory_bytes: 9032
l1 = []
l2 = []

S = input()
T = input()

for s in S:
    l1.append(s)

for t in T:
    l2.append(t)

count = 0
count1 = 0
lenth = int(len(S))

while lenth > count1:

    if l1[count1] == l2[count1]:
        count1 += 1
    else:
        count += 1
        count1 +=1

print(count)

Measured memory_bytes: 12616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    
    int ans = 0;
    rep(i, n - 2) rep3(j, i + 1, n - 1) {
        int A = a[i], B = a[j];
        int cc = max(A - B, B - A);
        auto it = lower_bound(a.begin() + j + 1, a.end(), A + B) - a.begin();
        auto it2 = upper_bound(a.begin() + j + 1, a.end(), cc) - a.begin();
        // cout << it << " " << it2 << endl;
        ans += abs(it2 - it);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

import itertools
answer = -(10 ** 18)
for a in itertools.product([0,1], repeat = 10):
  if sum(a) == 0:
    continue
  profit = 0
  for shop in range(N):
    profit += P[shop][sum(a[i]*F[shop][i] for i in range(10))]
  if answer < profit:
    answer = profit

print(answer)
  


Measured memory_bytes: 12164
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int K = in.nextInt();

        int ans = 0;
        for (int a = 1; a <= K; a++) {
            for (int b = 1; b <= K; b++) {
                int ab = gcd(a, b);
                for (int c = 1; c <= K; c++)
                    ans += gcd(ab, c);
            }
        }
        out.println(ans);

        out.flush();
    }

    static int gcd(int a, int b) {
        return a < b ? gcd(b, a) : b > 0 ? gcd(b,a % b) : a;
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 33288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] count = new int[3];
		for(int i=0;i<n;i++) {
			int num = in.nextInt();
			if(num%4==0) count[2]++;
			else if(num%2==0) count[1]++;
			else count[0]++;
		}
		if(count[0]<=count[2]) System.out.println("Yes");
		else if(count[0]==count[2]+1 && count[1]==0) System.out.println("Yes");
		else System.out.println("No");
		in.close();
	}

}


Measured memory_bytes: 48064
// https://atcoder.jp/contests/abc153/tasks/abc153_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, N;
  cin >> H >> N;

  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
  }

  if (sum >= H) drop("Yes");
  drop("No");
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll a, b, k;
    cin >> a >> b >> k;
    ll temp = a;
    a = max(0LL, a - k);
    if(a == 0)
        b = max(0LL, b - k + temp);
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
//ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

const int N = 1e6;

int n, k, A, B;
int a[N],s[N];


int main()
{
    cin>>n>>k;
    if(n>=2*k-1) puts("YES");
    else puts("NO");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int A, B, C;


int main() {
	cin >> A >> B >> C;
	if ((A<C&&C<B)||(B<C&&C<A)) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 15000

int linerserch(int *A,int n, int key){
    int i=0;
    A[n] = key; // 配列の最後に探したい要素を入れておく
    while(A[i] != key){
        i++;
        if(i == n) return 0;
    }
    return 1;
}

int main(){
    int n,m;
    int A[MAX];
    int sum=0;
    int key;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
      }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> key;
        sum += linerserch(A,n,key);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) a.size()

using namespace std;

typedef long long ll;

int main()
{
    int n, k; cin >> n >> k;
    vector <int> a (n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - k; i++) {
        if (a[i] >= a[i + k]) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;

  int S;
  if (N % 2) {
    S = N;
  } else {
    S = N + 1;
  }

  vector<vector<bool>> edge(N + 1, vector<bool>(N + 1, false));
  int count = 0;
  for (int i = 1; i <= N - 1; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      if (i == j || (S - i) == j) continue;
      edge[i][j] = true;
      ++count;
    }
  }

  cout << count << endl;
  for (int i = 1; i <= N - 1; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      if (!edge[i][j]) continue;
      cout << i << " " << j << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	long long N; std::cin >> N;
	long long power = 1;
	for (int i = 1; i <= N; ++i) {
		power *= i;
		power %= 1000000007;
	}
	std::cout << power << std::endl;
	return 0;
}


Measured memory_bytes: 3528
# -*- coding: utf-8 -*-
from collections import Counter
from collections import deque

H,W = list(map(int, input().rstrip().split()))
S_list = [list(input().rstrip()) for i in range(H)]
#-----

def checkRoute(matrix):
    # queue = [ ( (row, column),step ) ]
    # deque = [ ( (int, int   ),int ) ]
    queue = deque([  ( (1,1),1 )  ])

    delta = [(1,0),(-1,0),(0,1),(0,-1)]
    visited = set()
    
    while queue:
        (r,c),step = queue.popleft()
        
        for d in delta:
            next_r = r + d[0]
            next_c = c + d[1]
            
            if (next_r == H) and (next_c == W):
                return step+1
            
            if (1 <= next_r <= H) and (1 <= next_c <= W) and \
               (next_r, next_c) not in visited  and \
               matrix[next_r][next_c] == ".":
            
                queue.append( ( (next_r, next_c), step+1 ) )
                visited.add( (next_r, next_c) )

    return -1

#-----
# add dummy node(Black area) around the original data
for i in range(len(S_list)):
    S_list[i] = ["#"] + S_list[i][:] + ["#"]
    
S_list = [["#"]*(W+2)] + S_list[:] + [["#"]*(W+2)]
#-----

cnt_dic = Counter( sum(S_list,[]) )
min_step = checkRoute(S_list)

if min_step != -1:
    print( cnt_dic["."] - min_step )
else:
    print(-1)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define maxn 202333
using namespace std;
char str[maxn];
int a[maxn];
int ans[maxn];

int calc(int digit) {
	if(!digit) return 0;
	else return 1 + calc(digit % __builtin_popcount(digit));
}

long long powmod(long long x, long long p, long long mod) {
	long long ret = 1;
	for(; p; p >>= 1, x = x * x % mod) if(p & 1) ret = ret * x % mod;
	return ret;
}

int main() {
	for(int i = 1; i < maxn; ++i) ans[i] = calc(i);
	int n, pop = 0;
	scanf("%d", &n);
	scanf("%s", str + 1);
	for(int i = 1; i <= n; ++i) a[i] = str[i] - '0';
	for(int i = 1; i <= n; ++i) pop += a[i];
	long long Rm1 = 0, Rp1 = 0;
	if(pop > 1) {
		for(int i = 1; i <= n; ++i) if(a[i]) Rm1 += powmod(2, n - i, pop - 1);
		Rm1 %= pop - 1;
	}
	for(int i = 1; i <= n; ++i) if(a[i]) Rp1 += powmod(2, n - i, pop + 1);
	Rp1 %= pop + 1;
	for(int i = 1; i <= n; ++i) {
		if(a[i]) {
			if(pop == 1) cout << 0 << endl;
			else cout << 1 + ans[(Rm1 + (pop - 1) - powmod(2, n - i, pop - 1)) % (pop - 1)] << endl;
		} else {
			cout << 1 + ans[(Rp1 + powmod(2, n - i, pop + 1)) % (pop + 1)] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin >> x;
	while (true){
		bool ok = true;
		for (int z=2;z<=sqrt(x);z++){
			if (x % z == 0) ok = false;
		}
		if (ok) break;
		x++;
	}
	cout << x << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		long[] s = new long[n + 1];
		s[0] = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			s[i + 1] = s[i] + a[i];
		}
		Arrays.sort(s);
		long t = s[0];
		long cnt = 1;
		long ans = 0;
		for (int i = 1; i < n + 1; i++) {
			if (t == s[i]) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				t = s[i];
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 91928
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,count=0;
    cin >>N;
    vector<char> S(N);
    for(int i=0; i<N ; i++){
        cin >> S.at(i);
    }
    for(int i=0;i<N-2;i++){
        if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C') count++; 
    }
    cout << count << endl;
}

Measured memory_bytes: 256
def func():
    N, K = map(int, input().split())
    num = [0] * K
    for i in range(1, N + 1):
        num[i % K] += 1

    res = 0
    for a in range(K):
        b = (K - a) % K
        c = (K - a) % K
        if (b + c) % K != 0:
            continue
        res += num[a] * num[b] * num[c]

    print(res)


if __name__ == '__main__':
    func()


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
using namespace atcoder;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  dsu d(N);
  REP(i, Q){
    int t, u, v; cin >> t >> u >> v;
    if(t == 0){
      d.merge(u, v);
    }else{
      if(d.same(u, v)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
}

Measured memory_bytes: 3968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    string str;

    std::cin >> str;

    int sum = 0;
    int count = 0;
    int mul = 1;
    unordered_map<int, int> um;

    for (int i = str.length() - 1; i >= 0; --i) {
        sum = (sum + mul * (str[i] - '0')) % 2019;
        um[sum]++;
        mul *= 10;
        mul %= 2019;
    }

    for (auto &it : um) {
        count += it.second * (it.second - 1) / 2;
    }

    count += um[0];

    return count;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
int main()
{
    int x;
    int f[100];
    f[0]=f[1]=1;
    scanf("%d",&x);
    for(int i=2;i<=x;i++){
      f[i]=f[i-1]+f[i-2];
    }
    printf("%d\n",f[x]);
    return 0;
}

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

#define ll long long

using namespace std;
const int OO = 0x3f3f3f3f, MOD = 1000000007;

int arr[100005];
int mem[100005] = {};
int n;

int solve(int idx = 0)
{
    if(idx == n-1) return 0;
    if(idx >= n) return OO;

    if(~mem[idx]) return mem[idx];
    return mem[idx] = min(solve(idx+1) + abs(arr[idx] - arr[idx+1]), solve(idx+2) + abs(arr[idx] - arr[idx+2]));
}

int main()
{
    //freopen ("out.txt","w",stdout);

    cin >> n;
    memset(mem, -1, sizeof mem);
    for(int i = 0;i < n; i++)
        cin >> arr[i];

    cout << solve();

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

/**/

using namespace std;
using LLI = long long int;

const int MAX_N = 25;
int n, W;
int w[MAX_N], v[MAX_N];

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

int main(void) {
	int R, G;
	cin >> R >> G;
	int a = abs(R - G);
	if (R > G) {
		cout << G - a << endl;
	}
	else if (R < G) {
		cout << G + a << endl;
	}
	else {
		cout << G << endl;
	}
}

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

int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> R(N, vector<int>(0));
	for(int i=0;i<M;i++){
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		R[A].push_back(B);
		R[B].push_back(A);
	}
	int mark[N];
	for(int i=0;i<N;i++){
		mark[i] = -1;
	}
	mark[0] = 0;
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int P = que.front();
		que.pop();
		for(int i=0;i<(int)R[P].size();i++){
			if(mark[R[P][i]] == -1){
				que.push(R[P][i]);
				mark[R[P][i]] = P;
			}
		}
	}
	cout << "Yes" << endl;
	for (int i=1;i<N;i++){
		cout << mark[i] + 1 << endl;
	}
}

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

int main(){

  long long N, N_, i, cnt=0;
  map<long long, long long> Ss;
  cin>>N;
  N_=N;
  
  for(i=2; i*i<=N_; i++){
    while(N%i==0){
      Ss[i]++;
      N/=i;
    }
  }
  if(N!=1)Ss[N]++;
  
  for(auto p : Ss){
    long long e=p.second;
    long long tmp=0, cur=1;
    while(e>=cur) e-=cur++, tmp++;
    cnt+=tmp;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

long long t=1;

int main() {
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		t=(t*i)%1000000007;
	}
	cout<<t;
	
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int A,B,C; cin >> A >> B >> C;
    if(A==B && B==C) cout << "No" << endl;
    else if(A==B || B==C || A==C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    dif = 999
    ans = ''
    for i in range(1, 10):
        tmp = str(i) * 3
        if dif > int(tmp) - n >= 0:
            dif = abs(n - int(tmp))
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define lli long long int
int main() {
    fast;
    lli n;
    cin>>n;
    vector<lli>a;
    for(lli i=0;i<n;i++){
        lli s=0;
        cin>>s;
        a.push_back(s);
    }
    lli sum=0;
    for(lli i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
            sum+=(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }
          cout<<sum;  
}


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

int main () {
  long long N;
  cin >> N;
  string s = to_string(N);
  int cnt = 0;
  for (int i = 0; i < s.length(); ++i) {
    cnt += s[i] -'0';
  }
  if (N % cnt == 0) cout << "Yes";
  else cout << "No"; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <math.h>
#define PI 3.14159265359
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	int N;
	cin >> N;
	long long res = 0;
	for (int i = 1; i <= N; i++)
	{
		if (i % 3 != 0 && i % 5 != 0) {
			res += i;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int S, W;
int main(void){
    cin >> S >> W;
    if(S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}



Measured memory_bytes: 3636
use std::io::{BufRead, Write, stdin, stdout};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let n: u64 = s.split_whitespace().next().unwrap().parse().unwrap();
    s.clear();
    let mut a: Vec<i64> = Vec::with_capacity(n as usize);
    input.read_line(&mut s).unwrap();
    for buf in s.split_whitespace() {
        a.push(buf.parse().unwrap());
    }
    let sum: i64 = a.iter().fold(0, |acc, &x| acc + x);
    let cnt: i64 = sum / ((1 + n) * n / 2) as i64;
    let mut result = (sum % ((1 + n) * n / 2) as i64) == 0;
    let first = a[0];
    for i in 1..a.len() {
        if (a[i] - i as i64 * cnt - first) % n as i64 != 0 {
            result = false;
            break;
        }
    }
    for i in a {
        if i < cnt || i > cnt * n as i64 {
            result = false;
            break;
        }
    }
    writeln!(output, "{}", if result { "YES" } else { "NO" }).unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("5
4 5 1 2 3\n",
             "YES\n");
    }
    #[test]
    fn case2() {
        test("5
6 9 12 10 8\n",
             "YES\n");
    }
    #[test]
    fn case3() {
        test("4
1 2 3 1\n",
             "NO\n");
    }
}

Measured memory_bytes: 2556
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        char c;
        for(;;){
                scanf("%c",&c);
                if(c=='\n') break;
                //if(c==' ') printf(" ");
                if(islower(c)){
                        c=toupper(c);
                        printf("%c",c);
                }else{
                        c=tolower(c);
                        printf("%c",c);
                }
        }
        printf("\n");
        return 0;
}

Measured memory_bytes: 1100
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math
import fractions
import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    a,b=map(int,input().split())
    print((a*b)//fractions.gcd(a,b))

if __name__ == "__main__":
    main()

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

using namespace std;

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

	//int c_1 = 0;
	int c_2= 0;

	//int sq = (int)sqrt(n);

	for(int i = 1; i <= n; i += 2){
		int c_1 = 0;
		for(int j = 1; j * j < i; ++j){
			if(i % j == 0) ++c_1;
			else continue;
		}
		if(c_1 == 4) ++c_2;
		else continue;
	}

	cout << c_2 << "\n";
	
	return 0;

}

Measured memory_bytes: 256
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int N,M;
int A[10];
int dp[10000+100];
typedef pair<int,int> P;
map<int,int> Mp,K;
int main() {
  cout << fixed << setprecision(15);
  cin >> N >> M;
  K[1]=2;K[2]=5;K[3]=5;
  K[4]=4;K[5]=5;K[6]=6;
  K[7]=3;K[8]=7;K[9]=6;
  REP(i,M) {
    cin >> A[i];
    Mp.emplace(P(K[A[i]],0));
    if (A[i]>Mp[K[A[i]]]) Mp[K[A[i]]]=A[i];
  }
  sort(A,A+M,greater<int>());
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  REP(i,N+5)
    REP(j,M) 
      if(dp[i]!=-1)
        assign_if_greater(dp[i+K[A[j]]], dp[i]+1);
  while(N>0) {
    REP(i,M) {
      if( (N-K[A[i]])>=0 && dp[N-K[A[i]]]==dp[N]-1) {
        cout << A[i];
        N-=K[A[i]];
        break;
      }
    }
  }
 
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define  ll  long long
#define  pii pair<int,int>
#define  pll pair<ll , ll>
#define  debug cout << "this far" << endl;
#define  For(i, n) for(int i = 0; i < (n); ++i)
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
#define  gap " "
#define  ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
const int N = 5e5 + 4;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n ; cin >> n ;
    ll d ; cin >> d ;
    int cnt = 0 ;
     while (n--) {
         ll x , y ;
         cin >> x >> y ;
         if(x * x  + y * y <= d * d ) ++cnt ;
     }
     cout <<cnt << endl ;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static class Edge {
		public int src, dst, length;

		public Edge(int src, int dst, int length) {
			this.src = src;
			this.dst = dst;
			this.length = length;
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int L = Integer.parseInt(in.nextLine());
		int nodeNum = getNodeNum(L);
		// System.out.println("nodeNum: " + nodeNum);
		List<Edge> edges = genEdges(nodeNum, L);
		System.out.println(nodeNum + " " + edges.size());
		for (Edge edge : edges) {
			System.out.println(edge.src + " " + edge.dst + " " + edge.length);
		}
		in.close();
	}

	public static int getNodeNum(int L) {
		int result = 0;
		for (int i = 1; i <= 20; ++i) {
			if (Math.pow(2.0, (double) i) > L) {
				result = i;
				break;
			}
		}
		return result;
	}

	public static List<Edge> genEdges(int nodeNum, int L) {
		List<Edge> result = new ArrayList<>();
		for (int i = 1; i + 1 <= nodeNum; ++i) {
			int length = (int) Math.pow(2.0, i - 1);
			result.add(new Edge(i, i + 1, length));
			result.add(new Edge(i, i + 1, 0));
		}
		int l = L;
		for (int i = nodeNum - 1; i >= 1; --i) {
			if (l - Math.pow(2, i - 1) >= Math.pow(2.0, nodeNum - 1)) {
				// System.out.println(i + ", ");
				result.add(new Edge(i, nodeNum, (int) (l - Math.pow(2, i - 1))));
				l -= Math.pow(2.0, i - 1);
			}
		}
		return result;
	}
}

Measured memory_bytes: 21972
(function() {
	var S = parseInt(require('fs').readFileSync('/dev/stdin').toString());
	var s = S % 60;
	var M = (S - s) / 60;
	var m = M % 60;
	var h = (M - m) / 60;
	console.log(h + ":" + m + ":" + s);
}) ();

Measured memory_bytes: 15504
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size()<=k){
		cout << s << endl;
	}else{
		for(int i=0;i<k;i++){
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;
 
struct IOsetup{
  IOsetup(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
  }
}IO;

vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int32_t main(){
 string s;
 cin >> s;
 int curr;
 for (int i = 0; i < 7; i++){
  if (s == days[i]){
    curr = i;
    break;
  }
 }
 int ans = 7 - curr;
 cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
l = r = 0
while l < n:
    s = 0
    while r < n and a[r] > 0:
        s += a[r]
        r += 1
    ans += s // 2
    l = r + 1
    r = l
print(ans)

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

int uru(int y);

int main(void){
	bool f;
	int a,b;	
	cin>>a>>b;
	while(1){
		f=true;
		for(int i=a;i<=b;i++){
			if(uru(i)){
				f=false;
				cout<<i<<endl;
			}
		}
		if(f)cout<<"NA"<<endl;
		cin>>a>>b;
		if(a==0&&b==0)break; else cout<<endl;
	}

}


int uru(int y){
	if(y%4==0){
		if(y%100==0){
			if(y%400==0)return 1;
			return 0;
		}
		return 1;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
string s;/*定义字符串*/
int len; /*定义s长度*/
int main()
{
    /*好短啊！！！mua~*/
    cin>>s;/*输入s*/
    len=s.size();/*求出s长度*/
    cout<<s[0];/*输出第一个*/
    cout<<len-2;/*输出中间长度——总长度-（第一个和第二个）*/
    cout<<s[len-1];/*输出最后一个*/ 
    return 0;/*结束*/
}

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

#define pb push_back
#define S second
#define F first
#define sz size()
#define eps 0.000001
#define oo 2000000007
#define endl '\n'
#define bg begin()
#define nd end()
#define up upper_bound
#define lw lower_bound
#define debug(x) #x << " = " << x << "; "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,MOD = 1e9 + 7;
	cin >> n >> m;
	char mat[n][m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> mat[i][j];
		}
	}
	int dp[n][m];
	memset(dp, 0, sizeof(dp));
	dp[n - 1][m - 1] = 1;
	for(int i = n - 1; i >= 0; i--){
		for(int j = m - 1; j >= 0; j--){
			if(i < n - 1 && mat[i + 1][j] == '.') dp[i][j] = (dp[i][j] + dp[i + 1][j])%MOD;
			if(j < m - 1 && mat[i][j + 1] == '.') dp[i][j] = (dp[i][j] + dp[i][j + 1])%MOD;
		}	
	}
	cout << dp[0][0] << endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  cin >> H >> N;
  int AA[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>AA[i];
    sum+=AA[i];
  }
  if(H<=sum){
    cout <<"Yes"<< endl;
  }
  else{
    cout <<"No"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

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

    int ans = k;
    for(int i = 0; i < n - 1; i++){
        ans *= k - 1;
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
    int h,w,k,ichigo=0;
    cin>>h>>w>>k;
    char cake[h][w];
    int ans[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans[i][j]=0;

    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        cin>>cake[i][j];
        if(cake[i][j]=='#')ans[i][j]=++ichigo;
    }

//left
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans[i][j]!=0){
                //cout<<i<<" "<<j<<endl;
                int tmp=j-1;
                while(tmp>=0&&ans[i][tmp]==0)ans[i][tmp--]=ans[i][j];
            }
        }
    }
    //right
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans[i][j]!=0){
                //cout<<i<<" "<<j<<endl;
                int tmp=j+1;
                while(tmp<w&&ans[i][tmp]==0)ans[i][tmp++]=ans[i][j];
            }
        }
    }


    //up
    for(int j=0;j<w;j++){
        for(int i=0;i<h;i++){
            if(ans[i][j]!=0){
                //cout<<i<<" "<<j<<endl;
                int tmp=i-1;
                while(tmp>=0&&ans[tmp][j]==0)ans[tmp--][j]=ans[i][j];
            }
        }
    }

    //down
    for(int j=0;j<w;j++){
        for(int i=0;i<h;i++){
            if(ans[i][j]!=0){
                //cout<<i<<" "<<j<<endl;
                int tmp=i+1;
                while(tmp<h&&ans[tmp][j]==0)ans[tmp++][j]=ans[i][j];
            }
        }
    }






    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cout<<ans[i][j]<<(j==w-1?"\n":" ");
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
using namespace std;


int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}
int right(int i) {
    return 2 * i + 1;
}

int main() {
    int n, A[100001];;
    cin >> n;
    
    for (int j = 1; j <= n; j++) scanf("%d", &A[j]);
    
    for (int j = 1; j <= n; j++) {
        printf("node %d: key = %d, ", j , A[j]);
        if (parent(j) >= 1) printf("parent key = %d, ", A[parent(j)]);
        if (left(j) <= n) printf("left key = %d, ", A[left(j)]);
        if (right(j) <= n) printf("right key = %d, ", A[right(j)]);
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 3212
{$R-,S-,Q-,I-,O+}
var n,i,sad,l,r,m1,m2,temp1,temp2:int64;
    a:array[1..200000] of int64;

function f(b:int64):int64;
var i,ret:int64;
begin
  ret:=0;
  for i:=1 to n do inc(ret,abs(a[i]-b));
  f:=ret;
end;

function min(x,y:int64):int64;
begin
  if x>y then min:=y else min:=x;
end;

begin
  read(n);
  for i:=1 to n do begin read(a[i]);dec(a[i],i);end;
  r:=1000000000;
  l:=-1000000;
  sad:=min(f(l),f(r));
  while l<=r do begin
    m1:=(2*l+r) div 3;
    temp1:=f(m1);
    m2:=(l+2*r) div 3;
    temp2:=f(m2);
    if temp1 < temp2 then begin
      if sad>temp1 then sad:=temp1;
      r:=m2-1;
    end else begin
      if sad>temp2 then sad:=temp2;
      l:=m1+1;
    end;
  end;
  writeln(sad);
end.

Measured memory_bytes: 1664
nums = set(range(-200, 200))

X, N = map(int, input().split())
p = set(map(int, input().split()))
dist = 10**9
ans = 10**9

for k in sorted(nums - p):
    if abs(X - k) < dist:
        ans = k
        dist = abs(X - k)
print(ans)

Measured memory_bytes: 61980