akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e5+5;
vector<int> v[N];
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll f[N], dp[N], ans[N];
ll comb(int n,int r) {
    ll num = f[n];
    ll den = (f[r]*f[n-r])%mod;
    return (num*power(den,mod-2))%mod;
}
int cnt[N];
void dfs(int i,int p) {
    cnt[i] = 1;
    for(auto it:v[i]) {
        if(it!=p) {
            dfs(it,i);
            cnt[i] += cnt[it];
        }
    }
    int n = cnt[i]-1;
    dp[i] = 1;
    for(auto it:v[i]) {
        if(it!=p) {
            dp[i] *= (comb(n,cnt[it])*dp[it])%mod;
            dp[i] %= mod;
            n -= cnt[it];
        }
    }
}
int n;
void run(int i,int p) {
    ans[i] = dp[i];
    for(auto it:v[i]) {
        if(it!=p) {
            int t = (comb(n-1,cnt[it])*dp[it])%mod;
            dp[i] = (dp[i]*power(t,mod-2))%mod;
            int s = (comb(n-1,n-cnt[it])*dp[i])%mod;
            dp[it] = (dp[it]*s)%mod;
            run(it,i);
            dp[it] = (dp[it]*power(s,mod-2))%mod;
            dp[i] = (dp[i]*t)%mod;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    f[0] = 1;
    for(int i=1;i<N;i++) {
        f[i] = (f[i-1]*i)%mod;
    }
    cin>>n;
    for(int i=1,x,y;i<n;i++) {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,1);
    run(1,1);
    for(int i=1;i<=n;i++) {
        cout<<ans[i]<<"\n";
    }
}


Measured memory_bytes: 19444
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
ans = [0]*D
manzoku_down = [0]*26
for i in range(D):
    tmp = -float('inf')
    for j in range(26):
        last = 0
        for l in range(0,i+1):
            if ans[l] == j+1:
                last = j+1
        manzoku_down[j] = C[j]*((i+1)-last)
    for k in range(26):
        if S[i][k]-sum(manzoku_down)+manzoku_down[k] >= tmp:
            tmp = S[i][k]-sum(manzoku_down)+manzoku_down[k]
            ans[i] = k+1
for i in ans:
    print(i)

Measured memory_bytes: 68880
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int main(){
	char c;
	cin >> c;
	if(c>='A'&&c<='Z'){
		cout << "A";
	}
	else{
		cout << "a";	
	}
	return 0;
}




Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
   int i,count=0;
   char dummy[110],S[110];
   
   for(i=0;i<110;i++){
       dummy[i]=0;
       S[i]=0;
   }
   
  for(i=0;i<110;i++){
    scanf("%s",&dummy[i]);
 if(dummy[i]!=NULL){
 S[i]=dummy[i];
 count++;
 }
  }
  
  for(i=0;i<count;i++)
      S[i]='x';

   printf("%s\n",S);
    return 0;
}


Measured memory_bytes: 128
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 3620
s=input()
t=input()

alp='abcdefghijklmnopqrstuvwxyz'
d={}
for i in range(len(alp)):
    d[alp[i]]=i

t_arr=[[] for _ in range(26)]
s_arr=[[] for _ in range(26)]

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if a in t_arr[d[b]]:
        continue
    else:
        t_arr[d[b]].append(a)

for j in range(len(s)):
    a=s[j]
    b=t[j]
    if b in s_arr[d[a]]:
        continue
    else:
        s_arr[d[a]].append(b)


ans='Yes'
for k in range(26):
    if len(t_arr[k])>=2:
        ans='No'
        break
    if len(s_arr[k])>=2:
        ans='No'
        break

print(ans)

Measured memory_bytes: 9352
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner a = new Scanner(System.in);
        
        int b;
        int c=0;
        do{
            b = a.nextInt();
            c++;
            if(b!=0){
                System.out.println("Case "+c+": "+b);
            }
        }while(b!=0);
    }
}



Measured memory_bytes: 43004
import sys
n=int(input())
a=list(map(int,input().split()))
x=0
if(n==1):
  print(1)
  sys.exit()
for i in range(n-1):
  if(a[i+1-x]==a[i-x]):
    a.pop(i-x)
    n-=1
    x+=1
    if(n==3):break
if(a[0]==a[1]):
  a.pop(0)
  n-=1
