akhauriyash/Code-Regression huggingface dataset:
import sys

while True:
    n = int(raw_input())
    if n == 0:
        break
    m = int(raw_input())
    M = [[sys.maxint for j in range(n)] for i in range(n)]
    for i in range(n):
        M[i][i] = 0
    for i in range(m):
        a, b, d = map(int, raw_input().split(','))
        M[a][b] = d/100 - 1
        M[b][a] = M[a][b]
    X = set([0])
    Y = set(range(n)[0:])
    cost = 0
    while len(Y) > 0:
        mcost = sys.maxint
        for ex in X:
            for ey in Y:
                if mcost > M[ex][ey]:
                    mcost = M[ex][ey]
                    et = ey
        X.add(et)
        Y.remove(et)
        cost += mcost
    print cost

Measured memory_bytes: 6524
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    rep(i,n){
        if(a[i]<=(ll)1e18/ans) ans*=a[i];
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        stin(s);
        FOR(i,0,2){
                if(s[i]==s[i+1]){
                        sal("Bad")
                        return 0;
                }
        }
        sal("Good")
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define TMAX 1000001
#define PMAX 10001
int main(){
  char T[TMAX],P[PMAX];
  int i,l,m;
   
  scanf("%s",T);
  scanf("%s",P);
   
  l=strlen(T);
  m=strlen(P);
   
  for(i=0;i<l;i++){
    if(strncmp(&T[i],P,m)==0) printf("%d\n",i);
  }
  return 0; 
}  

Measured memory_bytes: 1548
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N, A, B;
	string str;
	cin>>N>>A>>B;
	cin>>str;
	int cnt=0, cnt_b=0;
	for(int i=0; i<N; i++){
		if(str[i]=='a' && cnt<A+B){
			cnt++;
			cout<<"Yes"<<endl;
		}else if(str[i]=='b' && cnt<A+B && cnt_b<B){
			cnt++;
			cnt_b++;
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcnt(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 1005

int a[maxn][maxn];
int n, m;

int main()
{
//	freopen("in.txt", "r", stdin);

	ios::sync_with_stdio(0);
	cin.tie(0);

	ms(a, 0);
	cin >> n >> m;
	Rep(run, m){
		int u, v;
		cin >> u >> v;
		For(i, 1, n) {
			if(a[i][u] && i != u) {
				a[i][v] = 1;
				a[v][i] = 1;
			}
			if(a[i][v] && i != v) {
				a[i][u] = 1;
				a[u][i] = 1;
			}
		}
		if(a[u][u]) a[v][v] = 1;
		if(a[v][v]) a[u][u] = 1;
		a[u][v] = 1;
		a[v][u] = 1;
	}

	int res = 0;
//	For(i, 1, n) cout << a[i][i] << endl;
	For(i, 1, n) For(j, 1, n) if(i < j){
		if(!a[i][j] && !a[j][i] && !a[i][i] && !a[j][j]) {
//			cout << i << " " << j << endl;
			res++;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;









int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,r;
    cin >> a >> b >> c >> d;
    long double pi=acos(-1);
    long double ang=abs(c*1.0/6*pi+d*1.0/60*pi/6-d*1.0/30*pi);
    ang=min(ang,2*pi-ang);
    long double ans=sqrt(a*a+b*b-2*a*b*cos(ang));
    cout << setprecision(20);
    cout << ans << el;
    
    return 0;
}





Measured memory_bytes: 4176
# ABC065B - Trained?
import sys
input = sys.stdin.readline

n = int(input())
lst = list(map(int, [input().rstrip() for _ in range(n)]))
button = lst[0]
count = 0
for _ in range(n):
    count += 1
    if button == 2:
        break
    button = lst[button - 1]
else:
    count = -1
print(count)

Measured memory_bytes: 53212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int h[100005];
vector<int> mem(100005,-1);
int dp(int n);
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    cout<<dp(n)<<"\n";
    return 0;
}
int dp(int n){
    if(n==1){
        mem[1]=0;
        return 0;
    }
    if(n==2){
        mem[2]=abs(h[n-1]-h[n]);
        return abs(h[n-1]-h[n]);
    }
    if(mem[n]<0){
        mem[n]=min(abs(h[n-1]-h[n])+dp(n-1),abs(h[n-2]-h[n])+dp(n-2));
    }
    return mem[n];
}

Measured memory_bytes: 6316
#include<iostream>
#include<cmath>
#include<cctype>
#include<vector>
using namespace std;
int main(){
        int n;
        scanf("%d",&n);
        int h=n/3600;
        //int m=(n-(h*3600))/60;
        int m=n%3600/60;
        int s=n%60;
        printf("%d:%d:%d\n",h,m,s);
        return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  string ans;
  cin >> a >> b >> c;
  if(a==b&&b!=c) ans = "Yes";
  else if(b==c&&c!=a) ans = "Yes";
  else if(a==c&&c!=b) ans = "Yes";
  else ans = "No";
  
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
ans=[]
while true
  m=n%26
  ans<<m
  m=26 if m==0
  break if n<=26
  n=(n-m)/26
end
ord=97
pu ans:ans.to_s
puts ans.map{|a| (ord+(a-1)%26).chr}.join.reverse


Measured memory_bytes: 14432
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

int main() {
	int n[1000], m[1000], p[10][1000],ans=0, i = 0;
	vector<int> v;
	while (cin >> n[i] >> m[i]) {
		if (n[i] == 0)break;
		for (int j = 0; j < n[i]; j++)cin >> p[i][j];
		i++;
	}
	for (int k = 0; k < i; k++) {
		ans = 0;
		v = vector<int>(1,0);
		for (int a = 0; a < n[k]; a++) {
			v.push_back(p[k][a]);
			for (int b = 0; b < n[k]; b++)
				v.push_back(p[k][a] + p[k][b]);
		}
		sort(v.begin(), v.end());
		for (int j = 0; j < v.size(); j++) {
			if (v[j] > m[k])break;
			decltype(v)::iterator itr= upper_bound(v.begin(), v.end(), m[k]-v[j]);
			itr--;
			ans = max(ans, v[j] + *itr);
		}
		cout << ans << endl;
	}
	return 0;
} 

Measured memory_bytes: 10740
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
const int MAXW = 510;
const int MAXH = 510;

int h, w;
int a[MAXH][MAXW];

void solve() {
  vector<PP> v;
  for (int y=0;y<h;y++) {
    if (w == 1 && y < h - 1 && (a[y][0] & 1)) {
      v.push_back(PP(P(y+1, 1), P(y + 2, 1)));
      a[y+1][0]++;
    }
    for (int x=0;x<w-1;x++) {
      int curx = y & 1 ? w - 1 - x : x;
      int nextx = y & 1 ? w - 1 - x - 1 : x + 1;
      if (a[y][curx] & 1) {
        v.push_back(PP(P(y + 1, curx + 1), P(y + 1, nextx + 1)));
        a[y][nextx]++;
      }
      if (x == w - 2 && y < h - 1) {
        if (a[y][nextx] & 1) {
          v.push_back(PP(P(y + 1, nextx + 1), P(y + 2, nextx + 1)));
          a[y+1][nextx]++;
        }
      }
    }
  }

  cout << v.size() << endl;
  for (int i=0;i<v.size();i++) {
    PP& pp = v[i];
    P& p1 = pp.first;
    P& p2 = pp.second;
    cout << p1.first << " " << p1.second << " " << p2.first << " " << p2.second << endl;
  }
}

int main() {
  cin >> h >> w;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      cin >> a[i][j];
    }
  }
  solve();
}


Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
const int INF = 1001001001;

template<class M, class L> struct LazyPropagationSegmentTree
{
	int n;
	int size;
	vector<M> data;
	vector<L> lazy;
	const function<M(M, M)> f_m;
	const M e_m;
	const function<L(L, L)> f_l;
	const L e_l;
	const function<M(M, L)> f;

	LazyPropagationSegmentTree(int n, function<M(M, M)> f_m, M e_m, function<L(L, L)> f_l, L e_l, function<M(M, L)> f) : n(n), f_m(f_m), e_m(e_m), f_l(f_l), e_l(e_l), f(f) {
		size = 1;
		while (size < n) size <<= 1;
		data.assign(size * 2, e_m);
		lazy.assign(size * 2, e_l);
	}

	void init(const vector<M> &init_vals) {
		data.assign(size * 2, e_m);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = f_m(data[2*i], data[2*i+1]);
	}

	void eval(int k) {
		if (lazy[k] == e_l) return;
		if (k < size) {
			lazy[2*k] = f_l(lazy[2*k], lazy[k]);
			lazy[2*k + 1] = f_l(lazy[2*k + 1], lazy[k]);
		}
		data[k] = f(data[k], lazy[k]);
		lazy[k] = e_l;
	}

	void update(int l, int r, L l_prop) {
		update_aux(l, r, l_prop, 1, 0, size);
	}

	void update_aux(int l, int r, L l_prop, int k, int k_l, int k_r) {
		eval(k);
		if (r <= k_l || k_r <= l) return;
		else if (l <= k_l && k_r <= r) {
			lazy[k] = f_l(lazy[k], l_prop);
			eval(k);
		} else {
			update_aux(l, r, l_prop, 2*k, k_l, (k_l + k_r) / 2);
			update_aux(l, r, l_prop, 2*k + 1, (k_l + k_r) / 2, k_r);
			data[k] = f_m(data[2*k], data[2*k + 1]);
		}
	}

	M query(int l, int r) {
		return query_aux(l, r, 1, 0, size);
	}

	M query_aux(int l, int r, int k, int k_l, int k_r) {
		eval(k);
		if (r <= k_l || k_r <= l) return e_m;
		else if (l <= k_l && k_r <= r) return data[k];
		else {
			M vl = query_aux(l, r, k*2, k_l, (k_l + k_r) / 2);
			M vr = query_aux(l, r, k*2 + 1, (k_l + k_r) / 2, k_r);
			return f_m(vl, vr);
		}
	}

	void eval_all() {
		for (int i = 1; i < 2*size; i++) eval(i);
	}

	M val(int idx) {
		return data[size + idx];
	}

	vector<M> val_vec() {
		vector<M> res(n);
		for (int i = 0; i < n; i++) res[i] = data[size+i];
		return res;
	}
};

int main() {
	int h, w;
	cin >> h >> w;
	struct M
	{
		int val, idx, l;
	};
	using L = int;
	M e_m = {-INF, INF, -1};
	L e_l = -INF-1;
	auto f_m = [&](M m1, M m2) -> M {
		if (m1.idx - m1.val < m2.idx - m2.val) return m1;
		else return {m2.val, m2.idx, m1.l};
	};
	auto f_l = [&](L l1, L l2) -> L {
		if (l2 == e_l) return l1;
		return l2;
	};
	auto f = [&](M m, L l) -> M {
		if (l == e_l) return m;
		return {l, m.l, m.l};
	};
	LazyPropagationSegmentTree<M, L> st(w, f_m, e_m, f_l, e_l, f);
	vector<M> init_vals(w);
	for (int i = 0; i < w; i++) {
		init_vals[i] = {i, i, i};
	}
	st.init(init_vals);
	for (int i = 1; i <= h; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		int val;
		if (a == 0) val = -INF;
		else val = st.query(a-1, a).val;
		st.update(a, b, val);
		M q = st.query(0, w);
		int ans = i + q.idx - q.val;
		if (q.val == -INF) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 13316
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    char c;
    cin >> a >> c >> b;
    int x = c;
    if (x == 43) cout << a + b <<"\n";
    else cout << a - b << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;


signed main(){
    ll a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N, M;
int G[310][310];

bool solve(int L) {
	int T[310];
	bool D[310];
	memset(D, 0, sizeof(D));
	int rem = M;
	int r = 0;
	while (rem > 0) {
		r++;
		memset(T, 0, sizeof(T));
		for (int i = 0;i < N;i++) {
			bool ok = 1;
			for (int j = 0;j < M && ok;j++) {
				int k = G[i][j];
				if (D[k] == 0) {
					ok = 0;
					T[k]++;
				}
			}
		}
		bool ck = 1;
		for (int i = 1;i <= M;i++) {
			if (T[i] > L) {
				ck = 0;
				D[i] = 1;
				rem--;
			}
		}
		if (ck) return 1;
	}
	return 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for (int i = 0;i < N;i++) {
    	for (int j = 0;j < M;j++) cin >> G[i][j];
    }
    int s = 0, b = N;
    while (s + 1 < b) {
    	int m = s + (b - s) / 2;
    	if (solve(m)) b = m;
    	else s = m;
    }
    cout << b << endl;
    return 0;
}

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

// 方針: 貪欲で攻める
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    map<int,int> A;
    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if(A.count(tmp)) A[tmp]++;
        else A[tmp] = 1;
    }
    int ans = 0;
    int pair = 0;
    for(auto i = A.begin(); i != A.end(); i++) {
        if( (*i).second % 2 == 1) {
            ans++;
        } else {
            pair++;
        }
    }
    ans += pair - pair % 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int path = 0;
        int pathB = 0;
        StringBuilder res = new StringBuilder();

        for(int i = 0; i < n; i++) {
            if(path < a + b) {
                if(S[i] == 'a') {
                    path++;
                    res.append("Yes\n");
                }
                else if(S[i] == 'b' && pathB < b) {
                    path++;
                    pathB++;
                    res.append("Yes\n");
                }
                else {
                    res.append("No\n");
                }
            }
            else {
                res.append("No\n");
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 41320
N = input()#人数
D, X = input().split()#日、残りチョコ
A = []
for i in range(int(N)):
    A.append(int(input()))

choco = int(X)
for day in range(int(D)):
    for Ai in A:
        if day % Ai == 0:
            choco = choco + 1

print(choco)

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << n*n*n << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    int n,r=0,count=0;
    cin >> n;
    vector<int> x(n);
    string s;
    cin >> s;
    rep(i,n){
        if(s[i]=='R'){
            x[i] = 1;
            r++;
        }
        else x[i] = 0;
    }
    if(r==0){
        cout << 0 << endl;
        return 0;
    }

    rep(i,r){
        if(x[i]==0) count++;
    }
    cout <<count <<endl;


    return 0;
}


Measured memory_bytes: 4376
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy

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

    int N; ll M; cin >> N >> M;
    ll lm = 1;
    ll data[N];
    F0R(i, N) {
        ll cur; cin >> cur; data[i] = cur;
        ll g = __gcd(lm, cur);
        lm = lm * cur / g;
        if (lm >= MX) {
            cout << 0 << endl; return 0;
        }
    }

    ll res = lm / 2;
    F0R(i, N) {
        if (res % data[i] != data[i] / 2) {
            cout << 0 << endl; return 0;
        }
    }

    ll ans = M / lm;
    ll val = M % lm;
    if (val >= lm / 2) ans++;
    cout << ans << endl;

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e4 + 7;
const int D = 107;
const int M = 1e9 + 7;

string k;
int d;
ll f[N][2][D];
bool vis[N][2][D];

void DP(int pos, bool prefix, int mod)
{
     if(vis[pos][prefix][mod]) return;
     vis[pos][prefix][mod] = 1;
     if(pos >= k.size())
     {
         if(mod == 0) f[pos][prefix][mod] = 1;
         else f[pos][prefix][mod] = 0;
         return;
     }
     ll& res = f[pos][prefix][mod];
     int lim = prefix? k[pos] - '0': 9;
     for(int i = 0; i <= lim; ++i)
     {
         int nxt = (mod + i) % d;
         DP(pos + 1, prefix && i == lim, nxt);
         res += f[pos + 1][prefix && i == lim][nxt];
         res %= M;
     }
}

void Enter()
{
     cin >> k >> d;
     DP(0, 1, 0);
     --f[0][1][0];
     if(f[0][1][0] < 0) f[0][1][0] += M;
     cout << f[0][1][0];
}

void Solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 19968
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <cmath>

int main(void)
{
    std::string a, b;
    std::cin >> a >> b;
    std::string c = a + b;
    std::stringstream ss;
    ss << c;
    int d;
    ss >> d;
    double ds = sqrt(d);
    if(ds == double(int(ds)))
        std::cout << "Yes" << std::endl; 
    else
        std::cout << "No" << std::endl; 
    return 0;
}


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

int main() {
  int N;
  string S;
  bool flag = false;
  
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      flag = true;
      break;
    }
  }
  
  if (flag) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


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

typedef long long LL;

int T;
LL a,b,c,d;

inline LL find_min(LL x,LL y,LL z){
	if(x%y>=z) return (x/y+1LL)*y+z;
	else return (x/y)*y+z;
}

inline void solve(){
	cin>>a>>b>>c>>d;
	if(a<b||d<b) {
		puts("No");
		return ;
	}
	if(c>b) {
		puts("Yes");
		return ;
	}
	LL gcd=__gcd(b,d);
	a%=gcd;
	LL tmp=find_min(c,gcd,a);
//	cout<<tmp<<endl;
	if(tmp<b) {
		puts("No");
		return ;
	} else {
		puts("Yes");
		return ;
	}
}

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scan = new Scanner(System.in)) {

			int n = scan.nextInt();
			
			int[] d = new int[n];
			for(int i=0; i<n; i++) {
				d[i] = scan.nextInt();
			}
			
			long ans= 0;
			
			for(int i=0; i<n-1; i++) {
				for(int j=i+1; j<n; j++) {
					ans += d[i]*d[j];
				}
			}
			
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;

namespace AtCorderPractice
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var vs=LnInts();
            if(vs[2]>=vs[0]&&vs[2]<=vs[1]){
                Console.WriteLine("Yes");
            }else{ Console.WriteLine("No"); }
        }

        public static string[] LnStrs()
        {
            var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return vs;
        }
        public static string LnStr()
        {
            var vs = Console.ReadLine().Trim();
            return vs;
        }
        public static int[] LnInts()
        {
            var vs = Console.ReadLine().Trim().Split(new[] {' '},StringSplitOptions.RemoveEmptyEntries);
            var ins = new int[vs.Length];
            for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);
            return ins;
        }
        public static int LnInt()
        {
            var vs = Console.ReadLine().Trim();
            return int.Parse(vs);
        }
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll ans = 0;
	ll a;
	double b, f;
	cin >> a >> b;
	ll w = b*100 + 0.01;

	ans = (a*w) / 100;

	cout << fixed << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

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

int main(){
  int n;
  cin >> n;
  vi p(n);
  int mn = 100000000, cnt = 0;
  rep(i,n){
    cin >> p[i];
    if(mn > p[i]){
      mn = p[i];
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

#define MAX_N 100005
int N, h[MAX_N][3], memo[MAX_N][3];

int main() {
  scanf("%i", &N);
  for (int d = 0; d < N; d++) {
  	for (int c = 0; c < 3; c++) {
  	  scanf("%i", &h[d][c]);
	}
  }
  memset(memo, -1, sizeof memo);
  for (int c = 0; c < 3; c++) {
  	memo[0][c] = h[0][c];
  }
  for (int d = 1; d < N; d++) {
  	for (int c = 0; c < 3; c++) {
  	  int &opt = memo[d][c];
  	  for (int cc = 0; cc < 3; cc++) {
  	    if (cc != c) {
  	      opt = max(opt, memo[d - 1][cc] + h[d][c]);
		  /*
  	      if (d == 1) {
  	        printf("%i %i %i %i\n", memo[d - 1][cc], h[d][c], cc, c);
		  }
		  */
		}
	  }
	}
  }
  /*
  puts("\ndebug");
  for (int d = 0; d < N; d++) {
  	for (int c = 0; c < 3; c++) {
  	  printf("%i ", memo[d][c]);
	}
	puts("");
  }
  puts("end-debug\n");
  */
  int ans = -1;
  for (int c = 0; c < 3; c++) {
  	ans = max(ans, memo[N - 1][c]);
  }
  printf("%i\n", ans);
  
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  string S;
  cin >> N >> S;
  ll cur=0;
  ll minval=0;
  rep(i,N){
    cur += (S[i]=='('?1:-1);
    minval=min(cur, minval);
  }
  string f = "";
  rep(i, abs(minval)){
    f+="(";
  }
  cur=0;
  minval=0;
  rep(i,N){
    cur += (S[N-1-i]==')'?1:-1);
    minval=min(cur, minval);
  }
  string t = "";
  rep(i, abs(minval)){
    t+=")";
  }
  cout << f+S+t;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void base(ll n,ll b){
    ll cnt=0;
    while(n>0){
        n/=b;
        cnt++;
    }
    cout<<cnt<<endl;
}
void convert(ll n,ll b,ll mx){
    ll t=0,r;
    ll p=0;
    while(n>0){
        r=n%b;
        t+=r*(pow(mx+1,p++));
        n/=b;
    }
    base(t,b);
}

void check(ll n,ll b){
    ll t=n,r;
    int mx=0;
    while(n>0){
        r=n%b;
        if(mx<r)mx=r;
        n/=b;
    }
    if(mx==1)base(t,b);
    else convert(t,b,mx);
}
int main() {
    ll n,b;
    while(cin>>n>>b){
        check(n,b);
    }
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while(t-->0) solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int n = scan.nextInt(), k = scan.nextInt(), q = scan.nextInt();
			int[] t = new int[n];
			for(int i = 0; i < q; i++) t[scan.nextInt()-1]++;
			for(int i = 0; i < n; i++) {
				out.println(k -q+t[i] > 0 ? "Yes" : "No");
			}
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
 
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
 
}

Measured memory_bytes: 35596
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


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



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    TSTART();
    int Fa = -1;
    int Lz = -1;
    REP(i,SZ(s)){
      if(s[i] == 'A' && Fa == -1){
	Fa = i;
      }
      if(s[i] == 'Z'){
	Lz = i;
      }
    }
    cout << Lz - Fa + 1 << endl;

    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 720
#include <stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a != b && b != c && c != a){
    printf("%d\n", 3);
  }else if(a != b || b != c || c != a){
    printf("%d\n", 2);
  }else{
    printf("%d\n", 1);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a,b,x;
    cin>>a>>b>>x;
    if(a*a*b/2<=x){
        cout <<setprecision(10)<< 180 * atan((2*(a * a * b - x)) / (a * a * a)) / PI << endl;
    }
    else{
        cout<<setprecision(10)<<180 * atan((b*b*a) / (2*x)) / PI << endl;
    }
}

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

int main(void){

  int first,last,input,i,times;
  times = 0;

  cin >> first >> last >> input;

  for(i=first; i<last+1; i++){
    if(input < i) break;
    if(input % i == 0)
      times++;
  }

  cout << times << endl;

  return 0;

}

Measured memory_bytes: 1164
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const MAX = 1000;
  const c = Array.from(Array(MAX + 1), () => []);

  let i, j, X, Y, xlen, ylen, maxlen;
  while ((X = lines.shift()) && (Y = lines.shift())) {
    xlen = X.length;
    ylen = Y.length;
    for (i = 0; i <= xlen; i++) c[i][0] = 0;
    for (j = 0; j <= ylen; j++) c[0][j] = 0;

    for (i = 1; i <= xlen; i++) {
      for (j = 1; j <= ylen; j++) {
        if (X[i - 1] === Y[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;
        else c[i][j] = Math.max(c[i - 1][j], c[i][j - 1]);
      }
    }
    console.log(c[xlen][ylen]);
  }
})();



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

using namespace std;

int main(){
    int ans=0,N;
    string S;
    cin >> N >> S;
    vector<int> ok(N,0);

    for(int i=1;i<N;i++){
        if(S[i]=='E'){
            ok[0]++;
        }
    }

    for(int i=0;i<N-1;i++){
        if(S[i+1]=='E' && S[i]=='E'){
            ok[i+1] = ok[i]-1;
        }else if(S[i+1]=='W' && S[i]=='W'){
            ok[i+1] = ok[i]+1;
        }else{
            ok[i+1] = ok[i];
        }
    }

    ans = ok[0];

    for(int i=1;i<N;i++){
        ans = min(ans,ok[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
	int N,Q;
	cin >> N >> Q;
	atcoder::dsu D(N);
	rep(i,Q)
	{
		int t,u,v;
		cin >> t >> u >> v;
		if (t == 0)
		{
			D.merge(u,v);
		}
		else
		{
			if (D.same(u,v)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4004
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    k = int(input().strip())
    n = len(s)
    strs = set()
    for i in range(n):
        for j in range(1, k+1):
            strs.add(s[i:min(i+j, n)])
    strs = list(strs)
    # print(sorted(strs))
    print(sorted(strs)[k-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 40560
#include <iostream>
#include <queue>

using namespace std;

const int INFTY=1<<29;

struct State{
	int i,j,c,f;
	State(){}
	State(int i,int j,int c,int f):i(i),j(j),c(c),f(f){}
	bool operator<(const State& s)const{return c<s.c;}
	bool operator>(const State& s)const{return c>s.c;}
};

int toint(char c)
{
	if(c=='S' || c=='T')
		return 0;
	if(c=='X')
		return INFTY;
	return c-'0';
}

int solve(const vector<vector<char> >& cliff,int si,int sj,int sf)
{
	static const int di[]={-2,-1,-1,0,0,0,1,1,2};
	static const int dj[]={1,1,2,1,2,3,1,2,1};
	
	int h=cliff.size(),w=cliff[0].size();
	priority_queue<State,vector<State>,greater<State> > pq;
	pq.push(State(si,sj,0,sf));
	vector<vector<vector<int> > > dp(2,vector<vector<int> >(h,vector<int>(w,INFTY)));
	while(pq.size()){
		State cur=pq.top(); pq.pop();
		if(dp[cur.f][cur.i][cur.j]!=INFTY)
			continue;
		if(cliff[cur.i][cur.j]=='T')
			return cur.c;
		dp[cur.f][cur.i][cur.j]=cur.c;
		for(int k=0;k<9;k++){
			int ni=cur.i+di[k];
			int nj=cur.j+(cur.f?-dj[k]:dj[k]);
			if(ni<0 || h<=ni || nj<0 || w<=nj || cliff[ni][nj]=='X')
				continue;
			int nc=cur.c+toint(cliff[ni][nj]);
			pq.push(State(ni,nj,nc,!cur.f));
		}
	}
	return INFTY;
}

int main()
{
	for(int w,h;cin>>w>>h && w|h;){
		vector<vector<char> > cliff(h,vector<char>(w));
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin>>cliff[i][j];
		int res=INFTY;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				if(cliff[i][j]=='S'){
					res=min(res,solve(cliff,i,j,0));
					res=min(res,solve(cliff,i,j,1));
				}
		cout<<(res==INFTY?-1:res)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1036
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#include <queue>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
int N;
void solve(){
	if(N % 2 == 0)
		cout << 1 / 2.0 << endl;
	else
		cout << (double)(N / 2 + 1) / (double)N << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
		solve();
	return 0;
}


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

int main() {
  int N;
   // 合計点
  int sum = 0;
  cin >> N;

  vector<int> V(N); // N個の宝石の個数データ
  vector<int> C(N); // N個の価値のデータ
  vector<int> a(N);
  vector<int> b(N);

  // 宝石の個数データを受け取る
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }

  // 価値のデータを受け取る
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  
  for (int i = 0; i < N; i++) {
   a.at(i)= V.at(i) - C.at(i);
  }
  
  for (int i = 0; i < N; i++) {
  if (a.at(i) <= 0) {
    a.at(i) = 0 ;
  }
  }
  // 合計点を計算
  for (int i = 0; i < N; i++) {
 
    // ①ここにプログラムを追記
    sum += a.at(i);
 
  }
    cout << sum  << endl;
}

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

using namespace std;

const int MOD = (int) 1e9 + 7;
const int MAXN = (int) 5e5;

string str;

int pi1[MAXN + 1], pi2[MAXN + 1];


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> str;
    n = str.size();
    str = " " + str;
    int k = 0;
    for(i = 2; i <= n; i++) {
        while(k > 0 && str[k + 1] != str[i])
            k = pi1[k];
        if(str[k + 1] == str[i])
            k++;
        pi1[i] = k;
    }
    if(pi1[n] ==  n - 1)
        cout << n << endl << 1;
    else  if(n % (n - pi1[n]) > 0 || n - pi1[n] == n) {
        cout << 1 << endl << 1;
    }
    else {
        for(i = 1; i < n - i + 1; i++)
             swap(str[i], str[n - i + 1]);
        k = 0;
        for(i = 2; i <= n; i++) {
            while(k > 0 && str[k + 1] != str[i])
                k = pi2[k];
            if(str[k + 1] == str[i])
                k++;
            pi2[i] = k;
        }
        //for(i = 1; i <= n; i++)
         //       printf("%d %c %d\n" ,i,str[i],pi2[i]);
        cout << 2 << endl;
        int ans = 0;
        for(i = 1; i < n; i++) {
            if((i % (i - pi1[i]) > 0 || i - pi1[i] == i) && (((n - i) % (n - i - pi2[n - i])) > 0 || n - i - pi2[n - i] == n - i)) {
                ans++;

            }
        }
        cout << ans;
    }
    //cin.close();
    //cout.close();
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fap(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;

// 0.1...cnt-1
inline ll hello_goodbye(ll cnt) {
	return (cnt * (cnt-1)) / 2;
}

int main() {
	FastIO;

	string s;
	cin >> s;

	vector< pair<char, int> > v;
	for(char c : s) {
		if(v.empty() or c != v.back().first) v.push_back(make_pair(c, 1));
		else v.back().second ++;
	}

	int cur = 0;
	ll res = 0;
	for(auto &qq : v) {
		if(qq.first == '<') {
			assert(cur == 0);
			res += hello_goodbye(qq.second + 1);
			cur = qq.second;
		}
		else {
			if(qq.second > cur) res += qq.second - cur;
			res += hello_goodbye(qq.second);
			cur = 0;
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 3352
loop do
  sn, dn = gets.split.map(&:to_i)
  break if sn == 0 && dn == 0

  sdn = dn + 1

  edges = []

  sn.times do
    ds = gets.split.map(&:to_i)
    for j in (0...dn)
      d = ds.shift
      if d > 0
        edges << [d, 0, j + 1, false]
      end
    end
  end

  for i in (1..(dn - 1))
    ds = gets.split.map(&:to_i)
    for j in ((i + 1)..dn)
      d = ds.shift
      if d > 0
        edges << [d, i, j, false]
        edges << [d, j, i, false]
      end
    end
  end

  edges.sort!
  #p edges

  used = [true] + dn.times.map{false}
  nused = 1
  dsum = 0

  while nused < sdn
    for e in edges
      d, i, j = e
      if used[i]
        e[3] = true
        if !used[j]
          used[j] = true
          nused += 1
          dsum += d
          break
        end
      end
    end

    edges.delete_if{|e| e[3]}
  end

  p dsum
end

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i < n; i++)
        cin >> q[i];
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
        vec[i] = i + 1;

    int a = 0, b = 0;
    int cnt = 0;
    do {
        if (vec == p)
            a = cnt;
        if (vec == q)
            b = cnt;
        cnt++;
    } while (next_permutation(vec.begin(), vec.end()));
    OUT(abs(a - b));
}

Measured memory_bytes: 256
class Dice
	def initialize(n=Array.new(6,0))
		@num = n
		@LRRoll = [:u, :b, :d, :f]
		@FBRoll = [:u, :l, :d, :r]
		@UDRoll = [:r, :b, :l, :f]
		reset
	end

	def reset
		@position = { u: @num[0],
									d: @num[5],
									r: @num[2],
									l: @num[3],
									f: @num[4],
									b: @num[1]
		}
	end

	def move(v)
		case v
		when "N"
			Roll(@LRRoll)
		when "S"
			Roll(@LRRoll, -1)
		when "E"
			Roll(@FBRoll)
		when "W"
			Roll(@FBRoll, -1)
		end
	end

	def move_roll(n)
		n.times { Roll(@UDRoll) }
	end

	def Roll(roll, v=1)
		v = -1 if v != 1
		t = @position[roll[0]]
		@position[roll[  0]] = @position[roll[1*v]]
		@position[roll[1*v]] = @position[roll[2*v]]
		@position[roll[2*v]] = @position[roll[3*v]]
		@position[roll[3*v]] = t
	end

	def v_up
		@position[:u]
	end

	def v_down
		@position[:d]
	end

	def v_foward
		@position[:f]
	end

	def v_back
		@position[:b]
	end

	def v_right
		@position[:r]
	end

	def v_left
		@position[:l]
	end

end

n = gets.chomp.split(" ").map &:to_i
d = Dice.new(n)

gets.to_i.times {
	d.reset
	m = gets.chomp.split(" ").map &:to_i
	up, back = m[0], m[1]

	case up
	when d.v_down
		2.times { d.move("N") }
	when d.v_right
		d.move("W")
	when d.v_left
		d.move("E")
	when d.v_foward
		d.move("S")
	when d.v_back
		d.move("N")
	end

  case back
	when d.v_left
		d.move_roll(1)
	when d.v_foward
		d.move_roll(2)
	when d.v_right
		d.move_roll(3)
	end

	p d.v_right
}

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

int main()
{
  	int a,b,c;
	cin >> a >> b >> c;

  int k ;
  cin >> k;
  
  int count = 0;
  
  while(a >= b) {
    b *= 2;
    count ++;
  }
  
  while(b >= c){
    c *= 2;
    count ++;
  }
  
  if (count <= k) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
    return 0;
}

Measured memory_bytes: 3628