akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int> arr;
    int input,ans(0);
    for (int i = 0; i < n; i++)
    {
        cin>>input;
        arr.push_back(input);
    }
    sort(arr.begin(),arr.end());
    for (int i = 0; i < k; i++)
    {
        ans+=arr[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define MOD 1000000007

//RSQ セグメント木
struct SegmentTree{
private:
	int N;
	vector<long long> node;
	const long long DEFAULT = 0LL;
public:
	void init(int n){ //初期化する O(N)
		node.clear();
		N = 1;
		while(N < n) N *= 2;
		for(int i=0; i<2*N-1; i++) node.push_back(DEFAULT);
	}
	void update(int i, long long x){ //値を変更する O(log N)
		i += N - 1;
		node[i] = x;
		while(i > 0){
			i = (i-1)/2; //親の取得は(i-1)/2
			node[i] = node[i*2+1] + node[i*2+2]; //子の取得はi*2+1,i*2+2
		}
	}
	long long sum(int a, int b, int k=0, int l=0, int r=-1){ //[a,b)の和を求める O(log N)
		if(r == -1) r = N;
		if(r <= a || b <= l) return DEFAULT; //交差する場合
		if(a <= l && r <= b) return node[k]; //完全に含む場合
		return sum(a, b, k*2+1, l, (l+r)/2) + sum(a, b, k*2+2, (l+r)/2, r);
	}
};

int N;
vector<pair<LL,LL>> v,w;
SegmentTree st,exist;

LL binary_search(LL capa){
	int ok = 0;
	int ng = N+1;
	while(ng-ok > 1){
		int m = (ok+ng) / 2;
		LL c = exist.sum(0, m);
		if(c == 0 || st.sum(0, m) <= capa * c) ok = m;
		else ng = m;
	}
	return exist.sum(0, ok);
}


int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		LL a,b;
		scanf("%d%d", &a, &b);
		v.PB(MP(a,b));
	}
	sort(v.begin(), v.end());

	for(int i=0; i<N; i++){
		w.PB(MP(v[i].second,i));
	}
	sort(w.begin(), w.end());

	st.init(N);
	exist.init(N);

	LL ans = 0;
	for(int i=N-1; i>=0; i--){
		st.update(w[i].second, v[w[i].second].first);
		exist.update(w[i].second, 1LL);
		ans = max(ans, binary_search(w[i].first));
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 32716
a,b,c,d = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
L = c*d//gcd(c,d)
def f(x):
  return int(b//x-(a-1)//x)
print(b-a+1-f(c)-f(d)+f(L))
  

Measured memory_bytes: 38452
#include<stdio.h>

int main(){
        int i = 0,j = 0;
        int n = 1;
        int s[1000];
        int sum = 0;
        int tmp;
        while(1){
                scanf("%d",&n);
                if(n == 0)
                        break;               
                for(j=0;j<n;j++){
                        scanf("%d",&s[j]);
                }
                
                for(i = 0;i < n;i++){
                        for(j = n - 1; j > i; j--){
                                if(s[i] > s[j]){
                                        tmp = s[i];
                                        s[i] = s[j];
                                        s[j] = tmp;
                                }
                        }
                }
                for(j = 1;j < n - 1;j++){
                        sum += s[j];
                }
                printf("%d\n",sum/(n-2));                
                sum = 0;
        }        
        return 0;
}

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

const int maxn=1e5+9;

int a[maxn];
int p[maxn];
int q[maxn];
int cnt1[maxn];
int cnt2[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];

    for(int i=1;i<=n;i+=2)
    cnt1[a[i]]++;
    for(int i=2;i<=n;i+=2)
    cnt2[a[i]]++;

    int max1=-0x3f3f3f3f;
    int max2=-0x3f3f3f3f;
    int tmp1,tmp2;
    for(int i=1;i<=maxn;i++)
    {
        if(cnt1[i]>max1)
        {
            max1=cnt1[i];
            tmp1=i;
        }
    }
    for(int i=1;i<=maxn;i++)
    {
       if(cnt2[i]>max2)
        {
            max2=cnt2[i];
            tmp2=i;
        }
    }
    int flag=0;
    int k=a[1];
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=k)
            flag=1;
    }
    if(flag==0)
    printf("%d\n",n/2);
    else
    {
        if(tmp1==tmp2)
        {
            int tmp=0;
            for(int i=1;i<=maxn;i++)
            {
                if(i==tmp1) cnt1[i]=0;
                if(i==tmp2) cnt2[i]=0;
                tmp=max(tmp,max(cnt1[i],cnt2[i]));
            }
            printf("%d\n",(n/2-max1)+(n/2-tmp));
        }
        else
        printf("%d\n",(n/2-max1)+(n/2-max2));
    }
    return 0;
}


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

