akhauriyash/Code-Regression huggingface dataset:
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	int n = 5;
	int ans;
	Rep(i,0,n){
		int num;	cin >> num;	
		if(num == 0){
			ans = i+1;
		}
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	//system("pause");
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define pf push_front

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if(a==0) return b;
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli MIN=-1*1e18;
const lli INF=1e18+999999999999999999;
const lli N=2e5+5;
const ldb pi=4*atan(1);

lli n,m,k,t;
//lli a,b,c,d;
lli p,q,l,r;
lli arr[N];
//lli a[N],b[N],c[N],d[N];
lli a,b,c,d;
lli x[1000005],y[1000005];
//map<lli,lli> m1,m2;
vector<lli> v,v1,v2;
lli pre[N],suff[N];
//lli vis[N]={0};
char grid[100][100];
vector<pair<lli,lli>> pl;

int32_t main(){
    fast_io
    lli i = 0,j=0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cout << fixed << setprecision(14);
   
    map<string,lli> mp;
   
    v.clear();
    v1.clear();
    v2.clear();
    pl.clear();
    
    cin >> a >> b >> c >> d;
    lli c1=a/d;
    if(a%d!=0) c1++;
    lli c2=c/b;
    if(c%b!=0) c2++;
    if(c1<c2) cout << "No";
    else cout << "Yes";

}

Measured memory_bytes: 3664
#include <iostream>

#define ll long long

using namespace std;

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if (a == b){
    cout << 1 << endl;
    return 0;
  }
  if (n == 1 || a > b){
      cout << 0 << endl;
    return 0;
  }
  if (n == 2){
    cout << 1 << endl;
  }
  ll mi = n*a + b-a;
  ll ma = n*b + a-b;
  cout << ma-mi+1 << endl;
  return 0;
}


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

using namespace std;

int main()
{
  string s;
  int k;
  cin >> s >> k;
  int size = s.size();
  vector<string> p;
  set<string> se;
  for (int i = 0; i < size; i++)
    for (int j = 1; j < size - i + 1 && j < 6; j++)
      if (se.count(s.substr(i, j)) == 0)
      {
        p.push_back(s.substr(i, j));
        se.insert(s.substr(i, j));
      }
  sort(p.begin(), p.end());
  cout << p[k - 1] << endl;

  return 0;
}


Measured memory_bytes: 2432
MOD = 10**9+7

n,m = map(int, input().split())
al = [True]*(n+1)
for _ in range(m):
    al[int(input())] = False

dp = [0]*(n+1) 
dp[0] = 1
for i in range(n):
    if i+2 <= n and al[i+2]:
        dp[i+2] += dp[i]
    if i+1 <= n and al[i+1]:
        dp[i+1] += dp[i]

print(dp[n]%MOD)

Measured memory_bytes: 503428
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

int main(){
    string s;
    ll k;
    cin >> s >> k;
    char ans='1';
    rep(i,k){
        if(s[i]=='1')continue;
        ans=s[i];
        break;
    }
    printf("%c\n",ans);
}


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


int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf("%d\n", min(n*a, b));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, K, d, tmp;
  ll c[1000]={};
  ll ans = 0;
  
  cin >> N >> K;
  rep(i,K){
    cin >> d;
    rep(j,d){
      cin >> tmp;
      c[tmp]++;
    }
  }

  FOR(i, 1, N+1){
    if(c[i]==0){
      ans++;
    }
  }
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    print(S.replace(',',' '))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9016
import itertools
import numpy as np
n = int(input())

names = {}
for i in range(n):
    initial = input()[0]
    names[initial] = names.get(initial, 0) + 1

print(np.sum(np.prod(pattern) for pattern in itertools.combinations([names.get(v, 0) for v in 'MARCH'], r=3)))


