akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#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 repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int l,n,k;
	cin>>l;
	while(l--){
		cin>>n>>k;
		k =min(n,k);
		int house[100010]={0};
		for(int i =0;i < n;i++){
			cin>>house[i];
		}
		vector<int> data;
		for(int i =1;i < n;i++){
			data.push_back(house[i]-house[i-1]);
		}
		sort(data.begin(),data.end(),greater<int>() );
		int ans =house[n-1]-house[0];
		for(int j =0;j <k-1;j++){
			ans -=data[j];
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2260
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
typedef pair<P, string> E;

int f[101][101];
int d[11][11];
int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= A; i++) {
		for (int j = 1; j <= B; j++) cin >> d[i][j];
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			for (int x = 1; x <= A; x++) {
				for (int y = 1; y <= B; y++) {
					f[i][j] = max(f[i][j], d[x][y] - x * i - y * j);
				}
			 }
		}
	}
	for (int x = 1; x <= A; x++) {
		for (int y = 1; y <= B; y++) {
			int D = 1 << 30;
			for (int i = 0; i <= 100; i++) {
				for (int j = 0; j <= 100; j++) {
					D = min(D, x*i + y * j + f[i][j]);
				}
			}
			if (D != d[x][y]) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}

	cout << "Possible" << endl;
	vector<E> edge;
	for (int i = 0; i < 100; i++) {
		edge.emplace_back(P(1 + i, 1 + i + 1), "X");
		edge.emplace_back(P(202 - i, 202 - i - 1), "Y");
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			edge.emplace_back(P(1 + i, 102 + j), to_string(f[i][j]));
		}
	}
	cout << 202 << " " << edge.size() << endl;
	for (E e : edge) {
		cout << e.first.first << " " << e.first.second << " " << e.second << endl;
	}
	cout << "1 102" << endl;
}

Measured memory_bytes: 1020
loop {
    a = gets.split(' ')
    if (a[1] == "?") 
        break
    end
    a[0], a[2] = a[0].to_i, a[2].to_i
    case a[1]
    when "+"
        puts(a[0] + a[2])
    when "-"
        puts(a[0] - a[2])
    when "*"
        puts(a[0] * a[2])
    when "/"
        puts(a[0] / a[2])
    end
}



Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e2+5;
const int INF = 0x3f3f3f3f;

int main( )
{
    std::ios::sync_with_stdio(0);cin.tie(0); 
	
	double n;
	cin >> n;
	n /= 3.0;
	printf("%.8f",(n*n*n));
    return 0;
}


Measured memory_bytes: 256
import array
import sys
from collections import deque
import math

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
#S = deque(list(input()))

for i in reversed(range(1,int(math.sqrt(N))+1)):
    if N % i == 0:
        j = N // i
        print(i+j-2)
        sys.exit()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

