akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int indeg[N];
int dp[N];
int vis[N];
int ans;
vector<int>v[N];
void dfs(int s){
	vis[s]=1;
	for(auto i : v[s]){
		indeg[i]--;
		dp[i] = max(dp[i] ,1+dp[s]);
		if(indeg[i]==0){
			dfs(i);
		}
	}
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n,m;
		cin >> n >> m;
		fm{
			int x,y;
			cin>>x>>y;
			v[x].pb(y);
			indeg[y]++;
		}
		fn1{
			if(indeg[i]==0 && !vis[i]){
				dfs(i);
			}
		}
		fn1{
			ans= max(ans,dp[i]);
		}
		cout <<ans ;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 61312
#include <cstdio>

long long N,A,B, x,y;

int main() {
	scanf("%lld %lld %lld", &N, &A, &B);
	for (int i = 1; i < N; i++) {
		scanf("%lld %lld", &x, &y);
		A = (A+x-1)/x*x;
		if (A/x*y < B) {
			B = (B+y-1)/y*y;
			A = B/y*x;
		} else B = A/x*y;
	}
	printf("%lld\n", A+B);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<cstdlib>
#include<time.h>
using namespace std;
int  m,x,y,a[10000];
int main()
{
	cin >> m >> x >> y;
	for (int i = 1; i <= m; i++)
	{
		for (int j = i + 1; j <= m; j++)
		{
			if (j < x && i < x)
			{
				a[j - i]++;
				//cout << i << " " << j <<" 1 "<<j-i<< endl;
			}
			else if (i <=x && j >= y)
			{
				a[j - i - (y - x)+1]++;
				//cout << i << " " << j <<" 2 "<< j - i - (y - x)+1<< endl;
			}
			else if (i >x&& j <= y && i < y)
			{
				int c;
				c = min(j - i, y - j + i - x + 1);
				a[c]++;
				//cout << i << " " << j <<" 3 "<< c<<endl;
			}
			else if (i >=x&& j > y&& i < y)
			{
				int c;
				c = min(j - i, j - y + i - x + 1);
				a[c]++;
				//cout << i << " " << j << " 4 "<< c<<endl;
			}
			else if(i<=x&&j<y)
			{
				int c;
				c = min(j - i, y - j + 1 + x - i);
				a[c]++;
				//cout << i << " " << j <<" 5 " <<c<<endl;
			}
			else if(i>=y)
			{
				a[j - i]++;
				//cout << i << " " << j << " 6 " << j-i << endl;
			}
			
		}
	}
	for (int i = 1; i <= m - 1; i++)
		cout << a[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){
    string a, b;
    int n;
    cin >> n >> a >> b;
    int i = 0, j =0 ;
    int cnt = 0;
    while(i < n || j < n){
        if(cnt%2 == 0) cout << a[i++];
        else cout << b[j++];
        cnt++;
    }
} 
signed main(){  
//  freopen("ii.txt", "w", stdin);
    flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    //goog(tc);
        solve();
    }
}

Measured memory_bytes: 256
#include <stdio.h>
void arry( int *a, int n )
{
int i=0;
int j=0;
int k=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
return ;
}
int main( void )
{
int a[10];
int i=0;
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
arry(a,10);
for(i=0;i<3;i++)
{
printf("%d\n",a[i]);
}
return 0;
}

Measured memory_bytes: 600
use std::*;

#[allow(dead_code)]
fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|a| a.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2d<T: str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, m) = (v[0], v[1]);
    let light: Vec<Vec<usize>> = (0..m).map(|_| read_vec()).collect();
    let p: Vec<usize> = read_vec();
    let ans = (0..1 << n)
        .filter(|i| {
            (0..m).all(|j| {
                let cnt = &light[j][1..]
                    .iter()
                    .filter(|&s| i & (1 << (s - 1)) > 0)
                    .count();
                cnt % 2 == p[j]
            })
        })
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
ll modpow(ll a, ll b, ll m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	ll memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int n, m, a[110];
signed main() {
	cin >> n >> m;
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (a[i] * 4 * m >= sum)cnt++;
	}
	cout << (cnt >= m ? "Yes" : "No") << endl;
	return 0;
}

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

const int MAX = 2005;
int n, k, d[MAX], E[MAX][MAX];
vector <int> g[MAX];
pair <int, int> e[MAX];

int main() {
	scanf("%d%d", &n, &k);

	for(int i = 1; i < n; i++) {
		int a, b; scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
		e[i] = { a, b };
	}

	int ans = INT_MAX;
	for(int r = 1; r <= n; r++) {
		queue <int> q;
		q.push(r);

		for(int i = 0; i <= n; i++)
			d[i] = -1;

		d[r] = 0;

		while(!q.empty()) {
			int u = q.front();
			q.pop();

			for(int v : g[u]) {
				if(d[v] == -1) {
					d[v] = d[u] + 1;
					q.push(v);
				}
			}
		}

		int tot = 0;
		for(int i = 1; i <= n; i++) {
			if(d[i] > k / 2)
				tot++;

			E[r][i] = d[i];
		}

		ans = min(ans, tot);
	}

	for(int i = 1; i < n; i++) {
		int a = e[i].first;
		int b = e[i].second;

		int tot = 0;
		for(int j = 1; j <= n; j++) {
			int bad = 0;

			if(E[a][j] > (k + 1) / 2)
				bad = 1;

			if(E[b][j] > (k + 1) / 2)
				bad = 1;

			tot += bad;
		}

		ans = min(ans, tot);
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16128
#include<iostream>

//関数の宣言
bool Input(int& h, int& w);
void Output(int h, int w);

int main()
{
	int h;
	int w;

	while (Input(h,w)){
		
		Output(h, w);

		std::cout << '\n';
	}

}
//入力関数
bool Input(int& h, int& w){
	std::cin >> h;
	std::cin >> w;

	if (h == 0 && w == 0){
		return false;
	}
	else{
		return true;
	}
}

//出力関数
void Output(int h, int w){
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (i == 0 || i == h-1){
				std::cout << '#';
			}
			else if(j==0||j==w-1){
				std::cout << '#';
			}
			else{
				std::cout << '.';
			}
		}
		std::cout << '\n';
	}
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  long long int sum[n];
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  int ans = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i + 1] <= 2 * sum[i]) {
      ans++;
    } else {
      break;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

const int MOD = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, k;
  cin >> n >> k;
  ll minv = k * (k - 1) / 2;
  ll maxv = 0;
  rep(i, 0, k) { maxv += n - i; }

  ll ans = maxv - minv + 1;
  ans %= MOD;
  rep(i, k, n + 1) {
    minv += i;
    maxv += n - i;
    ans += maxv - minv + 1;
    ans %= MOD;
  }

  cout << ans << endl;
}


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