Measured memory_bytes: 21472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int h,w;
    cin >>h >>w;
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,h)rep(j,w) cin >>a[i][j];

    int ans = 10101010;
    rep(i,h)rep(j,w){
        int tmp = 0;
        rep(y,h)rep(x,w){
            int d = min(abs(i-y), abs(j-x));
            tmp += d*a[y][x];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000;

using namespace std;

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

    double t, a;
    cin >> t >> a;
    double diff, close_t, x;
    int close_index;

    close_t = INF;
    close_index = 0;
    for (int i=1; i<=n; i++){
        cin >> x;
        diff = a - (t - x*0.006);
        if (diff<0) diff = -diff;
        if (close_t > diff) {
            close_t = diff;
            close_index = i;
        }
    }
    cout << close_index << endl;
}


Measured memory_bytes: 256
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


from math import factorial


def comb(n, r):
    return factorial(n) // (factorial(n-r) * factorial(r))


n, m = map(int, input().split())
r = 1
prime_fac = prime_factorize(m)
for v in prime_fac.values():
    r *= comb(v+n-1, v)
mod = 1000000000 + 7
print(r % mod)


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

int main(){
  int N,c=0,j=0;
  vector <int> length(1);
  cin >> N;
  
  vector <int> H(N);
  
  rep(i,N)
    cin >> H.at(i);
  

  
  rep(i,N-1){
  if(H.at(i)>=H.at(i+1)){
    length.at(j)++;
  }else{
    length.push_back(0);
    j++;
  }
  }
  
  sort(length.begin(),length.end());
  reverse(length.begin(),length.end());
  
  cout << length.at(0) << endl;
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= k) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3696
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var ab = Sarray();
            var a = ab[0];
            var b = ab[1];
            var aa = string.Join("",Enumerable.Range(0, a).Select(x => b));
            var bb = string.Join("",Enumerable.Range(0, b).Select(x => a));
            WriteLine(new[] { aa, bb }.OrderBy(x => x).First());
        }
    }
}


Measured memory_bytes: 19984
l, r = map(int, input().split())
mi = 2019
if r - l > 2020:
  mi = 0
else:
  for i in range(l,r+1):
    for j in range(i+1, r+1):
      mod = i*j % 2019
      if mod < mi:
        mi = mod
print(mi)

Measured memory_bytes: 3060
A = list(map(int, input().split()))
B = []
counter = 0
ans = 0
for X in A:
    B.append(X % 2)
    if X % 2:
        counter += 1
if counter == 1:
    ans += 1
    for i in range(3):
        if not B[i]:
            A[i] += 1

if counter == 2:
    ans += 1
    for i in range(3):
        if B[i]:
            A[i] += 1

for X in A:
    ans += (max(A)-X)//2

print(ans)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll K;
  cin >> K;
  queue<ll> q;
  vector<ll> ans;
  for (ll i=1; i<=9; i++) {
    q.push(i);
  }
  while (ans.size() < 200000) {
    ll x = q.front();
    q.pop();
    ans.push_back(x);
    ll mi = x % 10;
    for (ll t=mi-1; t <= mi+1; t++) {
      if (t < 0 || t > 9) continue;
      q.push(x*10 + t);
    }
  }
  cout << ans[K-1] << endl;
  return 0;
}


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

namespace ConsoleApplication3
{
    //ONLINE JUDGE (ITP1_6_D)

    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');               //n??¨m?????????????????????????´?
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);


            int[,] intArray = new int[n,m];

            for (int i = 0; i < n; ++i)                                 //????¬?????????????A?????°???1?????????????´?
            {
                string[] strArray = Console.ReadLine().Split(' ');
                
                for(int j = 0; j < m; ++j)
                {
                    intArray[i,j] = int.Parse(strArray[j]);
                }
            }


            int[] bi = new int[m];                                      //bi???????´?????????????????´?

            for (int i = 0; i < m; ++i)
            {
                bi[i] = int.Parse(Console.ReadLine());                     
            }


                for (int i = 0; i < n; ++i)                             //c????±???????
                {
                    int sum = 0;

                    for (int j = 0; j < m; ++j)
                    {
                        int x = bi[j] * intArray[i, j];
                        sum += x;
                    }
                    Console.WriteLine(sum);
                }

        }
    }
}

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

int A[3003], B[3003];
int dp[3003][3003][2];

int solve(int pos, int t, int flag)
{
    if(pos == 0)
        return 0;

    if(dp[pos][t][flag] != -1)
        return dp[pos][t][flag];
    
    int ans = solve(pos - 1, t, flag);

    if(t >= A[pos])
        ans = max(ans, solve(pos - 1, t - A[pos], flag) + B[pos]);
    
    if(flag == 0)
        ans = max(ans, solve(pos - 1, t, 1) + B[pos]);

    return dp[pos][t][flag] = ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N,T;
    cin >> N >> T;

    for(int i=1; i<=N; i++)
        cin >> A[i] >> B[i];

    memset(dp, -1, sizeof(dp));

    cout << solve(N, T-1, 0) << "\n";

    return 0;
}


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

