akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll n;
	scanf("%lld",&n);
	ll a[n];
	scanf("%lld",&a[0]);
	for(int i=1;i<n;i++){
		scanf("%lld",&a[i]);
		a[0]=__gcd(a[0],a[i]);
		
	}
	printf("%lld\n",a[0]);
}


Measured memory_bytes: 4484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

map<string, ll> m{};

int main()
{
  ll N;
  cin >> N;
  rep(i, N) {
    string a;
    cin >> a;
    if(m[a] == 0) ++m[a];
  }
  cout << m.size() << "\n";
}


Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
int N;
double get(vector<vector<vector<double>>>& m,int a,int b,int c){
  if(a < 0 or b < 0 or c < 0) return 0;
  if(a == 0 and b == 0 and c == 0) return 0;
  if(m[a][b][c] != 0) return m[a][b][c];
  int tot = a+b+c;
  m[a][b][c] = a*get(m,a-1,b,c)/tot + b*get(m,a+1,b-1,c)/tot + c*get(m,a,b+1,c-1)/tot + 1.0*N/tot;
  return m[a][b][c];
}
int main(){
  cin >> N;
  int a;
  vector<int> A(4);
  for(int i = 0; i < N; ++i){
    cin >> a;
    ++A[a];
  }
  vector<vector<vector<double>>> m(N+1,vector<vector<double>>(N+1,vector<double>(N+1)));
  cout << fixed << setprecision(10) << get(m,A[1],A[2],A[3]);
  return 0;
}

Measured memory_bytes: 219008
#include<bits/stdc++.h>
#define fail {puts("-1");return 0;}
using namespace std;
char s[100005];
int main()
{
    int n;
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n/2;i++)if(s[i]!=s[n-i])fail
    if(s[1]=='0'||s[n]=='1')fail
    int now=2;
    printf("1 2\n");
    for(int i=2;i<n;i++)
    {
        printf("%d %d\n",now,i+1);
        if(s[i]=='1')now=i+1;
    }
    return 0;
}

Measured memory_bytes: 3896
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
using namespace std;


int main(){
  int n, m;
  int i, j, k, l;
  string s;
  cin >> s;

  n = 0;

  for(i=0; i < 3 ;i++){
    if(s[i] == '1'){
      n++;
    }
  }

  cout << n << endl;


  return 0;
}


Measured memory_bytes: 256
n = int(input())
robots = []
for _ in range(n):
    x, l = map(int, input().split())
    robots.append([x-l, x+l])

robots = sorted(robots, key=lambda x: x[1])

cnt = 1
current_end = robots[0][1]
for i in range(1, n):
    if current_end <= robots[i][0]:
        cnt += 1
        current_end = robots[i][1]

print(cnt)

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

using namespace std;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define N 410
ll f[N][N],n,a[N];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int l=0;l<n;l++){
     for(int i=0;i+l<n;i++){
      ll j=i+l;
      if(l==0){
       f[i][j]=0;   
      }
      else{
       f[i][j]=1e17;
       ll sum=0;
       for(int k=i;k<=j;k++)sum+=a[k];
       for(int k=i;k<j;k++){
        chmin(f[i][j],f[i][k]+f[k+1][j]+sum);   
       }
      }
     }
    }
    cout<<f[0][n-1]<<endl;
 return 0;   
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i<n;i++)
#define MAX 105000
using namespace std;

int main (){
	/*for(int k = 1; k<MAX;k++)
	{
		if(PrimeCheck(v[k+1]))
		{
			//cout << v[k+1] << " ";
			v2[d] = v[k+1];
			d++;
		}
	}
	//rep(i,d) cout << v2[i] << " ";
	//cout << d << endl;*/
	int number;
	while(cin >> number,number)
	{


		int counter = 0;
		vector<bool>v(MAX+1,0);
		vector<int>v2(MAX,0);
		rep(i,MAX)
			v[i+1] = true;
		long long answer = 0;
		int lim = (int)sqrt(number);
		int d = 0;
//		cout << lim <<" ";
		for(int i = 2; i<MAX; i++)
		{
			if(v[i])
			{
				for(int j = 2; j <MAX/i;j++)
				{
					v[j*i]  = false;
					//cout << " " << i << "i*j=  " << i*j;
				}
				v2[d] = i;
				d++;
			}	
		}
		//rep(i,number) cout << v[i+1] << " ";
		for(int i = 2; i<MAX+1;i++)
		{	
			if(v[i])
			{
				answer+=i;
				counter++;
				//cout << " " << i;
				if(counter == number)
					break;
			}
			
		}
		cout  /*<< " answer is "*/ << answer << endl;
	    
	}
	return 0;
}

