akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Point{
    ll x;
    ll y;
    Point(ll x, ll y): x(x), y(y) {}

    bool operator<(const Point &another) const
    {
        if(x==another.x){
            return y < another.y;
        }else{
            return x < another.x;
        }
    }
};

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

bool flags[1010][1010];
ofstream of;

void flagFalse(){
    FOR(i, 0, 1010){
        FOR(j, 0, 1010){
            flags[i][j] = false;
        }
    }
}

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

    // input
    ll H, W;
    cin >> H >> W;

    // of.open("log.txt");

    vector<string> M(H);
    FOR(i, 0, H){
        cin >> M[i];
    }

    set<Point> se;
    ll black = 0;

    FOR(y, 0, H){
        FOR(x, 0, W){
            if(M[y][x]=='.'){
                // 隣が黒か
                FOR(k, 0, 4){
                    ll ny = y + dy[k];
                    ll nx = x + dx[k];

                    if(0<=ny && ny<H && 0<=nx && nx<W && M[ny][nx]=='#'){
                        se.insert(Point(x, y));
                    }
                }
            }
            else{
                black++;
            }
        }
    }
    // cout << "first black " << black << endl;

    ll count = 0;
    while(black!=W*H){
        count++;
        // of << "black " << black << endl;
        // of << endl;
        FOR(i, 0, H){
            of << M[i] << endl;
        }

        // of << black << endl;

        set<Point> new_set;
        for(auto point : se){
            ll x = point.x;
            ll y = point.y;
            if(M[y][x]=='.'){
                M[y][x] = '#';
                black++;
            }

            // 隣を見る
            FOR(k, 0, 4){
                ll ny = y + dy[k];
                ll nx = x + dx[k];

                if(0<=ny && ny<H && 0<=nx && nx<W && M[ny][nx]=='.'){
                    new_set.insert(Point(nx, ny));
                }
            }
        }

        se = new_set;
    }

    p(count);

    return 0;
}

Measured memory_bytes: 62976
from sys import stdin

s = stdin.readline().strip()
t_len = len(s) - 7

if t_len == 0:
  if s == 'keyence': print('YES')
  else: print('NO')
  exit()
else:
  for i in range(7):
    if s[:i] + s[i+t_len:] == 'keyence':
      print('YES')
      exit()
      
print('NO')

Measured memory_bytes: 9108
import time
from math import ceil
from collections import defaultdict, deque


def A(s):
  if s[-1] == 's':
    return s + 'es'
  return s + 's'


def B(n, d):
  for i in range(n - 2):
    if (d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and
        d[i + 2][0] == d[i + 2][1]):
      return 'Yes'
  return 'No'


def main():
  n = int(input())
  d = [list(map(int, input().split())) for i in range(n)]
  print(B(n, d))


if __name__ == '__main__':
  main()


Measured memory_bytes: 9468
#include <stdio.h>
#define N 100

char G[N+1][N+1];

main(){
  int u, k, v, i, j, n;
  for(i=0;i<=N;i++) for(j=0;j<=N;j++) G[i][j] = 0;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d%d", &u, &k);
    while(k--){
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }
  for(i=1;i<=n;i++) for(j=1;j<=n;j++) printf("%d%c", G[i][j], (j==n) ? '\n' : ' ');
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a + b) % 2 == 0 ? (a + b) / 2 : (a + b) / 2 + 1);
	}
}


