akhauriyash/Code-Regression huggingface dataset:
import copy
import math
import time
import statistics
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()

    n, m = get_int_multi()

    s = []

    for i in range(m):
        wk = get_int_list()
        wk = wk[1:]
        s.append(wk)

    p = get_int_list()

    ans = 0
    for i in range(2 ** n):
        ok = True
        for ii in range(m): # 電球ごとに調査
            count = 0
            for iii in range(n): # スイッチONOFF
                if ((i >> iii) & 1):
                    if (iii+1) in s[ii]:
                        count += 1
            if (count % 2 != p[ii]):
                ok = False
                break
        if ok:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()




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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N,M;
    cin>>N>>M;
    vector<map<int,bool>> tree(N);
    vector<int> incnt(N,0);
    rep(i,N+M-1){
        int A,B;
        cin>>A>>B;
        if(!tree[A-1][B-1]) incnt[B-1]++;
        tree[A-1][B-1]=true;
    }
    int root;
    rep(i,N) if(incnt[i]==0) root = i;
    queue<int> bfs;
    bfs.push(root);
    vector<int> parent(N);
    parent[root] = -1;
    vector<int> cnt(N,1);
    while(!bfs.empty()){
        int p = bfs.front();
        bfs.pop();
        for(auto nx:tree[p]){
            if(incnt[nx.first]==cnt[nx.first]){
                parent[nx.first] = p;
                bfs.push(nx.first);
            }
            else cnt[nx.first]++;
        }
    }
    rep(i,N) cout<<parent[i]+1<<endl;
}

Measured memory_bytes: 14316
module outputcolor
  sub main
    dim input_a as integer
    dim input_s as string = string.empty
    
    input_a = console.readline()
    input_s = console.readline()
    
    if (input_a >= 3200) then
      console.writeline(input_s)
    else
      console.writeline("red")
    end if
    
  end sub
end module


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    if(n%2)cout << n/2 + 1 << endl;
    else cout << n/2 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  string n;
  cin >> n;
  for (char c : n) cout << char(c ^ '1' ^ '9');
  cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;