if(n==2):
  print(1)
  sys.exit()
til=a[1]-a[0]
x=0
for i in range(n-1):
  tilt=a[i+1]-a[i]
  if(til*tilt<0):
    x+=1
    if(i+2>=n):
      break
    til=a[i+2]-a[i+1]
print(x+1)

Measured memory_bytes: 14480
#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) - 1; 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 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;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << ", ";
#define endln cerr << "\n";
#define chkpt cerr << "-----\n";

long long a, b;

long long solve(long long a, long long b) {
    if (a == 0 && b == 0) {
        return 1;
    }
    int x = __lg(a);
    int y = __lg(b);
    if (x == y) {
        return solve(a - (1LL << x), b - (1LL << y));
    }
    long long c = b - (1LL << y);
    long long q1 = a;
    long long q2 = (1LL << y) - 1;
    long long q3 = 0;
    long long q4 = 0;
    if (c) {
        int z = __lg(c);
        q4 = (1LL << z + 1) - 1;
    }
    if (q1 > q4) {
        return q2 - q1 + 1 + q2 - q1 + 1 + q4 - q3 + 1;
    }
    else {
        return q2 - q1 + 1 + q2 + 1;
    }
}

void solve() {
    cin >> a >> b;
    cout << solve(a, b) << "\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 256
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;

int main(){
    string str ; cin >> str ;
    int cnt = 0 ;
    int N = str.length() ;
    for( int i = 0 ; i < N / 2 ; i++ ){
        if( str[i] != str[N-i-1] )
            cnt++ ;
    }
    cout << cnt << endl ;
    return 0 ;
}


Measured memory_bytes: 3624
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N = attrs[0][0]
X = attrs[1].map{|a| a.to_i}
total = X.inject(:+)
p = (total/N.to_f).round
res = 0
X.each do |x|
  res += (x-p)**2
end
puts res


Measured memory_bytes: 1788
#include<iostream>
#include<cmath>

int main(void){
    std::string s;
    long long k;
    std::cin >> s >> k;

    const long long days = 5e15;
    int ans;

   for(int i = 0; i < s.size(); i++){
       int number = s.at(i) - '0';
       if(number == 1){
           k--;
       }
       else{
           k -= std::pow(number, days);
       }

       if(k <= 0){
           ans = number;
           std::cout << ans << std::endl;
           return 0;
       }
   }
   
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
result=0
if A == B:
    if A != C and B != C:
        result+=1
elif A == C:
    if A != B and B != C:
        result+=1
elif B == A:
    if B != A and C != B:
        result+=1
elif B ==C:
    if B != A and A != C:
        result+=1
elif C == A:
    if C != B and A == B:
        result+=1
elif C == B:
    if C != A and A == B:
        result+=1
if result==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
def addTime(x):
  return (x + 9) // 10 * 10

def diff(x):
  return addTime(x) - x

def main():
  a = [int(input()) for i in range(5)]
  ans = 0
  for i in a:
    ans = ans + addTime(i)
  
  diffList = []
  for i in a:
    diffList.append(diff(i))

  ans = ans - max(diffList)
  print(ans)

main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a.at(0) << b.at(1) << c.at(2) << endl;
}

Measured memory_bytes: 256
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb push_back

const int N = 2e6 + 7;
ll n,m,k,cnt,cur,ans;
ll dp[N][5],a[N],b[N],c[N];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);

	cin >> n;
	fori(i,1,n + 1)
		cin >> a[i] >> b[i] >> c[i];

	dp[1][1] = a[1], dp[1][2] = b[1], dp[1][3] = c[1];
	fori(i,2,n + 1){
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];	
	}

	cout << max({dp[n][1], dp[n][2], dp[n][3]});

}

Measured memory_bytes: 13312
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n, q int
	fmt.Fscan(r, &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}

	m := make(map[int64]int)
	var sum int64
	for i := 0; i < n; i++ {
		m[a[i]]++
		sum += a[i]
	}

	fmt.Fscan(r, &q)
	for ; q > 0; q-- {
		var b, c int64
		fmt.Fscan(r, &b, &c)
		sum += int64(m[b]) * (c - b)
		m[b], m[c] = 0, m[b]+m[c]
		fmt.Println(sum)
	}
}


Measured memory_bytes: 11164
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const long long INF = 1e18;


