akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, M;

void init()
{
}

void solve()
{
    ll v = M / N;
    FORR(i, v, 1){
        ll r = M - i*N;
        if(r % i == 0){
            cout << i << endl;
            return;
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
import sys
N = int(input())
a = [int(n) for n in input().split()]
# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
bucket = [0]*100000
for ak in a:
    bucket[ak]+=1
ans = 0
for i in range(1,99999):
    ans = max(ans,bucket[i-1] + bucket[i] + bucket[i+1])
print(ans)


Measured memory_bytes: 13964
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(int n = Integer.parseInt(scn.nextLine()); n > 0; n--) {
            System.out.println(scn.nextLine().replace("Hoshino", "Hoshina"));
        }
    }
}

Measured memory_bytes: 26280
A=list(input())
B=list(input())
C=list(input())
li=[A,B,C]
sw=True
k=0
while sw==True:
    if li[k][0]=="a":
        del li[k][0]
        k=0
    elif li[k][0]=="b":
        del li[k][0]
        k=1
    elif li[k][0]=="c":
        del li[k][0]
        k=2
    if li[k]==[]:
        sw=False
ans=["A","B","C"]
print(ans[k])


Measured memory_bytes: 9092
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l, q;
const int z = 26;
int ans;
string s;
int d[z + 1][500000];
int level[21][500000];

int main() {
	//freopen("x.in", "r", stdin);
	cin >> s;
	n = SZ(s);

	for (int i = n - 1; i >= 0; i--) {
		int c = s[i] - 'a';
		d[c][i] = i + 1;
		for (int j = c + 1; j <= z; j++) {
			if (d[j - 1][i]) d[j][i] = d[j - 1][d[j - 1][i]]; else break;
		}

		if (d[z][i])
		for (int j = 0; j < z; j++) if (!d[j][i]) {
			d[j][i] = d[j][d[z][i]];
		}
	}

	for (int i = n - 1; i >= 0; i--) if (d[z][i]) {
		level[0][i] = d[z][i];
		F1(j, 20) {
			if (level[j - 1][i]) {
				level[j][i] = level[j - 1][level[j - 1][i]];
			}
			else break;
		}
	}


	cin >> q;
	while (q--) {
		int L, R;
		cin >> L >> R;
		L--;
		string ans = "No";

		if (level[0][L]) {
			for (int k = 20; k >= 0; k--) {
				if (level[k][L] && level[k][L] <= R) {
					if (level[k][L] == R) {
						ans = "Yes";
						break;
					}
					L = level[k][L];
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

int main() {
  std::string s;

  std::cin >> s;

  std::vector<int> change_index;
  change_index.push_back(0);

  int state = 0;
  for (int i = 0, e = s.length(); i < e; ++i) {
    switch (state) {
      case 0:
        if (s[i] == 'L') {
          change_index.push_back(i);
          state = 1;
        }
        break;
      case 1:
        if (s[i] == 'R') {
          change_index.push_back(i);
          state = 0;
        }
        break;
    }
  }

  if (*(change_index.end() - 1) != s.length() - 1) {
    change_index.push_back(s.length());
  }

  std::vector<int64_t> child(s.length());

  for (int i = 1, e = change_index.size(); i < e; i += 2) {
    // RRRRRLを集める

    int rs = change_index[i - 1];
    int rl = change_index[i];
    if (rl - rs == 1) {
      child[rl] += 1;
      child[rl - 1] += 1;
    } else {
      child[rl] += (rl - rs) / 2 + 1;
      child[rl - 1] += (rl - 1 - rs) / 2 + 1;
    }

    // std::cout << i << ":";
    // for (auto c : child) {
    //   std::cout << c << " ";
    // }
    // std::cout << std::endl;

    // RLLLLLLを集める
    if ((i + 1) < e) {
      int le = change_index[i + 1] - 1;
      if (le == rl) {
        continue;
      }
      if ((le - rl) % 2 == 1) {
        child[rl] += (le - rl) / 2;
        child[rl - 1] += (le - rl) / 2 + 1;
      } else {
        child[rl] += (le - rl) / 2;
        child[rl - 1] += (le - rl) / 2;
      }
    }
    // std::cout << i << ":";
    // for (auto c : child) {
    //   std::cout << c << " ";
    // }
    // std::cout << std::endl;
  }

  for (auto c : child) {
    std::cout << c << " ";
  }

  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int sum(int a){
  int res = 0;
  while(a > 0){
    res += a % 10;
    a /= 10;
  }
  return res;
}

int main(){
  
  int n = in();
  int ans = INF;
  FOR(i, 1, n){
    int res = sum(i) + sum(n - i);
    chmin(ans, res);
  }
  cout << ans << endl;
  
  return 0;
}


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

int main() {
    int A,B;
  string S,T,U;
  cin >> S >>T>>A>>B>>U;
  
  if(U==S){
      A--;
      cout<<A<<" "<<B<<endl;
  }
else if(U==T){
B--;
cout<<A<<" "<<B<<endl;
}


  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int K;
cin >> K;
int cnt = 0;

for(int i = 1; i <= K; i++){ 
       for(int j = i + 1; j <= K; j++){ 
              if(i % 2 == 1 && j % 2 == 0) cnt++;
              else if(i % 2 == 0 && j % 2 == 1) cnt++;
       }
}

cout << cnt << endl; 
}

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

int main(void){
    string S,H="",T="";
    int Q,dir=1;
    cin>>S>>Q;
    for(int i=0;i<Q;++i){
        int q,f;
        char c;
        cin>>q;
        if(q==1){
            dir = 1-dir;
        }
        else{
            cin>>f>>c;
            if(dir==1){
                if(f==1){
                    H=c+H;
                }
                else{
                    T=T+c;
                }
            }
            else{
                if(f==1){
                    T=T+c;
                }
                else{
                    H=c+H;
                }
            }
        }
    }

    if(dir==0){
        reverse(S.begin(),S.end());
        reverse(H.begin(),H.end());
        reverse(T.begin(),T.end());
        cout<<T<<S<<H;
    }
    else{
        cout<<H<<S<<T;
    }
    return 0;
}

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

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v;
    vector<int>::iterator it;
    for(int i=1;i<=n;i++){
        int temp;
        cin>>temp;
        v.push_back(temp);
    }
    sort(begin(v),end(v));
    int sum=0;
    for(it=begin(v);it!=begin(v)+k;it++){
        sum=sum+*it;
    }
    cout<<sum;



}


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

const int mod = 1e9 + 7;
int n;
long long dp[2001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	dp[0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < i - 2; j++)
			dp[i] = (dp[i] + dp[j]) % mod;
	cout << dp[n] << '\n';
	return 0;
}

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

#define LARGE 100000
int V,E;
int color=0;

typedef struct list{
  int id;
  struct list *next;
}list;


list * makelist(int x){
  list *new = malloc(sizeof(list));
  new->id = x;
  new->next = NULL;
  return new;
}

void list_insert(list* L[], int x, list *new){
	list **p = &L[x];
	
	while((*p) != NULL){
	  p = &((*p)->next);
	}
	(*p) = new;
	
	return;
}

int push(int stack[], int x, int top){
  stack[top++] = x;
  return top;
}

int pop(int stack[], int *top){
  (*top)--;
  return stack[*top];
}

void dfs(int C[], int x, list* L[]){
  int stack[LARGE];
  int top = 0;
  int temp;
  list *p;
	
  color++;
  top = push(stack,x,top);
  while(top > 0){
    temp = pop(stack,&top);
    if(C[temp] == 0) C[temp] = color;
    p = L[temp];
    while(p != NULL){
      if(C[p->id] == 0){
	top = push(stack,p->id, top);
	C[p->id] = color;
			}
      p = p->next;
		}
  }
	
  return;
}

int main(){
  int i, j, s, t, q, x, y, C[LARGE];
  list *L[LARGE], *new;
 
  scanf("%d %d", &V, &E);
	
  for(i = 0 ; i < V ; i++){
    L[i] = NULL;
    C[i] = 0;
  }
	
  for(i = 0 ; i < E ; i++){
    scanf("%d %d", &s, &t);
    new = makelist(t);
    list_insert(L, s, new);
    new = makelist(s);
    list_insert(L, t, new);
  }
	
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%d %d", &x, &y);
    if(C[x] == 0) dfs(C, x, L);
    if(C[y] == 0) dfs(C, y, L);
    if(C[x ]== C[y]) printf("yes\n");
    else printf("no\n");
  } 
		
  return 0;
}


Measured memory_bytes: 9152
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!(
        n:usize, 
        a:i32, 
        b:i32,
        s:chars,
    );
    let mut cnt_a:i32 = 0;
    let mut cnt_b:i32 = 0;
    let mut cnt:i32 = 0;
    for (_i, x) in s.iter().enumerate() {
        if *x == 'a' {
            cnt_a+=1;
            if cnt < a + b {
                cnt+=1;
                println!("Yes");
            } else {
                println!("No");
            }
        } else if *x == 'b' {
            cnt_b+=1;
            if cnt < a + b && cnt_b <= b {
                cnt += 1;
                println!("Yes");
            } else{
                println!("No");
            }
        } else {
            println!("No");
        }
    }
 
}

Measured memory_bytes: 4732
N,W=map(int,input().split())
stones=[None]*N
allv=0
for i in range(N):
  w,v=map(int,input().split())
  allv+=v
  stones[i]=[w,v]
  
import numpy as np
MAXW=10**9+1
dp=np.full(allv+1,MAXW,dtype=int)
dp[0]=0
for i in range(len(stones)):
  w=stones[i][0]
  v=stones[i][1]
  np.minimum(dp[:-v]+w,dp[v:],out=dp[v:])
  
for i in range(len(dp)-1,-1,-1):
  if dp[i]<=W:
    print(i)
    break

Measured memory_bytes: 15756
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int K;
  cin>>K;
  long long dp[30][10];
  int judge=0;
  int a,b;
  for(int i=0;i<30;i++){
    for(int j=0;j<10;j++){
      if(i==0) dp[i][j]=1;
      else{
        if(j==0) dp[i][j]=dp[i-1][0]+dp[i-1][1];
        else if(j==9) dp[i][j]=dp[i-1][8]+dp[i-1][9];
        else dp[i][j]=dp[i-1][j-1]+dp[i-1][j]+dp[i-1][j+1];
      }
      if(j!=0) judge+=dp[i][j];
      if(judge>=K){
        judge-=dp[i][j];
        a=i;
        b=j;
        i+=40;
        j+=20;
      }//if(judge<K)
    }
  }
  while(a>=0){
          cout<<b;
          if(a==0) cout<<endl;
          else{
            int x=max(0,b-1);
            while(x<=min(b+1,9)){
              if(judge+dp[a-1][x]<K){
               judge+=dp[a-1][x];
                x++;
              }
              else{
                b=x;
                x+=3;
              }
            }//while
          }
    a--;
    }//while
  return 0;
}

Measured memory_bytes: 3216
<?php
$input = STDIN;

$suit = array('S', 'H', 'C', 'D');
$cards = array();

foreach ($suit as $s) {
    $cards[$s] = array_fill(1, 13, true);
}

$n = intval(trim(fgets($input)));

for ($i = 0; $i < $n; $i++) {
    list($s, $rank) = explode(' ', trim(fgets($input)));
    $cards[$s][(int) $rank] = false;
}

foreach ($suit as $s) {
    foreach (range(1, 13) as $n) {
        if ($cards[$s][$n]) {
            print("{$s} {$n}\n");
        }
    }
}


Measured memory_bytes: 9284
# AtCoder
N, X = map(int, input().split())
L = list(map(int, input().split()))


def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result


count = 1
cs = cumsum(L)
for i in cs:
    if X >= i:
        count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:TYPE();}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:TYPE();}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=200005;

int n,a[MAXN],b[MAXN];
bool check(int mid)
{
	for(int i=1;i<=2*n-1;++i)b[i]=(a[i]>=mid);
	int l=n,r=n;
	while(l>=2 && b[l-1]!=b[l])--l;
	while(r<=2*n-2 && b[r+1]!=b[r])++r;
	if(b[l]==b[r])return b[l];
	int t=(l+r)>>1;
	if(n<=t)return b[l];
	else return b[r];
}

int main()
{
	readint(n);
	for(int i=1;i<=2*n-1;++i)readint(a[i]);
	int L=1,R=2*n-1,mid,ans=0;
	while(L<=R)
	{
		mid=(L+R)>>1;
		if(check(mid))ans=mid,L=mid+1;
		else R=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
//23/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    ll n;
    cin>>n;
    string s1 ,s2;
    cin>>s1>>s2;

    for(ll i=0;i<s1.length();i++){
        cout<<s1[i]<<s2[i];
    }
    cout<<endl;



    return 0;
}


Measured memory_bytes: 256
from sys import stderr
N = int(input())
A = [int(i) for i in input().split()]

B = [0] * N

for i in range(N // 2, N):
    B[i] = A[i]

for i in reversed(range(N // 2)):
    s = sum(B[i::i + 1])
    B[i] = (A[i] - s) % 2

ans = [i + 1 for i, b in enumerate(B) if b == 1]
print(len(ans))
if ans:
    print(*ans)

Measured memory_bytes: 74204
#include<stdio.h>
/**gfdthjhkgfjghjgjfjhgjhg*/
#include/**gfdthjhkgfjghjgjfjhgjhg*/<string.h>
char /**gfdthjhkgfjghjgjfjhgjhg*/s[200010];
int a[27],b[27],l;
long long ans;
//sfjiusdghrsjgfdvbfdsjhgyfdbgfdkjnnhgofdjbdsigjkykjf
inline void write(long long x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
signed /**gfdthjhkgfjghjgjfjhgjhg*/main(){
  scanf("%s",s+1);
  l=strlen(s+1);
  for(register /**gfdthjhkgfjghjgjfjhgjhg*/int i=1;i<=l;i++)b[s[i]-/**gfdthjhkgfjghjgjfjhgjhg*/'a'+1]++;
  for(register int i=1;i<=l;i++){
    a[s[i]-'a'+1]++;
    ans+=l/**gfdthjhkgfjghjgjfjhgjhg*/-i-(b[s[i]-'a'+1]-a[s[i]-'a'+1]);
  }/**gfdthjhkgfjghjgjfjhgjhg*/
  ans+=1;
  write/**gfdthjhkgfjghjgjfjhgjhg*/(ans);
  putchar/**gfdthjhkgfjghjgjfjhgjhg*/('\n');
  /**gfdthjhkgfjghjgjfjhgjhg*/return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] A,B,C;

    private int lowerBound(int i,int[] a,int[] b) {
        int low = -1;
        int high = N;

        while(high - low > 1) {
            int mid = high + low >> 1;

            if (a[i] < b[mid]) {
                high = mid;
            } else {
                low = mid;
            }
        }

        return low;
    }

    private int upperBound(int i,int[] a,int[] b) {
        int low = -1;
        int high = N;

        while(high - low > 1) {
            int mid = high + low >> 1;

            if (a[i] < b[mid]) {
                high = mid;
            } else {
                low = mid;
            }
        }

        return high;
    }

    private void solve() {
        N = nextInt();
        A = new int[N];
        B = new int[N];
        C = new int[N];
        for(int i = 0;i < N;i++) {
            A[i] = nextInt();
        }
        for(int i = 0;i < N;i++) {
            B[i] = nextInt();
        }
        for(int i = 0;i < N;i++) {
            C[i] = nextInt();
        }

        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);

        long ans = 0;
        int a = 0,c = 0;
        for(int i = 0;i < N;i++) {

            while(a < N && B[i] > A[a]) {
                a++;
            }

            while(c < N && B[i] >= C[c]) {
                c++;
            }

            ans += (long)a * (N - c);
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

bool judge(int a, int b)
{
    int N = 16;
    if (a > N/2 || b >N/2) return false;

    return true;
}


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

    cout << (judge(a, b) ? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int w,h;
int g[21][21];
int dfs(int x,int y,int c){
    if(c==10) return 11;
    int ret=11;
    if(x!=0&&g[y][x-1]!=1)FOR(i,1,x+1){
        int tx=x-i;
        if(g[y][tx]==3) return c+1;
        if(tx>=1&&g[y][tx-1]==1){
            g[y][tx-1]=0;
            ret=min(ret,dfs(tx,y,c+1));
            g[y][tx-1]=1;
            break;
        }
    }
    if(x!=w-1&&g[y][x+1]!=1)FOR(i,1,w-x){
        int tx=x+i;
        if(g[y][tx]==3) return c+1;
        if(tx+1<w&&g[y][tx+1]==1){
            g[y][tx+1]=0;
            ret=min(ret,dfs(tx,y,c+1));
            g[y][tx+1]=1;
            break;
        }
    }
    if(y!=0&&g[y-1][x]!=1)FOR(i,1,y+1){
        int ty=y-i;
        if(g[ty][x]==3) return c+1;
        if(ty>=1&&g[ty-1][x]==1){
            g[ty-1][x]=0;
            ret=min(ret,dfs(x,ty,c+1));
            g[ty-1][x]=1;
            break;
        }
    }
    if(y!=h-1&&g[y+1][x]!=1)FOR(i,1,h-y){
        int ty=y+i;
        if(g[ty][x]==3) return c+1;
        if(ty+1<h&&g[ty+1][x]==1){
            g[ty+1][x]=0;
            ret=min(ret,dfs(x,ty,c+1));
            g[ty+1][x]=1;
            break;
        }
    }
    return ret;
}
int main(){
    while(cin>>w>>h,w){
        int sx,sy;
        rep(i,h)rep(j,w){
            cin>>g[i][j];
            if(g[i][j]==2) sx=j,sy=i;
        }
        int ans=dfs(sx,sy,0);
        if(ans>10) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3024
main :: IO ()
main = do
    [a,b,x] <- map read . words <$> getLine :: IO [Double]
    let y  = 2 * x / b / a
        y' = b - ((x / a * 2 / a) - b)
    print $ if a * a * b / 2 <= x
                then ((atan (y' / a)) * 180 / pi)
                else 90 - ((atan (y / b)) * 180 / pi)


Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
int main(){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<stack>
#include<stdio.h>
#include<string.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
priority_queue<int>que;
struct Node {
    int day;
    int price;
};
int cmd(Node a , Node b){
    return a.day==b.day?a.price>b.price:a.day<b.day;
}
int main(){
    int n,m;
    cin >>n >>m;
    Node p[100000];
    for(int i=0;i<n;i++)
        cin >>p[i].day>>p[i].price;
    sort(p,p+n,cmd);
    int num=0,cnt=0,sum=0;
    for(int j=0;j<m;j++){
        num=0;
        while(p[cnt].day<=j+1&&cnt<=n)
        {
            que.push(p[cnt].price);
            cnt++;
        }
        if(que.empty()==0)
        {
            sum+=que.top();
            que.pop();
        }
    }
    cout<<sum<<endl;
     return 0;
}

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

using namespace std;

const int INF=1e9+10;
const int N=1e5+10;

struct edge
{
    int to,cost;
    edge(int _to=0,int _cost=0):to(_to),cost(_cost){}
};

vector<edge> G[N];
int d[N];
int V,E,S;

void init(int n)
{
    for(int i=0;i<=n;i++)
    {
        G[i].clear();
    }
}
bool Bellman_Ford(int s)
{
    fill(d,d+V,INF);
    d[s]=0;

    for(int i=0;i<V;i++)
    {
        for(int j=0;j<V;j++)
        {
            for(int k=0;k<G[j].size();k++)
            {
                edge &e=G[j][k];
                if(d[e.to]>d[j]+e.cost&&d[j]!=INF)
                {
                    d[e.to]=d[j]+e.cost;
                    if(i==V-1) return true;
                }
            }
        }
    }
    return false;
}

int main()
{
    while(scanf("%d %d %d",&V,&E,&S)!=EOF)
    {
        init(V);
        for(int i=0;i<E;i++)
        {
            int s,t,c;
            scanf("%d %d %d",&s,&t,&c);
            G[s].push_back(edge(t,c));
        }
        if(Bellman_Ford(S))
        {
            puts("NEGATIVE CYCLE");
            continue;
        }
        for(int i=0;i<V;i++)
        {
            if(d[i]==INF)
            {
                puts("INF");
                continue;
            }
            printf("%d\n",d[i]);
        }
    }


    return  0;
}



Measured memory_bytes: 5588
//#pragma warning(disable : 4996)
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<fstream>
#include<stdio.h>
#include<map>
#include<set>
#include<limits.h>
#include<list>
#include <cassert>
#include<sstream>
#include <bitset>
#include<unordered_map>
using namespace std;
using ll = long long int;
using uint = unsigned int;

bool eqlvv(const vector<int>& l, const vector<int>& r) {
	if (l.size() != r.size())
		return false;
	for (int i = 0; i < l.size(); ++i)
		if (l[i] != r[i])
			return false;
	return true;
}
int main() {
	vector<int> fs[2] = { vector<int>(257, -1), vector<int>(257, -1) };
	int cnt[2] = { 0 };
	string s[2];
	cin >> s[0] >> s[1];
	vector<int> Sparse[2] = { vector<int>(s[0].size()), vector<int>(s[0].size()) };
	for (int i = 0; i < s[0].size(); ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (fs[j][s[j][i]] == -1) {
				fs[j][s[j][i]] = cnt[j]++;
			}
			Sparse[j][i] = fs[j][s[j][i]];
		}
	}
	cout << (eqlvv(Sparse[0], Sparse[1]) ? "Yes" : "No");

	return 0;
} 


Measured memory_bytes: 5444
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
  string s;

  cin >> s;

  int length = s.length();

  for (int i = 0; i < (length / 2); i++)
  {
    //cout << s[i] << " " << s[length - i - 1] << " ";
    if (strncmp(&s[i], &s[length - i - 1], 1))
    {

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

  if (strncmp(&s[0], &s[(length + 2) / 2], (length / 2)))
  {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

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

		int int1 = sc.nextInt();
		String str = sc.next();
		int int2 = sc.nextInt();

		if(str.equals("+")){
			System.out.println(int1 + int2);
		}else{
			System.out.println(int1 - int2);
		}
	}
}

Measured memory_bytes: 25172
n = int(input())
cnt_t = 0
for i in range(1, n + 1, 2):
    cnt = 0
    t = i
    for j in range(1, t + 1):
        if t % j == 0:
            cnt += 1
    if cnt == 8:
        cnt_t += 1
print(cnt_t)


Measured memory_bytes: 2940
#include <stdio.h>

int N, A, B; long long D[5050];

int main()
{
	scanf ("%d %d %d", &N, &A, &B);
	for (int i = 1; i <= N; i++){
		int x; scanf ("%d", &x);
		long long X[5050];
		for (int j = 0; j <= N; j++) X[j] = 1e18;
		for (int j = 0; j <= N; j++){
			if (j <= x){
				if (X[x] > D[j]) X[x] = D[j];
				if (X[j] > D[j] + A) X[j] = D[j] + A;
			}
			else{
				if (X[j] > D[j] + B) X[j] = D[j] + B;
			}
		}
		for (int j = 0; j <= N; j++) D[j] = X[j];
	}

	long long ans = 1e18;
	for (int j = 0; j <= N; j++) if (ans > D[j]) ans = D[j];
	printf ("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N, M;  cin >> N >> M;
    vector<set<int>> A(N);
    REP(i,N) {
        int L; cin >> L;
        A[i] = set<int>(); 
        REP(j, L) {
            int a; cin >> a; a--;
            A[i].insert(a);
        }
    }

    vb ok(M, true);

    REP(i,N) {
        REP(j,M){
            if (ok[j] && A[i].count(j) == 0) ok[j] = false;
        }
    }

    int ans = 0;
    REP(i,M) {
        if (ok[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


std::vector<long long> Eratosthenes(long long N) {
  std::vector<long long> arr(N+1);
  for(long long i = 0; i <= N; i++) arr[i] = 1;
	for(long long i = 2; i <= std::sqrt(N); i++) {
    if(arr[i]) for(long long j = 0; i * (j + 2) <= N; j++) arr[i *(j + 2)] = 0;
  }

  std::vector<long long> rtn;
	for(long long i = 2; i <= N; i++){
		if(arr[i]) rtn.push_back(i);
	}
  return rtn;
}


const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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*(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 main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;
  auto plist = Eratosthenes(N);

  std::vector<int> c(sz(plist));
  for(ll v = 1; v<=N; v++) {
    int n = v;
    for(int k=0; k<sz(plist); k++) {
      if ( n < plist[k] ) break;
      while ( n % plist[k] == 0 ) {
        n /= plist[k];
        c[k]++;
      }
    }
  }
  
  mint ans = 1;
  for(int k=0; k<sz(plist); k++) {
    ans = ans * (c[k]+1);
   }

  std::cout << ans.x << std::endl;

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "to", int, "cost");

void main() {
    int n, m;
    scan(n, m);
    auto adj = new Edge[][](n, 0);
    foreach (i ; 0 .. m) {
        int ui, vi;
        scan(ui, vi);
        ui--, vi--;
        adj[ui] ~= Edge(vi, 1);
    }
    int s, t;
    scan(s, t);
    s--, t--;

    auto adj3 = new Edge[][](3 * n, 0);
    foreach (u ; 0 .. n) {
        foreach (e ; adj[u]) {
            adj3[u] ~= Edge(n + e.to, 1);
            adj3[n + u] ~= Edge(2*n + e.to, 1);
            adj3[2*n + u] ~= Edge(e.to, 1);
        }
    }

    debug {
        writeln(adj3);
    }

    auto d = dijkstra(adj3, s);

    debug {
        writeln(d);
    }

    auto ans = d[t];
    writeln(ans < inf ? ans / 3 : -1);
}


auto dijkstra(Edge[][] adj, int s) {
    alias Pair = Tuple!(int, "num", int, "dist");
    //immutable inf = 10^^9 + 7;

    int N = adj.length.to!int;

    auto dist = new int[](N);
    dist[] = inf;
    dist[s] = 0;

    auto q = BinaryHeap!(Array!Pair, "a.dist > b.dist")();
    q.insert(Pair(s, 0));

    int rep = N - 1;

    while (!q.empty && rep) {
        auto v = q.front;
        q.popFront();

        if (dist[v.num] < v.dist) continue;

        rep--;

        foreach (e ; adj[v.num]) {
            if (dist[e.to] > dist[v.num] + e.cost) {
                dist[e.to] = dist[v.num] + e.cost;
                q.insert(Pair(e.to, dist[e.to]));
            }
        }
    }

    return dist;
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 18556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int xa,ya,xb,yb;
  cin >> xa >> ya >> xb >> yb;
  for(int i=0;i<yb-ya;i++)
    cout << 'U';
  for(int i=0;i<xb-xa;i++)
    cout << 'R';
  for(int i=0;i<yb-ya;i++)
    cout << 'D';
  for(int i=0;i<xb-xa+1;i++)
    cout << 'L';
  for(int i=0;i<yb-ya+1;i++)
    cout << 'U';
  for(int i=0;i<xb-xa+1;i++)
    cout << 'R';
  cout << "DR";
  for(int i=0;i<yb-ya+1;i++)
    cout << 'D';
  for(int i=0;i<xb-xa+1;i++)
    cout << 'L';
  cout << 'U' << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
    int a, b, c, i = 0, j = 0;
    double d, r, f;
    cin >> r ;
    printf("%.8lf %.8lf", r*r* 3.141592653589, 2 * r* 3.141592653589);
    return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}

LL frac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}

LL comb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = frac(n) * mpower(frac(r), MOD - 2) % MOD;
    res *= mpower(frac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    LL X, Y;
    cin >> X >> Y;

    if((X+Y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }


    LL n = (2 * X - Y) / 3;
    LL m = (2 * Y - X) / 3;

    if(n < 0 or m < 0){
        cout << 0 << endl;
        return 0;
    }

    LL ans = comb(n + m, n) % MOD;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) cout << s << endl;
  else{
    for(int i=0;i<k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
# coding: utf-8

n = int(input())
a_list = list(map(int,input().split()))
count = 0
i = 1

if not 1 in a_list:
    print("-1")
    exit()

for a in a_list:
    
    if i == a :
        count += 1
        i += 1

print(len(a_list)-count)

Measured memory_bytes: 26268
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 5010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

char t[] = " keyence";
char s[MAXN];

int main()
{
	
	scanf("%s", s+1);
	int n = strlen(s+1);
	int L = 0, R = 0;
	for (int i = 1; i <= 7; ++ i)
		if (t[i] == s[i]) L ++; else break;
	for (int i = 1; i <= 7; ++ i)
		if (t[7-i+1] == s[n-i+1]) R ++; else break;
	puts(L+R >= 7 ? "YES" : "NO");
	
	return 0;
}


Measured memory_bytes: 256
d, g = map(int, input().split())
scores = [list(map(int, input().split())) for _ in range(d)]

ans = 1000
for i in range(2 ** d):
    score = 0
    solved = 0
    for j in range(d):
        p, c = scores[j]
        if i & (1 << j):
            solved += p
            score += p * 100 * (j + 1) + c
        else:
            k = j

    if score >= g:
        ans = min(ans, solved)
        continue

    p, _ = scores[k]
    for j in range(p):
        solved += 1
        score += 100 * (k + 1)
        if score >= g:
            ans = min(ans, solved)
            break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)
 
long long A[1 << 19], B[1 << 19], S[1 << 19], N;
vector<pair<long long, long long>>vec;
 
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		scanf("%lld%lld", &A[i], &B[i]);
		vec.push_back(make_pair(A[i], B[i]));
	}
	sort(vec.begin(), vec.end());
	for (int i = 1; i <= N; i++) {
		A[i] = vec[i - 1].first;
		B[i] = vec[i - 1].second;
		S[i] = S[i - 1] + B[i];
	}
 
	long long maxn = -(1LL << 60), ans = -(1LL << 60);
	for (int i = N; i >= 1; i--) {
		maxn = max(maxn, S[i] - A[i]);
		long long E = -S[i - 1] + A[i];
		ans = max(ans, maxn + E);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22452
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    if (b == 0 && a == 0)
        cout << 1;
    else if (a == 0)
        cout << b/x + 1;
    else 
        cout << b/x - (a-1)/x;
    return 0;
}

Measured memory_bytes: 256
tar_len = input()
targets = map(int, input().split())

def how_many_times_divisible(elem):
    count = 0
    while True:
        if elem % 2 != 0: break
        count += 1
        elem = elem / 2
    return count

count = min(map(how_many_times_divisible, targets))
print(count)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long D, long long N){
    N += N == 100;
    if(D == 0){
        cout << N << endl;
    } else if (D == 1) {
        cout << N * 100 << endl;
    } else {
        cout << N * 10000 << endl;
    }
}

int main(){
    long long D;
    scanf("%lld",&D);
    long long N;
    scanf("%lld",&N);
    solve(D, N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<Int> a(3);

	for (Int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<Int>());

	cout << a[0]*10+a[1]+a[2] << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;
using namespace std;

const ll mod = 1000000007;

/*
ZZ(xi-xj)(yk-yl)
= Z(xi-xj) * Z(yk-yl)
Z(xi-xj)
Zxi
*/

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> x(n);
  vector<ll> y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  ll ans = 0;
  ll zi=0,zj=0,zk=0,zl=0;
  rep(i,n-1){
    zi += x[i+1]%mod*(i+1)%mod; zi %= mod;
    zj += x[i]%mod*(n-1-i)%mod; zj %= mod;
  }
  rep(i,m-1){
    zk += y[i+1]%mod*(i+1)%mod; zk %= mod;
    zl += y[i]%mod*(m-1-i)%mod; zl %= mod;
  }
  ans = (zi-zj+mod)%mod;
  ans *= (zk-zl+mod)%mod; ans %= mod;
  cout << ans % mod << endl;
  return 0;
}


Measured memory_bytes: 4800
m, f, r = map(int, input().split())

while True:
    if m == -1 and f == -1 and r == -1:
        break

    res = m + f
    if m == -1 or f == -1:
        print("F")
    elif 80 <= res:
        print("A")
    elif 65 <= res:
        print("B")
    elif 50 <= res:
        print("C")
    elif 30 <= res:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")

    m, f, r = map(int, input().split())



Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;

int main(){
	ll n; cin >> n;
	ll now_max = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i){
		ll h; cin >> h;
		if (h >= now_max){
			ans++;
			now_max = h;
		}
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

Z = 998244353


class Comb:
    def __init__(self, n):
        self.n = n
        self.e = [1] * (n + 1)
        for j in range(n):
            self.e[j + 1] = (self.e[j] * (j + 1)) % Z
    
    def z_pow(self, a, n):
        # a ^ n
        if n == 0:
            return 1
        if n == 1:
            return a % Z
        m = n // 2
        i = n - m * 2
        x = self.z_pow(a, m)
        return (x * x * self.z_pow(a, i)) % Z

    def get(self, i):
        if self.n - i < i:
            return self.get(self.n - i)
        return (self.e[self.n] * self.z_pow(self.e[i], Z - 2) * self.z_pow(self.e[self.n - i], Z - 2)) % Z


def calc(N, M, K):
    comb = Comb(N - 1)
    p = (M * (M - 1) ** (N - 1 - K)) % Z
    r = 0
    for x in range(K, -1, -1):
        r = (r + comb.get(x) * p) % Z
        p = (p * (M - 1)) % Z
    return r
    

(N, M, K) = tuple([int(s) for s in input().split()])
print(calc(N, M, K))

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

int main () {
  int a , b , c ;
  cin >> a >> b >> c ;
  
  if ( ( 10 * b + c ) % 4 == 0 ) {
    cout << "YES" << endl ;
  } else {
    cout << "NO" << endl ;
  }
}


Measured memory_bytes: 256