int main() {
  int64_t H,W;
  cin >> H >> W;

  if (H==1) {
    cout << "1" << endl;
  }
  else if (W==1) {
    cout << "1" << endl;
  }
  else {
    cout << (H*W+1LL)/2LL <<endl;
  }
  
}
 



Measured memory_bytes: 256
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    ans = 10**30
    for i in range(1<<N):
        hght = A[0]
        cst = 0
        cnt = 1
        for j in range(1,N):
            if (i>>j)&1:
                cnt += 1
                if A[j]<=hght: 
                    cst += hght-A[j]+1
                    hght += 1
                else:
                    hght = A[j]
            hght = max(hght,A[j])
        if cnt >= K:
            ans = min(ans,cst)
    
    print(ans)


if __name__ == "__main__":
    main()










Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b;
    cin >> a >> b;
    bool ans = a%3 == 0 || b%3 == 0 || (a+b) % 3 == 0;

    cout << (ans? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
import collections
n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

Ans=[0]*n

Chk=[False]*n
Dist=[float("inf")]*n
Chk[0]=True
Dist[0]=0
S=collections.deque()
S.append(0)
while S:
  s=S.popleft()
  for g in edge[s]:
    if not Chk[g]:
      S.append(g)
      Chk[g]=True
      Ans[g]=s+1



print("Yes")
for i in range(1,n):
  print(Ans[i])

Measured memory_bytes: 38636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

sx, sy, tx, ty = map(int, input().split())

tx -= sx
ty -= sy

s = str()
s += 'R' * tx
s += 'U' * ty
s += 'L' * tx
s += 'D' * (ty + 1)
s += 'R' * (tx + 1)
s += 'U' * (ty + 1)
s += 'L'
s += 'U'
s += 'L' * (tx + 1)
s += 'D' * (ty + 1)
s += 'R'

print (s)

Measured memory_bytes: 3064
// 2020-07-17 21:23:34
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

vector<vector<int> > G;
vector<int> dist;
void answer() {
  int n, m;
  cin >> n >> m;
  G.resize(3*n);
  dist.assign(3*n, -1);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].emplace_back(v+n);
    G[u+n].emplace_back(v+n+n);
    G[u+n+n].emplace_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;
  dist[s] = 0;
  queue<int> que;
  que.emplace(s);
  while(!que.empty()) {
    int u = que.front(); que.pop();
    for(int v : G[u]) {
      if(dist[v] >= 0) continue;
      dist[v] = dist[u] + 1;
      que.emplace(v);
    }
  }
  if(dist[t] == -1) cout << -1 << '\n';
  else cout << dist[t] / 3 << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(){
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
	
  	int ta, ac;
  	ta = ceil(double(C)/B);
  	ac = ceil(double(A)/D);
	ta = 2*ta - 1;
    ac = 2*ac;
  	if(ta < ac){cout << "Yes" << endl;}
  	else{cout << "No" << endl;}
}

Measured memory_bytes: 3624
using System;

namespace Multiples
{
    class Program
    {
        static void Main(string[] args)
        {
            int L, R, d ,cnt_i;

            string inD0 = Console.ReadLine();
            string[] cngD0 = inD0.Split(' ');

            
            L = int.Parse(cngD0[0]);
            R = int.Parse(cngD0[1]);
            d = int.Parse(cngD0[2]);

            cnt_i = 0;
            for (int i = L; i <= R; i++)
            {
                if((i % d) == 0)
                {
                    cnt_i++;
                }
            }


            Console.WriteLine(cnt_i);
        }
    }
}


Measured memory_bytes: 27380
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main(){
  string s; cin >> s;
  ll n = s.size();
  REP(i,n-1) if(s[i]==s[i+1]){
    cout << i+1 << " " << i+2 << endl;
    return 0;
  }
  REP(i,n-2) if(s[i]==s[i+2]){
    cout << i+1 << " " << i+3 << endl;
    return 0;
  }
  cout << -1 << " " << -1 << endl;
}



Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
typedef pair<ll, pair<ll, ll > > iip;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll N;
    cin >> N;

    string s1, s2; cin >> s1 >> s2;

    ll ans = 1;

    bool yokoF = false;
    bool tateF = false;
    for(ll i = 0; i < s1.length();){

        if(s1[i] == s2[i]){
            //最初縦並び1つ
            if(i != 0){
                if(yokoF == false){
                    ans *= 2;
                }else{
                    yokoF = false;
                }
            }else{
                ans *= 3;
            }
            i+=1;
            ans %= MOD;
            tateF = true;
        }else if(s1[i] == s1[i+1]){
            if(i != 0){
                if(tateF == false){
                    ans *= 3;
                }else{
                    ans *= 2;
                    tateF = false;
                }
            }else{
                ans *= 6;
                ans %= MOD;
            }
            ans %= MOD;
            i+=2;
            yokoF = true;
        }
    }  

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,even,odd;
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&x);
		if(x%2) odd++;
		else even++;
	}
	printf("%s\n",odd%2==0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
using ll = long long;
using namespace std;

int main() {
    int N, m, n = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> m;
        n += m - 1;
    }
    cout << n;

    return 0;
}