int main() {
	ll n;
  	cin>>n;
  	string s;
  	cin>>s;
  	ll r=0;
  
  for(int i=0;i<n;i++){
  	if(s[i]=='R')r++;//Rを全部数えて
  }
  
  ll ans=0;
  for(int i=0;i<r;i++){
  	if(s[i]!='R')ans++;//RまでにWがあったらrより右にあるRと交換
  }
  
  cout<<ans<<endl;
  return 0;
  	
  
}



Measured memory_bytes: 3740
#include <stdio.h>
#include <math.h>
typedef struct cord{
	int x;
	int y;
} cord;
int main(){
	cord town[8];
	long double sum = 0.0;
	int n, r1, r2, fact = 1;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &r1, &r2);
		town[i].x = r1;
		town[i].y = r2;
	}
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			if(i == j) continue;
			sum += sqrtl(powl(town[i].x - town[j].x, 2) + powl(town[i].y - town[j].y, 2));
		}
	}
	sum = sum*2/n;
	printf("%.10Lf\n", sum);
}

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

    long long int N,count=0,f=0,s=0;
    cin >> N;
    long long int a[N];
    map<long long int,long long int>m;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        m[a[i]]++;
    }

    sort(a,a+N);
    reverse(a,a+N);
    
    for(int i = 0; i < N; i++) {
        if(a[i] == a[i+1]) {
            continue; 
        }else if(m[a[i]] >= 4) {
            if(count == 0) {
                f = a[i];
                s = a[i];
                break;
            }else {
                s = a[i];
                count++;
            }
        }else if(m[a[i]] >= 2) {
            if(count == 1) {
                s = a[i];
            }else {
                f = a[i];
            }
            count ++;
        }
        if(count == 2) {
            break;
        }
    }
    
    cout << f * s << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,a,b) for (long long i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(long long)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n;

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  if (n < 1000) cout << "ABC";
  else cout << "ABD";
}


Measured memory_bytes: 256
/**
 * ?????°????????£????????????????????????????????????????°??????????????????????
 */

#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;

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


void read_problem(vector<int>& a, vector<int>& ms)
{
    int n;
    scanf("%d\n", &n);

    a.resize(n);
    REP(i, n) {
        scanf("%d", &a[i]);
    }

    int q;
    scanf("%d\n", &q);

    ms.resize(q);
    REP(i, q) {
        scanf("%d", &ms[i]);
    }
}

bool recurse(const vector<int>& a, int m, int sum, int i, bool use)
{
    if(i == a.size()) return false;

    if(use)
        sum += a[i];

    if(sum == m)
        return true;
    else if(sum > m)
        return false;

    return recurse(a, m, sum, i+1, false) ||
           recurse(a, m, sum, i+1, true);
}

bool attempt(const vector<int>& a, int m)
{
    return recurse(a, m, 0, 0, false) || recurse(a, m, 0, 0, true);
}

int main()
{
    vector<int> a;
    vector<int> ms;
    read_problem(a, ms);

    int q = ms.size();
    deque<bool> result(q);
    REP(i, q) {
        result[i] = attempt(a, ms[i]);
    }

    for(bool b : result) {
        puts(b ? "yes" : "no");
    }

    return 0;
}

Measured memory_bytes: 2664
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	string s;
	cin >> s;

	int del;
	if(s.front() == s.back()){
		del = s.size() - 3;
	}else{
		del = s.size() - 2;
	}

	cout << (del % 2 ? "First" : "Second") << endl;
}


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

