akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 12345;
const ll mod = 1e9 + 7;
ll f[N + 5];

ll power(ll a , ll b) {
    if(b == 0) return 1LL;
    ll d = power(a , b / 2);
    d *= d;
    d %= mod;

    if(b % 2 != 0) d *= a;

    d %= mod;

    return d;
}

ll inverse_mod(ll a) {
    return power(a , mod - 2);
}

ll ncr(ll no , ll r) {
    if(r == 0) return 1LL;
    if(r > no) return 0LL;
    if(r == no) return 1LL;
    ll ans = f[no];
    ans *= inverse_mod(f[r]);
    ans %= mod;
    ans *= inverse_mod(f[no - r]);
    ans %= mod;
    return ans;
}

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

    ll n ,k;

    cin >> n >> k;

    f[0] = 1;
    f[1] = 1;

    rep(i , 2 , N) {
        f[i] = i * f[i - 1];
        f[i] %= mod;
    }

    vector < ll > ans;

    rep(i , 1 , k) {
        ans.push_back((ncr(n - k + 1 , i)) * ncr(k - 1 , i - 1) % mod);
    }

    for(auto j : ans) cout << j << endl;

    return 0;
}


Measured memory_bytes: 384
const MOD: usize = 998244353;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let sum = a.iter().sum::<usize>();

    let mut dp = vec![0; sum + 1];
    dp[0] = 1;
    for &a in a.iter() {
        let mut next = vec![0; sum + 1];
        for r in 0..(sum + 1) {
            if dp[r] > 0 {
                next[a + r] += dp[r];
                next[a + r] %= MOD;
                next[r] += dp[r] * 2;
                next[r] %= MOD;
            }
        }
        dp = next;
    }

    let all = mod_pow(3, n);

    let mut ans = 0;
    for (r, count) in dp.into_iter().enumerate() {
        if r * 2 >= sum {
            ans += count;
            ans %= MOD;
        }
    }
    if sum % 2 == 0 {
        let mut dp = vec![0; sum + 1];
        dp[0] = 1;
        for &a in a.iter() {
            let mut next = vec![0; sum + 1];
            for r in 0..(sum + 1) {
                if dp[r] > 0 {
                    next[a + r] += dp[r];
                    next[a + r] %= MOD;
                    next[r] += dp[r];
                    next[r] %= MOD;
                }
            }
            dp = next;
        }
        let half = dp[sum / 2];

        println!("{}", (all + 3 * half + MOD - (3 * ans) % MOD) % MOD);
    } else {
        println!("{} ", (all + MOD - (3 * ans) % MOD) % MOD);
    }
}
// 1 1 1 2
// r r g b
// r r b g
// r g r b
// r b r g
// r g g b
// r b b g