Measured memory_bytes: 256
s = list(map(int, input().split()))

if(s[0] == s[1] and s[1] == s[2]):
    print(1)
elif(s[0] == s[1] or s[1] == s[2] or s[0] == s[2]):
    print(2)
else:
    print(3)

    


    





Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;

int N; pair<int, int> R[200200];

const long long mod = 998244353;
long long D[200200];

const int Z = 1 << 18;
int T[Z * 2];

void push(int x, int j)
{
	x += Z;
	while (x){
		T[x] = max(T[x], j);
		x /= 2;
	}
}

int pop(int x, int y)
{
	int r = 0;
	x += Z; y += Z;
	while (x < y){
		if (x & 1) r = max(r, T[x++]);
		if (y & 1) r = max(r, T[--y]);
		x /= 2; y /= 2;
	}
	return r;
}

int main()
{
	scanf ("%d", &N);
	for (int i = 0; i < N; i++) scanf ("%d %d", &R[i].first, &R[i].second), T[i+Z] = i;
	for (int i = Z - 1; i >= 1; i--) T[i] = max(T[i * 2], T[i * 2 + 1]);
	sort(R, R + N);

	D[N] = 1;
	for (int i = N - 1; i >= 0; i--){
		int j = pop(i, lower_bound(R + i, R + N, make_pair(R[i].first + R[i].second, 0)) - R);
		push(i, j);
		D[i] = (D[i + 1] + D[j + 1]) % mod;
	}

	printf ("%lld\n", D[0]);

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define deb(x) cout<<"-->  "<<#x<<" :  "<<x<<endl;
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    set<string> st;
    for(int x=0;x<n;x++){
        string v;
        cin>>v;
        st.insert(v);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 19244
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	char buf[512];
	scanf("%s", buf);
	const char* kupc = "KUPC";
	int c[4];
	memset(c, 0, sizeof(c));
	for (int i = 0; buf[i] != '\0'; ++i)
	{
		for (int j = 0; j < 4; ++j)
		{
			if (kupc[j] == buf[i])
			{
				++c[j];
				break;
			}
		}
	}
	int m = 1000;
	for (int i = 0; i < 4; ++i)
	{
		if (c[i] < m)
			m = c[i];
	}
	printf("%d\n", m);

	return 0;
}

Measured memory_bytes: 0
N = int(input())
AN = list(map(int,input().split()))

ans = 1				#配列数。切らない場合1なので初期値1
beforeDiff = 0				#一つ前の差分値。初期値は任意
chgFlag = True				#区切りフラグ。初期値は0番目に区切った扱いにするのでTrue

for i in range(1,N):			#i-1を参照するため1スタート
	diff = AN[i] - AN[i-1]
	
	if chgFlag or beforeDiff==0:	#符号を維持(区切り直後、前回の差が0)
		beforeDiff = diff	#区切り直後の差分値を入れる(重要なのは符号)
		chgFlag = False	#区切らない
		continue
		
	if beforeDiff*diff < 0:		#以前と符号が逆なら区切る
		chgFlag = True		#区切る
		ans += 1
		
print(ans)

Measured memory_bytes: 14224
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.IntStream.Builder;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Stack<Integer> s1 = new Stack<Integer>();
        Stack<Puddle> s2 = new Stack<Puddle>();
        int i = 0;
        IntStream.Builder all_sum = IntStream.builder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int c;
        while((c = br.read()) != -1){
            if(c == '\\') s1.push(i);
            else if(c == '/' && !s1.isEmpty()){
                int j = s1.pop();
                all_sum.add(i - j);
                IntStream.Builder areas = IntStream.builder();
                while(!s2.isEmpty() && s2.peek().pos() > j)
                    areas.add(s2.pop().area());
                s2.push(new Puddle(j, areas.build().sum() + i - j));
            }
            ++i;
        }
        System.out.println(all_sum.build().sum());
        
        StringBuilder sb = new StringBuilder();
        sb.append(s2.size());
        for(Puddle p : new ArrayList<Puddle>(s2))
            sb.append(" ").append(p.area());
        
        System.out.println(sb);
    }
}

