akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int x=K*2+1;
    int count=0;
    for(int i=0;i<7;i++){
        while(N>0){
            N-=x;
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3600
S = [int(a) for a in list(input())]

num = []
def make(B):
    if len(B) == 3:
        num.append(B)
        return
    B1 = B[:]
    B2 = B[:]
    B1.append(1)
    B2.append(-1)
    make(B1)
    make(B2)

make([])

for A in num:
    k = S[0] + S[1]*A[0] + S[2]*A[1] + S[3]*A[2]
    if k == 7:
        break

ans = []
for a in A:
    if a == 1:
        ans.append('+')
    else:
        ans.append('-')

print(str(S[0])+ans[0]+str(S[1])+ans[1]+str(S[2])+ans[2]+str(S[3])+'=7')

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    string ans;
    REP(i,x) ans = ans + 'R';
    REP(i,y) ans = ans + 'U';
    REP(i,x) ans = ans + 'L';
    REP(i,y) ans = ans + 'D';
    ans = ans + 'D';
    REP(i,x+1) ans = ans + 'R';
    REP(i,y+1) ans = ans + 'U';
    ans = ans + "LU";
    REP(i,x+1) ans = ans + 'L';
    REP(i,y+1) ans = ans + 'D';
    ans = ans + 'R';
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

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 &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double xA,yA,xB,yB,xC,yC,xD,yD;
	for(;cin>>xA>>yA>>xB>>yB>>xC>>yC>>xD>>yD;){
		if(xA==xB){cout<<(yC==yD?"YES":"NO")<<endl;}
		else if(xC==xD){cout<<(yA==yB?"YES":"NO")<<endl;}
		else cout<<((yA-yB)/(xA-xB)*(yC-yD)/(xC-xD)==-1?"YES":"NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

const int N_MAX = 100000;
const int R_MAX = 50;
const int BigNumber = 1000000007;	

 struct squaence{
	int start,length, counter;
	
	squaence(){}
	squaence(int _start, int _end){
		start = _start;
		length = _end - _start + 1;
		counter = 0;
	}
};



int main(){
	int s[R_MAX], t[R_MAX], N, R;
	
	long long SigmaFactrial[N_MAX+1];
	SigmaFactrial[0] = 0;
	long long factrial = 1;
	for(int i=1; i<N_MAX+1; i++){
		SigmaFactrial[i] = (SigmaFactrial[i-1]+factrial)%BigNumber;
		factrial = (factrial*i)%BigNumber;	
	}

	while(true){
		cin >> N;
		if(N==0) break;
		cin >> R;	
		
		vector<int> st_vector(2*R);
		for(int r=0; r<R; r++){
			int tmp_s, tmp_t;
			cin >> tmp_s >> tmp_t;
			s[r] = tmp_s-1;
			t[r] = tmp_t-1;
			st_vector[2*r  ] = s[r];
			st_vector[2*r+1] = t[r];
		}
		sort(st_vector.begin(), st_vector.end());
		st_vector.erase(unique(st_vector.begin(), st_vector.end()), st_vector.end());
		const int st_vector_size = st_vector.size();
		
		vector<squaence> number;
		int n=0;
		for(int j=0; j<st_vector_size; j++){
			if(n <st_vector[j])number.push_back(squaence(n, st_vector[j]-1));
			n = st_vector[j];
			number.push_back(squaence(n, n));
			n++;
		}
		if(n<N)number.push_back(squaence(n, N-1));
			
		map<int,int> index_map;
		for(int i=0; i<st_vector_size; i++){
			int v = st_vector[i];
			auto it = find_if(number.begin(), number.end(), [v](squaence s){return s.start==v;});
			index_map[v] = distance(number.begin(), it) ;
		}

		for(int r=0; r<R; r++){
			int rs = index_map[s[r]];
			int rt = index_map[t[r]];

			int ns = number[rs].start;
			int nt = number[rt].start;
			int cs = number[rs].counter;
			int ct = number[rt].counter;
				
			if(ns<nt)	ct++;
			else		cs--;
			for(int i=rs+1; i<rt; i++){
				int ni = number[i].start;
				if(ni < nt){
					ct+=number[i].length;
					if(ns<ni) number[i].counter++;
				}
				if(ni < ns){
					cs-=number[i].length;
					if(nt<ni) number[i].counter--;
				}
			}

			number[rs].counter = cs;
			number[rt].counter = ct;
			swap(number[rs], number[rt]);
		}
	
		n=0;
		long long index = 0;
		const int number_size = number.size();
		for(int i=0; i<number_size; i++){
			const squaence* s = &number[number_size-1-i];
			if(s->counter != 0)index += s->counter * (SigmaFactrial[n+s->length] - SigmaFactrial[n]) % BigNumber;
			n += s->length;
		}
		
		while(index<0) index+=BigNumber;
		cout << index%BigNumber << endl;
	}
	return 0;
}

Measured memory_bytes: 2000
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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

void calc(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)  cin >> A.at(i);
  string S;
  cin >> S;
  reverse(all(A));
  reverse(all(S));

  vector<ll> base;
  base.p_b(0);
  rep(i,N){
    ll tmp=A.at(i);
    rep(j,sz(base)) chmin(tmp,tmp^base.at(j));
    if(S.at(i)=='0'){
      base.p_b(tmp);
    }
    else if(S.at(i)=='1'){
      bool flag=false;
      rep(j,sz(base)){
        if(base.at(j)==tmp) flag=true;
      }
      if(!flag){
        cout << 1 << endl;
        return;
      }
    }
  }
  cout << 0 << endl;
  return;
}

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

  rep(_,T)  calc();

  return 0;
}

Measured memory_bytes: 3608
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    if(n <= 10) k += 100*(10-n);
    cout << k << endl;
}



Measured memory_bytes: 256
PROGRAM MaximalValue
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: c(:),b(:)
      integer(16) :: i
      
      read*,n
      allocate( c(n),b(n-1) )
      read*,b(1:n-1)

      do i = 2,n-1
        c(i) = min( b(i),b(i-1) )
      end do
      c(1) = b(1)
      c(n) = b(n-1)
      
      print*,sum(c)
   !   print*,c
      
      
      END PROGRAM

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long rest = x%11L;
		long result = (x-rest)/11L;
		result*=2L;
		if(rest>0) result++;
		if(rest>6) result++;
		System.out.println(result);
	}
}


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