int main(void) {
	int time;
	cin >> time;
	int second = time % (60 * 60) % 60;
	int minute = time % (60 * 60) / 60;
	int hour = time / (60 * 60);
	cout << hour << ":" << minute << ":" << second << endl;
	return 0;
}


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

using namespace std;

int main(){
  vector<int> v(3);
  
  for(int i=0;i<3;i++){
    cin>>v[i];
  }
  int a,b;
  sort(v.begin(),v.end());
  a=v[2]-v[1];
  b=v[2]-v[0];
  int ans=0;

  if(a%2==0&&b%2==0){
    ans=a/2+b/2;
  }
  else if(a%2!=0&&b%2!=0){
    ans++;
    a--;b--;
    ans+=(a/2+b/2);
  }
  else{
    if(a%2!=0){
      ans++;
      a++;
      ans+=(a/2+b/2);
    }
    else{
      ans++;
      b++;
      ans+=(a/2+b/2);
    }
  }

  cout << ans <<endl;

  return 0;
}



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

int main(){
  int N,C,K;
  cin>>N>>C>>K;
  std::vector<int> T(N);
  for(int i=0;i<N;i++)cin>>T[i];
  sort(T.begin(),T.end());
  int ans=0;
  int busgo=-1;
  int busfm=-1;
  for(int i=0;i<N;i++){
    if(busgo<T[i]||i>busfm+C-1){
      busgo=T[i]+K;
      ans++;
      busfm=i;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vector<pair<ll, pair<ll, ll>>> p(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a+b, make_pair(a, b));
    }
    sort(rall(p));

    ll taka = 0, aoki = 0;
    rep(i, n) {
        if(i%2 == 0) {
            taka += p[i].second.first;
        }
        else {
            aoki += p[i].second.second;
        }
    }
    
    out(taka - aoki);
    re0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
int main(){    
int m, h;    
char cards[256], temp[256], result[256];    
int i, j=0, len;    
while(1){        
scanf("%s", cards);        
len=strlen(cards);       
if(strcmp(cards, "-")==0&&len==1)break;        
scanf("%d", &m);        
for(;m>0;m--){            
scanf("%d", &h);            
strcpy(temp, cards);            
for(i=0;i<h;i++){                
cards[len-h+i]=temp[i];            }           
 for(i=0;i<len-h;i++){                
cards[i]=temp[i+h];            }        }        
for(i=0;i<len;i++){            
result[j++]=cards[i];        }        
result[j++]='\n';    }    
result[j]='\0';    
printf("%s", result);    
return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

struct UF
{
	int par[SIZE],rank[SIZE];
	int sz[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=1;
			sz[i]=-1;
		}
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	int get(int v)
	{
		return sz[find(v)];
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y)
		{
			sz[x]++;
			return;
		}
		if(rank[x]<rank[y])
		{
			par[x]=y;
			sz[y]+=sz[x];
			sz[y]++;
		}
		else
		{
			par[y]=x;
			sz[x]+=sz[y];
			sz[x]++;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
}uf;
vector <PP> edge;
bool use[SIZE];

int main()
{
	int n,h,w;
	scanf("%d %d %d",&n,&h,&w);
	for(int i=0;i<n;i++)
	{
		int r,c,a;
		scanf("%d %d %d",&r,&c,&a);r--,c--;
		edge.push_back(PP(a,P(r,c+h)));
	}
	sort(edge.begin(),edge.end(),greater<PP>());
	uf.init(h+w+2);
	ll ret=0;
	for(int i=0;i<edge.size();i++)
	{
		P p=edge[i].second;
		int a=uf.get(p.first),b=uf.get(p.second);
		if(a+b+1<=0)
		{
			uf.unite(p.first,p.second);
			ret+=edge[i].first;
			use[i]=true;
			//printf("* %d %d : %d\n",p.first,p.second,edge[i].first);
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 3956
#include <iostream>

using namespace std;

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

  if (X == 2) {
    cout << 2 << endl;
    return 0;
  }

  for (int i = X+(X%2==0); true; i+=2) {
      int j = 0;
      for (j = 3; j < i/2; j += 2) {
          if (i%j == 0) break;
      }
      if (j >= i/2 && i%2 != 0) {
          cout << i << endl;
          break;
      }
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const unsigned long M = 1046527;
const int L = 14;

char H[M][L];

long long getChar(char ch)
{
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum = 0, p = 1;
	for (int i = 0; i < strlen(str); ++i) {
		sum += p * getChar(str[i]);
		p *= 5;
	}
	return sum;
}

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

int find(char str[])
{
	long long key, h;
	key = getKey(str);
	for (long long i = 0;; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
}

int insert(char str[])
{
	long long key, h;
	key = getKey(str);
	for (long long i = 0;; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
}

int main()
{
	for (int i = 0; i < M; ++i) H[i][0] = '\0';

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

	for (int i = 0; i < n; ++i) {
		char cmd[L];
		char wrd[L];
		scanf("%s %s", cmd, wrd);

		if (cmd[0] == 'i') {
			insert(wrd);
		} else {
			cout << (find(wrd) ? "yes" : "no") << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 15524
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define F(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define print(x) cout << x << endl;
#define print_array(arr) F(i, arr.size()){cout << arr[i] << "-";}cout << endl;
#define print_line F(i, 60){cout << "--";}cout << endl;
const int mod = 1e9+7;
using namespace std;

void pre(){
	
}
void solve(){
	ll n;
	cin >> n;
	ll lim = sqrt(n)+1;
	int values[10] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45};
	vector<int> bases(lim, 0);
	ll temp = n;
	int ans = 0;
	while(temp > 1){
		bool isprime = true;
		for (ll i = 2; i <= sqrt(temp); ++i)
		{
			if(temp % i == 0){
				bases[i]++;
				temp /= i;
				isprime = false;
				break;
			}
		}
		if(isprime){
			if(temp >= lim){
				ans = 1;
				break;
			}
			bases[temp]++;
			temp = 1;
			break;
		}
	}
	// F(i, lim){
	// 	cout << bases[i] << " ";
	// }
	// print("")
	F(i, lim){
		if(bases[i] > 0){
			F(j, 10){
				if(bases[i] >= values[9-j]){
					ans += 9-j;
					break;
				}
			}
		}
	}
	print(ans)
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 7172
package main

import (
	"fmt"
	"math"
)

const limit = 100000

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, limit + 1)
	lst := make([]int, 0)
	for i := 0; i < limit + 1; i++ {
		arr[i] = math.MaxInt32
	}
	arr[0], arr[1] = 0, 1
	lst = append(lst, 1)
	for i := 6; i < limit; i *= 6 {
		lst = append(lst, i)
	}
	for i := 9; i < limit; i *= 9 {
		lst = append(lst, i)
	}
	for i := 2; i <= n; i++ {
		for _, j := range lst {
			if i >= j {
				arr[i] = min1(arr[i - j] + 1, arr[i])
			}
		}
	}
	fmt.Println(arr[n])
}

func min1(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

Measured memory_bytes: 1280
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        int ans = 0;

        for(int i = 0;i < n;i++){
            num[i] = sc.nextInt();
        }

        for(int i = 0;i < n-2;i++){
            if((num[i] < num[i+1] && num[i+1] < num[i+2])||((num[i] > num[i+1] && num[i+1] > num[i+2]))){
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class Edge:
    def __init__(self, dst, weight):
        self.dst, self.weight = dst, weight

    def __lt__(self, e):
        return self.weight > e.weight


class Graph:
    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, src, dst, weight):
        self.E[src].append(Edge(dst, weight))


class HeavyLightDecomposition:
    def __init__(self, g, root=0):
        self.g = g
        self.vid, self.head, self.heavy, self.parent = [0] * g.V, [-1] * g.V, [-1] * g.V, [-1] * g.V
        self.dfs(root)
        self.bfs(root)

    def dfs(self, root):
        stack = [(root, -1)]
        sub, max_sub = [1] * self.g.V, [(0, -1)] * self.g.V
        used = [False] * self.g.V

        while stack:
            v, par = stack.pop()
            if not used[v]:
                used[v] = True
                self.parent[v] = par
                stack.append((v, par))
                stack.extend((e.dst, v) for e in self.g.E[v] if e.dst != par)
            else:
                if par != -1:
                    sub[par] += sub[v]
                    max_sub[par] = max(max_sub[par], (sub[v], v))
                self.heavy[v] = max_sub[v][1]

    def bfs(self, root=0):
        from collections import deque
        k, que = 0, deque([root])
        while que:
            r = v = que.popleft()
            while v != -1:
                self.vid[v], self.head[v] = k, r
                for e in self.g.E[v]:
                    if e.dst != self.parent[v] and e.dst != self.heavy[v]:
                        que.append(e.dst)
                k += 1
                v = self.heavy[v]

    def lca(self, u, v):
        while self.head[u] != self.head[v]:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
            v = self.parent[self.head[v]]
        else:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
        return u

N = int(input())
g = Graph(N)
for i in range(N):
    for c in map(int, input().split()[1:]):
        g.add_edge(i, c, 1)
        g.add_edge(c, i, 1)
hld = HeavyLightDecomposition(g)
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(hld.lca(u, v))

Measured memory_bytes: 110136
N, M = map(int, raw_input().split())

L = []
R = []

for i in range(M):
    Li, Ri = map(int, raw_input().split())
    L.append(Li)
    R.append(Ri)

ans = min(R) - max(L) + 1

if ans > 0:
    print ans
else:
    print 0


Measured memory_bytes: 12164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;
#define INF 10000000;

ll MOD = 1e9 + 7;

int main()
{

    ll n, k;
    cin >> n >> k;

    vector<int> h(n);
    REP(i, n)
    cin >> h[i];

    sort(h.begin(), h.end());

    ll ans = h[k - 1] - h[0];
    for (int i = 0; i < n; i++)
    {
        ll t = h[i + k - 1] - h[i];
        ans = min(ans, t);
        if (k + i - 1 == n - 1)
            break;
    }
    Cout(ans);

    return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n,sum=0;
	cin>>n;
	ll dp[100005]={0};
	ll a[n];
	lp(i,0,n-1){
		cin>>a[i];
		sum+=a[i];
		dp[a[i]]++;
	}
	ll q;
	cin>>q;
	lp(i,0,q-1){
		ll x,y;
		cin>>x>>y;
		if(dp[x]){
			sum+=dp[x]*(y-x);
			dp[y]+=dp[x];
			dp[x]=0;
		}
		cout<<sum<<endl;
	}
	return 0;	
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1e18;
bool isOverflow(ull a, ull b) 
{ 
    // Check if either of them is zero 
  
    if (a == 0 || b == 0)  
        return false; 
      
    ull result = a * b; 
  //cout<<a<<" "<<b<<" "<<result<<endl;
    if (a == (result / b)) 
        return false; 
    else
        return true; 
} 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;    
    while(t--)
    {
        ull n,i,x=0;
        cin>>n;
        ull arr[n+1],pro=1;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            if(arr[i]==0)
                x++;
        }
        if(x>0)
        {
            cout<<"0"<<endl;
            return 0;
        }
        for(i=0;i<n;i++)
        {
            //cout<<x<<endl;
            if(isOverflow(pro,arr[i]))
            {
                cout<<"-1"<<endl;
                return 0;;
            }
            pro=pro*arr[i];
            //cout<<pro<<endl;
            if(pro>mod)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
        if(pro<=mod)
            cout<<pro<<endl;
        else
        {
            cout<<"-1"<<endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 4340
#include <stdio.h>
#include <stdbool.h>

int banum[10];
bool judge (int N,int K) {
    while (N > 0) {
        for (int i = 0; i < K; i++) {
            if (N % 10 == banum[i])
                return false;
        }
        N /= 10;
    }


    return true;
}

int main(void)
{
   int N, K;
    scanf("%d %d", &N, &K);
    for (int i = 0; i < K; i++)
        scanf("%d", &banum[i]);
    for (;;) {
        if (judge(N, K)) {
            printf("%d", N);
            return 0;
        }
        N++;
    }
}

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

int main() {
  
  vector<vector<int>> A(3,vector<int>(3));
  vector<vector<int>> B(3,vector<int>(3));
  
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A.at(i).at(j);
    }
  }
  int N = 0;
  cin >> N;
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin >> C.at(i);
  }
   for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<N; k++){
        if(A.at(i).at(j) == C.at(k)){
          B.at(i).at(j) = 1;
        }
      }
    }
   }
  bool ans = false;
  if(B.at(0).at(0) + B.at(0).at(1) + B.at(0).at(2) == 3) ans = true;
  if(B.at(1).at(0) + B.at(1).at(1) + B.at(1).at(2) == 3) ans = true;
  if(B.at(2).at(0) + B.at(2).at(1) + B.at(2).at(2) == 3) ans = true;
  if(B.at(0).at(0) + B.at(1).at(0) + B.at(2).at(0) == 3) ans = true;
  if(B.at(0).at(1) + B.at(1).at(1) + B.at(2).at(1) == 3) ans = true;
  if(B.at(0).at(2) + B.at(1).at(2) + B.at(2).at(2) == 3) ans = true;
  if(B.at(0).at(0) + B.at(1).at(1) + B.at(2).at(2) == 3) ans = true;
  if(B.at(0).at(2) + B.at(1).at(1) + B.at(2).at(0) == 3) ans = true;

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        int l = kbd.nextInt();
        int sum = 0;
        List<Integer> tastes = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            tastes.add(l + i);
            sum = sum + (l + i);
        }
        int saMin = 1000000;
        int taste = 0;
        for (int j = 0; j < n; j++) {
            int temp = 0;
            for (int k = 0; k < n; k++) {
                if (k != j) {
                    temp = temp + tastes.get(k);
                }
            }
            int saTemp = Math.abs(temp - sum);
            if (saMin > saTemp) {
                saMin = saTemp;
                taste = temp;
            }
        }
        System.out.println(taste);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include <algorithm>
using namespace std;
int main(void) {
	string S;
    cin >> S;
    int flag=0;
    int hantei=0;
    if(S.length()%2==1)hantei=1;
    for(int i=0;i<S.length()/2;i++){
        	if(S[2*i]!='h'||S[2*i+1]!='i')flag=1;
    }
    if(flag==1||hantei==1)cout <<"No"<<endl;
    else cout << "Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int ct = 0;
    For(i, 0, n){
        int a; cin>>a;
        if(a!=(i+1))
            ct++;
    }
    if(ct==0 || ct==2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string a, b;
  cin >> a >> b;
  if(a.size() > b.size()){
    cout << "GREATER";
    return 0;
  }
  else if(a.size() < b.size()){
    cout << "LESS";
    return 0;
  }
  else{
    REP(i, a.size()){
      if(a[i] > b[i]){
        cout << "GREATER";
        return 0;
      }
      if(a[i] < b[i]){
        cout << "LESS";
        return 0;
      }
    }
  }
  cout << "EQUAL";
}


Measured memory_bytes: 256
import math
n,m =map(int, input().split())
a = list(map(int, input().split()))

kei = sum(a)
ans = 0
line = kei / 4 / m
for i in a:
    if i >= math.ceil(line):
        ans+= 1
if ans>=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


long long gcd(long long a, long long b)
{
	while (b != 0) {
		long long t = b;
		b = a % b;
		a = t;
	}
	return a;
}

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

	long long a, b, c, d, s1, s2, ans, g;

	cin >> a >> b >> c >> d;
	g = c * d / gcd(c, d);
	s1 = b - (b / c) - (b / d) + (b / g);
	a--;
	s2 = a - (a / c) - (a / d) + (a / g);
	ans = s1 - s2;
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<array>
#include<queue>
#include<unordered_set>
using namespace std;

int main(){
  long long N, K;
  cin >> N >> K;

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  // next[0][i] := A[i]から始まるブロックの長さ
  // next[k][i] := A[i]から始まる2^k個のブロックの長さの和
  vector<vector<long long>> next(60, vector<long long>(N));
  {
  // prev_indices[n] := (n == A[i])となる前回のi
  vector<int> prev_indices(2e5 + 1, -1);
  for(int i = 0; i < 2 * N; i++){
    if(prev_indices[A[i % N]] != -1 && prev_indices[A[i % N]] < N){
      next[0][prev_indices[A[i % N]]] = i - prev_indices[A[i % N]] + 1;
    }
    prev_indices[A[i % N]] = i;
  }
  }

  int k;
  for(k = 1; k < 60; k++){
    bool end = false;
    for(int i = 0; i < N; i++){
      next[k][i] = next[k - 1][i] + next[k - 1][((i + next[k - 1][i]) % N)];
      if(next[k][i] > N * K){
        end = true;
        break;
      }
    }
    if(end){
      break;
    }
  }
  int k_max = k - 1;

  long long idx = 0;
  bool conti = true;
  while(conti){
    conti = false;
    for(int k = k_max; k >= 0; k--){
      if(idx + next[k][idx % N] <= N * K){
        idx = idx + next[k][idx % N];
        conti = true;
        break;
      }
    }
  }

  vector<int> ans;
  unordered_set<int> appeared;
  //vector<bool> appeared(2e5 + 1, false);
  for(; idx < N * K; idx++){
    if(appeared.count(A[idx % N])){
      for(int i = ans.size() - 1; i >= 0; i--){
        appeared.erase(ans[i]);
        if(ans[i] == A[idx % N]){
          ans.pop_back();
          break;
        }
        ans.pop_back();
      }
    }else{
      appeared.insert(A[idx % N]);
      ans.push_back(A[idx % N]);
    }
  }
  
  for(int i = 0; i < ans.size(); i++){
    if(i){
      cout << ' ';
    }
    cout << ans[i];
  }cout << endl;
}


Measured memory_bytes: 104804
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 100000000000000000
#define limit 200005
#define minval -100000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
	int n;
	cin >> n;

	vector<pll> a(n);
	rep(i,n)
		cin >> a[i].ft >> a[i].sd;

	sort(all(a));

	lli mns = a[0].ft + a[0].sd;
	lli mnd = a[0].ft - a[0].sd;
	lli ans = 0;
	loop(i,1,n,1)
	{
		lli s = a[i].ft + a[i].sd;
		lli d = a[i].ft - a[i].sd;

		ans = max(ans, s-mns);
		ans = max(ans, d-mnd);
		mns = min(mns, s);
		mnd = min(mnd, d);
	}
	cout << ans << '\n';
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 6360
#include <iostream>

int prize[] = {300000, 200000, 100000};

int main() {
	int x, y;
	int total = 0;

	std::cin >> x;
	std::cin >> y;

	if (x <= 3) {
		total += prize[x -1];
	}
	if (y <= 3) {
		total += prize[y -1];
	}
	if (x == 1 && y == 1) {
		total += 400000;
	}

	std::cout << total << std::endl;

	return 0;
}


Measured memory_bytes: 888
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		HashSet<Integer> list = new HashSet<Integer>();
		int count = 0;
		for(int i=0;i<n;i++){
			int c = list.size();
			list.add(scanner.nextInt());
			if(c != list.size()){
				count++;
			}
		}
		System.out.println(count-((n-count)%2));
	}

}


Measured memory_bytes: 62420
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int GetDays(int y, int m, int d)
{
if (m <= 2)y-- , m += 12;
int dy = 365 * (y - 1);
int c = y / 100;
int dl = (y >> 2) - c + (c >> 2);
int dm = (m * 979 - 1033) >> 5;
return dy + dl + dm + d - 1;
}

int main(){
	int y1,y2,m1,m2,d1,d2;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2)
	{
		if(y1==-1)break;
		cout<< GetDays(y2,m2,d2) -  GetDays(y1,m1,d1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>vec(N-1);
  vector<int>vv(N);
  for (int X=0; X<N-1; X++){
    cin >> vec.at(X);
    vv.at(vec.at(X)-1)+=1;
  }
  for (int X=0; X<N; X++){
    cout << vv.at(X) << "\n";
  }
}


Measured memory_bytes: 4832
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	
while(1){
	
	char m[1003][2];
	
	int n,mm;
	
	scanf("%d",&n);
	
	if(n == 0) break;
	
	for(int i = 0;i < n;i++){
		char t1,t2;
		cin >> t1 >> t2;
	//	scanf("%c %c",&t1,&t2);
	//	printf("pou");
		m[i][0] = t1;
		m[i][1] = t2;
		
	}
	
	scanf("%d",&mm);
	
	for(int i = 0;i < mm;i++){
		
		char tmp;
		
	//	scanf("%c",&tmp);
		cin >> tmp;
		for(int j = 0;j < n;j++){
			if(m[j][0] == tmp){
				printf("%c",m[j][1]);
				goto out;
			}
		}
		
		printf("%c",tmp);
		
		out:
		;
		
	}
	cout << endl;
		}
	return 0;	
}
			


Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  int N, K;
  cin >> N >> K;

  if(N == 1){
    cout << K << endl;
    return 0;
  }
  int ans = pow(K-1,N-1);
  ans *= K;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
#include <vector>
using namespace std;
string s;
int k;
vector <string> V;
int main()
{
	cin>>s;
	cin>>k;
	for (int i=0;i<s.length();i++)
 	{
		string cur;
		for (int j=i;j<s.length() && j<i+k;j++)
  		{
			cur+=s[j];
			V.push_back(cur);
		}
	}
	sort(V.begin(),V.end());
 	V.erase(unique(V.begin(),V.end()),V.end());
	cout<<V[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
int main(void)
{
	int a[4]={0},p=0,o=0,i;
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	p=a[0];
	o=a[3];
	for(i=1;i<=2;i++){
		if(p>a[i])
		p=a[i];
	}
	if(o>a[4])
	o=a[4];
	printf("%d\n",p+o-50);
	return 0;
}

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

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
using namespace std;

int main() {
    IO;
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n > k) {
        rep(i, 0, k) cout << s[i];
        cout << "...";
    } else {
        cout << s;
    }


}


Measured memory_bytes: 3648
//~:25
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

  for(int i=0;i<m;i++){
    set<string> pattern;
    string arrival;
    cin >> arrival;
    for(int j=1;j<arrival.size();j++){
      string train[2];
      train[0]=arrival.substr(0,j);
      train[1]=arrival.substr(j);

      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);
      
      reverse(train[0].begin(),train[0].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);

      reverse(train[1].begin(),train[1].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);

      reverse(train[0].begin(),train[0].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);      
    }
    cout << pattern.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 3220
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (a[n - 1] > 2) {
    cout << "-1\n";
    return 0;
  }
  int l = 2, r = 2;
  for (int i = n - 1; i >= 0; i--) {
    r += a[i] - 1;
    if (i != 0) {
      int k1, k2;
      if (l % a[i - 1] == 0) {
        k1 = l;
      } else {
        k1 = a[i - 1] * (l / a[i - 1] + 1);
      }
      k2 = a[i - 1] * (r / a[i - 1]);
      if (k1 < l || k1 > r || k2 < l || k2 > r) {
        cout << "-1\n";
        return 0;
      }
      l = k1, r = k2;
    }
  }
  cout << l << " " << r << "\n";
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  int n;
  cin>>n;
  long int num[n];
  int cnt=0;
  int ccnt=0;
  for(int i=0;i<n;i++){
    cin>>num[i];
    if(num[i]%2==0)
    cnt++;
    else
    ccnt++;
  }
  if(ccnt%2==0)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[4009],b[4009],c[4009];
ll mod = 1e9+7;
ll pot[4009];
ll vF[4009];
ll eF[4009];
ll ANS;
ll f[4009];
vector<ll> v[4009],I[4009],l[4009];
ll ans;
bool fMe(ll x, ll y, ll Haha){
   // cout << x <<endl;
    vF[x] = Haha;
    int fl=0;
    if(x == y) return true;
    for (ll i = 0; i < v[x].size(); i++){
        if(vF[v[x][i]] == Haha) continue;
        if(eF[I[x][i]] == 0) continue;
        if(!fMe(v[x][i],y,Haha)) continue;
        fl = 1;
        ANS = max(ANS, l[x][i]);
    }
    return fl;
}
main(){
    ll n,m,X;
    pot[0] = 1;
    for (ll i = 1 ; i <= 4000; i++)
        pot[i] = (pot[i-1] * 2) % mod;
    cin >> n >> m;
    cin >> X;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    for (ll i = 0 ; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
        l[a[i]].push_back(c[i]);
        l[b[i]].push_back(c[i]);
        I[a[i]].push_back(i);
        I[b[i]].push_back(i);
    }
    f[1] = 1;
    ll MST = 0;
    for (ll i = 0; i < n - 1; i++){
        ll E = 1e9, V = -1;
        for (ll j = 0; j < m; j++){
            if(f[a[j]] == 1 && f[b[j]] == 0 && (V == -1 || c[j] < c[V])){
                E = b[j];
                V = j;
            }
            if(f[b[j]] == 1 && f[a[j]] == 0 && (V == -1 || c[j] < c[V])){
                E = a[j];
                V = j;
            }
        }
        MST += c[V];
        f[E] = 1;
        eF[V] = 1;
    }
    if(MST == X)
        ans = (pot[n-1] - 2 + mod)*pot[m-n+1] % mod;

   // cout << MST << endl<<ans<<endl;
    ll T1 =0, T2 =0, T3 =0;
    for (ll i = 0; i < m; i++){
        if(eF[i]) continue;
        ANS = 0;
        fMe(a[i], b[i],i+1);
        ll Me = ANS;
       // cout << i <<" "<<c[i]<<" "<<MST-Me+c[i]<<" "<<Me<<endl;
        if(MST - Me + c[i] < X) T1 ++;
        if(MST - Me + c[i] == X) T2 ++;
        if(MST - Me + c[i] > X) T3 ++;
    }
    if(T2 == 0) {
        cout << ans << endl;
        return 0;
    }
    cout << (2*(pot[T3]*(pot[T2] - 1 + mod) % mod) % mod + ans) % mod << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
   int A,B,C;
   cin>>A>>B>>C;
   bool ans=false;
   for(int i=1;i<=100;i++){
       if(A*i%B==C) {ans=true; break;}
   }
   if(ans==true) cout<<"YES";
   else cout<<"NO";
   return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline


    nn = int(input())
    x = input()

    ans = 0
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                if i % 2 != 0:
                    divisors.append(i)
                if i != n // i and (n//i)%2 != 0:
                    divisors.append(n//i)

        divisors.sort(reverse = True)
        return divisors

    fact_n = make_divisors(nn)

    used = {}

    ans = 0

    for i in fact_n:
        num_len = int(nn/i)
        base = x[:num_len]
        can_divide = int(base, 2)+1
        for key, value in used.items():
            if num_len%key == 0:
                can_divide -= value
        if x < (base + format(2**num_len-1-int(base,2), 'b').zfill(num_len))*int((i-1)/2)+base:
            can_divide -= 1
        used[num_len] = can_divide
        ans += can_divide*num_len*2
        ans = ans%998244353


    print(ans%998244353)


Measured memory_bytes: 4348
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for(ll &i : a) cin >> i;
	sort(a, a+n);
	if(k >= n)
		cout << 0 << endl;
	else{
		ll sum = 0;
		for(ll i = 0; i<n-k; i++){
			sum+=a[i];
		}
		cout << sum << endl;
	}
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


Measured memory_bytes: 1792
n,m,l = map(int,input().split())
A = [[0] * m for i in range(n)]
B = [[0] * l for i in range(m)]
C = [[0] * l for i in range(n)]
for i in range(n):
	A[i] = list(map(int, input().split()))
for i in range(m):
	B[i] = list(map(int, input().split()))
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]
for line in C:
    print(*line)



Measured memory_bytes: 7068
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, m;
  string tmp;
  vector<string> user;
  bool open = false;
  cin >> n;
  while (n--) {
    cin >> tmp;
    user.push_back(tmp);
  }
  cin >> m;
  while (m--) {
    cin >> tmp;
    if (find(user.begin(), user.end(), tmp) == user.end()) {
      cout << "Unknown " << tmp << el;
    }
    else {
      if (open) {
        open = false;
        cout << "Closed by " << tmp << el;
      } else {
        open = true;
        cout << "Opened by " << tmp << el;
      }
    }
  }
}

Measured memory_bytes: 1220