class Puddle{
    private int _pos;
    public int pos(){ return _pos; };
    private int _area;
    public int area(){ return _area; };
    
    public Puddle(int _pos, int _area){
        this._pos  = _pos;
        this._area = _area;
    }

}


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

void selectionSort(int num[], int N);
void swap(int& x, int& y);
void showArray(int num[], int N);

int main()
{
	int n;
	cin>>n;
	int *num = new int[n];
	for(int i = 0; i < n; i++)
		cin>>num[i];
	selectionSort(num, n);
	return 0;
}

void selectionSort(int num[], int N)
{
	int irekae = 0, min;
	for(int i = 0; i<N-1; i++)
	{
		min = i;
		for(int j = i+1; j < N; j++)
			if(num[j]<num[min])
				min = j;
		if(min != i)
		{
			swap(num[i], num[min]);
			irekae++;
		}
	}
	showArray(num, N);
	cout<<irekae<<endl;
}

void swap(int& x, int& y)
{
	int temp = x;
	x = y;
	y = temp;
}

void showArray(int num[], int N)
{
	cout<<num[0];
	for(int i = 1; i < N; i++)
		cout<<' '<<num[i];
	cout<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N, A, B;
  cin >> N >> A >> B;

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

  ll r = (N / (A + B)) * A;
  ll mod = N % (A + B);
  if (mod > A) {
    r += A;
  } else {
    r += mod;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int X=sc.nextInt();
		int Y=sc.nextInt();
		sc.close();
		int money=0;
		if(N>K) {
			for(int i=0;i<K;i++)
				money+=X;		
			for(int i=0;i<N-K;i++) 
				money+=Y;
		}else {
			for(int i=0;i<N;i++)
				money+=X;
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll dp[1000006][2][2]; // dp[i][j][k] := 長さがiで j=1で0を含む k=1で1を含む

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            rep(a,2)rep(b,2){
                if(j==0){
                    (dp[i+1][1][b] += dp[i][a][b])%=mod;
                }else if(j==1){
                    (dp[i+1][a][1] += dp[i][a][b])%=mod;   
                }else{
                    (dp[i+1][a][b] += dp[i][a][b])%=mod;
                }
            }
        }
    }
    cout << dp[n][1][1] % mod << endl;
}