double btc = 380000.0;
int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    double x;
    string u;

    double ans = 0;
    REP(i,n){
        cin>>x>>u;

        if(u=="JPY"){
            ans += x;
        }else{
            //BTC
            ans = ans + (x*btc);
        }
    }
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
   ll n,k;
   cin>>n>>k;
   ll v[n];
   rep(i,n)cin>>v[i];
   ll ans = -INFL;
   rep(i,n+1){
       rep2(j,i,n+1){
           vl s;
           int le = k-i;
           //cout<<le<<endl;
           if(le<0)continue;
           rep(a,i){
               s.push_back(v[a]);
           }
           for(int a = n-1;a>=j&&le>=0;a--,le--){
               s.push_back(v[a]);
           }
           if(le<0)continue;
           sort(been(s));
           ll sum =0;
           rep(a,le){
               if(a>=s.size())break;
               if(s[a]>=0)break;
               sum-=s[a];
           }
           rep(a,s.size()){
               sum+=s[a];
           }
           ans=max(ans,sum);
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,k;
long long fac[4000005],inv[4000005],dp[2005][2005];
inline long long fpow(long long x,long long y){
	if(y==1)return x;
	long long t=fpow(x,y>>1);
	t=t*t%MOD;
	if(y&1)t=t*x%MOD;
	return t;
}
inline long long C(long long x,long long y){
	return (fac[x]*inv[y]%MOD)*inv[x-y]%MOD;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	if(k==1){
		cout<<"1\n";
		return 0;
	}
	fac[0]=inv[0]=1;
	for(int i=1;i<=4000000;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=fpow(fac[i],MOD-2);
	}
	dp[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(i)dp[i][j]=dp[i-1][j];
			if(j>i)dp[i][j]=(dp[i][j]+dp[i][j-1]*C(j*(k-1)+i-1,k-2)%MOD)%MOD;
		}
	}
	cout<<(dp[n][n]*fac[n])%MOD<<endl;
	return 0;
}

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

int main(){
 long long  n,r=0,g=0,b=0;
 string s;

 cin>>n>>s;

 rep(i,n){
     if(s.at(i)=='R')r++;
     if(s.at(i)=='G')g++;
     if(s.at(i)=='B')b++;
 }

  long long int sum=r*g*b;

for(int j=1;2*j<=n;j++){
    for(int i=0;i<n-2*j;i++){
        if(s.at(i)!=s.at(i+j)&&s.at(i+j)!=s.at(i+2*j)&&s.at(i+2*j)!=s.at(i)){sum--;}
    }
}

cout<<sum<<endl;
}


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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define MOD 1000000007
#define INF 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y) 
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	string s,t;
	ll a,b;
	cin>>s>>t>>a>>b;
	string u;
	cin>>u;

	if(u==s)
		cout<<a-1<<" "<<b;
	else
		cout<<a<<" "<<b-1;

	return 0;
}

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

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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main(void){
  string S;
  string T;
  int cnt=0;

  cin >> S >> T;
  rep(i,S.size()){
    if(S.at(i)!=T.at(i))
      cnt++;
  }
  cout << cnt <<endl;
  return 0;
}


Measured memory_bytes: 3852
var
a:array[1..4] of longint;
i,j,c,d,e,b:longint;
begin
for i:=1 to 3 do
read(a[i]);
for i:=1 to 3 do begin
if a[i]=5 then inc(j);
if a[i]=7 then inc(c);
end;
if (j=2) and (c=1) then write('YES')
else
write('NO');
end.

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[]
count,ans=0,0
for i in range(n):
  if A[i]<B[i]:
    count+=B[i]-A[i]
    ans+=1
  elif A[i]>B[i]:
    C.append(A[i]-B[i])
C.sort(reverse=True)
c=0
while count>0 and c<len(C):
  count-=C[c]
  c+=1
if count<=0:
  print(ans+c)
else:
  print(-1)

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



using namespace std;



int main(){

  char c[4];

  cin >> c;

  cin.ignore();



  for (int i = 0; i < 3; i++){

    if(c[i] == c[i + 1]){

      cout << "Bad" << endl;

      return 0;

    }

  }

  cout << "Good" << endl;

  return 0;



}



Measured memory_bytes: 256
from collections import Counter
S = input()
c = Counter(S)
if (c['N'] > 0 and c['S'] == 0) or (c['S'] > 0 and c['N'] == 0) or\
   (c['W'] > 0 and c['E'] == 0) or (c['E'] > 0 and c['W'] == 0):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
N,K=map(int, raw_input().split())
A=map(int, raw_input().split())

#10**12は2進数で40桁あるので、余裕を見て50桁分用意しておく
keta=50
L=[[N,0]]
#a1~anの同じ桁を見て、0の出現個数、1の出現個数を数える
for i in range(keta-1,-1,-1): #i 何桁目を見ているかを表す
    count=[ 0 for _ in range(2) ]
    for a in A:
        key=a>>i&1  #key aを2進数で表現した時、i桁目が0か1かをkeyに代入
        count[key]+=1
    L.append(count)