fn mod_pow(x: usize, mut e: usize) -> usize {
    let mut result = 1;
    let mut cur = x;
    while e > 0 {
        if e & 1 == 1 {
            result = (result * cur) % MOD;
        }
        cur = (cur * cur) % MOD;
        e >>= 1;
    }
    result
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x,y,z;cin>>x>>y>>z;
  int ans=(x-z)/(y+z);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
 
input = gets.chomp.split(" ").map(&:to_i)
 
summation = 0
 
input.each do |e|
  summation += e
end
 
border = summation / 2
 
summation2 = 0
number = 0
input.each do |e|
  break if summation2 > border 
  summation2 += e
  number = e
end
 
if summation2 - border > border - (summation2 - number)
	money =  summation - 2 * (summation2 - number)
else
	money = 2 * summation2 - summation
end
 
puts money

Measured memory_bytes: 18308
#include <bits/stdc++.h>
using namespace std;
int digitcnt(long long a){
    int cnt=0;
    while(a>0){
        a/=10;
        cnt++;
    }
    return cnt;
}
int main(){
    long long n, i, b, ans=10000000;
    cin >> n;
    for(i=1;i<=sqrt(n);i++){
        long long f, digcnta, digcntb;
        if(n%i==0){
            b=n/i;
            digcnta=digitcnt(i);
            digcntb=digitcnt(b);
            f=max(digcnta, digcntb);
            ans=min(ans, f);
        }
    }
    cout << ans <<endl;
    return 0;
}

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

struct node{
  int right;
  int left;
  int parent;
  int id;
};

#define MAX 251
#define N -1900000000

struct node T[MAX];

int n;

void insert(){
  int i;
  for(i = 2; i <= n; i++){
    if(T[i/2].left == N)T[i/2].left = T[i].id;
    else if(T[i/2].right == N)T[i/2].right = T[i].id;
    T[i].parent = T[i/2].id;
  }
}

void print(){
  int i;
  for( i = 1; i <= n; i++ ){
    printf("node %d: key = %d, ", i, T[i].id);
    if(T[i].parent != N) printf("parent key = %d, ", T[i].parent);
    if(T[i].left != N) printf("left key = %d, ", T[i].left);
    if(T[i].right != N) printf("right key = %d, ", T[i].right);
    printf("\n");
  }
}

int main(){
  int i;

  scanf("%d", &n);
  for( i = 1; i <= n; i++ ) T[i].right = T[i].left = T[i].parent =  N;
  for( i = 1; i <= n; i++ ) scanf("%d", &T[i].id);
  insert();
  print();
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char words[10][5]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
char in[10];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	double ret=0;
	for(int i=1;i<=a;i++){
		double tmp=1.0/a;
		int now=i;
		while(now<b){
			now*=2;
			tmp/=2;
		}
		ret+=tmp;
	}
 
	printf("%.12f\n",ret);
}

Measured memory_bytes: 128
# 参考: https://atcoder.jp/contests/abc067/submissions/3381633
N = gets.to_i

edges = Hash.new { |h, k| h[k] = [] }

while line = gets
  a, b = line.chomp.split.map(&:to_i)
  edges[a] << b
  edges[b] << a
end

def generate_costs(pos = 1, edges)
  costs = Array.new(N + 1, 0)
  done = Array.new(N + 1, false)
  queue = [pos]
  done[pos] = true
  while q = queue.pop
    edges[q].each do |i|
      if done[i] == false
        done[i] = true
        costs[i] = costs[q] + 1
        queue << i
      end
    end
  end
  costs
end

costs1 = generate_costs(1, edges)
costs2 = generate_costs(N, edges)

b = 0
w = 0
1.upto(N) do |i|
  if costs1[i] <= costs2[i]
    b += 1
  else
    w += 1
  end
end
puts(b <= w ? 'Snuke' : 'Fennec')

Measured memory_bytes: 20476
#include <iostream>

using namespace std;

int debtAfterWeek(int n)
{
	int debt = 100000;
	int last3digits;
	for (int i = 0; i < n; i++)
	{
		debt *= 1.05;
		last3digits = debt % 1000;
		debt -= last3digits;
		if (last3digits != 0)
		{
			debt += 1000;
		}
	}
	return (int)debt;
}

int main()
{
	int n;
	cin >> n;
	cout << debtAfterWeek(n) << endl;
	return 0;
}


Measured memory_bytes: 2976
#include<cstdio>
using ll = long long;

int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	ll a[N], ruiseki[N + 1], absruiseki[N + 1];
	ruiseki[0] = absruiseki[0] = 0;
	for (int i = 0; i < N; ++i){
		scanf("%lld", a + i);
		ruiseki[i + 1] = ruiseki[i] + a[i];
		absruiseki[i + 1] = absruiseki[i] + (a[i] > 0 ? a[i] : 0);
	}
	ll answer = 0;
	for (int i = 0; i < N - K + 1; ++i){
		if(answer < (ruiseki[i + K] - ruiseki[i] > 0 ? ruiseki[i + K] - ruiseki[i] : 0) + absruiseki[N] - absruiseki[i + K] + absruiseki[i]) answer = (ruiseki[i + K] - ruiseki[i] > 0 ? ruiseki[i + K] - ruiseki[i] : 0) + absruiseki[N] - absruiseki[i + K] + absruiseki[i];
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int n,i,y;
	int c0,c1,c2,c3,c4,c5,c6;

	scanf("%d",&n);
	while(n!=0){
	c0=c1=c2=c3=c4=c5=c6=0;
		for(i=0;i<n;i++){
			scanf("%d",&y);
			if(y>=60){
				c6++;
			}
			else if(y>=50){
				c5++;
			}
			else if(y>=40){
				c4++;
			}
			else if(y>=30){
				c3++;
			}
			else if(y>=20){
				c2++;
			}
			else if(y>=10){
				c1++;
			}
			else {
				c0++;
			}
		}
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",c0,c1,c2,c3,c4,c5,c6);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(void){
    string S;
    cin >> S;
    for(int i = 0;i < 2;i++){
        if(S[i] != S[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int n;
  int point = 1;
  ll k;
  cin >> n >> k;
  vector<int> v(n+1);
  map<int, int> m;
  bool ok = false;
  for (int i = 1; i <= n; i++){
    cin >> v.at(i);
  }
  ll loop = 0;
  int cur = 1;
  int fir, end = 0;
  int p = 0;
  for (int i = 1; i <= k; i++){
    m[cur]++;
    if (m[cur] == 2) {
      point = cur;
      break;
    }
    cur = v.at(cur);
  }
  cur = 1;
  for (int i = 1; i <= k; i++){
    cur = v.at(cur);
    if (cur == point ) {
      p++;
      if (p == 1) fir = i;
      if (p == 2) {
        end = i;
        loop = end -fir;
        break;
      }
    }
    if (i==k) {
      cout << cur << endl;
      return 0;
    }
  }
  cur = point;
  for (int i = 0; i < ((k-fir)%loop); i++){
    cur = v.at(cur);
  }
  cout << cur << endl;
}

Measured memory_bytes: 11356
// https://atcoder.jp/contests/abc123/tasks/abc123_d

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<long> vx, vy, vz, vxyz;
    vx.resize(x);
    vy.resize(y);
    vz.resize(z);

    for (int i = 0; i < x; i++) {
        cin >> vx[i];
    }
    for (int i = 0; i < y; i++) {
        cin >> vy[i];
    }
    for (int i = 0; i < z; i++) {
        cin >> vz[i];
    }
    sort(ALLR(vx));
    sort(ALLR(vy));
    sort(ALLR(vz));

    for (int a = 0; a < x; a++) {
        for (int b = 0; b < y; b++) {
            if ((a + 1) * (b + 1) > k)
                break;
            for (int c = 0; c < z; c++) {
                if ((a + 1) * (b + 1) * (c + 1) > k)
                    break;
                vxyz.push_back(vx[a] + vy[b] + vz[c]);
            }
        }
    }
    sort(ALLR(vxyz));
    for (int i = 0; i < k; i++) {
        cout << vxyz[i] << '\n';
    }

    return 0;
}

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

int64_t modpow(int64_t a, int64_t p, int64_t m)
{
  int64_t res = 1;
  for (int64_t e = a; p > 0; e = e * e % m, p /= 2) {
    if ((p & 1) != 0) {
      res *= e;
      res %= m;
    }
  }
  return res;
}

int main()
{
  int64_t n;
  cin >> n;
  const int64_t mod = 1'000'000'007;
  int64_t ans = 0;
  ans += modpow(10, n, mod);
  ans += modpow(8, n, mod);
  ans -= modpow(9, n, mod);
  if (ans < 0) ans += mod;
  ans -= modpow(9, n, mod);
  if (ans < 0) ans += mod;
  cout << ans % mod << endl;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int a[10010];

int f(int l, int r)
{
	int d = 1 + (int)log10(r);
	int res = 1;
	rep(i, 0, d)
	{
		res *= 10;
	}
	return res*l + r;
}

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

	int n;
	cin >> n;
	rep(i, 0, n)cin >> a[i];
	sort(a, a + n);

	int min1 = INF, min2 = INF, min3 = INF;
	rep(i, 0, n)rep(j, 0, n)
	{
		if (i == j)
		{
			continue;
		}
		int res = f(a[i], a[j]);
		if (res < min3)
		{
			swap(res, min3);
		}
		if (min3 < min2)
		{
			swap(min2, min3);
		}
		if (min2 < min1)
		{
			swap(min2, min1);
		}
	}

	cout << min3 << endl;

	return 0;
}


Measured memory_bytes: 3428
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;

typedef struct {
	long long point;
	long long no;


}dish_t;


int main(){


	/*Q3*/
	/*Q2*/


	/*Q1*/
	//typedef

	int x, t = 0;
	
	cin >> t >> x;

	double  ret = (double)t / x;

	cout << ret << endl;;

	return 0;

	/*Q2*/

	/*Q3*/

		/*Q4*/

		//return 0;
}


Measured memory_bytes: 256
class Dijkstra():
    """ ダイクストラ法
    重み付きグラフにおける単一始点最短路アルゴリズム

    * 使用条件
        - 負のコストがないこと
        - 有向グラフ、無向グラフともにOK

    * 計算量はO(E*log(V))

    * ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        """ 重み付き有向辺
        無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい

        Args:
            V(int): 頂点の数
        """
        self.G = [[] for i in range(V)]  # 隣接リストG[u][i] := 頂点uのi個目の隣接辺
        self._E = 0  # 辺の数
        self._V = V  # 頂点の数

    @property
    def E(self):
        """ 辺数
        無向グラフのときは、辺数は有向グラフの倍になる
        """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短コストを格納したリスト。
                     到達不可の場合、値はfloat("inf")
        """
        import heapq
        que = []  # プライオリティキュー（ヒープ木）
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加する

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            # キューに格納されている最短経路の候補がdの距離よりも大きければ、他の経路で最短経路が存在するので、処理をスキップ
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                # 頂点vに隣接する各頂点に関して、頂点vを経由した場合の距離を計算し、今までの距離(d)よりも小さければ更新する
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost  # dの更新
                    heapq.heappush(que, (d[e.to], e.to))  # キューに新たな最短経路の候補(最短距離, 頂点番号)の情報をpush
        return d

K=int(input())
pro=Dijkstra(K)
for i in range(0,K):
    pro.add(i,(i+1)%K,1)
    pro.add(i,(10*i)%K,0)

ans=pro.shortest_path(1)[0]
print(ans+1)

Measured memory_bytes: 93360
#include <bits/stdc++.h>
using namespace std;
int main(void){

	int A;
  cin >> A;
  int count = 0;
  
	for(int i = 1; i < 10; i++)
    {
      for(int j = 1; j < 10; j++)
      {
        if(i * j == A)
        {
          cout << "Yes";
          count = 1;
          break;
        }                
      }
      if(count == 1)
      {
        break;
      }      
    }
  
  if(count == 0)
  {
    cout << "No";
  }
  
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n,x;
  cin >> n >> x;
  int m[n];
  REP(i,n){
  	cin >> m[i];
    x -= m[i];
  }
  int ans = n;
  sort(m,m+n);
  ans += x / m[0];
  cout << ans << endl;

}


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

char s[25];

int main() {

	scanf("%s",s);

	int i;

	int len = strlen(s);

	for (i = 0; i < len; i++) {
		if (s[i] == ',') { printf(" "); }
		else { printf("%c",s[i]); }
	}
	printf("\n");


	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String).chars().collect::<Vec<_>>();
    let k = get!(usize);

    let len = s.len();
    let mut set = BTreeSet::new();
    for i in 0..k {
        for j in 0..len-i {
            let mut mozi = "".to_string();
            for l in j..j+i+1 {
                mozi.push(s[l]);
            }
            set.insert(mozi);
        }
    }
    println!("{}", set.into_iter().nth(k-1).unwrap());

}


Measured memory_bytes: 8572
import sys

input = sys.stdin.readline

N = int(input())
ab = [list(map(int,input().split())) for i in range(N-1)]

downnum = [0]*N
neighbor = [[] for i in range(N)]
for ai, bi in ab:
	downnum[ai-1] += 1
	neighbor[ai-1].append(bi-1)

K = max(max(downnum[1::])+1, downnum[0])
Kpre = [-1]*N
Kpre[0] = K
# anslist = [[0]*N for i in range(N)]
queue = [0]
knum = 1
while len(queue)>0:
	nq = []
	for i in queue:
		kk = Kpre[i]+1
		if kk>K: kk -= K
		for j in neighbor[i]:
			nq.append(j)
			Kpre[j] = kk
			kk += 1
			if kk>K: kk -= K

	queue = nq

print(K)
for ai, bi in ab:
	print(Kpre[bi-1])

Measured memory_bytes: 75612
#include<stdio.h>
int main(void){
	int n, m;
	int a;
	scanf("%d", &n);
	scanf("%d", &m);
	for(int i=0; i<m; i++){
		scanf("%d", &a);
		n -= a;
	}
	printf("%d\n", n>=0 ? n : -1);
	return 0;
}

Measured memory_bytes: 1732
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17

#include <stdio.h>

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

#define INF     1e7
#define EPS     1e-5
#define RANGE	110
#define SIN     0.70710678118654752440084436210485    // Sin(45)
#define COS     0.70710678118654752440084436210485    // Cos(45)
#define SINCOS  SIN

typedef struct { double x, y; } T;
T tbl[500000+RANGE];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (fabs(a->x - b->x) < EPS) {
		if (fabs(a->y - b->y) < EPS) return 0;
		if (a->y < b->y) return -1; return 1;
	}
	if (a->x < b->x) return -1;	return 1;
}

int main()
{
	int N, i, j, lim;
	int x, y;
	double dx, dy, d, t, ans;

	N = in();
	for (i = 0; i < N; i++) {
		x = in(), y = in();
		tbl[i].x = (x - y) * SINCOS;
		tbl[i].y = (x + y) * SINCOS;
	}
	qsort(tbl, N, sizeof(T), cmp);

	ans = INF; d = 0;
	for (i = 0; i < N; i++) {
		lim = i+RANGE; if (lim > N) lim = N;
		for (j = i+1; j < lim; j++) {
			dx = tbl[i].x-tbl[j].x; if (dx > d) continue;
			dy = tbl[i].y-tbl[j].y; if (dy > d) continue;
			t = dx*dx + dy*dy;
			if (t < ans) ans = t, d = sqrt(t);
		}
	}
	printf("%.0lf\n", ans);
	return 0;
}


Measured memory_bytes: 17020
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] point = new int[n];
		for(int i = 0; i < n; i++)
			point[i] = sc.nextInt();
		
		int cnt = 0;
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				cnt += point[i] * point[j];
			}
		}
		out.println(cnt);
		
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

