akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector <vector <int>> ar(100, vector <int>());
	for(int i=0; i<m; i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int x;
			cin >> x;
			ar[i].pb(x);
		}
	}	

	vector <int> p(100);
	for(int i=0; i<m; i++) cin >> p[i];
	int res=0;

	// bitmask
	for(int i=0; i<(1<<n); i++){
		bool ok = true;
		for(int j=0; j<m; j++){
			int sum = 0;
			for(int x: ar[j]){
				if( i & (1 << (x-1)) )
					sum++;
			}
			if(sum % 2 != p[j]){
				ok = false;
				break;
			}
		}
		if(ok){
			res++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 100010;
int n, m;
map<int, int> ma;
int val[N + N], sz[N + N], len = 0;
ll sum = 0, size;

int main() {
	srand(19260817);
	scanf("%d%d", &n, &m);
	for(int i = 1 ,x; i <= n; i++) scanf("%d", &x), ++ma[x];
	for(int i = 1; i <= m; i++) {
		int x, y; scanf("%d%d", &x, &y);
		ma[y] += x;
	}
	for(map<int, int>::iterator it = ma.begin(); it != ma.end(); ++it)
		val[++len] = it->first, sz[len] = it->second;
	for(int i = len; i; i--) {
		sum += (ll)sz[i] * val[i], size += sz[i];
		if(size >= n) {
			sum -= (ll)val[i] * (size - n); break;
		}
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int D = sc.nextInt();
        
        switch (D) {
        case 22:
            System.out.println("Christmas Eve Eve Eve");
            break;
        case 23:
            System.out.println("Christmas Eve Eve");
            break;
        case 24:
            System.out.println("Christmas Eve");
            break;
        default:
            System.out.println("Christmas");
        }
		
	}
}


Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
T = [[] for _ in range(N)]

for i in range(N-1):
  a, b = map(int, input().split())
  T[a-1].append(b)
  T[b-1].append(a)
PX = [list(map(int, input().split())) for _ in range(Q)]
C = [0 for _ in range(N)]
for p, x in PX:
  C[p-1] += x

def dfs(node, previousNode, previousPoint):
  C[node-1] += previousPoint
  for next in T[node-1]:
    if next != 1 and next != previousNode:
      dfs(next, node, C[node-1])
dfs(1, 0, 0)
print(" ".join(map(str, C)))

Measured memory_bytes: 266048
/*
*
*Problem Link : https://atcoder.jp/contests/dp/tasks/dp_s
*Platform: atcoder
*Status: correct
*Author: Mayukh Chakrabarti
*
*/

#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false)
#define boost cin.tie(NULL)
#define booster cout.tie(NULL)
#define endl "\n"
typedef long long int lld;

#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

using namespace std;

/*
* we require 3 states in this digit-dp question: position,tight and sum
*/
const lld mod = 1e9 + 7;
const lld N= 10005;
lld dp[N][2][105];
string k;
lld d;

lld solve(lld pos,bool tight,lld sum){
	if(pos == k.length())
		return sum==0 ;
	if(dp[pos][tight][sum] != -1)
		return dp[pos][tight][sum];
		
	lld ans= 0;
	lld end= ((tight)? (k[pos]-'0') : 9);
	
	for(lld i=0; i<=end ; i++){
		
		ans= (ans + solve(pos+1 , tight&(i==end) , (sum+i)%d) ) % mod;
	}
	
	return dp[pos][tight][sum] = ans;
	
	
}


int main(){
	
	speed;boost;
	
	cin>>k;
	cin>>d;
	
	
	memset(dp,-1,sizeof dp);
	cout<<( solve(0,1,0) - 1  + mod) % mod;//0 will also be calculated. So, we are decreasing the solution by 1.
	
	return 0;
}



Measured memory_bytes: 17408
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        int[] v = new int[N+1];
        int[] w = new int[N+1];

        for(int i=1; i<N+1; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        int dp[][] = new int[N+1][W+1];
        for(int i=0; i<N+1; i++)
            Arrays.fill(dp[i], 0);

        for(int ni=1; ni<N+1; ni++) {
            for(int wi=1; wi<W+1; wi++) {
                dp[ni][wi] = dp[ni - 1][wi];
                if(wi-w[ni] >= 0)
                    dp[ni][wi] = Math.max(dp[ni][wi], dp[ni-1][wi-w[ni]] + v[ni]);
            }
         }

        System.out.println(dp[N][W]);
    }
}



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

int main(){
  string S;
  string T;
  cin>>S;
  T="";
  int len=S.length();
  for (int i=0;i<len;i++){
    if(S.at(i)=='0'){
      T=T+"0";
    }
    if(S.at(i)=='1'){
      T=T+"1";
    }
    if((S.at(i)=='B')&&(!(T==""))){
      T=T.substr(0,T.length()-1);
    }
  }
  cout<<T<<endl;
}

      
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int cnt[4] = {};
    for (int i = 0; i < 3; i++) {
        int a, b; cin >> a >> b; a--, b--;
        cnt[a]++;
        cnt[b]++;
    }
    for (int i = 0; i < 4; i++) {
        if (cnt[i] == 3) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
/* C */

#include <iostream>
#include <iomanip>
using namespace std;

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

	double N = (double) n;

	double sum = 0;

	for (int i = 1; i <= n; ++i)
	{
		double cnt = 1 / N;
		int goal = k;
		while(goal > i){
			goal = (goal+1) /2;
			cnt /= 2;
		}
		sum += cnt;
	}

	cout << std::setprecision(12) << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define F 1001
using namespace std;
int dp[F][F];
int main(){
	for(int i=1;i<F;i++)for(int j=1;j<F;j++)dp[i][j]=0;
	for(int i=0;i<F;i++)dp[0][i]=1;
	for(int i=0;i<F;i++)dp[i][0]=1;
	for(int i=1;i<F;i++)for(int j=1;j<F;j++)dp[i][j]=(dp[i-1][j]+dp[i][j-1])%100000007;

	int r,e,a,b,c,d,ans;
	cin>>r>>e>>a>>b>>c>>d;
	a-=c,b-=d;
	if(a<0)a=-a;if(b<0)b=-b;
	if(a*2>r)a=r-a;if(b*2>e)b=e-b;
	ans=dp[a][b];
	if(a*2==r)ans*=2;if(b*2==e)ans*=2;
	cout<<ans%100000007<<endl;
	return 0;
}

Measured memory_bytes: 6952
N = int(input())

s = []
Binfront = 0
Ainend = 0
bothAB = 0
ABs = 0
for i in range(N):
    inputstring = input()
    s.append(inputstring)
    ABs += inputstring.count("AB")
    
    if inputstring[0] == "B" and inputstring[len(inputstring)-1] == "A":
        bothAB += 1
    elif inputstring[0] == "B":
        Binfront += 1
    elif inputstring[len(inputstring)-1] == "A":
        Ainend += 1


if bothAB > 0:
    ABs += bothAB - 1
    if Ainend > 0:
        ABs += 1
        Ainend -= 1
    if Binfront > 0:
        ABs += 1
        Binfront -= 1
ABs += min(Ainend,Binfront)

print(ABs)

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

int main() {
  int n,m;
  cin >> n >> m;
  
  int a[n];
  double count = 0;
  for (int i=0; i<n; i++){
	cin >> a[i];
    count = count + a[i];
  }
  
  
  double cond = count / (m*4);
  sort(a, a + n, greater<>());
  
  if (a[m-1] >= cond){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
   
  return 0;
}


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

int main() {
	string n;
	cin >> n;
	if ((n[0]==n[1]&&n[1]==n[2]) || (n[1]==n[2]&&n[2]==n[3])) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll>R(n),G(n),B(n),Rsum(n + 1),Gsum(n + 1),Bsum(n + 1);
  rep(i,n){
    if(s[i] == 'R')R[i]++;
    else if(s[i] == 'G')G[i]++;
    else B[i]++;
  }
  ll ans = 0;
  rep(i,n)Rsum[i + 1] = Rsum[i] + R[i];
  rep(i,n)Gsum[i + 1] = Gsum[i] + G[i];
  rep(i,n)Bsum[i + 1] = Bsum[i] + B[i];
  rep(i,n)REP(j,i + 1,n){
    if(s[i] == s[j])continue;
    ll tmp = 0,cum = j - i;
    char a = s[i],b = s[j];
    if(a > b)swap(a,b);
    if(a == 'B' && b == 'G'){// R
      tmp = Rsum[n] - Rsum[j];
      if(cum + j < n)if(s[cum + j] == 'R' && tmp > 0)tmp--;
    }
    else if(a == 'B' && b == 'R'){// G
      tmp = Gsum[n] - Gsum[j];
      if(cum + j < n)if(s[cum + j] == 'G' && tmp > 0)tmp--;
    }
    else if(a == 'G' && b == 'R'){
      tmp = Bsum[n] - Bsum[j] ;
      if(cum + j < n)if(s[cum + j] == 'B' && tmp > 0)tmp--;    
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
#![allow(non_snake_case)]

fn main() {
    // let s = std::io::stdin();
    // let mut sc = Scanner { stdin: s.lock() };
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    //let n: usize = sc.read();
    //let a: Vec<u64> = sc.vec(n);
    //let s = sc.chars();
    //let mut A: Vec<Vec<u64>> = (0..n).map(|_| sc.vec(n)).collect();
    let D:usize = sc.read();
    let C:Vec<i64> = sc.vec(26);
    let S: Vec<Vec<i64>> = (0..D).map(|_| sc.vec(26)).collect();
    let mut T: Vec<usize> = (0..D).map(|_| sc.read()).collect();
    let M: usize = sc.read();
    let DQ: Vec<Vec<usize>> = (0..M).map(|_| sc.vec(2)).collect();

    for v in DQ{
        let mut ans:i64 = 0;
        let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
        let d = v[0];
        let q = v[1];
        T[d-1] = q;
        for i in 0..D{
            ans += S[i][T[i]-1];
            past[T[i]-1] = i as i64;
            for j in 0..26{
                ans -= C[j]*((i as i64)-past[j]);
            }
        }
        println!("{}", ans);
    }
}

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);


impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}





Measured memory_bytes: 7516
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] S = new int[n];
		
		for (int i = 0; i < n; i ++) {
			S[i] = scanner.nextInt();
		}
		
		scanner.close();
		
		int count = mergeSort(S, 0, n);
		
		for (int i = 0; i < n - 1; i ++) {
			System.out.print(S[i] + " ");
		}
		System.out.println(S[n - 1]);
		
		System.out.println(count);
	}
	
	public static int merge(int[] A, int left, int mid, int right) {
		int count = 0;
		
		int n1 = mid - left;
		int n2 = right - mid;
		
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		
		System.arraycopy(A, left, L, 0, n1);
		L[n1] = Integer.MAX_VALUE;
		System.arraycopy(A, mid, R, 0, n2);
		R[n2] = Integer.MAX_VALUE;
		
		int i = 0;
		int j = 0;
		
		for (int k = left; k < right; k ++) {
			count ++;
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i ++;
			} else {
				A[k] = R[j];
				j ++;
			}
		}
		
		return count;
	}
	
	public static int mergeSort(int[] A, int left, int right) {
		int count = 0;
		
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			count += mergeSort(A, left, mid);
			count += mergeSort(A, mid, right);
			count += merge(A, left, mid, right);
		}
		
		return count;
	}
} 