T=[ float("-inf") for _ in range(keta+1) ]
F=[ float("-inf")  for _ in range(keta+1) ]
F[0]=0

for i in range(1,keta+1):
    bit=K>>(keta-i)&1
    if bit==1:
        F[i]=F[i-1]+2**(keta-i)*L[i][0] #未満:Falseのdp表の横向き（→）の遷移
        #max( 未満:False→未満：Trueへのdp表の斜めの遷移、 未満:Falseのdp表の横向き（→）の遷移 bitが1、未満:Falseのdp表の横向き（→）の遷移 bitが0 )
        T[i]=max( F[i-1]+2**(keta-i)*L[i][1],T[i-1]+2**(keta-i)*L[i][0],T[i-1]+2**(keta-i)*L[i][1] )
    else:
        F[i]=F[i-1]+2**(keta-i)*L[i][1] #未満:Falseのdp表の横向き（→）の遷移
        T[i]=max( T[i-1]+2**(keta-i)*L[i][0],T[i-1]+2**(keta-i)*L[i][1] )   #未満:Trueのdp表の横向き（→）の遷移


print max(T[-1],F[-1])


Measured memory_bytes: 40940
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7
 
D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(100):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)






Measured memory_bytes: 78932
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N;

  cin >> N;

  ll tmp_max = 0;
  ll sum = 0;
  ll get = 0;
  for(int i = 0; i < N; ++i){
    cin >> get;
    sum += get;
    if(get > tmp_max) tmp_max = get;
  }

  string res = "No";
  if(sum - tmp_max > tmp_max) res = "Yes";

  // cout << tmp_max << endl;
  // cout << sum - tmp_max << endl;

  cout << res << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,m;
    cin>>n>>m;
    set<ll> ar;
    for(ll i=0;i<n;++i){
        ll x;cin>>x;
        ar.insert(x/2);
    }
    ll c,times=0;
    for(auto x:ar)
    {
        if(times==0){
            ++times;
            c=x;
            continue;
        }
        c=(c*x)/__gcd(c,x);
        if(c>m){cout<<"0";return 0;}
    }
    for(auto x:ar)
    {
        if((c/x)%2==0){cout<<"0";return 0;}
    }
    ll ans=(m+c)/(2*c);
    cout<<ans;

    return (0);
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
 long long n;
 scanf("%lld",&n);
 long long h[n+10];
 long long tmp=0,ans=0;
 for(long long i=0;i<n;i++){
  scanf(" %lld",&h[i]);
  if(i>0&&h[i-1]>=h[i])tmp++;
  else{
   if(ans<tmp)ans=tmp;
   tmp=0;
  }
 }
 if(ans<tmp)ans=tmp;
 printf("%lld\n",ans);
return 0;}

Measured memory_bytes: 2492
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}

  

int main()
 {  fast();
int i,j,n,k;
	cin>>n>>k;
    VI a(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    int dp[k+1]={0};
    for(i=1;i<=k;i++)
    {
        for(j=0;j<n;j++)
        if(i-a[j]>=0)
        dp[i]=(dp[i]||!dp[i-a[j]]);
    }
    if(dp[k])
    cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
}
 
 
   
   

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int h, w;
	for (int a = 0; ; a++) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < w; i++) {
			cout << '#';
		}
		cout << endl;
		for (int i = 1; i < h - 1; i++) {
			cout << '#';
			for (int j = 1; j < w - 1; j++) {
				cout << '.';
			}
			cout << '#' << endl;
		}
		for (int i = 0; i < w; i++) {
			cout << '#';
		}
		cout << endl << endl;
	}
}


Measured memory_bytes: 3080
<?php
//error_reporting(0);
//list($N,$Q) =  explode(" ",trim(fgets(STDIN)));
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$d = trim(fgets(STDIN));
$e = trim(fgets(STDIN));
$k = trim(fgets(STDIN));