int main() {
    cin >> n >> m;
    vector< vector<ll> > reward(m+1);
    for(int i = 0; i < n; ++i) {
        ll a, b; cin >> a >> b;
        if(a <= m) reward.at(m-a).emplace_back(b);
    }

    priority_queue<ll> pque;
    ll ans = 0;
    for(int i = m; i >= 0; --i) {
        for(auto x : reward[i]) pque.push(x);
        if(!pque.empty()) {
            ans += pque.top();
            pque.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8440
print([((int(s[:2]) == 0 or int(s[:2]) > 12) and (int(s[2:]) == 0 or int(s[2:]) > 12)) * "NA" + (not (int(s[:2]) == 0 or int(s[:2]) > 12) and not (int(s[2:]) == 0 or int(s[2:]) > 12)) * "AMBIGUOUS" + ((int(s[:2]) == 0 or int(s[:2]) > 12) and not (int(s[2:]) == 0 or int(s[2:]) > 12)) * "YYMM" + (not (int(s[:2]) == 0 or int(s[:2]) > 12) and (int(s[2:]) == 0 or int(s[2:]) > 12)) * "MMYY" for s in [input()]][0])

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 31;

void solve() {
	string s, t;
	cin >> s >> t;
	int a, b;
	string u;
	cin >> a >> b >> u;
	if (u == s) a--;
	else b--;
	cout << a << " " << b;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  int A[2];
  cin >> A[0] >> A[1];
  int sum = 0;
  for (int i = 0; i < 2; i++) {
    if (A[0] > A[1]) {
      sum += A[0];
      A[0]--;
    } else {
      sum += A[1];
      A[1]--;
    }
  }
  cout << sum << endl;
  
  return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A')return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key % M;}
int h2(int key){ return 1 + (key % (M-1));}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i*h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}
int insert(char str[]){
  long long key ,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) +i*h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }
  return 0;
}



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

#define RED 0
#define GREEN 1
#define BLUE 2
#define MAX_N 4000

string s;
int R[MAX_N], G[MAX_N], B[MAX_N], S[MAX_N];
int N;
long cnt = 0, r = 0, g = 0, b = 0;

void solve(){
    for(int i = 2; i < N; i++){
        for(int j = 0; j < i - 1; j++){
            if(S[i] == S[j]) continue;
            if(S[i] + S[j] == 1){
                if((i - j) % 2 != 0) cnt += B[i - 1] - B[j];
                else cnt += B[i - 1] + B[(i + j) / 2 - 1] - B[(i + j) / 2] - B[j];
            }
            if(S[i] + S[j] == 2){
                if((i - j) % 2 != 0) cnt += G[i - 1] - G[j];
                else cnt += G[i - 1] + G[(i + j) / 2 - 1] - G[(i + j) / 2] - G[j];
            }
            if(S[i] + S[j] == 3){
                if((i - j) % 2 != 0) cnt += R[i - 1] - R[j];
                else cnt += R[i - 1] + R[(i + j) / 2 - 1] - R[(i + j) / 2] - R[j];
            }
        }
    }
    cout << cnt << endl;
    return;
}

int main(){
    cin >> N >> s;
    for (int i = 0; i < N; i++){
        if(s[i] == 'R') {
            r++;
            S[i] = RED;
        }
        if(s[i] == 'G') {
            g++;
            S[i] = GREEN;
        }
        if(s[i] == 'B') {
            b++;
            S[i] = BLUE;
        }
        R[i] = r;
        G[i] = g;
        B[i] = b;
    }
    solve();
}

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int we(int wl, int wr, int lel, int ler) {
	int ml = wl * lel;
	int mr = wr * ler;
	int bil = mr / gcd(ml, mr);
	int bir = ml / gcd(ml, mr);
	return (wl * bil)+(wr*bir);
}
int main(){
	int n;
	cin >> n;
	while(n!=0){
	vector<int> w(n);
	vector<int> lel(n);
	vector<int> ler(n);
	vector<int> nul(n);
	vector<int> nur(n);
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> lel[i] >> ler[i] >> l >> r;
		l--; r--;
		nul[i] = l; nur[i] = r;
	}
	vector<int> d(n,n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x, y;
			if (nul[j] == -1) {
				x = -1;
			}
			else {
				x = d[nul[j]];
			}
			if (nur[j] == -1) {
				y = -1;
			}
			else {
				y = d[nur[j]];
			}
			d[j]=min(d[j], max(x, y)+1);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (d[j] == i) {
				int wl, wr;
				int l = nul[j];
				int r = nur[j];
				if (l == -1) {
					wl = 1;
				}
				else {
					wl = w[l];
				}
				if (r == -1) {
					wr = 1;
				}
				else {
					wr = w[r];
				}
				w[j] = we(wl, wr, lel[j], ler[j]);
				ans = max(ans, w[j]);
			}
		}
	}
	cout << ans << endl;
	cin >> n;
	}
}



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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<pair<int, int>> X(N);
  vector<int> ans(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> X[i].first;
    X[i].second = i;
  }
  sort(all(X));
  for (int i = 0; i < N; i++) {
    if (i < N / 2)
      ans[X[i].second] = X[N / 2].first;
    else
      ans[X[i].second] = X[(N - 1) / 2].first;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 4608
#include <math.h>
 
int main()
{
        int N, T, A, H;
        int i, ans=1;
        double tmpa, tmpb=0x7ffffff;
 
        scanf("%d %d %d", &N, &T, &A);
        for(i=0; i<N; i++)
        {
                scanf("%d", &H);
                tmpa = fabs(A-(T-H*0.006));
                if(tmpb>tmpa)
                {
                        tmpb = tmpa;
                        ans = i+1;
                }
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 128
n=int(input())
pi=[]
for i in map(int,input().split()):
    pi.append(i)
#print(pi)
pmin=[]
pmin.append(pi[0])
for i in range(n-1):
    if pmin[i]>pi[i+1]:
        pmin.append(pi[i+1])
    else:
        pmin.append(pmin[i])
#print(pmin)

icnt=0
for i in range(n):
    if pi[i]<=pmin[i]:
        icnt=icnt+1
print(icnt)    


Measured memory_bytes: 24744
#include <iostream>
    #include<bits/stdc++.h>
    using namespace std;
    void print(vector<int>vec,int n){
        for(int i=0;i<n;i++){
            cout<<vec[i]<<" ";
        }
    }
     
    bool isprime(int n){
        
        int i;
        for( i=2;i<=sqrt(n);i++){
            if(!(n%i)){
                break;
            }
        }
        if(i<=sqrt(n)){
            return 0;
        }
        return 1;
    }
     
    int nextprime(int N){
        bool x = 0;
        int i=1;
        while(!x){
            if(isprime(N+i)){
                x=1;
            }
            i++;
        }
        return N+i-1;
    }
     
    int main()
    {
        int n;
        cin>>n;
        bool a = isprime(n);
        if(a){
            cout<<n<<endl;
        }
        else{
            cout<<nextprime(n)<<endl;
        }
        
        
    }

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::BTreeSet;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let k: usize = input();
    let mut sub_str: BTreeSet<String> = BTreeSet::new();
    for i in 0..s.len() {
        for j in 1..k+1 {
            if i + j > s.len() {
                break;
            }
            let sub: String = s.chars().skip(i).take(j).collect();
            // println!("{}", sub);
            if sub_str.len() > k && sub_str.iter().last().unwrap() < &sub {
                break;
            }
            sub_str.insert(sub);
        }
    }
    // println!("{:?}", sub_str);
    let mut i = 0;
    for s in sub_str.iter() {
        if i == k - 1 {
            println!("{}", s);
            return;
        }
        i += 1;
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           
           string s;
           cin >> s;
           
           int r = 0;
           
           for(int i = 0 ; i < n ; i++)
           {
              if(s[i] == 'R')r++; 
           }
           
           int ans = 0;
           for(int i = r ; i < n ; i++)
           {
               if(s[i] == 'R')ans++;
           }
           
           cout << ans << endl;
        }
    }



Measured memory_bytes: 3760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))
typedef pair<int, int> P;