Measured memory_bytes: 170460
//Ojas Kumar Dubey //
// el_freki //
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int md=1000000007;
#define test int t;cin>>t;while(t--)
#define f(i,j,n) for(int i=j;i<n;i++)
#define r(i,j,n) for(int i=j-1;i>=n;i--)
#define min INT_MIN
#define max INT_MAX
#define all(container) container.begin() , container.end()
#define sz(container) (int)container.size()
#define pii pair <int , int>
#define pll pair <long long int , long long int>
#define setp(x) setprecision(x)
// ------------------------------------Template End------------------------------ //
int main()
{
	fast;
	int n;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];	
	}
	for(int i=0;i<n-1;i++){
		cin>>c[i];
	}
	int p=0;
	for(int i=0;i<n;i++){
		p+=b[a[i]-1];
		if(a[i+1]==a[i]+1){
			p+=c[a[i]-1];
		}	
	}
	cout<<p;
}



Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(A, B, C) :- B - A =:= C - B.

main :-
    get_number(A, B, C),
    f(A, B, C) -> writeln("YES") ; writeln("NO").


Measured memory_bytes: 7964
N = int(input())
cards = list(map(int,input().split()))
print(" ".join(map(str,cards)))

for i in range(1,N):
    tmp = cards[i]
    j = i - 1
    while j >= 0 and tmp < cards[j]:
        cards[j+1] = cards[j]
        cards[j] = tmp
        j -= 1
    print(" ".join(map(str,cards)))