$diff[] = $b - $a;
$diff[] = $c - $a;
$diff[] = $d - $a;
$diff[] = $e - $a;
$diff[] = $c - $b;
$diff[] = $d - $b;
$diff[] = $e - $b;
$diff[] = $d - $c;
$diff[] = $e - $c;
$diff[] = $e - $d;

if (max($diff)<=$k) {
  printf("Yay!\n");
}
else {
  printf(":(\n");
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll llINF=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,k;
  cin>>n>>k;
  vi p(n);
  rep(i,n) cin>>p[i];
  sort(all(p));
  ll sum=0;
  rep(i,k){
    sum+=p[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = S % 3600 / 60;
		int s = S % 3600 % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}



Measured memory_bytes: 26292
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int a, b; cin >> a >> b;
    int ans;
    if (a > b)
        ans = a + a - 1;
    else if (a < b)
        ans = b + b - 1;
    else
        ans = a + b;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        n: u64,
    }
    let mut i = 1;
    let mut div = 0;
    while i * i <= n {
        if n % i == 0 {
            div = i;
        }
        i += 1;
    }
    let mut div2 = n / div;
    //debug!(div);
    //debug!(div2);
    let mut digit1 = 0;
    while div > 0 {
        div /= 10;
        digit1 += 1;
    }
    let mut digit2 = 0;
    while div2 > 0 {
        div2 /= 10;
        digit2 += 1;
    }
    let ans = max(digit1, digit2);
    println!("{}", ans);
}

Measured memory_bytes: 4352
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
string s;
LL dp[202][202];
const int mod = 1e9 + 7;