const ll mod = 1000000007;
ll dp[100005][2];

int main(){
  string s;
  cin >> s;
  int n = s.size();
  dp[0][1]=1;
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    dp[i+1][0] = dp[i+1][1] = 0;
    dp[i+1][0]+=(dp[i][0]*3)%mod;
    if(s[i]=='0'){
      dp[i+1][1]+=(dp[i][1])%mod;
    }else{
      dp[i+1][0]+=(dp[i][1])%mod;
      dp[i+1][1]+=(dp[i][1]*2)%mod;
    }
  }
  int ans = (dp[n][0]+dp[n][1]) % mod;
  cout << ans << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> dp(n+1);
    for(int i = 0; i <= n; i ++) dp[i] = 1e6;
    dp[0]=0;
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= i; j *= 6) {
            dp[i] = min(dp[i],dp[i-j]+1);
        }
        for(int j = 1; j <= i; j *= 9) {
            dp[i] = min(dp[i],dp[i-j]+1);
        }
    }
    cout << dp[n] << endl;
}

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



int ddp(vector<int>&nums,int K) {
	if(nums.size()==0 || nums.size()==1) return 0 ;
	vector<int>dp(nums.size(),INT_MAX) ;
	dp[0] =0 ;
	dp[1] = abs(nums[1]-nums[0]) ;
	for(int i =2;i<nums.size();i++){
        for(int j = 1;j<=K && i-j>=0;j++)
		dp[i] = min(dp[i],dp[i-j]+abs(nums[i]-nums[i-j])) ;
	}
	return dp[nums.size()-1] ;
} 

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int N; cin >> N ; int K ;cin >> K ;
	vector<int>arr(N) ;
	for(int i =0 ;i<N;i++) {
		cin >> arr[i] ;
	}
    int ans = ddp(arr,K) ;
	cout << ans ;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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<ll> L(N);
  rep(i,N) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[i] + L[j] > L[k]) ++ans;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

template<typename T = ll> struct UnionFind {
	vector<T> par;

	UnionFind( T n ) : par( n, -1 ) {}

	void init( T n ) { par.assign( n, -1 ); }
	T find( T x ) {
		if ( par[x] < 0 ) return ( x );
		else return ( par[x] = find( par[x] ) );
	}
	bool isSame( T x, T y ) {
		return ( find( x ) == find( y ) );
	}
	bool unite( T x, T y ) {
		x = find( x ); y = find( y );
		if ( x == y ) return ( false );
		if ( par[x] > par[y] ) swap( x, y );
		par[x] += par[y];
		par[y] = x;
		return ( true );
	}
	T size( T x ) { return ( -par[find( x )] ); }
};


int main()
{
	ll n, m; cin >> n >> m;
	UnionFind<ll> uf( n );
	rep( i, m )
	{
		ll a, b;
		cin >> a >> b;
		--a; --b;
		uf.unite( a, b );
	}

	ll ans = 0;
	rep( i, n )
	{
		if ( uf.find( i ) == i )
			++ans;
	}

	cout << ans - 1 << endl;

	return ( 0 );
}


Measured memory_bytes: 3620
N = int(input())
from collections import defaultdict
dic = defaultdict(int)
for _ in range(N):
    s = input()
    dic[s[0]]+= 1
print(dic['M']*dic['A']*dic['R']+dic['M']*dic['A']*dic['C']+dic['M']*dic['A']*dic['H']+dic['M']*dic['C']*dic['R']+dic['M']*dic['H']*dic['R']+dic['M']*dic['C']*dic['H']+dic['C']*dic['A']*dic['R']+dic['H']*dic['A']*dic['R']+dic['C']*dic['H']*dic['R']+dic['C']*dic['A']*dic['H'])