Measured memory_bytes: 5600
n,m,l = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]

for i in range(n):
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += a[i][k]*b[k][j]
        if j == l-1: print(ans)
        else: print(ans,end=' ')


Measured memory_bytes: 6572
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        if (n % 2 == 1) {
            System.out.println("No");
            return;
        }
        System.out.println(s.substring(0, n/2).equals(s.substring(n/2)) ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define ulli unsigned long long int
#define ui unsigned int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define eps 0.000001
#define endl '\n'
 
using namespace std ;
 
#define MAXN 100001
//lli spf[MAXN];  
//void sieve();
//set<lli> factors(lli x);
//void getZarr(string str, lli Z[]);
 
 
//lli power(lli x,lli y,lli p);
lli cnt[1000000 + 5]={0};
vector<pll> fac(lli n) 
{ 
    vector<pll> v;
    lli count = 0; 
  
    while (n%2 == 0)
     { 
        n /= 2; 
        count++; 
    } 
  
    if (count > 0) 
        v.pb({2,count}); 
  
    for (lli i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count > 0) 
            v.pb(mp(i,count)); 
    } 
  
    if (n > 2)  
        v.pb(mp(n,1));
    return v;
} 

int main()
{  
 


    lli n,p;
    cin>>n>>p;
    
    vector<pll> q;
    q=fac(p);
    
    lli ct=1;
    for(auto x:q)
      ct=ct*(pow(x.ff,x.ss/n));
    
    cout<<ct<<endl;


    

} 
 


    /*void sieve() 
    { 
        spf[1] = 1; 
        loopl(i,2,MAXN) 
            spf[i] = i; 
        for (lli i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
      
        for (lli i=3; i*i<MAXN; i++) { 
            if (spf[i] == i) { 
                for (lli j=i*i; j<MAXN; j+=i) 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        }
 
    } */
    /*
    multiset<lli> factors(lli x) 
    { 
        multiset<lli> pr; 
        while (x != 1) 
        { 
            pr.insert(spf[x]); 
            x = x / spf[x]; 
        } 
        return pr; 
    }
 
    */
 
 
 
    /*void getZarr(string str, lli Z[])
    {
        lli n = str.length();
        lli L, R, k;
        L = R = 0;
        for (lli i = 1; i < n; ++i){
            if (i > R){
                L = R = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            } else {
                k = i-L;
                if (Z[k] < R-i+1)
                    Z[i] = Z[k];
                else {
                    L = i;
                    while (R<n && str[R-L] == str[R])
                        R++;
                    Z[i] = R-L;
                    R--;
                }
            }
        }
    }
 
    */
 
 
   /* lli power(lli x, lli y, lli p) 
    { 
        lli res = 1;   
        x = x % p;  
        while (y > 0) 
        { 
            if (y & 1) 
                res = (res*x) % p; 
      
            y = y>>1;  
            x = (x*x) % p;   
        } 
        return res; 
    } 
    */
 

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