string S;
string t[4] = {"dream","erase","dreamer","eraser"};

int main(){
	cin >> S;
	int N = S.size();
	int state = -1;
	int id;
	for(int i=N-1;i>=0;i--){
		if(state==-1){
			for(int j=0;j<4;j++){
				if(S[i]==t[j][t[j].size()-1]){
					id = t[j].size()-2;
					state = j;
					break;
				}
			}
		}else{
			if(S[i]!=t[state][id]){
				if(state!=2 || (state==2 && id!=4)){
					cout << "NO" << endl;
					return 0;
				}else{
					if(S[i]==t[3][3]){
						state = 3;
						id = 2;
					}else{
						cout << "NO" << endl;
						return 0;
					}
				}
			}else{
				id--;
				if(id==-1){
					state = -1;
				}
			}
		}
	}
	cout << (id==-1? "YES":"NO") << endl;	
}

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

using namespace std;

int main(){
  int x,n,tmp;
  bool p[500]={};
  cin>>x>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    p[tmp+100]=true;
  }
  for(int i=0;i<201;i++){
    if(!p[x-i+100]){
            cout<<x-i<<endl;
      break;
    }
    else if(!p[x+i+100]){
      cout<<x+i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3588
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    int idx = s.length() - 1;
    int n = s.length();
    rep(i, n) {
        int l = 0;
        bool ok = true;
        int r = idx / 2;
//        cout << idx << endl;
        if ( idx % 2 != 0 ) {
            --idx;
            continue;
        }
        while(1) {
            if ( r == idx ) break;
//            cout << s[l] << " " << s[r] << endl;
            if ( s[l] != s[r] ) {
                ok = false;
                break;
            }
            ++l, ++r;
        }
        if ( ok ) {
            cout << idx << endl;
            return 0;
        }
        --idx;
    }
    return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

class DisjointSet {
    components: number;
    parents: number[];
    constructor(readonly size: number) {
        this.components = size;
        this.parents = new Array(size).fill(-1).map((value, index) => index);
    }

    find(node: number): number {
        if (node != this.parents[node])
            this.parents[node] = this.find(this.parents[node]);
        return this.parents[node];
    }

    union(node1: number, node2: number): void {
        let parent1 = this.find(node1),
            parent2 = this.find(node2);
        if (parent1 != parent2) {
            this.parents[parent1] = parent2;
            this.components -= 1;
        }
    }
}

function solve(): number {
    let reader = new Reader();
    let N = reader.readInt();
    let points: {x: number, y: number}[] = [];

    for (let i = 0; i < N; i++) {
        let [x, y] = reader.readInts();
        points.push({x: x, y: y});
    }

    if (N == 1)
        return 1;

    let minComponents = Number.POSITIVE_INFINITY;

    for (let i = 0; i < N; i++) {
        for (let j = i + 1; j < N; j++) {
            let p = points[j].x - points[i].x,
                q = points[j].y - points[i].y;
            let disjointSet = new DisjointSet(N);
            for (let k = 0; k < N; k++) {
                for (let l = k + 1; l < N; l++) {
                    if ((points[l].x - points[k].x == p && points[l].y - points[k].y == q) ||
                        (points[k].x - points[l].x == p && points[k].y - points[l].y == q)) {
                        disjointSet.union(l, k);
                    }
                }
            }
            minComponents = Math.min(minComponents, disjointSet.components);
        }
    }
    return minComponents;
};

console.log(solve());


Measured memory_bytes: 34516
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
        ll k = s[i] - 'A';
        k += n;
        k %= 26;
        cout << (char)('A' + k);
    }
    cout<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> e;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        e.push_back(make_pair(a,b));
    }
    int ans=0;
    rep(i,m){
        UnionFind uf(n+1);
        rep(j,m){
            if (i==j){
                continue;
            }
            else{
                int a=e[j].first;
                int b=e[j].second;
                uf.merge(a,b);
            }
        }
        int b1=1;
        for (int j=2;j<n+1;j++){
            if (!uf.issame(1,j)){
                b1=0;
            }
        }
        if (!b1){
            ans+=1;
        }

    }
    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, K = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N - 1)]