int main() {
  string s;
  cin >> s;
  int len = s.size();
  
  int black = 0;
  ll int ans = 0;
  rep(i, len) {
    char x = s[i];
    if(x == 'W') ans += black;
    else ++black;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3740
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]



S = str(input())
ans = "No"

if(S[2] == S[3] and S[4] == S[5]):
  ans = "Yes"
print(ans)


Measured memory_bytes: 38636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;

int main()
{
	int R,G,B, N;
	cin>>R>>G>>B>>N;
	int ans = 0;
	for (int r =0 ;r<= N/R;r++){
		int deci = N - r*R;
		for(int g = 0;g<=deci/G;g++){
			if((deci-g*G)%B==0)ans+=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
ll gcd(ll a,ll b) {
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
ll t,a,b,c,d;
int main() {
	cin >> t;
	rep(i, t) {
		cin >> a >> b >> c >> d;
		if (a < b) { cout << "No" << endl; continue; }
		if (b > d) { cout << "No" << endl; continue; }
		if (d%b == 0) { cout << (a%b <= c ? "Yes" : "No") << endl; continue; }
		ll n = d % b;
		if (b%n != 0) {
			if (gcd(b, n) == 1) { cout << (c >= b - 1 ? "Yes" : "No") << endl; }
			else {
				ll g = gcd(n, b);
				ll m = a % b; m %= g;
				cout <<(b-g+a%g <=c ? "Yes" : "No") << endl;
			} continue;
		}
		ll p = (a / b + 1)*b;
		p -= a; p = p/n-(p%n==0?1:0);
		cout<<((ll)(a%b+((p%b)*n%b))%b<=c? "Yes" : "No") << endl;
	}
	return 0;
}

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

int main() {
  int N,L;
  vector<string> S;
  string Sbuff;
  
  cin >> N >> L;
  for (int i=0;i<N;i++) {
    cin >> Sbuff;
    S.push_back(Sbuff);
  }
  sort(S.begin(), S.end());
  for (int i=0;i<N;i++) {
    cout << S.at(i);
  }
  cout << endl;
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

typedef unsigned long long ull;
typedef signed long long ll;

using namespace std;

int main() {
    ll X;
    cin >> X;

    for (ll x = -1000; x <= 1000; x++) {
        for (ll y = -1000; y <= 1000; y++) {
            ll ans = (x*x*x*x*x) - (y*y*y*y*y);
            if (X == ans) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("O2")
#pragma GCC target("popcnt")
#pragma GCC target ("avx2")
using namespace std;

int main(){
	long long n,k;
	cin >> n >> k;
	long long to[n+1],dist[n+1];
	for(long long i = 1 ; i <= n ; i += 1){
		cin >> to[i];
	}
	set<long long> st;
	long long curr = 1 , cnt = 0;
	while(true){
		if(st.count(curr)){
			break;
		}
		if(cnt == k){
			cout << curr << endl;
			return 0;
		}
		st.insert(curr);
		dist[curr] = cnt;
		cnt += 1;
		curr = to[curr];
	}
	long long curr2 = to[curr];
	vector<int> v = {curr};
	while(curr2 != curr){
		v.push_back(curr2);
		curr2 = to[curr2];
	}
	long long siz = v.size();
	cout << v[(k-dist[curr])%siz] << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A, B;
  cin >> A >> B;
  cout << 6 - A - B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
  //stream
  friend ostream& operator<<(ostream& os, const mint a);
};
ostream& operator<<(ostream& os, const mint a){
  os << a.x;
  return os;
}

int main(void) {
	string s; cin >> s;
	int n= s.size();
	vector<vector<mint>> dp(n+1,vector<mint>(13,0));
	dp[0][0]=1;
	rep(i,n){
		int d;
		if(s[i]=='?') d = -1; else d = s[i]-'0'; 
		rep(j,10){
			if(d!=-1&&j!=d) continue;
			for(int k=0; k<13; k++){
				dp[i+1][(k*10+j)%13] += dp[i][k];//ひっ算のイメージ！！
			}
		}
	}
	cout << dp[n][5] << endl;
}




Measured memory_bytes: 13696
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a,b,c;cin >>a>>b>>c;
    cout <<c<<" "<<a<<" "<<b<<endl;
}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=1,s=7;cin>>N;
  if(N%2==0||N%5==0)ans=-1;
  else{
    while(s%N!=0){
      s*=10;s+=7;s%=N;ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
bool f, f2;

void solve(int num, int co[]){
	if (num == 10){
		REP(i, 10){
			if (co[i] != 0)return;
		}
		f = 1;
		return;
	}

	if (co[num] >= 3){
		co[num] -= 3;
		if (co[num] > 0)solve(num, co);
		else solve(num + 1, co);
		co[num] += 3;
	}

	if (f2&&co[num] >= 2){
		co[num] -= 2;
		f2 = 0;
		if (co[num] > 0)solve(num, co);
		else solve(num + 1, co);
		co[num] += 2;
		f2 = 1;
	}

	if (num + 2 <= 9){
		if (co[num] >= 1 && co[num + 1] >= 1 && co[num + 2] >= 1){
			co[num]--;
			co[num + 1]--;
			co[num + 2]--;
			if (co[num] > 0)solve(num, co);
			else solve(num + 1, co);
			co[num]++;
			co[num + 1]++;
			co[num + 2]++;
		}
	}

	solve(num + 1, co);
}


int main(){
	while (cin >> s){
		int co[10] = {};
		V ans;
		REP(i, s.size()){
			co[s[i] - '0']++;
		}
		FOR(i, 1, 10){
			f = 0;
			f2 = 1;
			co[i]++;

			if (co[i] <= 4)solve(1, co);

			if (f)ans.push_back(i);
			co[i]--;
		}
		if (ans.size() == 0){
			cout << 0 << endl;
		}
		else{
			REP(i, ans.size()){
				if (i == 0)cout << ans[i];
				else cout << " " << ans[i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int x,a,b;cin>>x>>a>>b;
    cout<<x+a+b-max(max(x,a),b)<<endl;
}

Measured memory_bytes: 3564
import scala.util.control.Breaks._

object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toLong)
  var x = n % k
  breakable {
    while(true) {
      val y = if (x < k) k - x else x - k
      if (x <= y) break() else x = y
    }
  }
  println(x)
}

Measured memory_bytes: 25664
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll h, n;
    cin >> h >> n;
    vector<Pll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i].first >> a[i].second;
    }
    vector<ll> dp(h+1, LINF);
    dp[h] = 0;
    for(int i=0;i<n;++i) {
        for(int j=h;j>=0;--j) {
            dp[max(0LL, j-a[i].first)] = min(dp[max(0LL, j-a[i].first)], dp[j] + a[i].second);
        }
    }

    cout << dp[0] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a[3];
    int k;
    int ans = 0;

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

    sort(a, a + 3);

    for ( int i = 0; i < k; i++ ){
        a[2] *= 2;
    }

    cout << a[0] + a[1] + a[2] << endl;

    return 0;
}


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

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    int a[n];
    int flag = 0;
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    if(a[0]==a[n-1]){
        if(a[0]==n-1)flag=1;
        if(a[0] <= n/2)flag=1;
    }
    if(a[0]+1 == a[n-1]){
        int count = 0;
        rep(i,n){
            if(a[i] == a[0])count++;
        }
        int k = a[n-1];
        n -= count;
        k -= count;
        if(a[0]>=count){
            if(k <= n/2)flag = 1;
        }
    }

    if(flag>0)yn;
    return 0;
}
 
 


Measured memory_bytes: 640
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 35716
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        S: chars,
    }
    let N = S.len();
    let mut b_cnt = 0;
    let mut ans = 0;
    for i in 0..N {
        if S[i] == 'W' {
            ans += i - b_cnt;
            b_cnt += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main() {
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    ll count=0;
    rep(i, n-2) {
        int k = i+1;
        int j = i+2;
        while(k<=n-2 && j<=n-1) {
        while(l[i] + l[k] > l[j] && j <= n-1) {
             count++;
             j++;
        }
        k++;
        j = k+1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[100000];
		for(int i=0;i<100000;i++) a[i] = 0;
		for(int i=0;i<N;i++){
			int temp = sc.nextInt();
			if(temp>0){
				a[temp-1]++;
			}
			a[temp]++;
			if(temp<99999){
				a[temp+1]++;
			}
		}
		int max = 0;
		for(int i=0;i<100000;i++){
			if(max<a[i]){
				max = a[i];
			}
		}
		System.out.println(max);
	}

}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n, k, l[];

		n = sc.nextInt();
		k = sc.nextInt();
		l = new int[n];
		for (int i = 0; i < n; ++i)
			l[i] = sc.nextInt();
		sc.close();

		Arrays.sort(l);

		int max = 0;
		for (int i = n - 1; i >= n - k; --i)
			max += l[i];

		System.out.println(max);
	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,i,a[100000],b[100000],min;
	cin>>n>>x;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
		b[i]=abs(a[i]-x);
	min=b[1];
	for(i=1;i<=n;i++)
	{
		if(b[i]<min)
			min=b[i];	
	}
	for(;min>=1;min--)
	{
		for(i=1;i<=n;i++)
		{
			if(b[i]%min!=0)
				break;
		}
		if(i==n+1)
		{
			cout<<min;
			return 0;
		}
	}	
    return 0;
}




Measured memory_bytes: 1024
import math

l = []
n = int(input())
for i in range(n):
  x1, x2 = map(int,input().split())
  l.append([x1, x2])

r = []
for i in range(n):
  for j in range(i+1,n):
    r_ = math.sqrt((l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2)
    r.append(r_)

f = math.factorial(n-1)
f_ = math.factorial(n)
sum = 2 * f * sum(r)
print(sum/f_)

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

int main(){
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if (((a==5 & b==5 & c==7)||(b==5 & c==5 & a==7)||(c==5 & a==5 & b==7))){
		
		cout << "YES" << endl;
	}else{
		
		cout << "NO" << endl;
	} 
	
return 0;
}

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

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

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

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

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

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

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


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

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


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    vector<i64> C(N + 1, 0);
    REP(i, N) {
        cin >> A[i];
        C[i + 1] = C[i] + A[i];
    }

    i64 minc = 1152921504606846976;
    for (i64 i = 1; i <= N - 1; i++) {
        i64 left = C[i];
        i64 right = C[N] - C[i];
        chmin(minc, abs(left - right));
    }
    cout << minc << endl;

    return 0;
}

Measured memory_bytes: 6356
s=input()
k=int(input())
n=len(s)
d=set()
#d={s[i:j+1] for j in range(i,n) for i in range(n)}
#d={s[i:j+1] for i in range(n) for j in range(i,n)}
for i in range(n):
    for j in range(i,min(n,i+5)):
        d.add(s[i:j+1])
ans=sorted(list(d))
print(ans[k-1])


Measured memory_bytes: 4676
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

vector<int> prime;

bool isprime(int N) {
    if (N == 2) return true;
    else if (N % 2 == 0) return false;
    else if (N == 1) return false;
    for (int i = 3; i <= sqrt(N); i++) {
        if (N % i == 0)return false;
    }
    return true;
}

void factorial(int N, vector<int>& cnt) {
    int i = 0;
    while (!isprime(N)) {
        int p = prime[i];
        if (N % p == 0) {
            cnt[p]++;
            N /= p;
        }
        else i++;
    }
    if (isprime(N)) cnt[N]++;
}

int main() {
    int N;
    cin >> N;
    vector<int> cnt(N + 1);
    Rep(i, N + 1) {
        if (isprime(i)) prime.push_back(i);
    }
    for (int i = 2; i <= N; i++) factorial(i, cnt);
    ll ans = 1;
    for (int i = 0; i < prime.size(); i++) {
        if (cnt[prime[i]] >= 1) {
            ans *= cnt[prime[i]] + 1;
            ans %= 1000000007;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int r;
	cin >> r;
	cout << 2 * r * 3.1415 << endl;

	return 0;
}


Measured memory_bytes: 3780
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;


int main(int argc, char *args[]) {
	string s;
	cin >> s;
	int money = 700;
	if (s[0] == 'o')money += 100;
	if (s[1] == 'o')money += 100;
	if (s[2] == 'o')money += 100;
	cout << money << endl;
	
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n;
	unordered_map<string,int>mp;
	for(int i=0;i<n;++i){
		string s; cin>>s;
		++mp[s];
	}
	cin>>m;
	for(int i=0;i<m;++i){
		string t; cin>>t;
		--mp[t];
	}
	int mx=0;
	for(auto&i:mp)mx=max(mx,i.second);
	cout<<mx<<"\n"s;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;
    int m = max(a,(max(b,c)));
    int ans = a + b + c - m;
    for(int i = 0; i < k; i++){
        m *= 2;
    }
    ans += m;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
an = [int(i) for i in input().split()]
s  = sum(an)
h = s/N
ans = -1
m = float('inf')
for i in range(N-1,-1,-1):
    t = abs(h-an[i])
    if m >= t:
        m = t
        ans = i
print(ans)


Measured memory_bytes: 3060
from operator import add


def fold_right(v, length):
    global white_right
    for i in range(white_right, len(v[0])):
        if not any(list(zip(*v))[i]):
            white_right += 1
            continue
        for j in range(length - 1, -1, -1):
            for yoko in range(len(v)):
                v[yoko][i + j + length] += v[yoko][i + (length - 1 - j)]
                v[yoko][i + (length - 1 - j)] = 0
        return v


def fold_up(v, length):
    global white_up
    for i in range(white_up, -1, -1):
        if not any(v[i]):
            white_up -= 1
            continue
        for j in range(length - 1, -1, -1):
            # print(
            #     "i: {} j: {} length: {} i-j: {} i-j-length: {}".format(
            #         i, j, length, i - (length - 1 - j), i - j - length
            #     )
            # )
            v[i - j - length] = list(
                map(add, v[i - j - length], v[i - (length - 1 - j)])
            )
            v[i - (length - 1 - j)] = [0] * len(v[i - j])
        return v


def cut_cut_cut(v):
    global white_right
    global white_up
    for i in range(len(v) - 1, -1, -1):
        if not any(v[i]):
            continue
        white_up = i
        break
    for i in range(len(v[0])):
        if not any(list(zip(*v))[i]):
            continue
        white_right = i
        break


while True:
    n, m, t, p = map(int, input().split())
    if n == 0 and m == 0 and t == 0 and p == 0:
        break
    origami = [[0] * 500 for _ in range(500)]
    for i in range(m):
        for j in range(n):
            origami[len(origami) - 1 - i][j] = 1
    white_right = 0
    white_up = len(origami) - 1
    # print(*origami, sep="\n")
    for i in range(t):
        d, c = map(int, input().split())
        if d == 1:
            origami = fold_right(origami, c)
        else:
            origami = fold_up(origami, c)
        # print(d, c)
        # print(*origami, sep="\n")

    cut_cut_cut(origami)
    for i in range(p):
        x, y = map(int, input().split())
        print(origami[white_up - y][white_right + x])


Measured memory_bytes: 9736
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(void){
    while(1){
        ll t=0,n;cin>>t;
        if(t==0)break;
        cin>>n;
        ll time=0;
        ll s[n],f[n];
        rep(i,0,n){
          ll s,f;
            cin>>s>>f;
            time+=f-s;
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
    
}


Measured memory_bytes: 3096
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int H, W, N;
vector<string> original_field;
vector<string> field;

int dh[] = {1, 0};
int dw[] = {0, 1};

inline bool in_field(int h, int w){
    return 0<=h&&h<H && 0<=w&&w<W;
}

bool vanish(){
    //?¶?????????????true?????????
    vector<vector<int>> del_field(H, vector<int>(W));
    
    bool updated = false;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(field[h][w] == '.') continue;
            
            char color = field[h][w];
            for(int d=0; d<2; d++){
                if(del_field[h][w]>>d&1) continue;
                
                int l = 1;
                while(in_field(h+dh[d]*l, w+dw[d]*l) && field[h+dh[d]*l][w+dw[d]*l] == color) l++;
                if(l < N) continue;
                
                for(int i=0; i<l; i++){
                    del_field[h+dh[d]*i][w+dw[d]*i] |= 1<<d;
                    updated = true;
                }
            }
        }
    }
    
    if(updated)
        for(int h=0; h<H; h++)
            for(int w=0; w<W; w++)
                if(del_field[h][w])
                    field[h][w] = '.';
    
    return updated;
}

void down(){
    for(int w=0; w<W; w++){
        int top = -1;
        for(int h=H-1; h>=0; h--){
            if(field[h][w] == '.') continue;
            if(top >= 0)
                top--;
            else{
                int hi = h+1;
                while(hi < H && field[hi][w] == '.') hi++;
                top = hi-1;
            }
            swap(field[top][w], field[h][w]);
        }
    }
}

bool check(){
    down();
    while(vanish())
        down();
    
    for(int h=0; h<H; h++)
        for(int w=0; w<W; w++)
            if(field[h][w] != '.')
                return false;
    
    return true;
}

string solve(){
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int nh = i, nw = j+1;
            if(!in_field(nh, nw)) continue;
            
            field = original_field;
            swap(field[i][j], field[nh][nw]);
            if(check())
                return "YES";
            
        }
    }
    return "NO";
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    cin>>H>>W>>N;
    original_field = vector<string>(H);
    for(string &r: original_field) cin >> r;
    
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
int a,b,k;
int main(){
	cin>>a>>b>>k;
	if(b-a+1<=2*k){
	for(int i=a;i<=b;i++)printf("%d\n",i);
	}
	else {
		for(int i=a;i<=a+k-1;i++)printf("%d\n",i);
		for(int i=b-k+1;i<=b;i++)printf("%d\n",i);
	}
}


Measured memory_bytes: 256