class DIslandsWar {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n, m;
      in >> n >> m;
      vector<P> ab(m);
      REP(i, m) {
        int x, y;
        in >> x >> y;
        ab[i] = P(x, y);
      }
      sort(ab.begin(), ab.end(), [](P a, P b) {
          return a.second < b.second;
      });
      //tは前回採用した区間の終端
      int t = 0, ans = 0;
      REP(i, m) {
        if (t <= ab[i].first) {//前回採用した区間の終端と調べる区間の始端を比較
          ans++;
          t = ab[i].second;
        }
      }
      out << ans << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  DIslandsWar solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1792
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
int M = 1e9 + 7;
const int N = 1e6 + 10;
const int IM = 1e16;
const int PI = 3.14159265;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> memset substr pop_back  insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================


signed  main() {
    SPD_emergency
  
    int i, j, x, y, u, l;
    int tt = 1;
    // int t; cin >> t; while (t--)
    {   i = j = x = y = u = l = 0;
        int k;
        cin >> k;
        string s;
        cin >> s;
        if (s.size() > k) {
            for (i = 0; i < k; i++)
                cout << s[i];
            cout << "...";
        }
        else
            cout << s << endl;







        /**/
    }


    return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

struct uf_tree {
  vector<int> par, sizes;
  uf_tree(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (x == par[x]) {
      return x;
    }
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return;
    }
    if (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int N, M;
vector<int> p;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  uf_tree uf(N);
  p.resize(N);
  for (int i = 0; i < N; i++) {
    int pi;
    cin >> pi;
    pi--;
    p[i] = pi;
  }
  for (int i = 0; i < M; i++) {
    int xi, yi;
    cin >> xi >> yi;
    xi--;
    yi--;
    uf.unite(xi, yi);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (uf.same(p[i], i)) {
      ans++;
    }
  }

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<queue>
using namespace std;
 
#define what_is(x) cerr << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 10000000009
#define eps 1e-9
#define MAX 10
//#define N 100001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX]; 
ll fact[MAX];

const long long INF64 = 1e18;



ll find(vll &a,ll mx){
    ll ans=0;
    rep(i,0,sz(a)){
        ans+=(a[i]+mx-1)/mx;
        ans--;
    }
    return ans;
}
void solve(ll ttt){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,0,n)
    cin>>a[i];
  ll low=1,high=10000000000;
  if(k==0){
    ll mx=INT_MIN;
    rep(i,0,n){
        mx=max(mx,a[i]);
    }
    cout<<mx<<endl;
    return ;
  }
  while(low<high){
    ll mid=low+(high-low)/2;
    
    ll req_cut=find(a,mid);
    //cout<<"For mid = "<<mid<<" cuts req = "<<req_cut<<endl;
    if(req_cut>k){
        low=mid+1;
    }
    else
        high=mid;
  }
  cout<<(ll)low<<endl;

}
int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
     // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     //cin>>t;
    fix(12);
    rep(q,1,t+1){
        // cout<<"Case #"<<q<<": ";
         solve(q);
        //solve2();
    }
    return 0;
    
}        




Measured memory_bytes: 4736
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB=sorted(AB,key=lambda x: x[1])
day = 0
Flag = True
for i in range(N):
    day += AB[i][0]
    #print(day, AB[i][1])
    if day > AB[i][1]:
        Flag = False
        break
if Flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55264
import sys

def solve():
    input = sys.stdin.readline
    C = [[int(c) for c in input().split()] for _ in range(3)]
    possible = False
    for i in range(101):
        for j in range(101):
            for k in range(101):
                a11 = C[0][0] - i
                a12 = C[0][1] - j
                a13 = C[0][2] - k
                a21 = C[1][0] - i
                a22 = C[1][1] - j
                a23 = C[1][2] - k
                a31 = C[2][0] - i
                a32 = C[2][1] - j
                a33 = C[2][2] - k
                if a11 == a12 == a13 and a21 == a22 == a23 and a31 == a32 == a33:
                    possible = True
                    break
            if possible: break
        if possible: break
    print("Yes" if possible else "No")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

const long long INF = 2e18;
const int MAXN = 405;
long long dp[MAXN][MAXN];
long long ps[MAXN];


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

	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	for (int i = 1; i <= n; i++) ps[i] = ps[i-1] + a[i-1];
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) dp[i][j] = INF;
	}
	for (int i = 0; i < n; i++) dp[i][i] = 0;
	
	for (int d = 1; d < n; d++) {
		for (int i = 0; i < n - d; i++) {
			// handle [i, i+d], inclusive.
			long long sub = ps[i+d+1] - ps[i];
			for (int j = i; j < i + d; j++) {
				dp[i][i+d] = min(dp[i][i+d], dp[i][j] + dp[j+1][i+d] + sub);
			}
		}
	}
	
	cout << dp[0][n-1] << endl;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
 int main (){
    int a, b, c, x ;
    cin >>a >>b >>c;
    if(a > b ) {
		x=a;
		a=b;
		b=x;
	};
	if(b > c ) {
		x=c;
		c=b;
		b=x;
	};
	if(a > b) {
		x=a;
		a=b;
		b=x;
	};

	cout <<a <<" " << b << " " << c <<"\n";

    return 0 ;
 
}