MOD = 10 ** 9 + 7

def dfs(u, par):
    q = deque()
    q.append((u, par))
    ret = 1

    while q:
        u, par = q.pop()
        color_num = K - 1 if par == -1 else K - 2
        
        if len(graph[u]) > K:
            return 0
            
        for v in graph[u]:
            if v == par:
                continue
                
            ret *= color_num
            ret %= MOD
            color_num -= 1
            
            q.append((v, u))

    return ret

graph = [[] for _ in range(N)]
for u, v in edges:
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)

print(dfs(0, -1) * K % MOD)


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int life_a = a;
  int life_b = c;
  for (int i = 0; i < 100; i++)
  {
    life_a -= d;
    life_b -= b;
    if (life_b <= 0 & life_a <= 0)
    {
      cout << "Yes" << endl;
      break;
    }
    else if (life_b <= 0 & life_a >= 0)
    {
      cout << "Yes" << endl;
      break;
    }
    else if (life_b >= 0 & life_a <= 0)
    {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll r,d;
    vector<ll> x(11);
    cin >> r >> d >> x[0];
    for (int i = 0; i <= 10; i++)
    {
        x[i+1] = r*x[i] - d;
    }
    for (int i = 1; i <= 10; i++)
    {
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,a[202020];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	int x=0,y=0;
	fo(i,0,n){
		cin>>a[i];
		x=max(x,a[i]);
	}
	fo(i,0,n) if(a[i]==x)y++;
	int z=0;
	fo(i,0,n) if(a[i]!=x)z=max(z,a[i]);
	fo(i,0,n){
		if(a[i]==x&&y==1)cout<<z<<endl;
		else cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0229
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] vs = RArInt();
                if (vs.Sum() == 0) break;

                int b = vs[0]; int r = vs[1]; int g = vs[2]; int c = vs[3]; int s = vs[4]; int t = vs[5];

                int expense = (t - s - b * 5 - r * 3) * 3 + (b * 5 + r * 3) * 2;
                int income = (b * 5 + b) * 15 + (r * 3 + r) * 15 + g * 7 + c * 2;
                Console.WriteLine(100 - expense + income);
            }

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 14164
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define il inline
#define rg register
#define gi read<int>
using namespace std;
template<class TT>
il TT read() {
	TT o = 0,fl = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-') ch = getchar();
	if (ch == '-') fl = -1, ch = getchar();
	while (isdigit(ch)) o = o * 10 + ch - '0', ch = getchar();
	return fl * o;
}
int n ,m;
int main() {
    n = gi(), m = gi();
    if (n > 9 || m > 9) puts("-1");
    else printf("%d\n", n * m);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(input())

cnt = 0
w_last_index = N-1
for i in range(N):
  if c[i] == 'W':
    flag = True
    for j in range(w_last_index,i,-1):
      if c[j] == 'R':
        c[j] = 'W'
        w_last_index=j
        cnt+=1
        flag = False
        break
    if flag:
      break
print(cnt)

Measured memory_bytes: 10764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a, b, c, d;
  a = n / 1000;
  b = (n % 1000) / 100;
  c = (n % 100) / 10;
  d = (n % 10);
  bool x, y;
  if (a == b && b == c) {
    x = true;
  } else {
    x = false;
  }
  if (b == c && c == d) {
    y = true;
  } else {
    y = false;
  }
  
  if ( x || y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
const int mx = 2e5 + 10;
int fa[mx],sz[mx];
int gf(int x) { return fa[x]==x?x:fa[x]=gf(fa[x]); }

void merge(int x,int y) {
	x = gf(x); y = gf(y);
	if(x!=y) sz[x] += sz[y],fa[y]=x;
}
int32_t main()
{
   int n,m; cin >> n >> m;
   iota(fa,fa+mx,0);
   fill(sz,sz+mx,1);
   fr(_,m){
   	int x,y; cin >> x >> y;
   	merge(x,y);
   }
   int mx = 0;
   rep(i,1,n) mx = max(mx, sz[gf(i)]);
   cout << mx;

}

Measured memory_bytes: 7484
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
a.sort()
while True:
    alice += max(a)
    a.pop()
    a.sort()
    if a == []:
        break
    bob += max(a)
    a.pop()
    if a == []:
        break
print(alice - bob)

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

typedef long long ll;
using namespace std;

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

    auto divide_count = [](int n) {
        int cnt = 0;
        while (n % 2 == 0) {
            cnt++;
            n /= 2;
        }
        return cnt;
    };

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        sum += divide_count(a);
    }

    cout << sum;
    return 0;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast

    int n;
    int a[3][3];
    loop(i,3){
    	loop(j,3){
    		cin>>a[i][j];
    	}
    }
    cin>>n;
    int b[n];
    loop(i,n) cin>>b[i];
    bool vis[3][3];
    loop(i,3){
    	loop(j,3){
    		vis[i][j]=0;
    		loop(k,n){
    			if(a[i][j]==b[k]) vis[i][j]=1;
    		}
    	}
    }
    int c=0;
    
    loop(i,3){
    	if(vis[i][0] && vis[i][1] && vis[i][2]) {c=1;break;}
    }
    loop(j,3){
    	if(vis[0][j] && vis[1][j] && vis[2][j]) {c=1;break;}
	}
	if(vis[0][0] && vis[1][1] && vis[2][2]) c=1;
	if(vis[0][2] && vis[1][1] && vis[2][0]) c=1;

	if(c) pt("Yes");
	else pt("No");

}


/*

// 

*/

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
int i,j,ten[11],sum,w,n,sum2;
for(i=0;i<10;i++)
{
	scanf("%d",&ten[i]);
}
for(n=10;n>0;n--)
{
        for( i=0; i<9; i++ )
          {
            if ( ten[i]>ten[i+1] ) 
              {
                w=ten[i];
                ten[i]=ten[i+1];
                ten[i+1]=w;
              }
          }
	}
          sum=0;
          for(i=9;i>6;i--)
          {
          	sum+=ten[i];
          }
for(i=0;i<10;i++)
{
	scanf("%d",&ten[i]);
}
for(n=10;n>1;n--)
{
        for( i=0; i<9; i++ )
          {
            if ( ten[i]>ten[i+1] ) 
              {
                w=ten[i];
                ten[i]=ten[i+1];
                ten[i+1]=w;
              }
          }
 }
          sum2=0;
          for(i=9;i>6;i--)
          {
          	sum2+=ten[i];
          }
printf("%d %d\n",sum,sum2);
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(11);
  long double a,b,h,w,k;cin >> a >> b >> h >> w;
  k = (h*60+w)/2-w*6;k = min(k,(long double)(360.0)-k);
  cout << sqrt(a*a+b*b-(long double)(2.0)*a*b*cos(k/180*3.14159265359)) << "\n";
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;
const double PI = 3.14159265358979323846;
//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

  int N;
  cin>>N;int J=N;
  int counter=0;
  while(N>0){
    N-=1000;
    counter++;
  }
  
  cout<<counter*1000-J<<endl;
  
    
}



Measured memory_bytes: 3648
n = int(input())
time = list(map(int, input().split()))
speed = list(map(int, input().split()))
speed = [0] + speed + [0]
cumtime = [0] * (n+1)
for i in range(n):
    cumtime[i+1] = cumtime[i] + time[i]
dis = 0.0
prev = 0
l = cumtime[n]
tp = 1
for t in range(1, l+1):
    if t > cumtime[tp]:
        tp += 1
    v = speed[tp]
    v = min(v, prev + 1)
    for i in range(tp):
        v = min(v, t - cumtime[i] + speed[i])
    for i in range(tp+1, n+2):
        v = min(v, cumtime[i-1] - t + speed[i])
    if v == prev and v < speed[tp]:
        dis += v + 1/4
    else:
        dis += (v + prev) / 2
    prev = v
print(dis)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

n=int(input())
l=[]
num=1
for _ in range(n):
    num*=_+1
a=2
for k in range(3,n):
    a*=(k-1)
for i in range(n):
    x,y=map(int,input().split())
    l.append([x,y])
ans=[]
i=0
for i in range(n-1):
    for j in range(i+1,n):
        c=((l[j][0]-l[i][0])**2+(l[j][1]-l[i][1])**2)**(0.5)
        ans.append(c)
s=sum(ans)*(n-1)*a/num
print(s)

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

int main()
{
	long long N;

	cin >> N;
	long long result=N-1;

	for (long long i = 1; i <= sqrt(N); i++)
	{
		if (N%i == 0) {
			long long j = N / i;
			result = min(result, i + j - 2);
		}
	}

	cout << result;
	return 0;
}


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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int time_stamp = 0;
std::vector<int> d;
std::vector<int> f;

void dfs(std::vector<std::vector<int> > &G, std::vector<bool> &is_searched, int i){
	if(is_searched[i]){
		//time++;
		return;
	}
	is_searched[i] = true;
	time_stamp++;
	d[i] = time_stamp;

	for(int j = 0; j < G[i].size(); j++){
		dfs(G, is_searched, G[i][j]);
	}
	time_stamp++;
	f[i] = time_stamp;
	return;
}

int main(int argc, char **argv){
	int n, u, k, v;
	std::vector<std::vector<int> > G;
	std::vector<bool> is_searched;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	G.resize(n);
	is_searched.resize(n, false);
	d.resize(n, 0);
	f.resize(n, 0);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> u >> k;
#else
		std::cin >> u >> k;
#endif
		G[u - 1].resize(k);
		for(int j = 0; j < k; j++){
#if INPUT_FROM_FILE
			ifs >> v;
#else
			std::cin >> v;
#endif
			G[u - 1][j] = v - 1;
		}
	}

	for(int i = 0; i < n; i++){
		dfs(G, is_searched, i);
	}

	for(int i = 0; i < n; i++){
		std::cout << i + 1 << " " << d[i] << " " << f[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3108
using System;
using System.Linq;

namespace _0030
{
    class Program
    {

        static long ans;

        static void Cal(string str, long b)
        {

            switch (str)
            {
                case "+":
                    ans += b;
                    break;
                case "-":
                    ans -= b;
                    break;
                case "*":
                    ans *= b;
                    break;
                case "/":
                    ans /= b;
                    break;
                default:                   
                    break;

            }

           
        }


        static void Main(string[] args)
        {

            ans = 0;

            long a = long.Parse(Console.ReadLine());

            ans = a;

            string str;
            long b;

            do
            {
                str = Console.ReadLine();
                if (str == "=")
                {
                    Console.WriteLine(ans);
                    break;
                }
                b = long.Parse(Console.ReadLine());

                Cal(str, b);

            } while (true);
         
        }
    }
}


Measured memory_bytes: 16000
#include<cstdio>

bool judge(char a,char b){
    int u = (a-'0')*10 + (b-'0');
    return u<=12 && u>=1;
}

int main(){
    char s[5];
    scanf("%s",s);
    bool c1 = judge(s[0],s[1]);
    bool c2 = judge(s[2],s[3]);
    if(c1 && c2) printf("AMBIGUOUS\n");
    else if(c1) printf("MMYY\n");
    else if(c2) printf("YYMM\n");
    else printf("NA\n");
    return 0;
}

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

int main(){
    int n,d;
    cin >> n >> d;
    int x[n][d];
    rep(i,n){
        repj(j,d){
            cin >> x[i][j];
        }
    }
    int ans=0;
    for(int i=0; i<n; i++){
        for(int k=i+1; k<n; k++){
            double dist=0.0;
            repj(j,d){
                double tmp = x[i][j]-x[k][j];
                dist += (tmp*tmp);
            }
            dist = sqrt(dist);
            if(floor(dist)==dist){
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef pair<int,int> P;
#define X first
#define Y second
#define mid (l+r)/2
#define lc k<<1,l,mid
#define rc k<<1|1,mid+1,r
const int MAXN=3e5+10;
int n,m,k,seg[MAXN<<2],tag[MAXN<<2],res=0;
P dat[MAXN],st1[MAXN],st2[MAXN];

void pushdown(int k)
{
	if(!tag[k]) return;
	tag[k<<1]+=tag[k];seg[k<<1]+=tag[k];
	tag[k<<1|1]+=tag[k];seg[k<<1|1]+=tag[k];
	tag[k]=0;
}

void Update(int a,int b,int x,int k,int l,int r)
{
	if(a<=l&&r<=b){tag[k]+=x;seg[k]+=x;return;}
	pushdown(k);
	if(a<=mid) Update(a,b,x,lc);
	if(b>mid) Update(a,b,x,rc);
	seg[k]=max(seg[k<<1],seg[k<<1|1]);  
}

void solve()
{
	memset(seg,0,sizeof(seg));
	memset(tag,0,sizeof(tag));
	sort(dat+1,dat+k+1);
	
	int t1=0,t2=0;
	for(int i=1;i<=k;i++)
	{
		if(dat[i].Y<=m/2)
		{
			int lst=i-1;
			while(t1&&st1[t1].Y<dat[i].Y)
				Update(st1[t1].X,lst,st1[t1].Y-dat[i].Y,1,1,k),
				lst=st1[t1--].X-1;
			if(lst!=i-1) st1[++t1]=P(lst+1,dat[i].Y);
		}
		else
		{
			int lst=i-1;
			while(t2&&st2[t2].Y>dat[i].Y)
				Update(st2[t2].X,lst,dat[i].Y-st2[t2].Y,1,1,k),
				lst=st2[t2--].X-1;
			if(lst!=i-1) st2[++t2]=P(lst+1,dat[i].Y);			
		}
		
		st1[++t1]=P(i,0);st2[++t2]=P(i,m);
		Update(i,i,m-dat[i].X,1,1,k);
		res=max(res,seg[1]+dat[i+1].X);
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++) 
		scanf("%d%d",&dat[i].X,&dat[i].Y);
	dat[++k]=P(0,0);dat[++k]=P(n,m);
	solve();
	for(int i=1;i<=k;i++) 
		swap(dat[i].X,dat[i].Y);
	swap(n,m);
	solve();
	
	printf("%d",res*2);
	return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
string s;

int main(){FAST;xRand;
cin>>s;
if(sz(s)%2==1){
	cout<<"No"<<endl;
	return 0;
}
for(int i=0;i<sz(s);i+=2){
	if(s[i]=='h'&&s[i+1]=='i'&&i+1<sz(s)){
		;
	}else{
		cout<<"No"<<endl;
		return 0;
	}
}
cout<<"Yes"<<endl;

	// you should actually read the stuff at the bottom
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), slow multiset operations
	* do smth instead of nothing and stay organized
	* unordered_map, hash_map, scanf, calculate answer instead of ans*K
*/
/*


                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/




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

int main() {
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(begin(a), end(a));
	sort(begin(b), end(b));
	int m = 0;
	for (auto it = rbegin(b); it != rend(b) && *it > a.back() && h > 0; it++) {
		h -= *it;
		m++;
	}
	if (h > 0) {
		m += (h - 1) / a.back() + 1;
	}
	cout << m << endl;
	return 0;
}


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

#include <string>
int main(){
    int n; cin >> n;
    string str; cin >> str;
    long long r=0,g=0,b=0;
    for(int i=0; i<n; i++) {
        switch (str.at(i)){
            case 'R':
                r++;
                break;
            case 'G':
                g++;
                break;
            default:
                b++;
                break;
        }
    }
    long long ans = r*g*b;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            int k = 2*j-i;
            if(k>=n) continue;            
            if(str[i]!=str[j] && str[i]!=str[k] && str[j]!=str[k]) ans--;
        }
    }
    cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
	int64 a, b, c;
	cin >> a >> b >> c;
	cout << (2*b == a+c ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] intArray = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
                int h = intArray[0];
                int w = intArray[1];
                if (h == 0 && w == 0) break;

                for (int i=1; i<=w;i++)
                {
                    Console.Write('#');
                }
                Console.Write('\n');

                for (int j = 1; j <= h-2; j++)
                {
                    Console.Write('#');
                    for (int i = 1; i <= w - 2; i++)
                    {
                        Console.Write('.');
                    }
                    Console.Write('#');
                    Console.Write('\n');
                }
                

                for (int i = 1; i <= w; i++)
                {
                    Console.Write('#');
                }
                Console.Write('\n');
              	
				if(h!=0&&w!=0) Console.Write('\n');
            }
        }
    }
}



Measured memory_bytes: 16368
#include <stdio.h>
#define MAX_N 250

int N;
int heap[MAX_N];

int main() {
  int i, parent, left, right;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d", heap+i);
  }
  for(i = 0; i < N; ++i) {
    printf("node %d: key = %d, ", i+1, heap[i]);
    parent = (i-1)/2;
    left = i*2 + 1;
    right = i*2 + 2;
    if(i != 0) printf("parent key = %d, ", heap[parent]);
    if(left < N) printf("left key = %d, ", heap[left]);
    if(right < N) printf("right key = %d, ", heap[right]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2104
//#include <stdio.h>
#include <string>
#include <cstring> 
//#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    char str[5001]={0};
    scanf("%s", str);
    long len=strlen(str);
    
    long k;
    scanf("%ld", &k);

    vector<string> vv;

    long i;
    for(i=0; i<len; i++) {
        char tmp[6]={0};
        long k;
        for(k=0; k<5; k++) {
            if(i+k<len) {
                tmp[k]=str[i+k];
                vv.push_back( string(tmp) );
            }
        }
    }
    sort(vv.begin(), vv.end());
    unique(vv.begin(), vv.end());

    printf("%s\n", vv[k-1].c_str());

    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
stack<int> st;
int main()
{
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
    if(st.size()==0) st.push(s[i]);
    else if(st.top()==s[i]) st.push(s[i]);
    else st.pop();
  }
  cout<<n-st.size()<<endl;
  return 0;
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          Console.WriteLine(a[0]+a[1]>=a[2]?"Yes":"No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13268
def C():
    K, N = map(int, input().split())
    A = [int(n) for n in input().split()]
    minimum_distance = A[-1] - A[0]
    for i in range(1, N):
        minimum_distance = min(minimum_distance, K - A[-i] + A[-i-1])
    print(minimum_distance)
            
C()

Measured memory_bytes: 26444
#include <stdio.h>

int main()
{int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(W>=(x+r) && H>=(y+r))
    { if(x+r>0 && y+r>0)
        printf("Yes\n");
        else
            printf("No\n");
        
    }
    else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>  
using namespace std;  
typedef long long ll;  
const int INF = 0x3f3f3f3f;  
int main()  
{  
    int t;  
    cin>>t;  
    ll sum=0,a,b,minb=INF,flag=0;  
    while(t--){  
        cin>>a>>b;  
        sum+=b;  
        if(b<a&&minb>b)  
            minb=b;  
        if(b!=a)  
            flag=1;  
    }  
   
    if(flag==1)  
        cout<<sum-minb<<endl;  
    else  
        cout<<0<<endl;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long long ans = 0;
  for(int i = 0; i < n; i++){
    long long x; cin >> x;
    while(x%2 == 0){
      x /= 2;
      x *= 3;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print("hon")
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print("pon")
else:
    print("bon")

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

int main(){

    int n;
    while(cin>>n,n){
        int cnt[10]={0};
        while(n--){
            int a;
            cin>>a;
            cnt[a]++;
        }

        for(int i=0;i<10;i++){
            if(!cnt[i])cout<<"-"<<endl;
            else{
                for(int j=0;j<cnt[i];j++)cout<<"*";
                cout<<endl;
            }
        }
    }

    return 0;
}

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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

// Graph
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, C;
  cin >> N >> C;
  vector<vector<int>> imos(C + 1, vector<int>(100010, 0));
  for (int i = 0; i < N; i++)
  {
    int s, t, c;
    cin >> s >> t >> c;
    imos[c][s]++;
    imos[c][t + 1]--;
  }
  for (int i = 1; i <= C; i++)
  {
    for (int j = 1; j < 100010; j++)
    {
      imos[i][j] += imos[i][j - 1];
    }
  }
  int ans = 0;
  for (int j = 0; j < 100010; j++)
  {
    int cnt = 0;
    for (int i = 1; i <= C; i++)
    {
      if (imos[i][j])
        cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15860
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mm, tmp, ans = 0;
	cin >> nn >> mm;
	multiset<int64> aa;
	multiset<int64>::iterator ite;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		aa.insert(tmp);
	}
	for(int64 ii = 0;ii < mm;ii++)
	{
		ite = aa.end();
		ite--;
		tmp = *ite;
		ite = aa.erase(ite);
		aa.insert((int64)(tmp / 2));
	}
	for(ite = aa.begin();ite != aa.end();ite++)
	{
		ans += *ite;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8260