int main(){
    cin >> n;
    REP(i, n){
        char c;
        cin >> c;
        if(c != '-')s += c;
    }
    n = (int)s.size();
    dp[0][0] = 1;
    REP(i, n){
        REP(j, i + 1){
            if(s[i] == 'D'){
                (dp[i + 1][j] += dp[i][j] * j) %= mod;
                if(j)(dp[i + 1][j - 1] += dp[i][j] *j * j) %= mod;
            }else{
                (dp[i + 1][j + 1] += dp[i][j]) %= mod;
                (dp[i + 1][j] += dp[i][j] * j) %= mod; 
            }
        }
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 3488
import heapq
n=int(input())
a=[int(i) for i in input().split()]
 
heap_left=[]
left=0
for i in range(n):
    left+=a[i]
    heapq.heappush(heap_left,a[i])
 
lst_left=[left]
for i in range(n,2*n):
    tmp=heapq.heappushpop(heap_left,a[i])
    left=left-tmp+a[i]
    lst_left+=[left]
 
heap_right=[]
right=0
for i in range(2*n,3*n):
    right+=a[i]
    heapq.heappush(heap_right,-a[i])
 
lst_right=[right]
for i in range(2*n-1,n-1,-1):
    tmp=heapq.heappushpop(heap_right,-a[i])
    right=right-(-tmp)+a[i]
    lst_right+=[right]
 

ans=-10**100
for i in range(n+1):
    ans=max(ans,lst_left[i]-lst_right[-(i+1)])
 
print (ans)

Measured memory_bytes: 39132
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=5e5+5;
vector<int>g[maxm];
char s[maxm];
int in[maxm];
int d[maxm];
int n;
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	n++;
	for(int i=1; i<=n-1; i++)
	{
		if(s[i]=='>')
		{
			g[i+1].push_back(i);
			in[i]++;
		}
		else
		{
			g[i].push_back(i+1);
			in[i+1]++;
		}
	}
	queue<int>q;
	for(int i=1; i<=n; i++)
	{
		if(in[i]==0)
			q.push(i);
	}
	int ans=0;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		ans+=d[x];
		for(int v:g[x])
		{
			if(in[v])
			{
				in[v]--;
				d[v]=max(d[v],d[x]+1);
				if(!in[v])
					q.push(v);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 39304
let () =
  let s = Scanf.scanf "%s" (fun s -> s) in
  Array.init (String.length s / 2) (fun i ->
    (String.sub s 0 i = String.sub s i i, 2*i))
  |> Array.fold_left (fun z (b,s) -> if b then s else z) 0
  |> Printf.printf "%d\n"


Measured memory_bytes: 4480
N = int(input())
A = list(map(int,input().split()))
flg = False
co = 0
while(True):
    for i in range(N):
        if(A[i]%2==0):
            A[i] = A[i]/2
        else:
            flg = True
            break
    if(flg):
        break
    co = co+1
        
print(co)


Measured memory_bytes: 3060
import Control.Applicative ((<$>))
import qualified Control.Monad as Monad (forM, replicateM)

type Row = [Int]
type Spreadsheet = [Row]

main = do
    [r,c] <- getLine'
    xs <- Monad.replicateM r $ getLine'
    mapM_ (putStrLn . printFormat) =<< newSpreadsheet (c+1) xs

getLine' :: IO [Int]
getLine' = map read . words <$> getLine

printFormat :: Row -> String
printFormat xs = unwords $ show <$> xs

newSpreadsheet :: Int -> Spreadsheet -> IO Spreadsheet
newSpreadsheet n xs = do
    let xs' = zipWith (++) xs $ rowSums xs
    return $ xs' ++ columnSums n xs'

rowSums :: Spreadsheet -> Spreadsheet
rowSums = map $ (:[]) . sum

columnSums :: (Monad m) =>Int -> Spreadsheet -> m Row
columnSums n xs = Monad.forM [0..(n-1)] $ \i -> return $ sum $ map (!! i) xs

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

constexpr int MAXN = 1e5;
int h[MAXN];
int cost[MAXN];

int main(void) {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> h[i];
  cost[0] = 0;
  cost[1] = abs(h[1] - h[0]);

  for (int i = 2; i < N; i++)
    cost[i] = min(cost[i - 1] + abs(h[i - 1] - h[i]),
                  cost[i - 2] + abs(h[i - 2] - h[i]));

  cout << cost[N - 1] << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

int main(){
	int ans;
	int n;

	std::cin>>n;

	if(n==3 || n==5 || n==7)
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define um unordered_map
#define fi first
#define se second

int main()
{   
   fast;
    
    ll n, k; cin>>n>>k;
    ll arr[n], dp[n];
    
    for(ll i=0; i<n; i++)
    {
        cin>>arr[i];
        
        if(i==0)
            dp[i]=0;
        else if(i==1)
            dp[i]=abs(arr[i]-arr[i-1]);
        else
        {
            dp[i]=LONG_MAX;
            
            ll j=i-k;
            while(j<0)
                j++;
            
            while(j<i)
            {
                dp[i]=min(dp[i], dp[j] + abs(arr[i]-arr[j]));
                j++;
            } 
            
        }
    }
    
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5220
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long H;
  cin >> H;

  long long num_attacks = floor(log2(H));
  long long res = 1;
  for (long long i = 0; i < num_attacks; ++i) {
    res += pow(2, i + 1);
  }

  cout << res << endl;

  return 0;
}

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

int main(void){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    int cmp=0;
    vector<int> dt(5);
    int ret=0;
    int first=0, before=0,idx=0;
    for(int i=0;i<5;i++){
        cin>>dt[i];
    }
    int tmp = dt[0]%10;
    // cout<<"size: "<<dt.size()<<"\n";
    
    for(int i=0;i<5;i++){
        tmp=0;
        for(int j=0;j<dt.size();j++){
            if(dt[j]%10 == 0){
                tmp=0;
                before=dt[j];
                idx=j;
                break;
            }
            if(tmp<dt[j]%10){
                tmp = dt[j]%10; 
                before=dt[j];
                idx=j;
                // cout<<"step: "<<i<<" tmp: "<<tmp<<" before: "<<before<<" idx: "<<idx<<"\n";
            }
        }
        // for(int k=0;k<dt.size();k++){
        //     cout<<"-------------"<<endl;
        //     cout<<dt[k]<<endl;
        //     cout<<"-------------"<<endl;
        // }
        // cout<<"add : "<<before<<endl;
        ret+=before;
        if(i==4) break;
        if(ret%10 != 0) ret+=(10-tmp);
        dt.erase(dt.begin()+idx);
        // cout<<"removed size: "<<dt.size()<<" ret: "<<ret<<endl;
    }
    
    cout<<ret;

    return 0;
}

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

int main() {
    char a[1001];
    while(1){
        scanf("%s",a);
        if(a[0] == '0')break;
        int h = 0;
        for(int i = 0;i < strlen(a);i++){
            h += (a[i]-'0');
        
        }
        printf("%d\n",h);
    
    }
}


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

const int INF = 1e9 + 5;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vector<int> dp(n, INF);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    // for (int j = 1; i+j < n && j<=k; j++) {
    //   dp[i+j] = min(dp[i+j], dp[i]+abs(v[i+j]-v[i]));
    // }

    for (int j = i+1; j <= i+k; j++) {
      if (j < n)
        dp[j] = min(dp[j], dp[i]+abs(v[j]-v[i]));
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int dp[10][2][2][2][2][2];

int main() {
    string s;
    cin >> s;
    int digit = s.size();

    dp[0][0][0][0][0][0] = 1;

    // i: 上からi桁目まで見た
    // j: N未満であることが確定しているか
    // a: すでに7を選んでいるか
    // b: すでに5を選んでいるか
    // c: すでに3を選んでいるか
    // e: すでに3,5,7のどれかを選んでいるか

    for (int i = 0; i < digit; i++) {
        for (int j = 0; j < 2; j++) {
            int limit = j ? 9 : s[i] - '0';

            for (int d = 0; d <= limit; d++) {
                if (!(d == 7 || d == 5 || d == 3 || d == 0)) continue;

                for (int a = 0; a < 2; a++) {
                    for (int b = 0; b < 2; b++) {
                        for (int c = 0; c < 2; c++) {
                            for (int e = 0; e < 2; e++) {
                                if (e && d == 0) continue;

                                dp[i+1][j || d < limit][a || d == 7][b || d == 5][c || d == 3][e || d > 0] += dp[i][j][a][b][c][e];
                            }
                        }
                    }
                }
            }
        }
    }

    int ret = 0;
    for (int j = 0; j < 2; j++) {
        ret += dp[digit][j][1][1][1][1];
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
function bai(x,y) {
	var x1 = x, y1 = y;
	var temp;
	while (y1 != 0) {
		temp = y1;
		y1 = x1 % y1;
		x1 = temp;
	}
	return x*y/x1;
}
 
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var count = input[0]-0;
	var values = input[1].split(" ");
	var numerator = 1;
	var denominator = values[0]-0;
	for(var i = 1; i < count; i++) {
		var newDenominator = bai(denominator, values[i]-0);
		numerator *= newDenominator/denominator;
		numerator += newDenominator/values[i]-0;
        denominator = newDenominator;
	}
	
	console.log(denominator/numerator);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp;
long long f(vector<long long>&A,vector<long long>&B,int i,int W)
{
    if(dp[i][W]!=-1)
    return dp[i][W];
    if(i==A.size())
    return 0;
    long long x=0,y;
    if(W-A[i]>=0)
    x=f(A,B,i+1,W-A[i])+B[i];
    y=f(A,B,i+1,W);
    return dp[i][W]=max(x,y);
}

int main()
{
    int N,W;
    cin>>N>>W;
    vector<long long>A(N),B(N);
    for(int i=0;i<N;i++)
    cin>>A[i]>>B[i];
    dp.resize(N+1,vector<long long>(W+1,-1));
    cout<<f(A,B,0,W);
}

Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <iomanip>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int w, a, b;
  cin >> w >> a >> b;

  if(a < b && a + w < b){
    FINA(b - a - w);
  }
  else if(b < a && b + w < a){
    FINA(a - b - w);
  }
  else{
    FINA(0);
  }  
  
 return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{

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

    int n, k;

    cin >> n >> k;

    set<int> st; //ローカル変数として、stを生成

    //vector<vector<int>> vec(k, vector<int>(k, -1));

    vector<int> ve;
    rep(i,n){
        ve.push_back(-1);
    }

    int d;
    int buf;
    rep(i, k * 2)
    {
        cin >> d;
        rep(k, d)
        {
            cin >> buf;
            //vec[i][k] = buf;
            ve[buf-1] ++;
        }
    }
    int ans = 0;
    rep(i,n){
        if(ve[i]==-1){
            ans++;
        }
    }

cout << ans;

    return 0;
}

Measured memory_bytes: 3624
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}

bool beginwith(const string & src, const string &tar){
  if (src.size() < tar.size())return false;
  rep(i, tar.size()){
    if (src[i] == tar[i]);
    else return false;
  }
  return true;
}

bool endwith(const string & src, const string & tar){
  if (src.size() < tar.size())return false;
  rep(i, tar.size()){
    if (tar[tar.size()-i-1] == src[src.size() - i-1]);
    else return false;
  }
  return true;
}

bool solve(string &in){
  const string a = "keyence";
  if (in == a)return true;
  if (beginwith(in, a) || endwith(in, a))return true;

  int n = a.size();
  REP(i, 1, n){
    string t1 = a.substr(0, i), t2 = a.substr(i, n-i);
    if (beginwith(in, t1) && endwith(in, t2))return true;
  }
  return false;
}
 
int main(){
  string in;
  cin >> in;
  if (solve(in) )cout <<"YES" << endl;
  else cout <<"NO" << endl;
  return 0;
}
 
 


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

using namespace std;

using ll = long long;

template <typename T>
class BinaryIndexedTree {  // 1-indexed
  int N;
  vector<T> bit;

 public:
  BinaryIndexedTree(int N) : N(N) { bit.assign(N + 1, 0); }

  void add(int index, T num) {
    for (int x = index; x <= N; x += x & -x) bit[x] += num;
  }

  T sum(int index) {
    int ret = 0;
    for (int x = index; x > 0; x -= x & -x) ret += bit[x];
    return ret;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  auto aa = a;
  sort(aa.begin(), aa.end());
  int right = n, left = -1;
  while (right - left > 1) {
    int mid = (right + left) / 2;
    int med = aa[mid];
    auto b = a;
    for (auto &x : b) {
      if (x < med)
        x = -1;
      else
        x = 1;
    }
    for (int i = 1; i < n; ++i) {
      b[i] += b[i - 1];
    }
    BinaryIndexedTree<int> BIT(300001);
    ll num = 0;
    BIT.add(100001, 1);
    for (auto x : b) {
      num += BIT.sum(x + 100001);
      BIT.add(x + 100001, 1);
    }
    // cout << med << " " << num << endl;
    ll m = ((ll(1 + n) * n) / 2);
    if (num >= m / 2 + m % 2) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << aa[left] << endl;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
h = [0]+list(map(int,input().split()))

route = [[0] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())
    route[a].append(h[b])
    route[b].append(h[a])

cnt=0
for i in range(1,n+1):
    if h[i]>max(route[i]):
        cnt+=1
print(cnt)


Measured memory_bytes: 25820
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    int count = 0;

    for (int i = 0; i < s.length(); i++) {
      if (c[i] == '1') count++;
    }

    System.out.println(count);
  }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  int N,x,cnt=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];


  while(1){
    if(a[0]==0) x=0;
    else{
      x=1;
      cnt++;
    }

    for(int k=0;k<N;k++){
      if(a[k]!=0) break;
      if(k==N-1){
        cout<<cnt<<endl;
        return 0;
      }
    }

    for(int j=0;j<N;j++){
      if(a[j]!=0){
        a[j]--;
        if(x==0){
          cnt++;
          x=1;
        }
      }else{
        if(x==1) x=0;
      }
    }
  }
}


Measured memory_bytes: 256
function main(input) {
    var arr = input.replace(/\r?\n/g, "").split(" ");
    const A = arr[0], B = arr[1], C = arr[2];
    var flg = false;
    if (A == B && B != C) flg = true;
    if (B == C && C != A) flg = true;
    if (C == A && A != B) flg = true;
    console.log(flg ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> d(2*n);
    rep(i, 2*n) cin >> d[i];
    int cnt = 0;
    for (int i=0;i<2*n;i+=2) {
        if (d[i] == d[i+1]) cnt++;
        else cnt = 0;
        if (cnt >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

typedef long long int lint;

void swap(lint *l, lint *r){
    lint tmp = *l;
    *l = *r;
    *r = tmp;
}

lint attack(lint hp){
    if(hp == 1){
        return 1;
    }
    else{
        return 2*attack(hp/2) + 1;
    }
}

int main(){
    lint H;
    scanf("%lld", &H);

    lint total;
    total = attack(H);
    printf("%lld\n", total);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
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); }
 
int main(){
	ll n;
	string s;
	cin >> n >> s;

	vector<ll> w(300001, 0);
	vector<ll> e(300001, 0);
	for (ll i = 1; i <= n; i++){
		e[i] = e[i-1] + (s[i-1] == 'E');
		w[i] = w[i-1] + (s[i-1] == 'W');
	}

	ll ans = 10e9;
	for (ll i = 0; i <= n; i++){
		ll east = e[n] - e[i + 1];
		ll west = w[i] - w[0];
		ans = min(ans, east + west);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    if (V <= P) {
        ll X = A[N-P]-M;
        auto it = lower_bound(A.begin(), A.end(), X);
        cout << distance(it, A.end()) << endl;
    }else {
        ll l = -1, r = N-P;
        while (r-l > 1) {
            ll c = (l+r)/2;
            if (A[c] + M < A[N-P]) {
                l = c;
                continue;
            }
            vector<ll> B;
            for (int i = N-P; i >= 0; i--) {
                if (i != c) B.push_back(M+A[c]-A[i]);
            }
            auto it = lower_bound(B.begin(), B.end(), M);
            ll sum = 0;
            sum += M*distance(it, B.end());
            while (it != B.begin()) {
                it--;
                sum += (*it);
            }
            if (sum >= M*(V-P)) r = c;
            else l = c;
        }
        cout << N-r << endl;
    }
    return 0;
}


Measured memory_bytes: 2896
import sys
import bisect
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

#累積和を取って片方を全探索、もう片方を二分探索


n,m,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
lst2 = list(map(int,readline().split()))

def cumsum(lst): #元のリストを保持
    res = lst[:]
    for i in range(1,len(res)):
        res[i] += res[i-1]
    return res
lst3 = [0] + cumsum(lst1)
lst4 = cumsum(lst2)


ans = 0
for i in range(0,n+1):
    res = k-lst3[i]
    if res < 0:
        break
    res2 = bisect.bisect_right(lst4,res)
    ans = max(ans,i+res2)

print(ans)

Measured memory_bytes: 106960
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    bool flag = true;
    ll sum = 0;
    ll plus = 0;
    REP(i,n) {//+-+-なかんじで
        sum += a[i];
        if(flag && sum<=0) {
            plus += abs(sum)+1;
            sum = 1;
        }
        if(!flag && sum>=0) {
            plus += abs(sum)+1;
            sum = -1;
        }
        flag = !flag;
    }
    flag = false;
    sum = 0;
    ll minus = 0;
    REP(i,n) {//-+-+なかんじで
        sum += a[i];
        if(flag && sum<=0) {
            minus += abs(sum)+1;
            sum = 1;
        }
        if(!flag && sum>=0) {
            minus += abs(sum)+1;
            sum = -1;
        }
        flag = !flag;
    }
    cout << min(minus,plus) << endl;
    return 0;
}

Measured memory_bytes: 1152