Measured memory_bytes: 1164
#include<bits/stdc++.h> 
using namespace std;
int main() {
    int t;
    std::cin >> t;
    if(t==0)
    {
        std::cout << 1 << std::endl;
    }
    else
    {
        std::cout << 0 << std::endl;
    }
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N= 202;
const ll lmod = 1e9+7;


int main(){
  string s;
  cin >> s ;
  rep(i,s.size()-8){
    printf("%c",s[i]);
  }
  cout << endl;
  return 0;
}

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

int main(){
  char c;
  cin >> c;
  if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}

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

int main(){
  long long l,r;
  cin>>l>>r;
  if(r-l>=2019)cout<<0<<endl;
  else {
    long long kotae=LLONG_MAX;
    for(long long i=l;i<r;i++){
      for(long long j=i+1;j<=r;j++){
        kotae=min(kotae,(i%2019*j)%2019);
      }
    }
    cout<<kotae<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    vector<char> s;
    string S;
    std::cin >> S;
    for(int i=0; i<4; i++){
        s.push_back(S[i]);
    }
    std::sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[3]){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    else{
        std::cout << "No" << std::endl;
        return 0;
    }
}
*/
/*
int main(){
    int N;
    std::cin >> N;
    int a[N];
    int count =0;
    for(int i=0; i<N; i++){
        std::cin >> a[i];
    }
    for(int i=1; i<N-1; i++){
        if((a[i]-a[i-1])*(a[i]-a[i+1])<0){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}
*/

int main(){
    int a,N;
    std::cin >> N;
    vector<int> q;
    for(int i=0; i<N; i++){
        std::cin >> a;
        q.push_back(a);
    }
    std::sort(q.begin(), q.end());
    std::cout << q[N/2]-q[N/2-1]<< std::endl;
    return 0;
}

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

int main(){
    while(1){
        int n,x;
        cin >> n >> x;
        if(n==0) break;
        
        int count=0;
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k==x) count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

const int MOD = 1000000007;
const int MAX =200000;


int main() {
  int bingo[3][3];
  bool marked[3][3];
  int n;
  bool cond = false;
  int num;
  rep(i, 3) {
    rep(j, 3){
      cin >> bingo[i][j];
      marked[i][j] = false;
    }
  }
  cin >> n;
  rep(i, n) {
    cin >> num;
    rep(j, 3) {
      rep(k, 3) {
        if(num == bingo[j][k]) marked[j][k] = true;
      }
    }
  }
  rep(i, 3) {
    if(marked[i][0] && marked[i][1] && marked[i][2]) cond = true;
    if(marked[0][i] && marked[1][i] && marked[2][i]) cond = true;
  }
  if(marked[0][0] && marked[1][1] && marked[2][2]) cond = true;
  if(marked[0][2] && marked[1][1] && marked[2][0]) cond = true;
  cout << (cond? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n,d=map(int,input().split())
x=[]
for i in range(n):
    p=[int(j) for j in input().split()]
    x.append(p)

ans=0
import itertools
for i,j in itertools.combinations(range(n),2):
    res=0
    for k in range(d):
        res+=(x[i][k]-x[j][k])**2
    q=res**0.5
    if q==q*10//10:
        ans+=1
print(ans)




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

c = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N+1):
    t = str(i)
    a, b = int(t[0]), int(t[-1])
    c[a][b] += 1

sum_num = 0
for s1 in range(10):
    for e1 in range(10):
        for s2 in range(10):
            for e2 in range(10):
                if s1 == e2 and e1 == s2:
                    sum_num += c[s1][e1] * c[s2][e2]

print(sum_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 510000;
signed main(void){
    string s; cin>>s;
    vector <int> alp(26);
    
    int ans = 0;
    rep(i,s.size()) alp[s[i]-'a']++;
    rep(i,26){
        for(int j=i+1;j<26;j++){
            ans += alp[i]*alp[j];
        }
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int N, a; int X[101] = {}; int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++){ 
		cin >> a; 
		if (X[a] == 0)X[a]++;
	}
	
	for (int i = 1; i < 101; i++)ans += X[i];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

template <class T>
void print(T& v) {
    for (auto &p : v) std::cout << "(" << p.first << ", " << p.second << ")" << std::endl;
    std::cout << std::endl;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i]--;
    }

    i64 l = 0, r = n + 1;
    while (r - l > 1) {
        auto k = (l + r) / 2;
        // { ケタ, 個数 }
        std::deque<std::pair<i64, i64>> q { { 0, 0 } };
        // std::cout << "k : " << k << std::endl;

        i64 prev = 10000000000;
        bool flg = true;
        for (int i = 1; i < n; i++) {
            // std::cout << i << std::endl;
            if (a[i] > a[i - 1]) continue;

            if (k == 1) {
                flg = false;
                break;
            }

            if (prev >= a[i]) {
                while (q.back().first > a[i]) q.pop_back();

                int curr = a[i];
                while (!q.empty() && q.back().first == curr && q.back().second == k - 1) {
                    q.pop_back();
                    curr--;
                }

                if (q.empty()) {
                    flg = false;
                    break;
                }

                if (q.back().first == curr) q.back().second++;
                else q.emplace_back(curr, 1);
            } else {
                q.emplace_back(a[i], 1);
            }
            // print(q);

            prev = a[i];
        }

        if (flg) r = k;
        else l = k;
    }

    std::cout << r << std::endl;

    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        String T = scan.next();
        char[] s = S.toCharArray();
        char[] t = T.toCharArray();
        int[] hs = new int[26];
        int[] ht = new int[26];
        for(char x : s) {
            hs[x - 'a'] += 1;
        }
        Arrays.sort(hs);
        for(char x : t) {
            ht[x - 'a'] += 1;
        }
        Arrays.sort(ht);
        boolean answer = true;
        for (int i = 0; i < 26; i++) {
            if (hs[i] != ht[i]) {
                answer = false;
                break;
            }
        }
        System.out.println(answer ? "Yes" : "No");
    }
}


Measured memory_bytes: 28600
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	string s,t;
	cin>>s>>t;
	string s2 = t.substr(0,s.size());
	if(s2==s)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}
int main()
{
	int t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

double dx1, dy1, dx2, dy2, dx3, dy3, px, py;

int main(){
	while (cin >> dx1 >> dy1 >> dx2 >> dy2 >> dx3 >> dy3 >> px >> py){
		double s = fabs((dx2 - dx1)*(dy3 - dy1) - (dx3 - dx1)*(dy2 - dy1)) / 2.0;
		double s1 = fabs((dx1 - px)*(dy2 - py) - (dx2 - px)*(dy1 - py)) / 2.0;
		double s2 = fabs((dx2 - px)*(dy3 - py) - (dx3 - px)*(dy2 - py)) / 2.0;
		double s3 = fabs((dx3 - px)*(dy1 - py) - (dx1 - px)*(dy3 - py)) / 2.0;

		if (fabs(s - (s1 + s2 + s3)) <= EPS){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1216
#include <stdio.h>


inline int gcd(int a, int b) {
    while (a != b) {
        if (a > b)
            a = a - b;
        else
            b = b - a;
    }
    return a;
}

inline int lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}

int main() {
    int n, i, a, l;

    scanf("%d", &n);
    scanf("%d", &a);

    l = a;
    for (i = 1; i < n; i++) {
        scanf("%d", &a);
        l = lcm(a, l);
    }
    printf("%d\n", l);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

bool compare(pair<int,int> a,pair<int,int> b){
    return a.second>b.second;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a[n];
    unordered_map<int,int> odd,even;
    unordered_map<int,int> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
        m[a[i]]++;
        if(i&1)
            odd[a[i]]++;
        else
            even[a[i]]++;
    }
    if(m.size()==1){
        cout << n/2;
        return 0;
    }
    vector< pair <int,int> > o,e;
    for(auto it=odd.begin();it!=odd.end();it++)
        o.pb({it->first,it->second});
    for(auto it=even.begin();it!=even.end();it++)
        e.pb({it->first,it->second});
    sort(o.begin(),o.end(),compare);
    sort(e.begin(),e.end(),compare);
    if(o[0].first!=e[0].first){
        cout << n-o[0].second-e[0].second;
    }
    else{
        cout << min(n-o[0].second-e[1].second,n-o[1].second-e[0].second);
    }
}

Measured memory_bytes: 10172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<N;i++){
    if(s.substr(i)==t.substr(0,N-i)){cout<<N+i<<endl;return 0;}
  }
  cout<<2*N<<endl;
  
  return 0;  
}

Measured memory_bytes: 3592
from collections import deque
def main():
    N, M = map(int, input().split())
    d = [-1 for i in range(N)]
    par = [-1 for i in range(N)]
    adj = [list() for i in range(N)]

    for i in range(M):
        A, B = map(int, input().split())
        adj[A-1].append(B-1)
        adj[B-1].append(A-1)

    dq = deque()
    dq.append(0)
    d[0] = 0

    while(len(dq) > 0):
        n = dq.popleft()
        for i in range(len(adj[n])):
            if d[adj[n][i]] != -1:
                continue
            else:
                dq.append(adj[n][i])
                d[adj[n][i]] = d[n] + 1
                par[adj[n][i]] = n

    reachable = True

    for i in range(1, len(par)):
        if par[i] == -1:
            reachable = False

    if reachable :
        print("Yes")
    else:
        print("No")

    for i in range(1, len(par)):
        print(par[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 35196
#include <stdio.h>

static
const int seg[ ]
  = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x27, 0x7F, 0x6F };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int st = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( ~n ) ) break ;

    while ( n-- )
    {
      int d, r;

      scanf ( "%d", &d );

      r = st ^ seg[ d ];
      printf ( "%d%d%d%d%d%d%d\n"
          , !!( r & 0x40 ), !!( r & 0x20 ), !!( r & 0x10 )
          , !!( r & 0x08 ), !!( r & 0x04 ), !!( r & 0x02 ), !!( r & 0x01 ) );
      st = seg[ d ];
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
(defun main ()
  (let* ((n (read))
         (c (make-array (list (1+ n))))
         (d (make-array (list (1+ n))))
         (b (make-array (list n))))
    (loop :for i :from 1 :to n
          :for a := (read)
          :do (incf (aref c a)))
    (loop :for i :from 1 :to n
          :do (setf (aref b (1- i)) (read))
          :do (incf (aref d (aref b (1- i)))))
    ;; 
    (loop :for i :from 1 :to n
          :do (incf (aref c i) (aref c (1- i)))
          :do (incf (aref d i) (aref d (1- i))))
    ;;
    (loop :for i :from 1 :to n
          :for j := (1- i)
          :for m := (+ (- (aref c i) (aref c j)) (- (aref d i) (aref d j)))
          :if (< n m)
          :do (progn 
                (format t "No~%")
                (return-from main)))
    ;;
    (loop :with ans := 0
          :for i :from 1 :to n
          :for x := (- (aref c i) (aref d (1- i)))
          :do (setf ans (max ans x))
          :finally (progn
                     (format t "Yes~%")
                     (loop :for j :from 0 :to (- n 2)
                           :do (format t "~A " (aref b (mod (- j ans) n))))
                     (format t "~A~%" (aref b (mod (- n 1 ans) n)))))))
(main)


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

int main() {
    int H, W; cin >> H >> W;
    int count = 0;
    for (int i = 0; i < H; ++i) {
        string S; cin >> S;
        for (auto c : S) if (c == '#') ++count;
    }
    if (count == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    deque<char> s;
    for(auto c : S){
        s.push_back(c);
    }
    int ans = 0;
    while(s.size() > 1){
        char l = s.front(), r = s.back();
        // cout<<l<<" "<<r<<endl;
        if(l==r) {
            s.pop_front(); s.pop_back();
            continue;
        }
        else if(l=='x' && r!='x'){
            s.push_back('x');
            ans++;
            // s.pop_front(); s.pop_back();
            continue;
        }
        else if(l!='x' && r=='x'){
            s.push_front('x');
            ans++;
            // s.pop_front(); s.pop_back();
            continue;
        }
        else if(l !='x' && r != 'x'){
            ans=-1;
            break;
        }
    }
    cout<<ans<<endl;
}
// code_festival_2017_qualc_c

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};



int main() {
    string s; cin >> s;
    if(s == "keyence"){cout << "YES" << endl; return 0;}
    int n = s.size();
    bool ok = false;

    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            string S = "";
            for(int k = 0; k < i; k++){
                S += s[k];
            }
            for(int k = j+1; k < n; k++){
                S += s[k];
            }
            if(S=="keyence") ok = true;
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO"  << endl;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int x, y; cin>>x>>y;
    if(x>=0 && y>=0){
        if(x<=y) cout << y-x << endl;
        else{
            if(y==0) cout << x+1 << endl;
            else cout << -y+x+2 << endl;
        }
    }
    else if(x>=0 && y<0){
        if(abs(x)==abs(y)) cout << 1 << endl;
        else if(abs(x)>abs(y)) cout << x+y+1 << endl;
        else cout << -x-y+1 << endl;
    }
    else if(x<0 && y>=0){
        if(abs(x)==abs(y)) cout << 1 << endl;
        else if(abs(x)>abs(y)){
            if(y==0) cout << -x << endl;
            else cout << -y-x+1 << endl;
        }
        else cout << y+x+1 << endl;
    }
    else{
        if(x<=y) cout << y-x << endl;
        else cout << x-y+2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)

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

    map<char, int> table = {{'M', 0}, {'A', 1}, {'R', 2}, {'C', 3}, {'H', 4}};
    int cnt[5] = {};
    rep(i, 0, N) {
        string s;
        cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
            cnt[table[s[0]]]++;
    }

    ll ans = 0;
    rep(i, 0, 5) {
        rep(j, i + 1, 5) {
            rep(k, j + 1, 5) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
	long long a,c,product;
	double b;
	cin>>a>>b;
	
	b=b+1e-7;
	c=b*100;
	product=(a*c)/100;
	cout<<product;
	
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long MOD = 1e9+7;
int main(){
   long n,ans=0;
   cin >> n;
   long a[n];
   rep(i,n) cin >> a[i];
   rep(i,60){
       long x = 0;
       rep(j,n){
           if(a[j]>>i&1) x++;
       }
       long now = x*(n-x);
       rep(j,i) now = now*2%MOD;
       ans += now;
       ans %= MOD;
   }
   cout << ans << endl;
}

Measured memory_bytes: 2560
#include <cstdio>

int main()
{
	int n, i, j;
	scanf("%d", &n);

	int a[n];
	for(i = 0; i < n; i++)
		scanf("%d", &a[i]);

	int b[n];
	for(i = n - 1; i >= 0; i--){
		j = n - 1 - i;
		b[j] = a[i];
	}

	for(i = 0; i < n; i++){
		if(i == 0) printf("%d", b[i]);
		else printf(" %d", b[i]);
	}

	printf("\n");
	
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,a = 2,cnt = 0;
    string s;
    cin >> n;
    if(n == 0)cout << 0;
    while (n != 0) {
        if(n % a != 0){
            n -= pow(-2, cnt);
            s += '1';
        }else{
            s += '0';
        }
        a *= 2;
        ++cnt;
    }
    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun a b c ->
    let bc = min b c in
    let o = bc * 2 in
    let c = c - bc in
    let b = b - bc in

    let ac = min a c in
    let o = o + ac in
    let c = c - ac in
    let a = a - ac in
    let o = if c > 0 then o + 1 else o in
    let o = o + b in
    Printf.printf "%d\n" o
)

Measured memory_bytes: 3788
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    string s = readln.chomp;
    int cnt;
    foreach (i; 1 .. n) {
        if (s[i] == s[i-1]) ++cnt;
    }
    min(n-1, cnt+2*k).writeln;
}

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int k = 2 * N / K;
    int odd = (k + 1) / 2;
    int eve = k - odd;
    long ans = 0;
    ans += pow(eve, 3);
    if(K%2 == 0) ans += pow(odd, 3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;

	vector<int>xl(n + 1);
	rep(i, n)cin >> xl[i];
	vector<int>yl(m + 1);
	rep(i, m)cin >> yl[i];

	xl[n] = x;
	yl[m] = y;

	bool XX = false;
	bool YX = false;
	
	sort(xl.begin(), xl.end());
	reverse(xl.begin(), xl.end());

	sort(yl.begin(), yl.end());

	bool okay = false;
	for (int i = -100; i < 101; i++) {
		if (xl[0] < i && i <= yl[0]) {
			okay = true;
			break;
		}
	}
	if (okay) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}


Measured memory_bytes: 256