ll n, k;
int a[200000];
int to[2000001];
int pos[200001];
vector<int> v;

int main() {
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    memset(pos, -1, sizeof(pos));
    /*
    int st = k%(n+1);
    if (st == 0) {
        cout << endl;
        return 0;
    }
    st--;
    */
    rep(i,2*n) {
        if (pos[a[i%n]] != -1) to[pos[a[i%n]]] = i%n;
        pos[a[i%n]] = i%n;
        /*
        if (!saw[a[i]]) {
            v.push_back(a[i]);
            saw[a[i]] = true;
        } else {
            int pos = v.size()-1;
            while (v[pos] != a[i]) {
                saw[v[pos]] = false;
                v.pop_back();
                pos--;
            }
            v.pop_back();
            saw[a[i]] = false;
        }
        */
    }
    /*
    rep(i,v.size()) cout << v[i] << " ";
    cout << endl;
    */
    int pos = 0;
    int cnt = 0;
    while (true) {
        if (pos == 0 && cnt != 0) {
            break;
        }
        if (to[pos] <= pos) {
            cnt++;
            /*
            if (k == 0) {
                for (int i = pos; i < n; ) {
                    cout << a[i] << " ";
                    if (to[i] < n) i = to[i];
                    else i++;
                }
                cout << endl;
                return 0;
            }
            */
        }
        pos = (to[pos]+1)%n;
        if (pos == 0) {
            cnt++;
        }
        //cerr << pos << " " << cnt << endl;
    }
    k %= cnt;
    if (k == 0) {
        cout << endl;
        return 0;
    }
    while (true) {
        //cerr << pos << " " << k << endl;
        if (to[pos] <= pos) {
            k--;
            if (k == 0) {
                for (int i = pos; i < n; ) {
                    if (i < to[i]) i = to[i]+1;
                    else {
                        cout << a[i]+1 << " ";
                        i++;
                    }
                }
                cout << endl;
                return 0;
            }
        }
        pos = (to[pos]+1)%n;
        if (pos == 0) {
            k--;
            if (k == 0) {
                cout << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 3840
#include<stdio.h>
#include<string.h>
#define rep(i,n) for (int i = 0; i < (n); i++)

#define M 1046527
#define NIL (-1)
#define L 14
using ll = long long;

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  else return 0;
}

// 文字列から数値へ変換してkey を生成する
ll getKey (char str[]) {
  ll sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1 (int key) { return key % M; }
int h2 (int key) { return 1 + (key % ( M - 1 )); }

int find (char str[]) {
  ll key, i, h;
  key = getKey (str); // 文字列を数値に変換
  for (i = 0;; i++) { 
    h = (h1(key) + i*h2(key)) % M;
    if ( strcmp(H[h],str) == 0 ) return 1; // strcmp：文字列比較 0で一致
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}


int insert (char str[]) {
  ll key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for (i = 0;; i++) { // ハッシュの衝突が起きる限りハッシュを計算する（オープンアドレス法）
    h = (h1(key) + i*h2(key)) % M;
    if ( strcmp(H[h],str) == 0 ) { // strcmp：文字列比較(0で一致) insert済み
      // printf("%lld\n", key);
      return 1; 
    } else if ( strlen(H[h]) == 0 ) { // 未挿入のデータ
      strcpy(H[h], str); // strcpy(コピー先のアドレス, コピー元のアドレス)
      // printf("%s\n", H[h]);
      return 0;
    }
  } 
  return 0;
}

int main() {
  int i, n, h;
  char str[L]; // 検索文字列
  char com[9]; // 命令
  for ( i = 0; i < M; i++ ) H[i][0] = '\0'; // H[ハッシュ][データ]
  scanf ("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf ("%s %s", com, str);

    if ( com[0] == 'i' ) {
      insert(str);
    } else {
      if ( find(str) ) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17060
'use strict';(function(input){
  
  input=input.trim().split(/\s+/).map(x=>x-0);
  const K=input[0],
        X=input[1];
  const ans=[];
  for(let x=X-K+1;x<=X+K-1;x++)
    ans.push(x);
  console.log(ans.join(' '));
})(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
int n;
int a[600];
int main(){
	n=gi();
	rep(i,1,2*n)a[i]=gi();
	sort(a+1,a+1+2*n);
	int ans=0;	
	for(int i=1;i<=2*n;i+=2)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [b]
    else
      match str.[ct] with
        ' ' -> b::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let _ = read_line ()
  and r = match read_line () |> split with
      h::t -> List.fold_left (fun x y -> y^" "^x ) h t
    | _ -> ""
  in print_endline r;;

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

class Main{

	public static void quickSort(int[] arr, int left, int right){
		if (left <= right) {
		int p = arr[(left+right) / 2];
		int l = left;
		int r = right;
		
		while(l <= r) {
			while(arr[l] < p){ l++; }
			while(arr[r] > p){ r--; }

			if (l <= r) {
				int tmp = arr[l];
				arr[l] = arr[r];
				arr[r] = tmp;
				l++; 
				r--;
			}
		}
		quickSort(arr, left, r);
		quickSort(arr, l, right);
		}
	}
		
		 public static void arrayPrintln(int[] arr){
		 	for(int i=arr.length-1; i>=0; i--){
		 		if(i!=0){
		 			System.out.print(arr[i] + " ");
		 		}
		 		else System.out.print(arr[i]);
		 	}
        	System.out.println("");
    	}
		
				
		public static void main(String args[]) throws IOException{
			String str;

			int[] inp = new int[5];

			Scanner scan = new Scanner(System.in);
			
			while(scan.hasNext()){
				for(int i=0;i<5;i++){
					str = scan.next();
					int x = Integer.valueOf(str).intValue();
					inp[i] = x;
				}
				quickSort(inp, 0, inp.length-1);
				arrayPrintln(inp);
			}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
int main(void){
    std::vector<int> num(3);
    for (int i = 0; i < 3; i++) std::cin >> num.at(i);
    std::sort(num.begin(), num.end());
    std::cout << num.at(2) * 10 + num.at(1) + num.at(0) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	vector<vector<ll>> A(N, vector<ll>(31));
	vector<ll> B(31);
	rep(i, 31) {
		B.at(i) = 0;
	}
	rep(i, N) {
		ll a;
		cin >> a;
		rep(j, 30) {
			A.at(i).at(j) = a % 2;
			if (a % 2 == 1) {
				B.at(j)++;
			}
			a /= 2;
		}
	}
	rep(i, N) {
		ll an = 0;
		rep(j, 30) {
			an *= 2;
			if (B.at(29 - j) % 2 == 0) {
				if (A.at(i).at(29 - j) == 1) {
					an++;
				}
			}
			else {
				if (A.at(i).at(29 - j) == 0) {
					an++;
				}
			}
		}
		cout << an <<" ";
	}
	

}


Measured memory_bytes: 57816
/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
typedef pair<double, long> key;

struct comp {
    bool operator()(pair<int,int> p1, pair<int,int> p2) {
        if (p1.first < p2.first) return false;
        if (p2.first < p1.first) return true;
        return p1.second < p2.second;
    };
};
//greater<pair<int,int> , greater<int>>

//int dp[N][3];
int main(){
	fastIO;
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
    //    freopen("../output.txt","w",stdout);
    //#endif
	ll n,w;
    cin >> n >> w;
    ll weigh[n];
    ll val[n];
    for(int i=0;i<n;i++)
    	cin >> weigh[i] >> val[i];
    ll dp[n+1][w+1];
    memset(dp , 0 , sizeof(dp));
    for(ll i=n-1;i>=0;i--){
    	for(ll j=0;j<=w;j++){
    		dp[i][j] = dp[i+1][j];
    		if(j>=weigh[i]){
    			dp[i][j] = max(dp[i+1][j] , val[i] + dp[i+1][j-weigh[i]]);
    		}
    	}
    }
    cout << dp[0][w] << endl;
	return 0;

}



Measured memory_bytes: 79232
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let q: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let lr: Vec<(usize, usize)> = (0..q).map(|_| (read(), read())).collect();

    let mut count = vec![0; n];
    let mut cnt = 0;

    for i in 0..n - 1 {
        if s[i] == 'A' && s[i + 1] == 'C' {
            cnt += 1;
            count[i + 1] = cnt;
        } else {
            count[i + 1] = cnt;
        }
    }

    for (l, r) in lr {
        println!("{}", count[r - 1] - count[l - 1]);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6908
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        string[] line = Console.ReadLine().Split(' ');
        int N = int.Parse(line[0]);
        int M = int.Parse(line[1]);
        int n = 0;
        int m = 0;

        if (N >= 2)
        {
            n = (N * (N - 1)) / 2;
        }
        if (M >= 2)
        {
            m = (M * (M - 1)) / 2;
        }
        Console.WriteLine(n + m);
    }
}

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

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

using namespace std;
int dp[210][101];

int main() {
  REP(i,210)REP(j,101)dp[i][j]=-1000000000;
  int d,n;
  cin>>d>>n;
  vector<int> t(d);
  REP(i,d)cin>>t[i];
  vector<tuple<int,int,int>> cl;
  REP(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    cl.emplace_back(a,b,c);
  }
  REP(i,d){
    REP(j,n){
      int a,b,c;
      tie(a,b,c)=cl[j];
      if(t[i]<a||t[i]>b) continue;
      REP(k,101){
        if (i) dp[i+1][c] = max(dp[i+1][c], dp[i][k] + abs(c-k));
        else dp[i+1][c] = 0;
      }
    }
  }
  int mx = 0;
  REP(i,101)mx=max(mx,dp[d][i]);
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll A, B;
  cin >> A >> B;
  cout << max({A + A - 1, A + B, B + B - 1}) << rt;
}

Measured memory_bytes: 256
#include<iostream>
#include<limits.h>
#define SENTINEL INT_MAX //SENTINELをとても大きい値で初期化する
using namespace std;
typedef long long ll;
ll counter=0;
void Merge(long long S[],int left,int mid,int right){//擬似コードに従った、Merge
  int n1 = mid-left;
  int n2 = right-mid;
  ll L[n1+1];
  ll R[n2+1];
 
  for(int i=0;i<n1;i++){
    L[i] = S[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=S[mid+i];
  }
  L[n1]=R[n2]=SENTINEL;//番兵設置
  int i=0;
  int j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      i=i+1;
      counter++;
    }
    else{
      S[k]=R[j];
      j=j+1;
      counter++;
    }
  }
}
 
void Merge_Sort(long long S[],int left,int right){//擬似コードに従った,Merge_Sort
  
  if(left+1<right){
    int mid = (left+right)/2;
    Merge_Sort(S,left,mid);
    Merge_Sort(S,mid,right);
    Merge(S,left,mid,right);
  }
}
 
 
 
int main(){
  int n;
  ll S[600000];
 
  cin >> n;
    for(int i=0;i<n;i++){
      cin >> S[i];
    }
 
    Merge_Sort(S,0,n);
 
    for(int i=0;i<n;i++){
      cout << S[i];
      if(i != n-1)cout << " ";
    }
    cout << endl;
    cout << counter << endl;
 
  return 0;
}

Measured memory_bytes: 8676
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

ans = 1
for _ in range(n):
    ans = lcm(ans, int(input()))
print(ans)


Measured memory_bytes: 61612
N=int(input())
numbers=list(map(int,input().split()))
new_numbers=sorted(numbers,reverse=True)
Alice=0

Bob=0
for i in range(N//2+N%2):
    Alice+=new_numbers[2*i]
for i in range(N//2):
    Bob+=new_numbers[2*i+1]
print(Alice-Bob) 


Measured memory_bytes: 3060
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let dfs vs n =
  let d = Array.make n (-1) in
  let rec doit i id =
    d.(i) <- id;
    List.iter (fun v -> if d.(v) = (-1) then doit v id) vs.(i) in
  Array.iteri (fun i e -> if e = (-1) then doit i i) d;
  d

let read_ns () =
  match read_line () |> split_on_char ' ' |> List.map int_of_string with
  | [x; y] -> (x, y)
  | _ -> assert false

let () =
  let (n, m) = read_ns () in
  let vs = Array.make n [] in
  for _ = 0 to m - 1 do
    let (s, t) = read_ns () in
    vs.(s) <- t :: vs.(s);
    vs.(t) <- s :: vs.(t);
  done;
  let d = dfs vs n in
  let q = read_int () in
  for _ = 0 to q - 1 do
    let (s, t) = read_ns () in
    Printf.printf (if d.(s) = d.(t) then "yes\n" else "no\n")
  done

Measured memory_bytes: 18848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

bool has_divisor(int N,int i) {
    if(i==N) return false;
    if(N%i==0) return true;
    return has_divisor(N,i+1);
}

bool is_prime(int N) {
    if(N==1) return false;
    else if(N==2) return true;
    else return !has_divisor(N,2);
}

int main() {
    int X;
    cin>>X;
    int answer;
    for(int i=X; X<1000000; i++) {
        if(is_prime(i)==true) {
            answer=i;
            break;
        }
    }
    printf("%d\n",answer);
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = [0] * N
A = list(map(int, input().split()))

d = defaultdict(lambda: 0)

def comb2(x):
    return int(x * (x - 1) / 2)

for x in A:
    d[x] += 1

comp = 0
for k,v in d.items():
    comp += comb2(v)


for i in A:
    ans = comp - comb2(d[i]) + comb2(d[i] - 1)
    print(ans)

Measured memory_bytes: 28316
s = input()

li = []
for i, c in enumerate(s):
    if c == '?':
        if i == len(s) - 1:
            c = 'D'
        else:
            if i > 0 and li[i - 1] == 'P':
                c = 'D'
            elif s[i + 1] == 'D' or s[i + 1] == '?':
                c = 'P'
            else:
                c = 'D'
    li.append(c)


print(''.join(li))

Measured memory_bytes: 10964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); // すぬけ君の数
        int K = sc.nextInt(); // お菓子の種類
        int[] d = new int[K]; // 何人お菓子をもっているか
        int[][] A = new int[K][N]; // 誰がお菓子をもっているか
        int[] sunuke = new int[N];

        for (int i = 0; i < K; i++) {
            d[i] = sc.nextInt();
            for (int j = 0; j < d[i]; j++) {
                A[i][sc.nextInt() - 1]++;
            }
        }
        for (int i = 0; i < K; i++) {
            for (int j = 0; j < N; j++) {
                if (A[i][j] != 0) {
                    sunuke[j]++;
                }
            }
        }
        int ans = 0;

        for (int i = 0; i < N; i++) {
            if (sunuke[i] == 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 46068
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
arrs=list(itertools.permutations(range(1,n+1)))
cnt1=0
cnt2=0
for i in range(len(arrs)):
  if arrs[i]==p:
    cnt1=i
  if arrs[i]==q:
    cnt2=i
print(abs(cnt2-cnt1))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
    cin >> a >> b;
    if(a > 0)
        {
        	cout << "Positive" << endl;
		}
	    else if(a == 0||(a < 0 && b > 0))
	        {
	        	cout << "Zero" << endl;
			}
	        else if((abs(b) - abs(a)) % 2 != 0)
		        {
		        	cout << "Positive" << endl;
				}
                else cout << "Negative" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define Maxn 4005
using namespace std;
int main(){
	long long int n, sum, r=0, g=0, b=0;
	string s;
	cin >> n >> s;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else if(s[i]=='B') b++;
	}
	sum=r*g*b;
	for(int p=0;2*p<n;p++){
		for(int i=0;i+2*p<n;i++){
			if(s[i]!=s[i+p]&&s[i]!=s[2*p+i]&&s[i+p]!=s[2*p+i]) sum--;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3608
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n_str: String,
    }
    let n_bytes = n_str.as_bytes();
    let mut reminder = 0;
    for &b in n_bytes {
        let digit = b - b'0';
        reminder += digit;
        if reminder >= 9 {
            reminder -= 9;
        }
    }
    if reminder == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2424
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 100000
#define MAXK 1000
int x[MAXN+5],y[MAXN+5],m[MAXN+5];
int y1[10*MAXK+5];
int main()
{
	int N,K,Max=0,cnt=0;
	scanf("%d %d",&N,&K);
	for(int i=1;i<=N;i++)
	{
		char ch[25];
		scanf("%d %d %s",&x[i],&y[i],ch);
		x[i]=x[i]%(2*K);
		y[i]=y[i]%(2*K);
		if(ch[0]=='W') m[i]=1;
			else m[i]=0;
	}
	for(int i=0;i<=K;i++)
	{
		cnt=0;
		memset(y1,0,sizeof(y1));
		for(int j=1;j<=N;j++)
		{
			int p=(i<=x[j]&&x[j]<i+K);
			int q=(0<=y[j]&&y[j]<K);
			if(p ^ q==m[j])
			{
				cnt++;
				y1[y[j]]++;
			}
			else 
				y1[y[j]]--;
		}
		for(int j=0;j<=K;j++)
		{
			if(cnt>Max)Max=cnt;
			if(N-cnt>Max) Max=N-cnt;
			if(j!=K)
				cnt=cnt-y1[j]-y1[K+j];
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 1408
n=int(input())
res=0
if (n%2)==0:
    x=5
    while True:
        if (n//x)==0:
            break
        d=n//x
        if (d%2)==1:
            d=(d-1)//2
        else:
            d//=2
        res+=d
        x*=5
print(res)

Measured memory_bytes: 38256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
sums = []
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sums.append(i*500+j*100+k*50)
print(sums.count(X))

Measured memory_bytes: 14160
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, m, p[100009];
vi v[100009];
si s, s2, s3;
void search(int a){
  s.insert(a);
  s2.insert(a);
  s3.insert(p[a]-1);
  each(itr, v[a]){
    if(s2.find(*itr) != s2.end()) continue;
    search(*itr);
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> p[i];
  FOR(i, 0, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  int ans = 0;
  FOR(i, 0, n){
    if(s.find(i) != s.end()) continue;
    search(i);
    each(itr, s3) if(s2.find(*itr) != s2.end()) ans++;
    s2.clear();
    s3.clear();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23168
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()





int main(){
  

  int n;
  cin>>n;
  vi data(n+1);
  for (int i=1;i<=n;i++){
    int tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  vi answer(n+1,0);
  
  for (int i=n;i>=1;i--){
    int sum=0;
    for (int j=2*i;j<=n;j+=i){
      sum+=answer.at(j);
      sum%=2;
    }
    answer.at(i)=abs(data.at(i)-sum)%2;
  }
  
  int count=0;
  for (int i=1;i<=n;i++){
    count+=answer.at(i);
  }
  
  cout<<count<<endl;
  for (int i=1;i<=n;i++){
    if (answer.at(i)==1){
      cout<<i<<" ";
    }
  }
  cout<<endl;
  
  


}












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

int n;
int l[2000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> l[i];
	sort(l, l + n);
	
	int ans = 0;
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			int a = l[i] + l[j];
			int id1 = lower_bound(l, l + n, a) - l;
			int cnt = id1 - (j + 1);
			ans += cnt;
		}
	}
	cout << ans << endl;
	return 0;
}

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

string w, t;
int cnt = 0;

int main(){
  cin >> w;
  while(cin >> t){
    if(t == "END_OF_TEXT") break;
    for(int i = 0; i < t.size(); i++){
      t[i] = tolower(t[i]);
    }
    if(t == w) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3136