Measured memory_bytes: 74268
/*_47*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pll pair<ll,ll>
#define pk pair<pll,ll>
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define pr_vec(v) for(auto __:v) cout<<__<<" ";
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const int N = 1e2 + 5;
ll dp[N][10];
ll get(ll id, ll val)
{
    if(val<0 or val>9)
        return 0;
    if(id == 1)
        return 1;
    if(dp[id][val] != -1)
        return dp[id][val];
    ll ans = get(id - 1, val - 1) + get(id - 1, val) + get(id - 1, val + 1);
    return dp[id][val] = ans;

}
void solve()
{
    memset(dp, -1, sizeof dp);
    ll k;
    cin >> k;
    ll tot = 0, id = 0, len;
    rep(i, 10)
    {
        get(N - 1, i);
    }
    if(k <= 9)
    {
        cout << k;
        return;
    }
    tot = 9;
    bool flag = 0;
    for(ll i = 2; i < N; i++)
    {
        if(flag)
            break;

        // cout<<tot<<" ";
        for(ll j = 1; j < 10; j++)
        {
            // cout << dp[i][j] << " ";

            if(tot + dp[i][j] < k)
                tot += dp[i][j];
            else
            {
                len = i;
                id = j;
                flag = 1;
                break;
            }
        }
        // cout << endl;

    }
    // cout << len << " " << id;

    cout << id;
    len--;
    std::vector<ll> v = {-1, 0, 1};
    while(len)
    {
        for(auto j : v)
            if(tot + get(len, id + j) < k)
                tot += get(len, id + j);
            else
            {
                cout << id + j;
                id = id + j;
                len--;
                break;
            }

    }




}

int main()
{




    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        // cout << endl;
    }


}


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

using namespace std;
int a[100008],dp[100009],n;
int sol(int x)
{
    if (x==n-1) return 0;
    if (dp[x]!=-1) return dp[x];
    if (x==n-2) return dp[x]=abs(a[x]-a[x+1]);
    else return dp[x]=min(abs(a[x]-a[x+1])+sol(x+1),abs(a[x]-a[x+2])+sol(x+2));
}
int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cout<<sol(0);
    return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {    
    string s; int k; cin >> s >> k;

    set<string> used;
    bool fg = false;

    vector<string> substrings;
    rep(i, s.size()){
        substrings.push_back(s.substr(i));
    }
    sort(all(substrings));
    for(string t: substrings){
        if(fg) break;
        rep(i, t.size()){
            string u = t.substr(0, i+1);
            used.insert(u);
            if(used.size() == k && !fg){
                cout << u << ln;
                fg = true;
                break;
            }
        }
    }    
} 


Measured memory_bytes: 16128
#include <iostream>
#include <memory>
#include <vector>

using namespace std;

int main(){
    vector<int> dat;
    int n,itmp;
    cin>>n;

    for(int i=0;i<n;++i){
        cin>>itmp;
        dat.push_back(itmp);
    }

    int q, count=0;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>itmp;
        for(auto x : dat){
            
            if(x==itmp){
                count++;
                break;
            }
        }
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2000;

bitset<N * N> can;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int s = 0;
	can[0] = 1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s += x;
		can |= (can << x);
	}
	for (int i = 0; i < N * N; i++) {
		if (i >= s - i && can[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 5096
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i = x - k + 1 ; i < x + k - 1 ; i++ ){
            System.out.print(i +" ");
        }
        System.out.println(x + k - 1);
        sc.close();
    }
}

Measured memory_bytes: 38488
#include <iostream>
using namespace std;
int main(){
    
    int x, y ;
    
    do{
       cin >> x >> y;
       if((x==0)&&(y==0)){
       }
       else{
           if(x<y){
               cout << x << " " << y << endl;
           }
           else{
               cout << y << " " << x << endl;
           }
       }
    } while((x>0)||(y>0));
    
    
    
    
    
    
    
}


Measured memory_bytes: 3128
N,M= map(int,input().split())

H = list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]
tenbou_list=[[] for i in range(N)]#tenbou_list[0]は0の展望台(1)につながる展望台の番号
for i in AB:
    tenbou_list[i[0]-1].append(i[1]-1)
    tenbou_list[i[1]-1].append(i[0]-1)
count=0
num=0
for i in tenbou_list:
    k=0
    i=list(set(i))
    if len(i)==0:#つながる展望台なし
        count+=1
    else:
        for j in i:
            if H[j]>=H[num]:
                k+=1
                break
        if k==0:
            count+=1
    num+=1
print(count)

Measured memory_bytes: 111072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)1000000007
#define pb push_back
#define endl "\n"
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repo(i,b) for(int i=(int)0;i<b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int dp[3005][3005];

signed solve(){
	string a,b;
	cin>>a>>b;
	int n = a.length(), m = b.length();
	rep(i,1,n+1){
		rep(j,1,m+1){
			if(a[i-1]==b[j-1]) dp[i][j]=max(dp[i-1][j-1]+1, dp[i][j]);
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n,j=m;
	string s;
	while(i+j){
		if(i and dp[i][j]==dp[i-1][j]) i--;
		else if(j and dp[i][j]==dp[i][j-1]) j--;
		else s+=a[i-1],i--,j--;
	}
	reverse(all(s));
	cout<<s<<endl;
	return 0;
}

signed main(){
	fast;
	int tests=1;
	// cin>>tests;
	while(tests--){
		solve();
	}
}

Measured memory_bytes: 74068
#include <stdio.h>

int main(){
    int N;
    int an;
    int a[3];
    int num;
    int anum[3];
    bool byes = true;

    num =0;
    for(int i=0;i<3;i++){
        a[i] = -1;
        anum[i] = 0;
    }

    scanf("%d",&N);

    for(int j=0;j<N;j++){
        scanf("%d",&an);
        if(num == 0){
            num++;
            a[0] = an;
            anum[0]+=1;
        }
        else if(num<3)
        {
           for(int i=0;i<num;i++){
               if(a[i] == an){
                   anum[i]+=1;
                   break;
               }
               else if(i == num - 1){
                   a[num] = an;
                   anum[num]+=1;
                   num++;
                   break;
               }
            }

        }
        else{
        for(int i=0;i<3;i++){
            if(a[i] == an){
                anum[i]++;
                break;
            }
            else if(i == 2 && byes){
                byes = !byes;
            }
        }
        }
    }
    int aaa = a[0] ^ a[1] ^ a[2];
    if(byes && ((N%3!=0)||(num != 3 ) || (anum[0] != anum[1]) ||(anum[0] != anum[2]) || (aaa != 0)) ){
            byes = !byes;
        }

    if(num == 1 && a[0] == 0){
        byes = !byes;
    }
    if(num == 2 && a[0] == 0 && anum[1] == (anum[0] *2)){
        byes = !byes;
    }
    if(num == 2 && a[1] == 0 && anum[0] == (anum[1] *2)){
        byes = !byes;
    }

    if(byes){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
n = int(input())
g = [[] for i in range(n)]
for i in range(n):
    g[i] = list(map(lambda x:int(x)-1,input().split()))[2:]

def dfs(v,t):
    t += 1
    d[v] = t
    for i in g[v]:
        if d[i]==-1:
            t = dfs(i,t)
    t += 1
    f[v] = t
    return t

t = 0
d = [-1]*n
f = [-1]*n

for i in range(n):
    if d[i]==-1:
        t = dfs(i,t)

for i in range(n):
    print(i+1,d[i],f[i])


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

struct edge{int to;int cap;int rev;};
struct Dinic{
private:
  int n;
  vector<vector<edge>> v;
  vector<int> dist,iter;
public:
  Dinic(int sz):n(sz),v(sz),dist(sz),iter(sz){}
    
  void addedge(int from,int to,int cap){
    int x=v[to].size(),y=v[from].size();
    v[from].push_back({to,cap,x});
    v[to].push_back({from,0,y});
  }
    
  void bfs(int s){
    fill(dist.begin(),dist.end(),-1);
    queue<int> q;
    dist[s]=0;
    q.push(s);
    while(q.size()){
      int x=q.front();q.pop();
      rep(i,v[x].size()){
        edge &e=v[x][i];
        if(e.cap>0&&dist[e.to]<0){
          dist[e.to]=dist[x]+1;
          q.push(e.to);
        }
      }
    }
  }
    
  int dfs(int x,int t,int f){
    if(x==t)return f;
    for(int& i=iter[x];i<(int)v[x].size();++i){
      edge& e=v[x][i];
      if(e.cap>0&&dist[x]<dist[e.to]){
        int d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          v[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  int max_flow(int s,int t){
    int flow=0;
    while(1){
      bfs(s);
      if(dist[t]<0)return flow;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,(1LL<<31)-1))>0)flow+=f;
    }
  }
};

int main(){
  int h,w;
  cin >> h >> w;
  Dinic dn(h+w+2);
  rep(i,h){
    string s; cin >> s;
    rep(j,w){
      if(s[j]=='S'){
        dn.addedge(h+w, i, inf);
        dn.addedge(h+w, h+j, inf);
      }
      if(s[j]=='T'){
        dn.addedge(i, h+w+1, inf);
        dn.addedge(h+j, h+w+1, inf);
      }
      if(s[j]=='o'){
        dn.addedge(i, h+j, 1);
        dn.addedge(h+j, i, 1);
      }
    }
  }
  int ans=dn.max_flow(h+w, h+w+1);
  if(ans>=inf){ans=-1;}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
import java.util.*;

import javax.tools.ForwardingJavaFileObject;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Integer []A=new Integer[a];
        Integer []B=new Integer[b];
        Integer []C=new Integer[c];
        for(int i=0;i<A.length;i++){
            A[i]=sc.nextInt();
        }
        for(int i=0;i<B.length;i++){
            B[i]=sc.nextInt();
        }
        for(int i=0;i<C.length;i++){
            C[i]=sc.nextInt();
        }
        Arrays.sort(A,Collections.reverseOrder());
        Arrays.sort(B,Collections.reverseOrder());
        Arrays.sort(C,Collections.reverseOrder());
        
        Integer[]account=new Integer[X+Y+c];
        for(int i=0;i<X;i++){
            account[i]=A[i];
        }
        for(int i=0;i<Y;i++){
            account[X+i]=B[i];
        }
        for(int i=0;i<c;i++){
            account[X+Y+i]=C[i];
        }
        Arrays.sort(account,Collections.reverseOrder());
        long count=0;
        for(int i=0;i<X+Y;i++){
            count+=account[i];
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 102688
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

A = sorted(A, reverse=True)
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

tot = 0
for i in range(N - 1):
    if i % 2 == 0:
        tot += A[i // 2]
    else:
        tot += A[i // 2 + 1]

print(tot)


Measured memory_bytes: 31464
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> red(N*2+1, -1);
  vector<int> blue(N*2+1, -1);
  int a, b;
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    red[a] = b;
  }
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    blue[a] = b;
  }

  int res = 0;
  int tmp=-1,tmpi=0;


  for (int i=0; i<red.size(); i++) {
    if (blue[i] == -1) continue;
    tmp = INT_MAX;
    tmpi = INT_MAX;
    for (int k=0; k<i; k++) {
      if (red[k] == -1) continue;
      if (red[k] < blue[i]) {
        if (tmp > blue[i] - red[k]) {
          tmp = blue[i] - red[k];
          tmpi = k;
        }
      }
    }
    if (tmpi != INT_MAX)  {
      red[tmpi] = -1;
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
class Solve{
    public long a;
    public long b;
    public long c;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        if(a%2 == 0 || b%2 == 0 || c%2 == 0){
            Console.WriteLine(0);
        }
        else {
            if(a < b){
                if(b < c){
                    Console.WriteLine(a*b);
                }
                else{
                    Console.WriteLine(a*c);
                }
            }
            else{
                if(a < c){
                    Console.WriteLine(a*b);
                }
                else{
                    Console.WriteLine(b*c);
                }
            }
        }
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);
    }    
}

Measured memory_bytes: 2648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func nextString() string {
	stdInScanner.Scan()
	return stdInScanner.Text()
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	K := nextInt()
	price := make([]int, N)

	min := 1001
	var index int
	for i := 0; i < N; i++ {
		price[i] = nextInt()
		if price[i] < min {
			min = price[i]
			index = i
		}
	}
	answer := min
	limit := min
	price[index] = 0
	min = 1001

	if K > 1 {
		for i := 0; i < K-1; i++ {
			for j := 0; j < N; j++ {
				if price[j] >= limit && price[j] < min {
					min = price[j]
					index = j
				}
			}
			price[index] = 0
			answer += min
			limit = min
			min = 1001
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 1776
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long a,b,c,d,e,f,g,h;
cin>>a>>b;
int arr[a];
for (int i = 0; i < a; ++i)
{

	cin>>arr[i];
}

int arr2[a];
int x1=0;
arr2[0]=x1;
long long count=0;
if (arr2[0]<=b)
{
	/* code */
	count++;
}
for (int i = 1; i < a+1; ++i)
{
	/* code */
	x1+=arr[i-1];
	arr2[i]=x1;

	if (arr2[i]<=b)
	{
		/* code */
		count++;
	}
}