Measured memory_bytes: 3424
from collections import Counter

n = int(input())
d = list(map(int, input().split()))

minD = min(d)
maxD = max(d)
c = Counter(d)

abc = 0
arc = n
ans = 0

for i in range(minD, maxD+1):
    abc += c[i-1]
    arc -= c[i-1]
    
    if abc == arc:
        ans += 1

print(ans)

Measured memory_bytes: 14812
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;
    ans += string(tx - sx, 'R');
    ans += string(ty - sy, 'U');
    ans += string(tx - sx, 'L');
    ans += string(ty - sy, 'D');
    ans += 'D';
    ans += string(tx - sx + 1, 'R');
    ans += string(ty - sy + 1, 'U');
    ans += "LU";
    ans += string(tx - sx + 1, 'L');
    ans += string(ty - sy + 1, 'D');
    ans += 'R';
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int d[10000];

int main(){
	
	while(1){
		
		int n,m;
		cin  >> n >> m;
		
		if(n==0 and m==0) break;
		
		pair<int,int> p[n];
		
		for(int i=0;i<n;i++){
			cin >> p[i].second >> p[i].first;
		}
		sort(p,p+n);
		for(int i=n-1;i>=0;i--){
			if(p[i].second<m){
				m-=p[i].second;
				p[i].second=0;
			}else{
				p[i].second-=m;
				m=0;
			}
		}
		int sum=0;
		for(int i=0;i<n;i++){
			sum+=(p[i].first*p[i].second);
		}
		cout << sum << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3092
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

lst = inputs[1]
sum = lst.inject(:+)

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

pd lst
pd sum

arr = []
acc = 0
lst.each do |l_i|
  acc += l_i
  arr << ((sum - acc) - acc).abs
end

pd arr

puts arr.min


Measured memory_bytes: 1788
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    print("x"*len(s))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str;
	string s;

	cin >> str >> s;
	sort(str.begin() , str.end());
	sort(s.begin() , s.end() , greater<int>());

	if(s > str)
	{
		cout << "Yes";
	}
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
n=10000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    try:n=int(input())
    except:break
    c=0
    for i in range(2,n):
        if (p[i],p[n-i+1])==(1,1):c+=1
    print(c)

Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
int a,b;
cin >> a >> b;

cout << 6-a-b << endl;

return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  ll x;
  cin >> x;
  ll ans = 0ll;
  ans += (x / 500ll) * 1000ll;
  ll re = x % 500ll;
  ans += (re / 5ll) * 5ll;
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
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();
		int C = sc.nextInt();
		int K = sc.nextInt();


    if(K<=A){
        System.out.println(K);
    }else if(K<=A+B){
        System.out.println(A);
    }else if(K>=A+B+C){
        System.out.println(A-C);
    }else{
        System.out.println(A-(K-(A+B)));
    }
	}
    }