signed main(){
   string s;
   string q ="keyence";
   cin >> s;
   int i=0;
   int t=0;
   for(int j=0;j<7;j++){
    
       if(i==0){
           if(q[j]!=s[j]){
               i=1;
            if(q[j]!=s[j-7+s.length()])t=1;
            }
       }
       else{
           if(q[j]!=s[j-7+s.length()])t=1;
       }
   }
   if(t==0)cout <<"YES";
   else cout <<"NO";



    return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    create_mod_tables(2100000);
    int64_t now = comb_mod(r1+c1, r1);
    int64_t ans = now;
    int r = r1, c = c1;
    for(int s=r1+c1+1; s<=r2+c2; s++){
        mul(now, 2);
        add(now, comb_mod(s-1, r+1));
        add(now, comb_mod(s-1, c+1));
        r++;
        c++;
        if(r > r2){
            add(now, MOD - comb_mod(s, r));
            r--;
        }
        if(c > c2){
            add(now, MOD - comb_mod(s, c));
            c--;
        }
        add(ans, now);
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int n;
double dp[300+2][300+2][300+2];

double rec(int i, int j, int k) {
  if(dp[i][j][k] >= 0) return dp[i][j][k];
  if(i == 0 && j == 0 && k == 0) return 0;

  double &ret = dp[i][j][k];
  ret = 0;
  if(i > 0) ret += rec(i-1, j, k) * i;
  if(j > 0) ret += rec(i+1, j-1, k) * j;
  if(k > 0) ret += rec(i, j+1, k-1) * k;
  ret += n;
  ret *= 1.0/(i+j+k);

  return ret;
}

int main()
{
  cin >> n;
  vector<int> num(4, 0);
  rep(i, n) {
    int a; cin >> a;
    ++num[a];
  }
  rep(i, 302) rep(j, 302) rep(k, 302) dp[i][j][k] = -1; 
  printf("%0.13f\n", rec(num[1], num[2], num[3]));
}

Measured memory_bytes: 215552
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; vl num(100001,0); ll sum = 0; ll count = 0;
  rep(i,n){ ll x; cin >> x; num[x]++; }
  
  for(ll i=0; i < 100001; i++){
    if(num[i] != 0){
      sum += num[i] - 1;
      count++;
    }
  }
  if(count == 1) cout << 1 << endl;
  else if(sum % 2 == 0) cout << count << endl;
  else cout << count - 1 << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}

int main(){
	int N;
	cin >> N;
	vector<string> S = getv<string>(N);

	long long c[5] = {};
	rep(i,N){
		char ch = S[i][0];
		if(ch=='M') c[0]++;
		else if(ch=='A') c[1]++;
		else if(ch=='R') c[2]++;
		else if(ch=='C') c[3]++;
		else if(ch=='H') c[4]++;
	}
	// rep(i,5)
	// 	cout << c[i] << " ";
	// cout << endl;

	long long sum = 0;
	sum += c[0]*c[1]*c[2];
	sum += c[0]*c[1]*c[3];
	sum += c[0]*c[1]*c[4];
	sum += c[0]*c[2]*c[3];
	sum += c[0]*c[2]*c[4];
	sum += c[0]*c[3]*c[4];
	sum += c[1]*c[2]*c[3];
	sum += c[1]*c[2]*c[4];
	sum += c[1]*c[3]*c[4];
	sum += c[2]*c[3]*c[4];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 6640
n,m,x = map(int, input().split())
c = []
data = []
for i in range(n):
    q = list(map(int, input().split()))
    c.append(q[0])
    data.append(q[1:])

ans = 10**10
for i in range(1<<n):
    use = []
    for bit in range(n):
        if i>>bit&1:
            use.append(bit)
    under = [0 for _ in range(m)]
    now = 0
    for j in use:
        for k,a in enumerate(data[j]):
            under[k] += a
        now += c[j]
    check = True
    for k in range(m):
        if under[k] < x:
            check = False
    if check:
        ans = min(ans, now)

print(ans if ans < 10**10 else -1)

Measured memory_bytes: 69096
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}

const ll MAXN = (ll)3e3+10;
const long long INF = 1LL<<60;
ll dp[MAXN][MAXN];

int main(void) {
   string s,t;
   cin>>s;
   cin>>t;
   rep(i,MAXN) rep(j,MAXN) dp[i][j] = 0;
   rep (i,s.size()) rep(j,t.size()) {
      if (s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
      else {
         chmax(dp[i+1][j+1],dp[i][j+1]);
         chmax(dp[i+1][j+1],dp[i+1][j]);
      }
   }
   // cout<<dp[s.size()][t.size()]<<endl;

   int i = s.size();
   int j = t.size();
   stack<char> ans;
   while(1) {
      if (i==0 || j==0) break;
      if (dp[i][j]==dp[i-1][j]) i--;
      else if (dp[i][j-1]==dp[i][j]) j--;
      else {
         i--;
         j--;
         // cout<<s[i]<<endl;
         ans.push(s[i]);
      }
   }
   while(ans.size()) {
      cout<<ans.top();
      ans.pop();
   }
   cout<<endl;




   return 0;
}

Measured memory_bytes: 71040
Sp = input()
T = input()
len_Sp = len(Sp)
len_T = len(T)
ans = ''
cnt = 0

i = len_Sp-len_T
while(i >= 0):
    j = len_T-1
    while(j >= 0):
        if Sp[i + j] == T[j] or Sp[i + j] == '?':
            cnt += 1
        else:
            cnt = 0
            break;
        j -= 1
    if cnt == len_T:
        Sp_list = list(Sp)
        for k in range(len_T):
            Sp_list[i + k] = T[k]
        ans = ''.join(Sp_list)
        ans = ans.replace('?', 'a')
        print(ans)
        break;
    i -= 1
if cnt != len_T:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int a,b,c; cin>>a>>b>>c;
  int x[a][b],y[b][c];
  rep(i,0,a) rep(j,0,b) cin>>x[i][j];
  rep(i,0,b) rep(j,0,c) cin>>y[i][j];
  ll z[a][c];
  rep(i,0,a){
    rep(j,0,c){
      ll d=0;
      rep(k,0,b){
        d+=x[i][k]*y[k][j];
      }
      z[i][j]=d;
    }
  }
  rep(i,0,a){
    rep(j,0,c){
      cout<<z[i][j];
      if(j!=c-1) cout<<" ";
    }
    co("");
  }
  
  return 0;
}


Measured memory_bytes: 3236
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#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;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    ll ans = 0;
    ans += a[0] != 0;
    a[0] = 0;
    vector g(n, vector<ll>());
    rep(i,1,n){
        g[a[i]].emplace_back(i);
    }
    vector depth(n, vector<ll>());
    vector<ll> dp(n);

    auto dfs = [&](auto self, ll now, ll pre = -1, ll d = 0) -> void {
        depth[d].emplace_back(now);
        for(auto to : g[now]){
            if(to == pre)continue;
            self(self, to, now, d + 1);
        }
    };

    dfs(dfs, 0);
    rrep(i,n,0){
        for(auto j : depth[i]){
            ll d = 0;
            for(auto to : g[j]){
                if(dp[to] == k && j != 0){
                    ans++;
                    dp[to] = 0;
                }
                chmax(d, dp[to]);
            }
            d++;
            dp[j] = d;
        }
    }
    debug(depth, dp);
    cout << ans << "\n";
}