Measured memory_bytes: 34728
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int M, K;
	scanf("%d%d", &M, &K);
	if(M == 0)
	{
		if(K==0)
			puts("0 0");
		else
			puts("-1");
		return 0;
	}
	if(M==1)
	{
		if(K==0)
			puts("0 0 1 1");
		else
			puts("-1");
		return 0;
	}
	if(K>=(1<<M))
	{
		puts("-1");
		return 0;
	}
	for(int i=(1<<M)-1; i>=1; --i)
		printf("%d ",i^K);
	printf("%d ", K);
	for(int i=1; i<=(1<<M)-1; ++i)
		printf("%d ",i^K);
	printf("%d ", K);
	puts("");
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	int i,j = 0;
	string str;
	bool flag = false;

	cin>>str;

	while(!flag) {
		flag = true;
		for(i = j;i < str.size();i++) {
			if(str[i] == 'S' && str[i+1] == 'T') {
				str.erase(i,2);
				flag = false;
				if(i != 0)
					j = i-1;
				break;
			}
		}
	}
	
	cout<<str.size();
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    s += s;
    if(s.find(t) != string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    if ((a+b)>=c) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const int INF=2e9;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;

map<pair<vi,vi>,int> dp;
int f(vi a, vi b) {
	if (a==b) return 0;
	auto it=dp.find(MP(a,b)); if (it!=dp.end()) return it->snd;
	int n=a.size();
	int hi=0;
	for (int x=0;x<n;x++) {
		if (a[x]==0) continue;
		int lo=1e9;
		vi c=a; --c[x];
		for (int y=0;y<n;y++) {
			if (b[y]==0) continue;
			vi d=b; --d[y];
			chkmin(lo,f(c,d)+1);
		}
		chkmax(hi,lo);
	}
	return dp[MP(a,b)]=hi;
}
ll smart(vi a, vi b) {
	if (a==b) return 0;
	int n=a.size();
	ll ans=0; ll extra=0;
	for (int i=0;i<n;i++) {
		if (a[i]<=b[i]) {
			ans+=b[i];
			extra+=b[i]-a[i];
		}
	}
	int mingain=INF;
	ll sumgain=0;
	for (int i=0;i<n;i++) {
		if (a[i]>b[i]) {
			int cost=a[i]-b[i]+1;
			int gain=b[i];
			if (cost<=extra) {
				sumgain+=gain;
				chkmin(mingain,gain);
			}
		}
	}
	if (mingain!=INF) ans+=(sumgain-mingain);
	return ans;
}
void solve(int N, vi A, vi B){
	printf("%lld\n",smart(A,B));
	return;
}
void test() {
	int seed=clock();
	srand(seed);
	int n=rand()%3+1;
	vi a,b;
	for (int i=0;i<n;i++) {a.PB(rand()%3);}
	for (int i=0;i<n-1;i++) b.PB(rand()%3);
	int diff=0;
	for (auto &w:a) diff+=w;
	for (auto &w:b) diff-=w;
	if (diff<0) return;
	b.PB(diff);
	int slow=f(a,b);
	int fast=smart(a,b);
	if (slow!=fast) {
		for (auto &w:a) printf("%d ",w); printf("\n");
		for (auto &w:b) printf("%d ",w); printf("\n");
		printf("slow:%d fast:%d seed:%d\n",slow,fast,seed);
		exit(0);
	}
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	//for (int i=0;i<1000;i++) test();
	int N;
	scanf("%d",&N);
	vi A(N-1+1);
	vi B(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%d",&A[i]);
		scanf("%d",&B[i]);
	}
	solve(N, A, B);
	return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;

int32_t main()
{
    IOS;

    int n,ans=0;
    
    cin>>n;
    
    int a[N];
    
    for(int i=1;i<=n;i++)
     cin>>a[i];
    
    sort(a+1,a+1+n);
    
    deque <int> fun;
    
    fun.push_front(a[1]);
    fun.push_back(a[n]);
    
    int i,j;
    
    for(i=2,j=n-1;i<j;)
    {
         int x=fun.front();
         int y=fun.back();
         
         int var1=max(abs(a[i]-x),abs(a[i]-y));
         int var2=max(abs(a[j]-x),abs(a[j]-y));
         
         if(var1>var2)
         {
          if(abs(a[i]-x)>abs(a[i]-y))
               fun.push_front(a[i]);
          else
               fun.push_back(a[i]);
               i++;
         }
         else
         {
              
               if(abs(a[j]-x)>abs(a[j]-y))
               fun.push_front(a[j]);
               else
               fun.push_back(a[j]);
               j--;
         }
                  
    }
    
    if(i==j)
    {
         int x=fun.front();
         int y=fun.back();
         
         
         if(abs(a[i]-x)>abs(a[i]-y))
          fun.push_front(a[i]);
         else
          fun.push_back(a[i]);
    }
    
    deque <int> :: iterator it,itr; 
    
    for(it=fun.begin();it!=fun.end();it++)
    {
         itr=it+1;
         if(itr==fun.end())
          break;
          
          ans+=abs(*it-*itr);
    }
    
    cout<<ans;
    
    return 0;

}

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

void solve(long long N, std::vector<std::string> S){
    map<string, ll> mp;
    for(ll i = 0; i < N; ++i) mp[S[i]]++;
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6376
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn median(x: &[i64]) -> i64 {
    let n = x.len();

    let mut x = x.to_owned();
    x.sort();

    if n % 2 == 0 {
        (x[n / 2 - 1] + x[n / 2]) / 2
    } else {
        x[n / 2]
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let mut A = vec![];
    let mut B = vec![];

    for _ in 0..N {
        let a = scan.word::<i64>();
        let b = scan.word::<i64>();

        let (a, b) = if N % 2 == 0 { (a * 2, b * 2) } else { (a, b) };

        A.push(a);
        B.push(b);
    }

    let am = median(&A);
    let bm = median(&B);

    let n = (bm - am + 1).max(0);

    println!("{}", n);
}


Measured memory_bytes: 13616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
signed main(){

	int N, M;
	cin>>N>>M;
	vpint A;
	for(int i=0;i<M;i++){
		int s, c;
		cin>>s>>c;
		s--;
		A.eb(s, c);
	}

	for(int i=0;i<1000;i++){
		string S=to_string(i);
		if(S.length()!=N)
			continue;
		//reverse(S.begin(), S.end());
		bool isOk=1;
		for(pint p:A){
			int s, c;
			tie(s, c)=p;
			if(S[s]-'0'!=c)
				isOk=0;
		}
		if(isOk){
			cout<<i<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;

	return 0;
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

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

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = 0;
    ans += (h2-h1)*60;
    ans += (m2-m1);
    ans-=k;

    cout << ans << endl;



    return 0;
}



Measured memory_bytes: 3648
# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    S = stdin.readline().rstrip()
    front = S[:int(len(S) / 2)]
    back = S[-int(len(S) / 2):][::-1]

    count = 0
    for i in range(len(front)):
        if front[i] != back[i]:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, n;
    cin >> h >> n;
    vll a(n), b(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
    // dp[i] : i ダメ与えるために必要な最小魔力
    vll dp(h + 1, 1e15);
    dp[0] = 0;

    REP(cur, h) {
        REP(i, n) {
            if (cur + a[i] > h) dp[h] = min(dp[h], dp[cur] + b[i]);
            else dp[cur + a[i]] = min(dp[cur + a[i]], dp[cur] + b[i]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
int main(void){
    while(1){
        int n, k, ans = 0;
        cin >> n >> k;
        if(n == 0 && k == 0) break;
        bool flag = false;
        vector<bool> num(n + 1, false);
        rep(i, k){
            int tmp; scanf("%d", &tmp);
            if(tmp == 0){
                flag = true;
                continue;
            }
            num[tmp] = true;
        }
        int pre = 0;
        int cnt = 0;
        int now;
        int end = 0;
        bool rennkekanouflag = false;
        reps(i, 1, n + 1){
            if(num[i] == true){
                if(i == end + 2) rennkekanouflag = true;
                cnt++;
            }else{
                now = cnt;
                if(flag == true){
                    if(rennkekanouflag == true) ans = max(ans, pre + now + 1);
                    else ans = max(ans, now);
                }else{
                    //printf("%d\n", now);
                    ans = max(ans, now);
                }
                cnt = 0;
                rennkekanouflag = false;
                pre = now;
                end = i;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3156
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	string s; cin>>s;
	int i=sz(s)-1;
	while(i!=-1){
		cerr<<i<<"\n";
		if(i>=4 && s.substr(i-4,5)=="dream") i-=5;
		else if(i>=6 && s.substr(i-6,7)=="dreamer") i-=7;
		else if(i>=4 && s.substr(i-4,5)=="erase") i-=5;
		else if(i>=5 && s.substr(i-5,6)=="eraser") i-=6;
		else{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int LR[1000][1000];
	int al[M];
	int ar[M];
	rep(i, 0, M) {
		int l, r;
		cin >> l >> r;
		al[i] = l;
		ar[i] = r;
	}
	int ap[Q];
	int aq[Q];
	rep(i, 0, Q) {
		int p, q;
		cin >> p >> q;
		ap[i] = p;
		aq[i] = q;
	}
	rep(i, 0, M) {
		for(int j = 1; j <= al[i]; ++j) {
			for (int k = ar[i]; k <= N; ++k) {
				++LR[j][k];
			}
		}
	}
	vi v(0);
	rep(i, 0, Q) {
		v.push_back(LR[ap[i]][aq[i]]);
	}
	repv(i, v) {
		cout << v[i] << endl;
	}
}


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

int main(){
  int N;
  cin >> N;
  char s[150];
  int i;
  for(i=0;i<N;i++){
    cin >> s[i];
  }
  int y=0;
  for(i=0;i<N;i++){
    if(s[i]=='Y'){
      y++;
    }
  }
  if(y){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    map<int, int> used;
    rep (i, 1000) {
        int num[4] = {i / 100, (i % 100) / 10, i % 10, -1};
        int s1 = i / 100, s2 = (i % 100) / 10, s3 = i % 10;
        int now = 0;
        rep (j, n) {
            if (s[j] - '0' == num[now]) now++;
        }
        if (now == 3) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int n,k,h=1;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		h+=min(h,k);
	}
	cout<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> P(N),p(N);
  for(int i=0;i<N;i++){cin >> S[i] >> P[i]; p[i]=-1*P[i];}
  vector<pair<string,int>> pa(N);
  for(int i=0;i<N;i++){pa[i]=make_pair(S[i],p[i]);}
  sort(pa.begin(),pa.end());
  map<pair<string,int>,int> ma;
  int cnt=1;
  for(int i=0;i<N;i++){
    ma[make_pair(pa[i].first,pa[i].second)]=cnt;
    cnt++;
  }
  vector<pair<int,int>> pb(N);
  for(int i=0;i<N;i++){
    pb[i].first=ma[make_pair(S[i],-1*P[i])]; pb[i].second=i+1;
  }
  sort(pb.begin(),pb.end());
  for(int i=0;i<N;i++)cout << pb[i].second << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if (s == "keyence") {
        cout << "YES" << endl;
        return;
    }
    REP(i,0,n) REP(j,i+1,n) {
        if (s.substr(0,i) + s.substr(j,n-j) == "keyence") {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[55];

int main(void){
	int n,i,j;
	ll ans = 0ll,tmp,mx;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	while(true){
		tmp = 0ll; mx=-INFLL;
		for(i=0; i<n; ++i){
			tmp += a[i]/n;
		}
		ans += tmp;
		for(i=0; i<n; ++i){
			a[i] -= (a[i]/n)*(n+1);
			a[i] += tmp;
			mx = max(mx,a[i]);
		}
		cout << endl;
		if(mx<n){
			cout << ans << endl;
			break;
		}
	}
	return 0;
}


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

int main()
{
    int N;
    while (cin >> N, N) {
        auto count_list = array<int, 10>();

        while (N--) {
            int kind;
            cin >> kind;
            count_list[kind]++;
        }

        for (auto count : count_list) {
            if (count > 0) {
                while (count--) {
                    cout << '*';
                }
            } else {
                cout << '-';
            }
            cout << endl;
        }
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;

int N, D;

int main(){
    cin >> N >> D;

    int ans = 0;
    int x = 0;
    while(x < N){
        ans++;
        x = x + 2 * D + 1;
    }

    cout << ans << endl;
}

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

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	char x;

	cin >> x;

	if (x >= 97 && x <= 122) {
		cout << "a" << endl;
	}
	else if (x >= 65 && x <= 90) {
		cout << "A" << endl;
	}
	return 0;
}

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

typedef long long ll;
const int maxn = 2e5 + 10;

int n;
ll a[maxn];
ll num[maxn] = {0};
ll sum = 0;


int main()
{
    scanf("%d",&n);
    ll maxx = -1;
    for(int i = 1; i <= n; i ++){
      scanf("%lld",&a[i]);
      maxx = max(maxx, a[i]);
      num[a[i]] ++;
    }
    for(int i = 1; i <= maxx; i ++){
      sum += (num[i] * (num[i] - 1)) / 2;
    }

    for(int i = 1; i <= n; i ++){
      ll ans = (num[a[i]] - 1) * (num[a[i]] - 2) / 2 + sum - ((num[a[i]] * (num[a[i]] - 1)) / 2);
      printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4736
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = parseInt(input.trim());
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var check = [000,111,222,333,444,555,666,777,888,999];
  for(var i = 0; i < check.length; i++){
    if(check[i - 1] < input && check[i] >= input){
       myout(check[i]);
      return;
       }else if(check[i] == input){
             myout(check[i]);
      return;   
                }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;

  rep(i, a + 1) {
    rep(j, b + 1) {
      rep(k, c + 1) {
        if (i * 500 + j * 100 + k * 50 == x) 
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

#define double long double
ll N;
double x[50], y[50];

double binsearch(double l, double r, bool(*f)(double)){
    long long loop = 0;
    while(r - l > 1e-9 && loop < 1000){
        double m = (l + r) / 2;
        if(f(m)) r = m;
        else l = m;
        loop++;
    }
    return r;
}

double l2(double a, double b, double c, double d){
    return (a - c) * (a - c) + (b - d) * (b - d);
}

double dist(double a, double b, double c, double d){
    return sqrt(l2(a, b, c, d));
}

bool exist(double r){
    REP(i, N - 1){
        FOR(j, i + 1, N){
            double d = dist(x[i], y[i], x[j], y[j]);
            if(2 * r < d) continue;
            double ux = (x[j] - x[i]) / d;
            double uy = (y[j] - y[i]) / d;
            double h = sqrt(r * r - l2(x[i], y[i], x[j], y[j]) / 4);
            double px = (x[j] + x[i]) / 2 - uy * h;
            double py = (y[j] + y[i]) / 2 + ux * h;
            double qx = (x[j] + x[i]) / 2 + uy * h;
            double qy = (y[j] + y[i]) / 2 - ux * h;
            bool ok = true;
            REP(k, N){
                if(k == i || k == j) continue;
                if(dist(px, py, x[k], y[k]) > r) ok = false;
                
            }
            if(ok) return true;
            ok = true;
            REP(k, N){
                if(k == i || k == j) continue;
                if(dist(qx, qy, x[k], y[k]) > r) ok = false;
            }
            if(ok) return true;     
        }
    }
    return false;
}

signed main(){
    cin >> N;
    REP(i, N) cin >> x[i] >> y[i];
    printf("%.9Lf\n",binsearch(0, 1e9, exist));
    return 0;
}

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

bool M(int a){
	if(a!=0 && a<=12){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	string S;
	cin>>S;
	string a,b;
	a=S.at(0);
	a+=S.at(1);
	b=S.at(2);
	b+=S.at(3);
	int c,d;
	c=stoi(a);
	d=stoi(b);
	if(M(c)&&M(d)){
		cout << "AMBIGUOUS"<<endl;
	}
	else if(M(c)&& !M(d)){
		cout<<"MMYY"<<endl;
	}
	else if(M(d) && !M(c)){
		cout <<"YYMM"<<endl;
	}
	else if(!M(d) && !M(c)){
		cout <<"NA"<<endl;
	}
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    rep(i, n) {
        char temp;
        cin >> temp;
        if (temp == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int g[7][2] = {
	{1, 2},
	{6, 3},
	{1, 6},
	{4, 5},
	{5, 2},
	{2, 1},
	{6, 6}
};

int main() {
	string str;
	while (cin >> str, str != "#") {
		int pos = 0;
		REP(i, str.size()) pos = g[pos][str[i] - '0'];
		
		if (pos == 5) puts("Yes");
		else puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if(a>b)
		cout << "a > b" << endl;
	else if(a==b)
			cout << "a == b" << endl;
		 else
		 	cout << "a < b" << endl;
	return 0;
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	long long ans = 1;
	int n; cin >> n;
	for_(i,1,n+1) {
		ans *= i;
		ans %= (long long)(1e9 + 7);
	}
	cout << ans << endl;
}

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

struct magic {
	int A;
	int B;
} ;

int useMagic[10001];

int main(void) {
	int H, N;
	cin >> H >> N;
	vector <magic> M(N);
	for (int i = 0; i < N; i++) {
		cin >> M[i].A >> M[i].B;
	}

	for (int i = 0; i <= 10000; i++) {
		useMagic[i] = 10000*10000+1;
	}

	useMagic[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int before = 0; before < H; before++) {
			int after = before + M[i].A;
			if (after > H) after = H;
			useMagic[after] = min(useMagic[after], useMagic[before] + M[i].B);
		}
	}
	cout << useMagic[H] << endl;
  return 0;
}


Measured memory_bytes: 384