Measured memory_bytes: 35676
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(void){

	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int m,n;
	m=min(a,b);
	m=min(m,c);
    n=min(x,y);
    cout<<m+n-50<<endl;

	return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

void test_case(){
   int n; cin >> n;
   int A[n];
   for(int i = 0; i < n; i++){
     cin >> A[i];
   }
   sort(A, A + n);
   int res = 0;
   for(int i = 0; i < n; i++){
     for(int j = i + 1; j < n; j++){
       for(int k = j + 1; k < n; k++){
         set < int > s;
         s.insert(A[i]);
         s.insert(A[j]);
         s.insert(A[k]);
         if(A[i] + A[j] > A[k] && (int)s.size() == 3) res++;
       }
     }
   }
   
   cout << res;
  
  
}

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
    test_case();
    cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3664
import bisect

N, Q = list(map(int, input().split()))
S = input() + ' '
x, y = [], []

for i in range(N):
    if S[i:i+2] == 'AC':
        x.append(i+1)
        y.append(i+2)

for i in range(Q):
    l, r = list(map(int, input().split()))

    idx = [-1, -1]

    idx[0] = bisect.bisect_left(x, l)
    idx[1] = bisect.bisect_right(y, r)

    print(idx[1] - idx[0])

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

	int n, b,rem,q; cin>>n>>b;
	int i=1;
	int converted=0;

	while(n>=b){
		rem=n%b;
		//cout<<"rem= "<<rem<<endl;
		n=n/b;
       converted=converted+rem*pow(b,i);
       i++;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=100000;
const int mod=1000000007;
const ll inf=1e18;
ll dp[105][MX+5],w[105],v[105],n;

int main()
{
    FasterIO;
    ll i,j,k,W;
    cin>>n>>W;
    for(i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
    }
    ll res=0;
    for(i=1; i<=n; i++)
    {
        dp[i][v[i]]=min(w[i],dp[i-1][v[i]]?dp[i-1][v[i]]:inf);
        res=max(res,v[i]);
        for(j=0; j<=MX; j++)
        {
            if(dp[i-1][j])
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j]?dp[i][j]:inf);
                if(dp[i][j]<=W) res=max(res,j);
                dp[i][j+v[i]]=min(w[i]+dp[i-1][j],dp[i-1][j+v[i]]?dp[i-1][j+v[i]]:inf);
                if(dp[i][j+v[i]]<=W)
                    res=max(res,j+v[i]);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 78080
#include <stdio.h>
int main(){
 int N,M;
 scanf("%d %d",&N,&M);
 int A[M];
 int sum=0;
 for(int i=0;i<M;i++){
  scanf("%d",&A[i]);
  sum+=A[i];
  }
  if(N>=sum)printf("%d",N-sum);
   else printf("-1");
 return 0;
}

Measured memory_bytes: 2184
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    int N;
    cin >> N;
    map<ll, ll> ma;
    for (int x = 1; x * x <= N; x++) {
        for (int y = 1; y * y <= N; y++) {
            for (int z = 1; z * z <= N; z++) {
                int num = x * x + y * y + z * z + x * y + y * z + z * x;
                ma[num]++;
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        cout << ma[i] << endl;
    }
}

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

set<int> se;
int i = 1;
int main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    int s; cin >> s;
    se.insert(s);

    while (true) {
        if (s % 2 == 0) {
            s/=2;
            if (se.find(s) == se.end()) {
                se.insert(s);
                i++;
            } else {
                cout << i+1 << endl;
                return 0;
            }
        }
        else {
            s = 3*s + 1;
            if (se.find(s) == se.end()) {
                se.insert(s);
                i++;
            }
            else {
                cout << i+1 << endl;

                return 0;
            }
        }

    }


 
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<long double> value(n);
  for (int i = 0; i < n; i++) cin >> value.at(i);
  sort(value.begin(), value.end());
  long double sum = value.at(0) / pow(2, n - 1);
  for (int i = 1; i < n; i++)
    sum += value.at(i) / pow(2, n - i);
  cout << fixed << setprecision(6) << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int N,K,i,j;
        cin >> N >> K;
        int a[N];
        int f[N];
        for (i=0; i<N; i++){
            cin >> a[i];
        }
        f[0] = 0;
        f[1] = abs(a[1]-a[0]);
        if (K==1){
        for (i=2;i<N;i++){
                f[i] = f[i-1] + abs(a[i]-a[i-1]);
        }}else{
        for (i=2;i<N;i++){
        for (j=1;j<K;j++){
             if (j==1){
                     f[i] = f[i-j]+abs(a[i]-a[i-j]);
             }
             if (i-j-1>=0){
                     f[i] = min(f[i] , (f[i-j-1]+abs(a[i]-a[i-j-1])) );
        }}}}
         cout << f[N-1];
}


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

int main() {
    int t;
   // cin>>t;
   t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n][3];
        for(ll i=0;i<n;i++)
        {
            for(int j=0;j<3;j++)
            cin>>a[i][j];
        }
        ll dp[n][3];
        dp[0][0]=a[0][0];
        dp[0][1]=a[0][1];
        dp[0][2]=a[0][2];
        
        for(int i=1;i<n;i++)
        {
            dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    }
}

Measured memory_bytes: 8316
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  while(true)
  {
    ll n; cin>>n;
    if(n==0) {break;}
    ll m,M,sum=0;
    m=10000;
    M=0;
    rep(i,n)
    {
      ll s; cin>>s;
      sum+=s;
      m=min(m,s);
      M=max(M,s);
    }
    cout<<(sum-M-m)/(n-2)<<endl;
  }  
  return 0;
}




Measured memory_bytes: 3004
n = int(input())

h = list(map(int, input().split()))

l = h[0] - 1
for i in range(1, n):
  r = h[i]
  if l - r  >= 1:
    print("No")
    break
  if not l == r:
    l = r-1
else:
  print("Yes")

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main() {
   int n;
   cin >> n;
   vector<ll>b(n);
   set<ll>a;
   cin >> b[0];
   ll g = b[0],ans=b[0];
   rep(i, 1, n){
      ll c = a.size();
      cin >> b[i];
      a.insert(b[i]);
      if(a.size()>c){
         g = gcd(ans,b[i]);
         ans = ans*(b[i]/g);
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <cstring>
using namespace std;

const int MAX_N = 30000<<3;
const double PI = 4.0*atan(1.0);

int N, NN;
double prev[MAX_N], cur[MAX_N];
complex<double> xs[MAX_N], zs[MAX_N];

static const complex<double> I(0,1);

void init(){
	scanf("%d", &N);
}

void fft(complex<double> a[], int n, bool inv = false){
	double theta = 2 * PI / n * (inv ? -1 : 1);
	for(int m=n; m>=2; m>>=1){
		int mh = m >> 1;
		for(int i=0; i<mh; ++i){
			complex<double> w = exp(i*theta*I);
			for(int j=i; j<n; j+=m){
				int k = j + mh;
				complex<double> x = a[j] - a[k];
				a[j] += a[k];
				a[k] = w * x;
			}
		}
		theta *= 2;
	}
	int i = 0;
	for(int j=1; j<n-1; ++j){
		for(int k=n>>1; k>(i^=k); k>>=1);
		if(j<i){
			swap(a[i], a[j]);
		}
	}
	if(inv){
		for(int i=0; i<n; ++i){
			a[i] /= n;
		}
	}
}

void calc(){
	for(int i=0; i<NN; ++i){
		xs[i] = complex<double>(prev[i], 0.0);
	}
	fft(xs, NN);
	for(int i=0; i<NN; ++i){
		zs[i] = xs[i] * xs[i];
	}
	fft(zs, NN, true);
	memset(cur, 0, sizeof(cur));
	cur[0] = 1.0;
	for(int i=1; i<=N; ++i){
		cur[i] = zs[i-1].real() / i;
	}
}

void solve(){
	NN = 4<<(31 - __builtin_clz(N));
	fill(prev, prev+NN, 0.0);
	prev[0] = prev[1] = 1.0;
	bool small = false;
	printf("%f\n", prev[N]);
	for(int i=0; i<N-1; ++i){
		if(small){
			puts("0.0");
		}
		else{
			calc();
			printf("%.12f\n", cur[N] - prev[N]);

			if(i>50 && cur[N] - prev[N] < 1e-5){
				small = true;
			}
			memcpy(prev, cur, sizeof(prev));
		}
	}
}

int main(){
	init();
	solve();

	return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//全二点間の距離
//ヨ i,d[i][i]<0なら負の閉路
in MAX_dist=1e9+7;
in V=0;
vector<vector<in>> d(0,vector<in>(0,MAX_dist));//d[x][y]:=x->yのcost,枝が無ければMAX_dist,d[i][i]=0

void init(in n){
    d=vector<vector<in>>(n,vector<in>(n,MAX_dist));
    rep(i,n) d[i][i]=0;
    V=n;
}

void warshall(){
    rep(k,V){
        rep(i,V){
            if(d[i][k]==MAX_dist) continue;
            rep(j,V){
                if(d[k][j]==MAX_dist) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    init(n);
    vector<vector<in>> a(n,vector<in>(n));
    rep(i,n)rep(j,n) cin>>a[i][j];
    rep(i,n)rep(j,n) d[i][j]=a[i][j];
    warshall();
   if(d!=a){
     cout<<-1<<endl;
     return 0;
   }
    rep(i,n)REP(j,i+1,n){
        rep(k,n){
            if(i==k) continue;
            if(j==k) continue;
            if(d[i][j]==d[i][k]+d[k][j]){
                a[i][j]=0;
                a[j][i]=0;
                break;
            }
        }
    }
    in ans=0;
    rep(i,n)rep(j,n) ans +=a[i][j];
    cout<<ans/2ll<<endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
#define int long long

int a[100000];
signed main() {
	int n; scanf("%lld", &n);
	rep(i, n)scanf("%lld", &a[i]);
	sort(a, a + n);
	int l = 0, r = n - 1;
	while (l != r) {
		int t = (l + r) / 2;
		int sum = a[t];
		rep(i, n) {
			if (i == t)continue;
			if (sum * 2 >= a[i])sum += a[i];
			else goto g;
		}
		r = t; continue;
	g:; l = t + 1;
	}
	printf("%lld\n", n-l);
}

Measured memory_bytes: 1024
N = input()
N = str(N)
F = int(N)

#one =int(N[-1])
#two =int(N[-2])
#thr =int(N[-3])
#N = int (N)


if F >= 100 and (int(N[-1]) == 7 or int(N[-2])==7 or int(N[-3]) == 7):
    print("Yes")
elif F >= 10 and (int(N[-1]) == 7 or int(N[-2])==7):
    print("Yes")
elif F >= 0 and (int(N[-1]) == 7):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61864
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string a,b,c;
	cin>>a>>b>>c;
	if(a==b) cout<<c<<endl;
	else if(b==c) cout<<a<<endl;
	else cout<<b<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cstring>
#include <stdio.h>
#include <string.h>
using namespace std;
#define ll long long



int main() {



    string s;
    cin>>s;

    if(s[0] == 'S') {
        cout<<"Cloudy"<<'\n';
    }
    else if(s[0] == 'C') {
        cout<<"Rainy"<<'\n';
    }
    else {
        cout<<"Sunny"<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int per20(int x, int y, int b, int p);

int main(void)
{
	int x, y, b, p, n, sum, quo, fin;
	
	scanf("%d", &n);
	
	while (n != 0){
		n--;
		
		scanf("%d%d%d%d", &x, &y, &b, &p);
		if (!(b >= 5 && p >= 2)){
			sum = x * b + y * p;
			quo = per20(x, y, b, p);
			if (sum < quo)fin = sum;
			else fin = quo;
		}
		else fin = x * 0.8 * b + y * 0.8 * p;
		
		
		printf("%d\n", fin);
		
	}
	
	return (0);
}

int per20(int x, int y, int b, int p)
{
	int tb, tp;
	
	if (b > 5){
		tb = b;
		tp = 2;
	}
	else if (p > 2){
		tb = 5;
		tp = p;
	}
	else {
		tb = 5;
		tp = 2;
	}
	return (x * 0.8 * tb + y * 0.8 * tp);
}

Measured memory_bytes: 600
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

c = input()
print("vowel" if c in ["a", "e", "i", "o", "u"] else "consonant")




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
vector <int> nei[MAX + 7];
int pre[MAX + 7];
queue <int> Q;
int dp[MAX + 7];
int main()
{
    int n, m, a, b;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        pre[b]++;
        nei[a].push_back(b);
    }
    for(int i = 1; i <= n; i++)
        if(pre[i] == 0)
            Q.push(i);
    while(!Q.empty()){
        int v = Q.front();
        Q.pop();
        for(auto x: nei[v]){
            dp[x] = max(dp[x], dp[v] + 1);
            pre[x]--;
            if(pre[x] == 0)
                Q.push(x);
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i++)
        res = max(res, dp[i]);
    cout << res <<  '\n';
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <set>
#include <string>

using namespace std;

set<string> X;

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

  for (int len=1; len<=5; ++len) {
    for (int start=0; start+len<=s.size(); ++start) {
      string substr = s.substr(start, len);
      X.insert(substr);

      if (X.size()>5) {
	X.erase(--X.end());
      }
    }
  }

  int k = 1;
  for (auto& x : X) {
    if (k++==K) {
      cout << x << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 105
int N;
char s[MAXN];
bool x[30],y[30];//x[i]/y[i]:左/右是否有字母i
int main()
{
	int ans=0;
	scanf("%d\n%s",&N,s+1);
	for(int i=1;i<=N-1;i++)
	{
		int res=0;
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		for(int j=1;j<=i;j++)
			x[s[j]-'a']=1;
		for(int j=i+1;j<=N;j++)
			y[s[j]-'a']=1;
		for(int i=0;i<=29;i++)
			if(x[i]&&y[i])
				res++;
		if(res>ans) ans=res;
	}
	printf("%d\n",ans);
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double t, x;
    cin>>t>>x;
    double ans = t/x; 
    cout<<fixed;
    cout<<setprecision(4)<<ans<<endl;
    return 0;
}

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

int main(){
	int a,b,c,s;
	cin>>a>>b>>c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>c)swap(a,c);
	cout<<a+b;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static BufferedReader br;
	public static void main(String[] args)throws IOException{
		br = new BufferedReader(new InputStreamReader(System.in));
		int c[]=new int[26];
		String str;
		while((str = br.readLine())!=null){
			str = str.toLowerCase();
			for(int i=0;i<str.length();i++){
				char a='a';
				for(int j=0;j<26;j++){
					if(!Character.isLetter(str.charAt(i)))break;
					if(a==str.charAt(i)){
						c[j]++;
					}
					a++;
				}
			}
		}
		for(int i=0;i<26;i++){
			System.out.println((char)('a'+i)+" : "+c[i]);
		}
	}
}

Measured memory_bytes: 24752
#include<iostream>

using namespace std;

int main(void) {
	int h, w;
	char a[8][8];
	int total = 0;

	cin >> h >> w;

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

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				total++;
			}
		}
	}

	if (total == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	map<long long,long long> mp;
	long long ans = 0;
	
	for(int i=0;i<N;i++){
		ans += mp[i-A[i]];
		mp[A[i]+i]++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 27372
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, k;
    cin>>n>>k;
    ll r, s, p;
    cin>>r>>s>>p;
    string t;
    cin>>t;

    vector<ll> x(n, 0);
    for(ll i=0;i<n;++i){
        if(i < k){
            if(t[i] == 'r'){
                x[i] = p;
            }else if(t[i] == 's'){
                x[i] = r;
            }else if(t[i] == 'p'){
                x[i] = s;
            }
        }else{
            if(t[i] == 'r'){
                x[i] = p;
                if(x[i-k] == p and t[i-k] == 'r'){
                    x[i] = 0;
                }
            }else if(t[i] == 's'){
                x[i] = r;
                if(x[i-k] == r and t[i-k] == 's'){
                    x[i] = 0;
                }
            }else if(t[i] == 'p'){
                x[i] = s;
                if(x[i-k] == s and t[i-k] == 'p'){
                    x[i] = 0;
                }
            }
        }
    }
    ll ans = 0;
    for(ll i=0;i<n;++i){
        ans += x[i];
        //cout<<x[i]<<endl;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4272
#include<stdio.h>
int main()
{
    int i,j,a,b,c,d=0,e,f;
    char s[1000],t[1000],u[1000];
    char v,w;
    scanf("%s %s",s,t);
    a=strlen(s);

    for(i=0;i<a;i++)
    {
        if(s[i]==t[i])
        {
            d++;
        }
    }
    if(d==a)
    {
        printf("Yes\n");
        return 0;
    }
    d=0;

    for(j=0;j<a;j++){
            d=0;
    for(i=0;i<a;i++)
    {
        if(i==0)
        {
            if(i%2==0)
            {
                v=s[a-1];
                w=s[i];
                s[i]=v;
            }
            else
            {
                v=s[i];
                s[i]=w;
            }
        }
        else
        {
            if(i%2==0)
            {
                w=s[i];
                s[i]=v;
            }
            else
            {
                v=s[i];
                s[i]=w;
            }
        }
    }

    for(i=0;i<a;i++)
    {
        if(s[i]==t[i])
        {
            d++;
        }
    }
    if(d==a)
    {
        printf("Yes\n");
        return 0;
    }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int D; //365
    cin >> D;

    int c[26];
    rep(i, 0, 26) {
        cin >> c[i];
    }

    int s[D][26];
    rep(i, 0, D) {
        rep(j, 0, 26) {
            cin >> s[i][j];
        }
    }

    int t[D] = {};
    srand(time(NULL));
    rep(i, 0, D) {
        t[i] = rand() % 26;
    }

    ll mx_score = -1e18;
    int cnt = 10000;
    while (cnt--) {
        int d = rand() % 365;
        int q = rand() % 26;
        int old = t[d];
        t[d] = q;

        ll score[D] = {};
        vector<int> last_day(26, -1);
        rep(i, 0, D) {
            if (i != 0) score[i] = score[i - 1];
            //増加分
            score[i] += s[i][t[i]];

            last_day[t[i]] = i;

            //減少分
            ll decrease = 0;
            rep(j, 0, 26) {
                decrease += c[j] * (i - last_day[j]);
            }
            score[i] -= decrease;
        }
        //cout << "score[D - 1]: " << score[D - 1] << endl;
        if (mx_score > score[D - 1]) {
            t[d] = old;
        } else {
            mx_score = score[D - 1];
        }
    }

    rep(i, 0, D) cout << t[i] + 1 << endl;
    return 0;
}


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

int main(){
    ll n, p;
    cin >> n >> p;

    int a[n];
    int eve = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0){
            eve++;
        }
    }

    ll ans = pow(2, eve);

    if(n == eve && p == 0){
        cout << ans << endl;
    }else if(n == eve && p == 1){
        cout << 0 << endl;
    }else{
        cout << setprecision(16) << pow(2, n - 1) << endl;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
	int[] values;
	int size;
	public Main(int length)
	{
		values = new int[length];
		size = 0;
	}
	
	public void add(int i)
	{
		values[size] = i;
		size++;
	}
	
	public void print()
	{
		for(int i = 0; i < size; i++)
		{
			System.out.print("node " + (i + 1) + ": ");
			System.out.print("key = " + values[i] + ", ");
			if(i != 0)
			{
				System.out.print("parent key = " + values[(i - 1)/2] + ", ");
			}
			if((2 * i) + 1 < size)
			{
				System.out.print("left key = " + values[(2*i)+1] + ", ");
			}
			if((2 * i) + 2 < size)
			{
				System.out.print("right key = " + values[(2*i)+2] + ", ");
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int size = in.nextInt();
		Main h = new Main(size);
		for(int i = 0; i < size; i++)
		{
			h.add(in.nextInt());
		}
		
		h.print();
	}
}















Measured memory_bytes: 27092
function Main(input){
    input = input.split(" ");
    input = input.map(function(val){return parseInt(val, 10);});
    var priceA = input[0] < input[2] * 2 ? input[0] : input[2] * 2;
    var priceB = input[1] < input[2] * 2 ? input[1] : input[2] * 2;
    var sum = 0;
    
    if(input[0] + input[1] > input[2] * 2){
        var n = input[3] < input[4] ? input[3] : input[4];
        sum += n * 2 * input[2];
        input[3] -= n;
        input[4] -= n;
    }
    
    sum += input[3] * priceA;
    sum += input[4] * priceB;
    
    console.log(sum);
}    
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import java.util.*;

public class Main {

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

        switch(d) {
            case "22":
                System.out.println("Christmas Eve Eve Eve");
                break;
            case "23":
                System.out.println("Christmas Eve Eve");
                break;
            case "24":
                System.out.println("Christmas Eve");
                break;
            case "25":
                System.out.println("Christmas");
                break;
        }
    }
}

Measured memory_bytes: 19796
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
    long long A, B, K;
    cin >> A >> B >> K;

    if (A >= K) {
        cout << A - K << " " << B << endl;
    }
    else if (B >= K - A) {
        cout << 0 << " " << B - K + A << endl;
    }
    else {
        cout << "0 0" << endl;
    }

    return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  int res = -1;
  for (int i = 1; i <= 1000; i++) {
    if (res == -1 && i * 2 / 25 == A && i / 10 == B)
      res = i;
  }
  cout << res << endl;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;

    ist >> N;

    /* ------- 計算 ------- */

    while (N != 0)
    {
        if (N % 10 == 7)
        {
            ost << "Yes" << endl;
            return;
        }
        N /= 10;
    }

    ost << "No" << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    ll dp[S.size()+1][13];
    //rep(i,0,13)dp[0][i] = 0;
    //dp[0][0] = 1;
    ll ans = 0;
    int digit[] = {1,10,9,12,3,4};
    rep(i,0,13)dp[1][i] = 0;
    if(S.back() == '?'){
        rep(i,0,10)dp[1][i] = 1;
    }else{
        int num = S.back() - '0';
        dp[1][num] = 1;
    }
    rep(i,1,S.size()){
        rep(j,0,13)dp[i+1][j] = 0;

        char c = S[S.size()-i-1];
    
        if(c == '?'){
            rep(next,0,10){
                rep(j, 0, 13){
                    //int num = next * 10 + j;
                    int num = next * digit[(i+0)%6] + j;
                    num %= 13;
                    dp[i+1][num] += dp[i][j];
                }
            }
            rep(j,0,13)dp[i+1][j] %= MOD;
        }else{
            int next = c - '0';
            rep(j,0,13){
                //int num = next * 10 + j;
                int num = next * digit[(i+0) % 6] + j;
                num %= 13;
                dp[i+1][num] = dp[i][j];
            }
        }
    }
    //rep(i,0,13)cout << i << ":" << dp[S.size()][i] << endl;
    cout << dp[S.size()][5] << endl;
}

Measured memory_bytes: 10624
using System;
using System.Linq;
using System.Collections.Generic;
namespace Solution
{
    class Solution
    {
        static void Main(string[] args)
        {
            int n = int.Parse(System.Console.ReadLine());
            int[] x = new int[n];
            for(int i = 0; i < n; i++)
            {
                x[i] = int.Parse(System.Console.ReadLine());
            }
            Array.Sort(x);
            int tmp = x[0];
            for (int i = 1; i < n; i++)
            {
                if (tmp == x[i]) x[i] = 0;
                else tmp = x[i];
            }
            int count = 0;
            for(int i = 0; i < n; i++)
            {
                if (x[i] != 0) count++;
            }
            System.Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exist(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    sort(all(A));
    bool f = true;
    REP(i,N-1) if(A[i+1]==A[i]) f=false;
    cout << (f?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 100
#define WHITE 0
#define BLACK 1
#define NIL -1
#define INF 10000
int n;
int d[N],pi[N],color[N],G[N][N];
int prim(void){
  int mincost,u,v,i,weight=0;
  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[0]=WHITE;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(G[u][v]!=NIL){
	if(color[v]!=BLACK && G[u][v]<d[v]){
	  pi[v]=u;
	  d[v]=G[u][v];
	}
      }
    }
  }
  for(i=0;i<n;i++) weight+=d[i];
  return weight;
}
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      scanf("%d",&G[i][j]);
    }
  }
  printf("%d\n",prim());
  return 0;
}

Measured memory_bytes: 640
/*
lakshaygpt28
Lakshay Gupta
*/

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: 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...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 3e3 + 10;

double p[N];
ll n;
double dp[N][N];
bool vis[N][N];
double solve(ll i, ll heads);

int main() {
    fast_io();
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> p[i];
    }
    cout << fixed << setprecision(15);
    cout << solve(0, 0) << "\n";
    return 0;
}

double solve(ll i, ll heads) {
    auto &ans = dp[i][heads];
    if (vis[i][heads]) {
        return ans;
    }
    // debug(i, heads);
    vis[i][heads] = true;
    if (i >= n) {
        if (heads >= n / 2 + 1) {
            ans = 1;
            return ans;
        } else {
            ans = 0;
            return ans;
        }
    }
    ans = solve(i + 1, heads) * (1.0 - p[i]) + solve(i + 1, heads + 1) * p[i];
    return ans;
}


Measured memory_bytes: 79872
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int N, M, Q;
int ans = 0;
vector<tuple<int, int, int, int>> v;

int calc(vector<int> &A){
    int ret = 0;
    for(int i=0; i<Q; i++){
        int a, b, c, d;
        tie(a, b, c, d) = v[i];
        if(A[b]-A[a]==c) ret += d;
    }
    return ret;
}

void search(int idx, vector<int> &A){
    if(idx == N){
        ans = max(ans, calc(A));
        return;
    }
    int fr = A[idx-1];
    for(int i=fr; i<=M; i++){
        A[idx] = i;
        search(idx+1, A);
    }
}

int main(){
    cin >> N >> M >> Q;
    v.resize(Q);
    REP(i, Q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        v[i] = make_tuple(a, b, c, d);
    }
    vector<int> A(N);
    for(int i=1; i<=M; i++){
        A[0] = i;
        search(1, A);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d, score;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26)), pos(26);

int get_score(vector<int> t){
    vector<int> pos(26, 0);
    int ans = 0;
    rep(i, t.size()){
        int l = i + 1 - pos[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        pos[t[i]] = i+1;
    }
    rep(i, 26){
        int l = t.size() + 1 - pos[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t, pos(26, 0);
    rep(i, d){
        int max_score = -mod;
        int best_j = -1;
        rep(j, 26){
            t.push_back(j);
            int score = get_score(t);
            if(max_score < score){
                best_j = j;
                max_score = score;
            }
            t.pop_back();
        }
        t.push_back(best_j);
    }
    vector<int> ans = t;
    double start_temp = 100, end_temp = 10;
    int current_max_score = get_score(t), i = 0;
    while(clock() < 1.95 * CLOCKS_PER_SEC){

        if(i % 2 == 0){
            int D = rand() % d, q = rand() % 26;
            int old = t[D];
            int olds = get_score(t);
            t[D] = q;
            int score = get_score(t);
            double temp = start_temp + (end_temp - start_temp) * clock() / (1.95 * CLOCKS_PER_SEC);
            double prob = exp((olds - score)/temp);

            if(chmax(current_max_score, score)){
                ans = t;
            }else{
                if(prob <= (double)(rand() % 10000) / 10000){
                    t[D] = old;
                }
            }

            if(prob >= ((rand()%inf)/(double)inf))t[D] = old;
        }else{
            int a = 5 + rand() % (d-10), b = 1 + rand() % 4;
            int olds = get_score(t);
            swap(t[a], t[b]);
            int score = get_score(t);
            double temp = start_temp + (end_temp - start_temp) * clock() / (1.95 * CLOCKS_PER_SEC);
            double prob = exp((olds - score)/temp);

            if(chmax(current_max_score, score)){
                ans = t;
            }else{
                if(prob <= (double)(rand() % 10000) / 10000){
                    swap(t[a], t[b]);
                }
            }
        }
    }
    rep(i, d)cout << ans[i]+1 << endl;
}


Measured memory_bytes: 3832
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int t,x;
    cin>>t>>x;
    double res = (double)t/x;
    cout<<fixed<<setprecision(6)<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main (){
  int n, r, formula=0;
  scanf("%d%d", &n, &r);

  if(n<10){
    formula= 100*(10-n);
    printf("%d\n", r+formula);
  }

  if(n>=10){
    printf("%d\n", r);
  }

  return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//
// g++ -std=c++14 main.cpp
//

//#include "main.hpp"
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <tuple>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin >> n;
    
    vector<int> v(n, -1);
    int a[105][105] = {};
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            a[u - 1][v - 1] = true;
        }
    }
    
    queue<int> que;
    int num[105] = {}, idx = 0;
    que.push(0);
    v[0] = 0;
    num[0] = 1;
    
    bool at[105] = {};
    at[0] = true;
    while (!que.empty()) {
        int q = que.front();
        for (int j = 0; j < n; j++) {
            if (a[q][j] && !at[j]) {
                at[j] = true;
                que.push(j);
                v[j] = idx + 1;
                num[idx + 1]++;
            }
        }
        num[idx]--;
        if (!num[idx]) idx++;
        que.pop();
    }
    
    for (int i = 0; i < n; i++) cout << i + 1 << " " << v[i] << endl;
    
}
// g++ -std=c++14 main.cpp



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 301;
ll A[MAX_N][MAX_N];
ll D[MAX_N][MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) REP(j, N) A[i][j] = nextInt();
  REP(i, N) REP(j, N) D[i][j] = A[i][j];

  REP(k, N) REP(i, N) REP(j, N) {
    D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
  }

  bool possible = true;
  REP(i, N) REP(j, N) if (A[i][j] != D[i][j]) {
    possible = false;
  }

  if (!possible) {
    cout << -1 << endl;
    return 0;
  }

  ll INF = 1LL << 58;
  ll ans = 0;
  REP(i, N) REP(j, N) if (i < j) {
    ll min_d = INF;
    REP(k, N) if (k != i && k != j) {
      chmin(min_d, A[i][k] + A[k][j]);
    }
    if (A[i][j] != min_d) {
      ans += A[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,m,c,b[30],a;
signed main(){
	cin>>n>>m>>c;
	rep(i,m)cin>>b[i];
	int ans=0;
	rep(i,n){
		int sum=0;
		rep(j,m){
			cin>>a;
			sum+=a*b[j];
		}
		sum+=c;
		if(sum>0)ans++;
	}
	cout<<ans<<endl;
	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 rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  string s,t;
  cin >> s >> t;

  t = t.substr(0, s.size());

  if (s == t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int coin = 0;
		int ans = 0;

		while(coin < C) {
			coin += A;
			ans ++;
			if(ans % 7 == 0) {
				coin += B;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 26392