Measured memory_bytes: 25100
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int n;  cin >> n;
    int cnt = 0;
    for(int x=0;x<n;x++){
        int t;  cin >> t;
        if(t != x+1)
            cnt++;
            if(cnt > 2){
                cout << "NO";
                exit(0);
            }
    }
   
    cout << "YES";

    return 0;
}


Measured memory_bytes: 256
while True:
  a,b= map(int,raw_input().split())
  if a== 0 and b ==0: break
  c=b-a
  ans,ans2,ans3=0,0,0
  while c>=1000:
    c-=1000
    ans+=1
  while c>=500:
    c-=500
    ans2+=1
  while c>=100:
    c-=100
    ans3+=1
  else:
    print ans3,ans2,ans

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

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

	if (a+b >= c)
    {
     cout << c + b << endl; 
    }
  else if (a+b < c)
  {
   cout <<  b + a+b + 1 << endl;
  }
}


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

#define abs(N) (((N)>0)?(N):(-1)*(N))

#define W 101
#define NAN -10000
// candidate of height

int mht(int x,int y, int _x, int _y){
	return abs(x-_x)+abs(y-_y);
}

int main() {
	int N;
	cin >> N;
	int x[N],y[N],h[N];
	for (int k = 0; k < N; ++k) {
		cin >> x[k] >> y[k] >> h[k];
	}
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < W; ++j) {
			bool flag=true;
			int hij=NAN;
			for (int k = 0; k < N; ++k) {
				if(h[k]!=0){
					int d = mht(x[k],y[k],i,j);
					if(hij==NAN){
						hij = h[k]+d;
					}else{
						if(hij!=h[k]+d) flag=false;
					}
				}
			}
			for (int k = 0; k < N; ++k) {
				if(h[k]==0){
					int d = mht(x[k],y[k],i,j);
					if(hij>d){
						flag=false;
					}
				}
			}
			if(flag){
				printf("%d %d %d",i,j,hij);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152 {
    class C {
        static void Main (string[] args) {
            int n = int.Parse (Console.ReadLine ());
            int[] p = Console.ReadLine ().Split ().Select (int.Parse).ToArray ();
            int ans = 1;
            int min = p[0];
            for (int i = 1; i < n; i++) {
                if (min < p[i]) {} else { ans++; min = p[i]; }
            }
            Console.WriteLine (ans);
        }
    }
}

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

int main()
{
  int n, k;
  std::cin >> n >> k;
  int64_t ans = k;
  for (int i = 0; i < n - 1; ++i)
  {
    ans *= (k - 1);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
/***************************************************************
	File name: AtCoderAGC040F.cpp
	Author: ljfcnyali
	Create time: 2020年06月07日 星期日 09时53分17秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 1e7 + 10;
const int Mod = 998244353;

int ans, n, a, b, X, Y, fac[maxn], inv[maxn];

inline int power(int a, int b){ int r = 1; while ( b ) { if ( b & 1 ) r = r * a % Mod; a = a * a % Mod; b >>= 1; } return r; }

inline int C(int n, int m) { return n < m ? 0 : (fac[n] * inv[m] % Mod) * inv[n - m] % Mod; }

inline int Get(int x, int y)
{
    return C(x + y - 1, x - 1) - C(x + y - 1, y - 1);
}

signed main()
{
    n = maxn - 10;
    fac[0] = inv[0] = 1; REP(i, 1, n) fac[i] = fac[i - 1] * i % Mod;
    inv[n] = power(fac[n], Mod - 2); for ( int i = n - 1; i >= 1; -- i ) inv[i] = inv[i + 1] * (i + 1) % Mod;
    scanf("%lld%lld%lld", &n, &a, &b); 
    if ( a == 0 && b == 0 ) { puts("1"); return 0; }
    X = b; Y = b - a;    
    if ( X + (X - Y) == n ) ans = Get(X, X - Y);
    REP(i, 1, n)
    {
        b = n - i - X;
        if ( b < 0 ) break ;
        int H = X - b;
        if ( H < Y ) continue ;
        H -= Y;
        int num = Get(X, b);
        ans = (ans + num * C(H + i - 1, i - 1)) % Mod;
    }
    printf("%lld\n", (ans + Mod) % Mod);
    return 0;
}


Measured memory_bytes: 156544
"use strict";

function difference(setA, setB) {
    var _difference = new Set(setA);
    for (var elem of setB) {
        _difference.delete(elem);
    }
    return _difference;
}

function main(input) {
    let line = input.split("\n");
    let AB = new Set(line.slice(0, line.length - 1));
    for (let s of difference(new Set(["1", "2", "3"]), AB)) {
        console.log(s);
        break;
    }
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s, c;
    int q, t, f;
    bool isReverse = false;
    cin >> s >> q;
    rep(i, q){
        cin >> t;
        if (t == 1){
            isReverse = !isReverse;
        }
        else{
            cin >> f >> c;
            if (f == 1){
                if(isReverse){
                    s += c;
                }
                else{
                    s.insert(0, c);
                }
            }
            else{
                if(isReverse){
                    s.insert(0, c);
                }
                else{
                    s += c;
                }
            }
        }
    }
    if (isReverse) reverse(all(s));
    cout << s << endl;
}

Measured memory_bytes: 900
#include<stdio.h>
#include<string.h>

int main(void)
{
  //宣言
  int K,i;
  char S[100],s[101];
  S[0] = '\n';
  s[0] = '\n';
  //読み込み
  scanf("%d",&K);
  scanf("%s",S);
  //結果
  if(strlen(S)>K)
  {
  	for(i=0;i<K;i++)
    {
      printf("%c",S[i]);
    }
   printf("...");
  }else{
	printf("%s",S);
  }

  return 0;

}

Measured memory_bytes: 1724
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int N,M,K,D[20],v[105][105];
bool visit[(1<<16)];
int bits[105] = {};

int main() {
  cin>>N>>M>>K;
  REP(i,0,M){
    int d;
    cin>>d;
    D[i] = d-1;
    bits[D[i]] = (1<<i);
  }
  REP(i,0,N){
    REP(j,0,K){
      cin>>v[i][j];
    }
  }
  REP(i,0,(1<<16)) visit[i] = false;
  queue< pair<int, int> > stq;  //????????¨?±?????????¨??¶???, ????????????
  stq.push(make_pair((1<<M)-1, 0));
  visit[(1<<M)-1] = true;;
  while(!stq.empty()){
    int state = stq.front().first;
    int step = stq.front().second;
    stq.pop();

    REP(j,0,K){ /*??¶???state????????????K????????????????????¨?????????????????????*/
      int nextState = state;
      vector<int> fromv;
      vector<int> tov;
      REP(i,0,M){
        if(state & (1<<(i/*D[i]*/))){
          fromv.push_back(/*i*//*D[i]*/bits[D[i]]);
          //REP(k,0,M) if(v[D[i]][j]-1 == D[k]) tov.push_back(k);
          if(bits[v[D[i]][j]-1] != 0) tov.push_back(bits[v[D[i]][j]-1]);
        }
      }
      //REP(i,0,fromv.size()) nextState &= ~(1<<fromv[i]); //from????????????????????????????????¨???
      REP(i,0,fromv.size()) nextState &= ~fromv[i];
      //REP(i,0,tov.size()) nextState |= (1<<tov[i]);  //to????????????????????????????????????
      REP(i,0,tov.size()) nextState |= tov[i];
      if(nextState==0){
        cout<<step+1<<endl;
        return 0;
      }
      if(!visit[nextState]){
        stq.push(make_pair(nextState, step+1));
        visit[nextState] = true;
      }
    }
  }

  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int x, a, b; cin >> x >> a >> b;
    if(a >= b) cout << "delicious" << endl;
    else if(b-a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,k; cin >> n >> m >> k;
    ll a[n+1],b[m+1];
    vector<ll> rui_a(n+1),rui_b(m+1);
    rep(i,0,n) cin >> a[i];
    rep(i,0,m) cin >> b[i];
    rui_a[0] = 0;
    rui_b[0] = 0;
    rep(i,1,n+1) rui_a[i] += rui_a[i-1] + a[i-1];
    rep(i,1,m+1) rui_b[i] += rui_b[i-1] + b[i-1];
    ll ans = 0;
    rep(i,0,n+1) {
        if(rui_a[i] <= k) {
            auto itr  = upper_bound(all(rui_b),k-rui_a[i]);
            ll tmp = itr - rui_b.begin();
            ans = max(ans,i + tmp - 1);
        }
    }
    cout << ans << endl;
}

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

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

const ll MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;
ll n, ans, id = -1, f = inf, ID = -1;
ll down[MAX_N];
vector <pii> G[MAX_N];

ll dfs1 (ll v = 0, ll p = 0) {
    down[v] = 1;
    for (pii u: G[v])
        if (u.first != p)
            down[v] += dfs1(u.first, v);

    return down[v];
}

void dfs2 (ll v = 0, ll p = 0) {
    for (pii u: G[v])
        if (u.first != p) {
            dfs2(u.first, v);

            ans += u.second * min(down[u.first], n - down[u.first]) * 2LL;
            if (down[u.first] == n - down[u.first])
                ID = u.second;
        }
}

void dfs3 (ll v = 0, ll p = 0) {
    id = v;
    for (pii u: G[v])
        if (u.first != p && down[u.first] >= ((n + 1) / 2))
            dfs3(u.first, v);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for (ll i = 0; i < n - 1; i++) {
        ll v, u, w;
        cin >> v >> u >> w;
        v--, u--;

        G[v].push_back({u, w});
        G[u].push_back({v, w});
    }

    dfs1();
    dfs2();
    dfs3();

    if (ID != -1) {
        cout << ans - ID << "\n";
        return 0;
    }
    
    for (pii p: G[id])
        f = min(f, p.second);

    cout << ans - f << "\n";
    return 0;
}
// 

Measured memory_bytes: 13952