Measured memory_bytes: 35580
#include<stdio.h>
int main(){
  int large_a=0;
  int large_b=0;
  int min_1=0;
  int min_2=0;
  int max=0;
  scanf("%d %d",&large_a,&large_b);
  min_1=large_a-large_b;
  if(min_1>0)
  {
    min_2=min_1-1;
    if(min_2>0)
    {
      max=large_a*2-1;
    }else 
    {
      max=large_a+large_b;
    }
  }else
  {
    min_2=large_b-large_a-1;
    if(min_2>0)
    {
      max=large_b*2-1;
    }else
    {
      max=large_a+large_b;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010,INF=2000000000;
ll a[N];
ll dp[N][2];
ll n;
template<class T>
T mx(T a,T b){
	if(a>b) return a;
	return b;
}
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(ll i=0;i<=n;++i){
		for(ll j=0;j<3;++j){
			dp[i][j]=-(ll)INF*INF;
		}
	}
	if(n&1){
		dp[1][0]=a[1];
		for(ll i=3;i<=n;i+=2) dp[i][0]=dp[i-2][0]+a[i];
		dp[2][1]=a[2];
		for(ll i=4;i<=n;i+=2) dp[i][1]=mx(dp[i-2][1],dp[i-3][0])+a[i];
		dp[3][2]=a[3];
		for(ll i=5;i<=n;i+=2) dp[i][2]=mx(mx(dp[i-2][2],dp[i-3][1]),dp[i-4][0])+a[i];
		printf("%lld",mx(mx(dp[n][2],dp[n-1][1]),dp[n-2][0]));
	}
	else{
		dp[1][0]=a[1];
		for(ll i=3;i<=n;i+=2) dp[i][0]=dp[i-2][0]+a[i];
		dp[2][1]=a[2];
		for(ll i=4;i<=n;i+=2) dp[i][1]=mx(dp[i-2][1],dp[i-3][0])+a[i];
		printf("%lld",mx(dp[n][1],dp[n-1][0]));
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<ll>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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(a>b){a=b;return true;}return false;}

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
	int n,k;
	cin>>n>>k;
	cout<<!!(n%k)<<endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
  string s,sout;
  int i;
  cin>>s;

  for(i=0;i<s.length();i++){
    if(s[i]=='B'){
      if (!(sout.empty())) {
        sout.pop_back();
      }
    }
    else{
      sout+=s[i];
    }
  }

  cout<<sout;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T semiopenSum(int l, int r) {
        // [l,r)の半開区間
        return sum(r-1) - sum(l-1);
    }
};  // BIT<int> bit(N);

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    BIT<ll> bit(N);
    rep(i, N) bit.add(i, A[i]);
    rep(i, Q) {
        int q, a, b;
        cin >> q >> a >> b;
        if (q == 0) {
            bit.add(a, b);
        } else {
            ll sum = bit.semiopenSum(a, b);
            cout << sum << '\n';
        }
    }
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 10176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 200010;

int ft[maxn];
int n,k;

int ls(int x) {
	return x & (-x);
}

void up(int x) {
	for (;x <= n;x += ls(x)) ft[x]++;
}

int query(int x) {
	int res = 0;
	for (;x; x -= ls(x)) res += ft[x];
	return res;
}

int32_t main() {
	FAST
	cin >> n >> k;
	vector <pi> v;
	int curs = 0;
	for (int i =1;i<=n;i++) {
		int x; cin >> x;
		curs += x;
		v.push_back(pi(curs - i*k,i));
		//cout << i << " " << x-i*k << "\n";
	}
	sort(v.begin(),v.end());
	int ans = 0;
	for (auto cur: v) {
		if (cur.f >= 0) ans++;
		ans += query(cur.s);
		up(cur.s);
		//cout << cur.f << " " << cur.s << " " << ans << "\n";
	}
	
	cout << ans;
	
}









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

int main(){
	long long n, ans = 1e9;
	cin >> n;
	for(long long a = 1; a * a <= n; a++) if(n % a == 0){
		ans = min(ans, max((long long)(log10(a) + 1), (long long)(log10(n / a) + 1)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int  A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A <= C && C <= B && B <= D){
        cout << B - C << endl;
    }
    else if (C <= A && B <= D){
        cout << B - A << endl;
    }
    else if(A <= C && D <= B){
        cout << D - C << endl;
    }
    else if (C <= A && A <= D && D <= B){
        cout << D - A << endl;
    }
    else if (D <= A || B <= C){
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    cnt += 1
    if cnt == 3:
      break
  else:
    cnt = 0
if cnt >= 3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 62436
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;



int main(){
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    long long P, Q;
   
    P = (A1-B1) * T1;
    Q = (A2-B2) * T2;
    if (P<0) {
        P = -P;
        Q = -Q;
    }
    if (P+Q==0) {
        cout << "infinity" << endl;
        return 0;
    }
    if (P+Q>0) {
        cout << "0" << endl;
        return 0;
    }
    
    long long v = 2*(P/(-Q-P))+1;
    if (P%(-Q-P)==0) {
        v--;
    }
    
    cout << v << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y;
  cin >> x >> y;
  ll d=__gcd(x,y);
  if(d==y) {
    pr(-1);
    return;
  }
  pr(x);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c+max({a,b,c})*9<<endl;
	
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long

using namespace std;

const int N=100010;

int n;
int a[N],b[N],c[N];
ll t[N],s[N];

int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]);
    for (int i=1;i<=n;++i) scanf("%d",&b[i]);
    for (int i=1;i<=n;++i) scanf("%d",&c[i]);
    sort(a+1,a+n+1);sort(b+1,b+n+1);sort(c+1,c+n+1);
    for (int i=1;i<=n;++i) {
        t[i]=n-(upper_bound(c+1,c+n+1,b[i])-c)+1;
    }
    for (int i=n;i>=1;--i) s[i]=s[i+1]+t[i];
    ll ans=0;
    for (int i=1;i<=n;++i) ans+=s[upper_bound(b+1,b+n+1,a[i])-b];
    printf("%lld\n",ans);
    system("pause");
}


Measured memory_bytes: 3072
import queue
K=int(input())
q = queue.Queue()

for i in range(1,10):
    q.put(i)

for j in range(0,K-1):
    x=q.get()
    #print(x)
    xtail=x%10
    if xtail!=0:
        q.put(x*10+xtail-1)
    q.put(x*10+xtail)
    if xtail!=9:
        q.put(x*10+xtail+1)

print(q.get())

Measured memory_bytes: 13136
#include<bits/stdc++.h>
using namespace std;
int main(){
    string w;
    int n=100000;
    string t;
    cin >> w;
    int count=0;
    for(int i=0;i<n;i++){
        cin >> t;
        if(t=="END_OF_TEXT"){
            n=i;
            break;
        }
        for(int j=0;j<t.length();j++){
            if(t[j]>='A' && t[j]<='Z') t[j]=t[j]+32;
        }
        if(t==w) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3144
def solve(x):
	res = 0
	for i in xrange(1,x+1):
		if x%i == 0:
			res += 1
	return res

n = input()
ans = 0
for i in xrange(1,n+1):
	if solve(i) == 8 and i&1:
		ans += 1
print ans


Measured memory_bytes: 29164
#include <cstdio>
#define int long long
int n;
long long ans,a[200005],sum;
signed main(){
  scanf("%lld",&n);
  for(int i=1; i<=n; i++){
    scanf("%lld",&a[i]);
    if(a[i]==0){
      n--;
      i--;
      continue;
    }
    a[i]%=1000000007;
    sum+=a[i];
    sum%=1000000007;
  }
  for(int i=1; i<n; i++){
    sum-=a[i]%1000000007;
    if(sum<0) sum+=1000000007;
    ans=(ans+(sum*a[i]+1000000007)%1000000007)%1000000007;
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 3236
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = [True]*N
C = [1]
now = 0
while B[now]:
    B[now] = False
    now = A[now] - 1
    C.append(now+1)
start = C.index(C[-1])
D = C[start:-1]
L = len(D)
if K < start:
    print(C[K])
else:
    K -= start
    K %= L
    print(D[K])

Measured memory_bytes: 95336
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll x,a,b; cin>>x>>a>>b;
    if(b-a<=0)cout<<"delicious"<<endl;
    else if(b-a<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}





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

using namespace std;

typedef long long ll;

vector< vector<int> > G;
int dist[2][100100];
ll cnt[2][100100];
int N, M, s, t;

void bfs(int v)
{
  int c = v == s ? 0 : 1;
  queue<int> que;
  dist[c][v] = 0;
  que.push(v);
  while(!que.empty()) {
    int now = que.front(); que.pop();
    for(int i = 0; i < G[now].size(); i++) {
      int to = G[now][i];
      if(!~dist[c][to]) {
	dist[c][to] = dist[c][now] + 1;
	que.push(to);
      }
    }
  }
}

int main()
{
  cin >> N >> M >> s >> t;
  --s, --t;
  G.resize(N);
  for(int i = 0; i < M; i++) {
    int x, y; cin >> x >> y;
    --x, --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  memset(dist, -1, sizeof(dist));
  memset(cnt, 0, sizeof(cnt));  
  bfs(s); bfs(t);  
  for(int i = 0; i < N; i++) {
    cnt[0][dist[0][i]]++;
    cnt[1][dist[1][i]]++;
  }
  ll ans = 0LL;
  for(int i = 0; i < dist[0][t]-1; i++) {
    ans += cnt[0][i]*cnt[1][dist[0][t]-i-2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11796
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string A,B;
  cin>>A>>B;
  string ans;
  for(int i=0;i<N;i++){
    cout<<A.at(i)<<B.at(i);
  }
  return 0;
}


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

int main(){
	set<string> dic;
  	int n; cin >> n;
  	
  	for(int i = 0; i < n;i++){
    	string s; cin >> s;
      	dic.insert(s);
    }
  	
  	cout << dic.size() << endl;
} 

Measured memory_bytes: 19228
#include<stdio.h>
 
int main(int argc, char const *argv[]) {
  int n,m,l,i,j,k;
  int a[100][100]={0},b[100][100]={0};
  long long int c[100][100]={0};
  scanf("%d %d %d", &n, &m, &l);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  //printf("\n");
  for (i = 0; i < m; i++) {
    for (j = 0; j < l; j++) {
      scanf("%d", &b[i][j]);
    }
  }
  //printf("\n");
  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      for (k = 0; k < m; k++) {
          c[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      printf("%lld", c[i][j]);
      if (j < l-1) {
        printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

struct State{
    // (y,x), floor f, bit b
    int y,x,f,b;
};

inline int switch_num(char c){
    if('a'<=c && c<='j') return c-'a';
    if('A'<=c && c<='J') return c-'A';
    return -1;
}

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

const int INF = 19191919;
const int N = 50, M = 1<<10;
int d[N][N][2][M];

int main(){
    int w,h;
    cin >>w >>h;

    vector<string> m(h);
    rep(i,h) cin >>m[i];

    int s;
    cin >>s;
    vector<vector<string>> ms(s);
    rep(i,s){
        ms[i] = vector<string>(h);
        rep(j,h) cin >>ms[i][j];
    }

    rep(i,N)rep(j,N)rep(k,2)rep(l,M) d[i][j][k][l] = INF;

    pi start, goal;
    rep(i,h)rep(j,w){
        if(m[i][j] == '%') start = {i,j};
        if(m[i][j] == '&') goal = {i,j};
    }

    auto IN = [&](int y, int x){ return 0<=y && y<h && 0<=x && x<w; };
    auto FLOOR = [&](int y, int x, int bit){
        int ret = 0;
        if(m[y][x]=='^' || ('A'<=m[y][x] && m[y][x]<='J')) ret = 1;
        rep(i,s)if(bit>>i&1){
            if(ms[i][y][x]=='*') ret = !ret;
        }
        return ret;
    };

    queue<State> que;
    d[start.fi][start.se][0][0] = 0;
    que.push({start.fi, start.se, 0, 0});
    while(!que.empty()){
        State c = que.front();
        que.pop();

        // move another floor
        if(m[c.y][c.x]=='|'){
            State nc(c);
            nc.f = !nc.f;
            if(d[nc.y][nc.x][nc.f][nc.b] > d[c.y][c.x][c.f][c.b]+1){
                d[nc.y][nc.x][nc.f][nc.b] = d[c.y][c.x][c.f][c.b]+1;
                que.push({nc});
            }
        }

        // operate switch
        int sn = switch_num(m[c.y][c.x]);
        if(sn!=-1){
            State nc(c);
            nc.b ^= (1<<switch_num(m[c.y][c.x]));
            if(ms[sn][c.y][c.x] == '*') nc.f = !nc.f;

            if(d[nc.y][nc.x][nc.f][nc.b] > d[c.y][c.x][c.f][c.b]+1){
                d[nc.y][nc.x][nc.f][nc.b] = d[c.y][c.x][c.f][c.b]+1;
                que.push({nc});
            }
        }

        // move adjacent
        rep(i,4){
            State nc(c);
            nc.y += dy[i];
            nc.x += dx[i];
            if(!IN(nc.y, nc.x) || m[nc.y][nc.x]=='#') continue;

            if(m[nc.y][nc.x]=='|' || nc.f==FLOOR(nc.y,nc.x,nc.b)){
                if(d[nc.y][nc.x][nc.f][nc.b] > d[c.y][c.x][c.f][c.b]+1){
                    d[nc.y][nc.x][nc.f][nc.b] = d[c.y][c.x][c.f][c.b]+1;
                    que.push({nc});
                }
            }
        }
    }

    int ans = INF;
    rep(i,2)rep(j,1<<s) ans = min(ans, d[goal.fi][goal.se][i][j]);
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 23692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	cout<<(n-2)*180<<'\n';
	
	return 0;
}


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

using namespace std;

int main()
{
  int H, W;

  cin >> H >> W;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      string S;
      cin >> S;
      if(S == "snuke") {
        cout << (char) ('A' + j) << i + 1 << endl;
        return (0);
      }
    }
  }


}


Measured memory_bytes: 256
s = int(input())
mod = 10**9 + 7

dp = [0]*(s+1)
dp[0] = 1

x = 0
for i in range(1,s+1):
    for j in range(0,(i-3)+1):
        dp[i] += dp[j]
        dp[i] %= mod
    
print(dp[s])

Measured memory_bytes: 9128
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] a = new int[7];
        for (int i = 1; i < 7; i++) {
            a[i] = scanner.nextInt();
        }

        char[] b = scanner.next().toCharArray();
        for (int i = 0; i < b.length; i++) {
            if (b[i] == 'N') {
                a[0] = a[1];
                a[1] = a[2];
                a[2] = a[6];
                a[6] = a[5];
                a[5] = a[0];
            } else if (b[i] == 'S') {
                a[0] = a[1];
                a[1] = a[5];
                a[5] = a[6];
                a[6] = a[2];
                a[2] = a[0];
            } else if (b[i] == 'E') {
                a[0] = a[1];
                a[1] = a[4];
                a[4] = a[6];
                a[6] = a[3];
                a[3] = a[0];
            } else {
                a[0] = a[1];
                a[1] = a[3];
                a[3] = a[6];
                a[6] = a[4];
                a[4] = a[0];
            }
        }
        System.out.println(a[1]);

    }

}



Measured memory_bytes: 26212
/*input
12 100
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main() {
	IOS;
	int a,b;
	cin>>a>>b;
	if(a>=13){
		cout << b << endl;
	}
	else if(a >5){
		cout << b/2 << endl;
	}
	else
		cout << 0 ; 
return 0;
}


Measured memory_bytes: 256
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>

#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

#include<fstream>
#include<chrono>
using namespace std;
// using namespace __gnu_pbds;

#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define maxheap      priority_queue<int>
#define minheap      priority_queue<int,vi,greater<int>>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MOD = 1e9+7;
ld EPS = 1e-12;

signed main()
{
    VR46 ofstream out("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU TEST CASE BNAKE TEST KRLE
    // OUT OF BOUNDS BHI DEKHLIO CHUTIYE
    int t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        int n;
        cin>>n;
        if( n&1 ) return cout<<"0\n", 0;
        int ans = 0;
        ans += n/10;
        int f = 50;
        while( f<=n )
        {
            ans += n/f;
            f *= 5;
        }
        cout<<ans<<endl;
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;

    // *( hsh.find_by_order(k) ) kth smallest, from 0
    // hsh.order_of_key(k) num of ele str less than k
    // change less to less_equal for multiset pbds
}

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

int main() {
  int a, b, cnt = 0;
  while (cin >> a >> b){
    int cnt = 0, n = a + b;
    while (n) {
      cnt++;
      n /= 10;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3044
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int k,j,count=0;
    i=1;
    for(;count<n;){
        j=a[i];count++;
        if(j==2){printf("%d\n",count);return 0;}

        i=a[j];count++;
        if(i==2){printf("%d\n",count);return 0;}


    }
    printf("-1\n");
        return 0;
}


Measured memory_bytes: 2088
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t
const double EPS = 1e-8;

int main()
{
    int n, d, i, j, ans = 0;
    cin >> n >> d;
    vector<vector<int>> v(n, vector<int>(d));
    for(i = 0; i < n; ++i)
        for(j = 0; j < d; ++j)
            cin >> v[i][j];
    for(i = 0; i < n; ++i)
        for(j = i+1; j < n; ++j)
        {
            int x = 0;
            for(int k = 0; k < d; ++k)
                x += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            int rx = sqrt(x) + EPS;
            ans += x == rx*rx;
        }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
  
  if((N[0]==N[1]&&N[1]==N[2])
     ||(N[1]==N[2]&&N[2]==N[3]))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << ':' << x << endl;
#define loop3(i, k, n) for(i=k; i<n; i++)
#define ll  long long 
#define loop(i,n) for(int i=0;i<n;i++)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define v1d vector<ll> 
#define v2d vector<vector<ll>>

const int INF = 1e9 +5 ;
void max_self(ll &a, ll b)
{
    a = max(a,b);
}
int main()
{
    ll n,W;
    cin>>n>>W;
    v1d v(n),w(n);
    //v2d dp(n,vector<ll>(W+1));
    ll dp[n+1][W+1] = {};
    loop(i,n)
    {
        cin>>w[i]>>v[i];
    }
    loop(j,W+1)
    dp[0][j] = 0;
    for(ll i = 1; i<=n;i++)
    {
        for(ll j = 0; j<=W; j++)
        {
            if(w[i-1] > j)
            dp[i][j] = dp[i-1][j];
            else
            {
                dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j - w[i-1]]);
            }
            
        }
        //deb(i);
    }
    cout<<dp[n][W];

    
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<tuple>
#include<utility>
#include<stdlib.h>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	int N, M;
	cin >> N >> M;

	bool broken[N + 1] = {};
	int a;
	rep(i,0,M) {
		cin >> a;
		broken[a] = true;
	}

	LL ans = 0, prev1 = 1, prev2 = 0;
	rep(i,1,N+1) {
		if (broken[i]) {
			ans = 0;
		}
		else {
			ans = (prev1 + prev2) % 1000000007;
		}
		prev2 = prev1;
		prev1 = ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n,h,sum = 0;
    cin >> h >> n;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
    }
    if(h <= sum) dunk("Yes");
    else dunk("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<"ABC"<<n<<endl;
	
	
	

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static public void main (String args[]){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a>b){
			if(b>c)
				System.out.println(c+" "+b+" "+a);
			else{
				if(a>c)
					System.out.println(b+" "+c+" "+a);
				else
					System.out.println(b+" "+a+" "+c);
			}
		} else {
			if(a>c)
				System.out.println(c+" "+a+" "+b);
			else{
				if(b>c)
					System.out.println(a+" "+c+" "+b);
				else
					System.out.println(a+" "+b+" "+c);
			}
		}
	}
}

Measured memory_bytes: 26216
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    string str;
    cin>>str;
    
    if(str=="ABC")
      cout<<"ARC"<<endl;
    else if(str=="ARC")
      cout<<"ABC"<<endl;
    
    return 0;
  
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string s = cin.nextString();
        int K = cin.nextInt();

        List<string> S = new List<string>();
        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 1; j <= 5; j++)
            {
                if (i + j <= s.Length)
                {
                    S.Add(s.Substring(i, j));
                }
            }
        }

        string[] distinct = S.Distinct().ToArray();
        Array.Sort(distinct);
        Console.WriteLine(distinct[K - 1]);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 15456
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
     t=1;
    while (t--)
    {
        ll n, f=0;
        cin>>n;
        vl v1(n,0),v2(n,0);
        flu(i,0,n)
        {
            cin>>v1[i]>>v2[i];
        }
        flu(i,0,n)
        {
            if(v1[i]==v2[i])
            {
                ll c=1;
                flu(j,i+1,i+3)
                {
                    if(v1[j]==v2[j])
                    c++;
                    if(c==3)
                    {
                        f=1;
                        break;
                    }
                }
            }
            if(f==1)break;
        }
        if(f==1)cout<<"Yes"<<e;
        else cout<<"No"<<e;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {
  double r;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> r;
  cout << 2*r*3.14159265 << endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli H,M;
  cin >> H >> M;
  if(H==1||M==1){
  cout << 1 << endl;
    return 0;
  }
  if(H%2==0){
  cout << M*(H/2) << endl;
  }
  else
  {
  
  if(M%2==1){
  
    cout << (H/2)*M+M/2+1 << endl;
  
  }
  
    else{
      
    cout << (H/2)*M+M/2 << endl;
  
    }
  
  
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
		int k;
	cin>>k;
	int x=7%k;
	for(int i=1;i<=k;++i){
		if(x==0){
			return cout<<i,0;
		}
		x=(x*10+7)%k;
	}
	cout<<-1;
	return 0;
}
	


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    int ans=x;
    for(int i=0;i<n;i++){
        ans+=(d-1)/A[i]+1;
    }
    cout << ans << endl;
}

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

typedef long long ll;
using namespace std;

int line[100005] = {};

int main()
{

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

    bool match = true;
    if(n % 2 == 1){ //奇数個
        if(line[0] != 1)  match = false; //奇数だと0は絶対1つあるので
            for(int i = 1; i <= n / 2; i++){
                if(line[i * 2] != 2) match = false;
            }
    }else{//偶数個
        for (int i = 0; i < n / 2; i++){
            if(line[i * 2 + 1] != 2) match = false;
        }
    }

    ll ans = 1;
    for(int i = 0; i < n / 2; i++){
        ans = ans * 2 % 1000000007;
    }
    
    if(match == true) cout << ans << endl;
    else cout << '0' << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;



public class Main{

  public static double Ca (double a,int n){
    double aa=1;
    for(int i=0;i<n;i++){
      aa*=a;
    }
    return aa;
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n=scanner.nextInt();
    int k=scanner.nextInt();
    int num=0;
    double ans=0;
    int flg=0;

    //double nn=1/(double)n;

    for(int i=1;i<=n;i++){
      flg=0;
      double nn=1/(double)n;
        num=i;
        while(num<k){
          flg++;
          num*=2;
        }
        for(int j=0;j<flg;j++){
          nn*=0.5;
        }
        ans+=nn;
        //System.out.println(ans);
    }
    System.out.printf("%.12f\n",ans);
  }
}


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


int main(){

    int N;
    cin >> N;


    vector<int> prime;

    for( int i = 3; i <= N; i += 2 ){
        bool div = true;
        for( int j = 3; j < i; j ++ ){
            if( i % j == 0 ){
                div = false;
                break;
            }
        }
        if( div ) prime.push_back( i );
    }

    int ans = 0;

    for( int i = 1; i <= N; i += 2 ){
        int value = i;
        int divisor = 1;
        vector<int> num( prime.size() );
        for( int j = 0; j < prime.size(); j++ ){
            while( value % prime[j] == 0 ){
                value /= prime[j];
                num[j]++;
            }
        }
        for( int j = 0; j < prime.size(); j++ ){
            divisor *= num[j] + 1;
        }
        if( divisor == 8 ) ans++;
    }
    
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256