cout<<count<<endl;

return 0;
}

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

int main(){
    char a; cin >> a;
    if(a-'a' >= 0 && a-'a' <= 26){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define lli long long int

#define MOD 1000000007
int main(void)
{
	lli n,m;
	scanf("%lld %lld",&n, &m);
	lli i, j, k;
	i = 0;
	j = 0;
	k = 0;
	lli *a;
	a = (lli *)malloc(sizeof(lli)*(n+2));
	while (i < m)
	{
		scanf("%lld",&(a[i]));
		i++;
	}
	i = 0;
	lli *dp;
	dp = (lli *)malloc(sizeof(lli)*(n+2));
	dp[0] = 1;
	dp[1] = 1;
	j = 0;
	if(a[0] == 1)
	{
		dp[1] = 0;
		j++;
	}
	i = 2;
	while (i <= n)
	{
		dp[i] = (dp[i-1]%MOD+dp[i-2]%MOD)%MOD;
		if(a[j] == i)
		{
			dp[i] = 0;
			j++;
		}
		//printf("debug i:%lld, j:%lld, dp:%lld\n",i, j, dp[i]);
		i++;
	}
	printf("%lld\n",dp[n]);
	return (0);
}



Measured memory_bytes: 1792
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 100005;
const int MOD = 1e9 + 7;
int a[N], inv[N];
int n,k;

int power (int p, int q) {
    int s = 1;
    for (;q;q>>=1,p=p*p%MOD) if (q&1) (s *= p) %= MOD;
    return s;
}

void init() {
    scanf(II,&n,&k);
    rep (i,n) scanf(I,&a[i]);
    sort (a,a+n);
    repa (i,n) inv[i] = power(i,MOD-2);
    int p=1, ans=a[k-1];
    for (int i=k;i<n;i++) {
        (p*=i)%=MOD;
        (p*=inv[i-k+1])%=MOD;
        (ans+=a[i]*p)%=MOD;
    }
    ans += MOD-a[n-k]; p=1;
    for (int i=k;i<n;i++) {
        (p*=i)%=MOD;
        (p*=inv[i-k+1])%=MOD;
        (ans+=MOD-a[n-i-1]*p%MOD) %= MOD;
    }
    printf(IN,ans);
}

void solve() {

}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(long long &a, long long b) { if (a > b) a = b; }

int main(){
  ll i, j;
  string str;
  cin >> str;
  string key = "keyence";
  ll count1 = 0;
  ll count2 = 0;
  ll judge = 0;
  for(i = 0; i < str.size() && judge == 0; i++){
    if(key[count1] == str[i])
      count1++;
    else 
      judge = 1;
    
  }
  judge = 0;
  for(i = 0; i < str.size() && judge == 0; i++){
    if(key[6 - count2] == str[str.size() - 1 - i])
      count2++;
    else 
      judge = 1;
  }
  if(count1 + count2 >= 7)
  cout << "YES" << endl;
  else 
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){

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


	string str;
	cin >> str;

	bool p =true;
	int len = str.size();
	for(int i=0;i<len/2;i++){
		if(str[i]!=str[len-i-1]){
			p = false;
			break;
		}
	}

	if(p==true){
		string tmp = str.substr(0,(len-1)/2);
		//cout << tmp << endl;
		for(int i=0;i<tmp.size()/2;i++){
			if(tmp[i]!=tmp[tmp.size()-i-1]){
				p = false;
				break;
			}
		}	
	}

	if(p==true){
		string tmp = str.substr((len+3)/2-1,len-((len+3)/2-1));
		//cout <<"next="<< tmp <<" "<<(len+3)/2-1<< endl;
		for(int i=0;i<tmp.size()/2;i++){
			if(tmp[i]!=tmp[tmp.size()-1-i]){
				p = false;
				break;
			}
		}
	}	

	if(p==true) cout << "Yes";
	else cout << "No";



	return 0;
}


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

using namespace std;


int main(void){
    string ABCD;
    cin >> ABCD;
    for(int n = 0; n < 8; n++){
        int nn = n;
        int s = ABCD[0] - '0';
        for(int j = 1; j < 4; j++){
            if(nn % 2 == 0){
                s -= ABCD[j] - '0';
            }else{
                s += ABCD[j] - '0';
            }
            nn /= 2;
        }
        if(s == 7){
            cout << ABCD[0];
            for(int j = 1; j < 4; j++){
                if(n % 2 == 0){
                    cout << "-";
                }else{
                    cout << "+";
                }  
                cout << ABCD[j];
                n /= 2;
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np


############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])

data = []
write = stdin.readline().split()
data = set()
for i in range(N):
    #print(write)
    data.add(write[0])
    write = stdin.readline().split()
    
print(len(data))



Measured memory_bytes: 49048
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int maximum = 0;
    rep(i,N-1) maximum = max(maximum, A[i + 1] - A[i]);
    maximum = max(maximum, (K - A[N - 1] + A[0]));
    cout << (K - maximum) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

typedef pair<ll, ll> res;

int N;
vector<ll> A, S;

// [a, b), [b, c)
ll sumdiff(int a, int b, int c) {
  return abs(S[c] - 2 * S[b] + S[a]);
}

int main () {
  cin >> N;

  A.resize(N), S.resize(N+1, 0);
  rep(i,N) {
    cin >> A[i];
    S[i+1] = S[i] + A[i];
  }

  ll ans = 1e15;
  int p = 1, r = 3;
  for(int q = 2; q < N - 1; q++) {
    while(sumdiff(q, r+1, N) < sumdiff(q, r, N)) r++;
    while(sumdiff(0, p+1, q) < sumdiff(0, p, q)) p++;
    vector<ll> B = {S[p]-S[0], S[q]-S[p], S[r]-S[q], S[N]-S[r]};
    sort(B.begin(), B.end());
    ans = min(ans, B[3] - B[0]);
  }

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


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int H, W;
	cin >> H >> W;
	vector<string>s(H);
	rep(i, H)cin >> s[i];
	int init = 0;
	if (s[0][0] == '#')init++;
	if (s[H - 1][W - 1] == '#')init++;
	vector<vector<int>>dp(H, vector<int>(W, init));
	rep(i, H) {
		rep(j, W) {
			if (i == 0 && j == 0)continue;
			int a, b;
			if (!i)a = INF;
			else if (s[i - 1][j] != s[i][j])a = dp[i - 1][j] + 1;
			else a = dp[i - 1][j];
			if (!j)b = INF;
			else if (s[i][j - 1] != s[i][j])b = dp[i][j - 1] + 1;
			else b = dp[i][j - 1];
			dp[i][j] = min(a, b);
		}
	}
	int ans = dp[H - 1][W - 1] / 2;
	cout << ans << endl;
}

Measured memory_bytes: 384
M=10**6
p=[1]*M
p[0]=p[1]=0
for i in range(2,4*10**4):
    if p[i]:
        for j in range(i*i,M,i):
            p[j]=0
C=[0]*M
for i in range(2,M):
    if p[i] and p[(i+1)//2]:
        C[i]=C[i-1]+1
    else:
        C[i]=C[i-1]
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(C[r]-C[l-1])

Measured memory_bytes: 68060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] ss = Console.ReadLine().Split(' ');
      long a = long.Parse(ss[0]);
      long b = long.Parse(ss[1]);
      long x = long.Parse(ss[2]);
      long l = b - a + 1;
      if(a % x == 0)
        l += x;
      l += (a % x) - 1;
      long c = l / x;

      Console.WriteLine(c);
      Console.ReadLine();
    }

  }
}

Measured memory_bytes: 27524
#include<stdio.h>
int main()
{
    int a,b,c,ans;
    scanf("%d%d%d",&a,&b,&c);
   if(a==b)
   ans=2;
   if(b==c)
   ans=2;
   if(c==a)
   ans=2;
   if(a==b&&b==c&&c==a)
   ans=1;
   if(a!=b&&b!=c&&c!=a)
   ans=3;
    printf("%d",ans);
    return 0;
    
}

Measured memory_bytes: 128
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
i, c = 0, 0
m = list()
while i < len(a)-1:
    if a[i] == a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)

Measured memory_bytes: 15020