akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

struct BIT {
  using Val = int;
  int n;
  vector<Val> tree;
  BIT(int n):n(n),tree(n+1) {}
  void fill(Val val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, Val val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  Val range(int idx) {
    Val sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
};

const int INF = 1001001001;
const int MAX_N = 2005;
int dp[MAX_N][MAX_N];
int idx_b[MAX_N];
int idx_w[MAX_N];
int bb[2*MAX_N][MAX_N]; // bb[i][j] := 元の列のi番目より左にある B のうち番号が j より大きいものの個数。
int ww[2*MAX_N][MAX_N];

int main2() {
  int N = nextInt();
  vector<char> c(2*N);
  vector<int> a(2*N);

  REP(i, 2*N) {
    cin >> c[i] >> a[i];
    if (c[i] == 'B') {
      idx_b[a[i]] = i;
    } else {
      idx_w[a[i]] = i;
    }
  }

  {
    CLR(bb, 0);
    BIT bit(2*N+10);
    int s = 0;
    REP(i, 2*N) {
      if (c[i] == 'B') {
        bit.add(a[i], 1);
        s++;
      }
      for (int j = 0; j <= N; j++) {
        bb[i][j] = s - bit.range(j);
      }
    }
  }
  {
    CLR(ww, 0);
    BIT bit(2*N+10);
    int s = 0;
    REP(i, 2*N) {
      if (c[i] == 'W') {
        bit.add(a[i], 1);
        s++;
      }
      for (int j = 0; j <= N; j++) {
        ww[i][j] = s - bit.range(j);
      }
    }
  }

  REP(i, MAX_N) REP(j, MAX_N) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(w, N+1) REP(b, N+1) {
    if (w == 0 && b == 0) continue;
    int val = INF;
    if (w - 1 >= 0) {
      int i = idx_w[w];
      int cost = bb[i][b] + ww[i][w];
      chmin(val, dp[w-1][b] + cost);
    }
    if (b - 1 >= 0) {
      int i = idx_b[b];
      int cost = bb[i][b] + ww[i][w];
      chmin(val, dp[w][b-1] + cost);
    }
    dp[w][b] = val;
  }
  int ans = dp[N][N];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 78848
n = int(input())
A = list(map(int,input().split()))
pre_col = A[0]
flg = False
res = 0
for i in range(1, n):
    if flg or A[i] != pre_col:
        pre_col = A[i]
        flg = False
    elif A[i] == pre_col:
        res += 1
        flg = True
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};


int main(){
    int n,k;
    while(scanf("%d%d",&n,&k),n||k){
        int cnt[100];
        for(int i=0;i<k;i++)scanf("%d",&cnt[i]);
        for(int i=0;i<n;i++){
            for(int j=0;j<k;j++){
                int val;
                scanf("%d",&val);
                cnt[j]-=val;
            }
        }
        bool flag=true;
        for(int i=0;i<k;i++)flag&=(cnt[i]>=0);
        puts(flag?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    if (s.length() == 3) {
        reverse(all(s));
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (a, b): (i64, i64) = (read::<i64>(), read::<i64>());
    if a == b {
        println!("a == b");
    } else if a < b {
        println!("a < b");
    } else {
        println!("a > b");
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5020
n, q = map(int, input().split())
s = input()
appmap = [0] * (n + 1)
for i in range(n):
    appmap[i + 1] = appmap[i] + (1 if s[i: i + 2] == "AC" else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(appmap[r - 1] - appmap[l - 1])


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

VV G;
V c, dp;
Vll ans;
int s = 0;

ll chs(ll x) {
  return x*(x+1)/2;
}

void dfs(int u, int p=-1) {
  int tmp = s + dp[c[u]];
  ++s;
  for (auto v : G[u]) if (v != p) {
    dp[c[u]] = -s;
    dfs(v, u);
    ans[c[u]] -= chs(s + dp[c[u]]);
  }
  dp[c[u]] = tmp - s;
}


int main() {
  ll n; cin >> n;
  G.assign(n, V());
  c.assign(n, 0);
  dp.assign(n, 0);
  ans.assign(n, n*(n+1)/2);

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);
  
  rep(i, n) {
    ans[i] -= chs(s + dp[i]);
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 29868
#include <stdio.h>

int main() {
    int W, H;
    int x, y, r;

    scanf("%d %d %d %d %d",&W,&H, &x, &y, &r);

    if(x >= r && x + r <= W && y >= r && y + r <= H)
        puts("Yes");
    else
        puts("No");

    return 0;
}

Measured memory_bytes: 584
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B, C, D = map(int, rl().split())
    for i in range(200):
        if i % 2 == 0:
            C -= B
            if C <= 0:
                print('Yes')
                exit()
        else:
            A -= D
            if A <= 0:
                print('No')
                exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9180
#include<iostream>
using namespace std;
int main(){
  int K,A,B;
  cin>>K>>A>>B;
  for(int i=A; i<=B; i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
a.append(0)
a.insert(0,0)

val_sum=0
for i in range(n+2):
    val_sum += abs(a[i]-a[i-1])

for i in range(1,n+1,1):
        c1 = abs(a[i+1]-a[i]) + abs(a[i]-a[i-1])
        c2 = abs(a[i+1] - a[i-1])
        print(val_sum - c1 + c2)

Measured memory_bytes: 14048
#!/usr/bin/env python3

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
B = []

for i in range(len(A)):
    if ''.join(A[i]) != '.'*len(A[i]):
        B.append(A[i])


C = list(zip(*B))
R = []
for i in range(len(C)):
    if ''.join(C[i]) != '.'*len(C[i]):
        R.append(C[i])

R = list(zip(*R))

for r in R:
    print(''.join(r))


Measured memory_bytes: 63824
#include <iostream>

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

  bool flag = ((a == (b + c)) || (b == (c + a)) || (c == (a + b)));
  if ( flag ) {
    std::cout << "Yes" << std::endl;
  } else  {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

long long inv(long long n) {
    long long res = 1;
    while (n > 1) {
        res *= (MOD - MOD/n);
        res %= MOD;
        n = MOD % n;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i=0; i<n+1; ++i) {
        cin >> a.at(i);
    }

    vector<int> cnt(n+1);
    int two = -1;
    for (int i=0; i<n+1; ++i) {
        if (++cnt.at(a.at(i)) > 1) {
            two = a.at(i);
            break;
        }
    }
    int f = find(a.begin(), a.end(), two) - a.begin();
    int b = find(a.rbegin(), a.rend(), two) - a.rbegin();
    vector<ll> comb(n+1), combfb(n);
    ll nume = 1, deno = 1;
    for (int i=0; i<=n; ++i) {
        comb.at(i) = nume * inv(deno) % MOD;
        nume *= n + 1 - i;
        deno *= i + 1;
        nume %= MOD;
        deno %= MOD;
    }
    nume = deno = 1;
    for (int i=0; i<=f+b; ++i) {
        combfb.at(i) = nume * inv(deno) % MOD;
        nume *= f + b - i;
        deno *= i + 1;
        nume %= MOD;
        deno %= MOD;
    }

    vector<ll> res(n+2);
    res.at(1) = n;
    for (int i=2; i<n+1; ++i) {
        res.at(i) = (comb.at(i) - combfb.at(i-1)) % MOD;
        if (res.at(i) < 0) res.at(i) += MOD;
    }
    res.at(n+1) = 1;
    for (int i=1; i<n+2; ++i) cout << res.at(i) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4352
N,*M=`dd`.split.map &:to_i;A=M.shift N;D=[*0..10**6];s=0;2.upto(N-2){|i|s+=A[i];1.upto(A[i]){|j|D.unshift D[j*2-1]}};M.map{|e|p (D[e]||e-s)+A[0]-A[1]}

Measured memory_bytes: 88496
H,W = map(int,input().split())
masu = [list(input()) for _ in range(H)]

def koritu(h,w):
    bo=0
    hoko = [[1,0],[0,1],[-1,0],[0,-1]]
    for ya in hoko:
        if 0 <= h+ya[0] < H and 0 <= w+ya[1] < W:
            if masu[h+ya[0]][w+ya[1]] == '#':
                bo = 1
    return bo
   
   
k = 1
for w in range(W):
    for h in range(H):
        if masu[h][w] == '#' and koritu(h,w)==0:
            print('No')
            break
    else:
        continue
    break
else:print('Yes')

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

int main(void){
	int i,j,k,n,p[10001],a[200000];
	p[0]=0;
	for(i=0;i<200000;i++)a[i]=1;
	for(i=2,k=1;k<=10000;i++){
		if(a[i]==1){
			p[k]=i+p[k-1];k++;
			if(i<500)for(j=i*i;j<200000;j+=i)a[j]=0;
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break; else printf("%d\n",p[n]);
	}
	return 0;
}

Measured memory_bytes: 1420
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	long long minx=2020;
	for(long long i=n;i<=m;i++){
		for(long long j=n;j<=m;j++){
			if(i==j) continue;
			minx=min(minx,(i*j)%2019);
			if(minx==0){
				cout<<minx;
				return 0;
			}
		}
	}
	cout<<minx;
}

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

int main()
{
    int  x,y,a; double t;
    cin>>x>>y;
    /*t=x/y;
    a=t;*/
    if (x%y==0) { cout<<"-1"; return 0;}
    for (int i=x; ; i+=x)
    {
        if (i%y!=0) { cout<<i; break;}
    }
    return 0;
}

Measured memory_bytes: 256
// D - Redistribution
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int S; cin>>S;
	int MOD = 1e9 + 7;
	vector<int64_t> C(S+1, 0);
	C[0] = 1;
	rp(n, 3, S+1) // n:[3,S]
		rp(i, 3, n+1){ // i:[3,n], sum(C[0,n-3])
			C[n] += C[n-i];
			C[n] %= MOD;
		}
	cout<< C[S] <<endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 0);
    for (int x = 1; x * x <= n; x++){
        for (int y = 1; y * y <= n; y++){
            for (int z = 1; z * z <= n; z++){
                int val = x * x + y * y + z * z;
                val += x * y + x * z + y * z;
                if(val <= n){
                    dp[val]++;
                }
            }
        }
    }
    rep(i,n){
        cout << dp[i + 1] << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	string a,b,c;
	cin >> n >> a >> b >> c;

	int ans = 0;
	rep(i,n){
		const int val = (a[i] == b[i]) + (a[i] == c[i]) + (b[i] == c[i]);
		if(val <= 1) ans++;
		if(val <= 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

int main() {
	int  x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	int diff1 = std::abs(x - a);
	int diff2 = std::abs(x - b);
	if (diff1 < diff2) {
		printf("A");
	} else {
		printf("B");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
     long long N,A[10000];
     long long i;
     cin>>N;
     for( i=0;i<N;i++){
		cin>>A[i];
	
     if(i==N-1){
		cout<<A[i]<<endl;
	}
	else{
		cout<<A[i]<<" ";
	}
}
		if(i==N-1){
			cout<< endl;
		}
	 for(long long i=1;i<N;i++){
		 long long v=A[i];
		 long long j=i-1;
		 while(j>=0&&A[j]>v){
			 A[j+1]=A[j];
			 j--;
		 }
		 A[j+1]=v;
		 
	 for(long long i=0;i<N;i++){
		 if(i==N-1){
		 cout<<A[i];
	 }
	 else{
		 cout<<A[i]<<" " ;
	 }
   }
   cout<<endl; 
 }
}



Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define hash_type pair<long long, long long>
#define int_type long long
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

struct RollingHash {

    int_type base1;
    int_type base2;
    int_type mod1;
    int_type mod2;
    vector<int_type> hash1;
    vector<int_type> hash2;
    vector<int_type> pow1;
    vector<int_type> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    hash_type get(int l,int r) {
        int_type t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        int_type t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

    hash_type concat(hash_type h1, hash_type h2, int h2_len) {
        return make_pair((h1.first*pow1[h2_len]+h2.first)%mod1, (h1.second*pow2[h2_len]+h2.second)%mod2);
    }

};

vector<int> zalgo(string& s)
{
    int len = s.length();
    vector<int> ret(len);
    ret[0] = len;
    int start = 1;
    int length = 0;
    while(start < len)
    {
        while(start + length < len && s[length] == s[start+length]) ++length;
        ret[start] = length;
        if(length == 0) 
        {
            ++start;
            continue;
        }

        int offset = 1;
        while(start + offset < len && offset + ret[offset] < length)
        {
            ret[start + offset] = ret[offset];
            ++offset;
        }
        start += offset;
        length -= offset;
    }

    return ret;
}
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ret = 0;
    for(int i=0;i<n;++i)
    {
        string query = s.substr(i);
        vector<int> zarray = zalgo(query);

        for(int j=0;j<zarray.size();++j)
        {
            if(zarray[j] <= j)
            {
                ret = max(ret, zarray[j]);
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    char c;
    cin >> c;
    string ans="consonant";
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        ans="vowel";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//Bismillah_Hir_Rahmanir_Rahim

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,temp;
    scanf("%d",&n);
    while(n>0)
    {
        temp = n%10;
        if(temp==9){
            printf("Yes\n");

            return 0;
        }
        n = n/10;
    }
printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int e, m;
  while (cin >> e, e) {
    m = e;
    for (int i = 0; i*i <= e; ++i) {
      for (int j = 0; j*j*j + i*i <= e; ++j) {
	m = min(m, e + i + j - i*i - j*j*j);
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string S; cin >> S;
  string k = "keyence";
  
  bool flag = false;
  rep(i,S.size()){
    for (int j=i;j<S.size();j++){
      string s = S.substr(0,i) + S.substr(j);
      if (s==k) flag = true;
    }
  }
  cout << (flag? "YES" : "NO") << endl;

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
int n, k, a[N];
ll s[N];
ll dp[405][405];
void cal(int l, int r) {
	if (dp[l][r] != -1) return;
	if (l == r) {
		dp[l][r] = 0;
		return;
	}
	dp[l][r] = 1e18;
	for (int i = l; i < r; ++i) {
		cal(l, i); cal(i + 1, r);
		dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + s[r] - s[l - 1]);
	}
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], s[i] = s[i - 1] + a[i];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			dp[i][j] = -1;
	cal(1, n);
	cout << dp[1][n];
}


Measured memory_bytes: 3584
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict, deque
    from itertools import combinations

    N = int(readline())

    edge = defaultdict(list)

    for i in range(N - 1):
        a, b = map(int, readline().split())
        edge[a - 1].append((b - 1, i))
        edge[b - 1].append((a - 1, i))

    def bfs(s, g):
        que = deque()
        que.append((s, []))
        visited = [False] * N
        visited[s] = True

        while que:
            cur, path = que.popleft()
            if cur == g:
                return set(path)
            for nx, i in edge[cur]:
                if not visited[nx]:
                    new_path = path + [i]
                    que.append((nx, new_path))
                    visited[nx] = True

    M = int(readline())
    constraints = []
    for _ in range(M):
        u, v = map(int, readline().split())
        u -= 1
        v -= 1
        constraints.append(bfs(u, v))

    cnt = 0
    for i in range(1, M + 1):
        sign = 1 if i % 2 == 1 else -1
        for per in combinations(range(M), r=i):
            incl = set()
            for x in per:
                incl = incl.union(constraints[x])
            cnt += sign * 2 ** ((N - 1) - len(incl))

    print(2 ** (N - 1) - cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75016
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
    string s, t;
    ll i,j,n,m;
    cin>>s>>t;
    n= s.size(), m= t.size();

    //vl id[mx];
    map<char, vl> mp;
    for(i=0; i< n; i++)
    mp[s[i]].pb(i);

    ll ans=0, fl=0;
    for(i=0; i< m; i++){
        if(!mp[t[i]].size())
        {
            fl=1;
            break;
        }
    }
    if(fl)
    cout<<"-1";
    else{

        stack<ll> st;
        st.push(mp[t[0]][0]);
        for(i=1; i< m; i++){
            ll kk= st.top();
            st.pop();
            auto it= ub(mp[t[i]].begin(), mp[t[i]].end(), kk);
            if(it != mp[t[i]].end()){
                
                st.push(*it);
            }
            else{
                st.push(n);
                st.push(mp[t[i]][0]);
            }
        }
        while(!st.empty()){
            ans+= st.top();
            st.pop();
        }
        ans++;
        cout<<ans;
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 2116
#include <stdio.h>

int main() {
	int a, b, c, d, s1, s2;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);

	if (a <= b) {
		s1 = a;
	}
	else {
		s1 = b;
	}
	if (c <= d) {
		s2 = c;
	}
	else {
		s2 = d;
	}

	printf("%d", s1 + s2);

	return 0;
}

Measured memory_bytes: 128
class Combination:
  def __init__(self, n_max, mod=10**9+7):
    self.mod = mod
    self.modinv = self.make_modinv_list(n_max)
    self.fac, self.facinv = self.make_factorial_list(n_max)

  def __call__(self, n, r):
    return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

  def make_factorial_list(self, n):
    # 階乗のリストと階乗のmod逆元のリストを返す O(n)
    # self.make_modinv_list()が先に実行されている必要がある
    fac = [1]
    facinv = [1]
    for i in range(1, n+1):
      fac.append(fac[i-1] * i % self.mod)
      facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
    return fac, facinv

  def make_modinv_list(self, n):
    # 0からnまでのmod逆元のリストを返す O(n)
    modinv = [0] * (n+1)
    modinv[1] = 1
    for i in range(2, n+1):
      modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
    return modinv

N,M,K = map(int,input().split())
ans = 0
MOD = 998244353
comb = Combination(2*(10**5)+1, MOD)
for i in range(K+1):
  res = (M * pow(M-1, N-i-1, MOD)%MOD * comb(N-1, i)%MOD)%MOD
  ans = (ans + res)%MOD

print(ans)

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

using namespace std;

int main(){
  int N;
  int AB = 0;
  int B_A = 0;
  int X_A = 0;
  int B_X = 0;
  int result = 0;
  cin >> N;
  for (int i=0;i<N;i++) {
    bool b_flag = false;
    bool a_flag = false;
    string s;
    cin >> s;
    size_t l = s.size();
    if (s[0] == 'B') {
      b_flag = true;
    }
    if (s[l-1] == 'A') {
      a_flag = true;
    }
    if (a_flag && b_flag) {
      B_A++;
    } else if (a_flag) {
      X_A++;
    } else if (b_flag) {
      B_X++;
    }
    for (int i=0;i<l-1;i++) {
      if (s[i] == 'A' && s[i+1] == 'B') {
	AB++;
      }
    }
  }

  if (B_A > 0) {
    result += B_A - 1;
    if (X_A > 0) {
      result++;
      X_A--;
    }
    if (B_X > 0) {
      result++;
      B_X--;
    }
  }
  result += min(X_A, B_X);
  result += AB;
  cout << result << endl;
  return(0);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d,e;
 cin>>a>>b>>c>>d>>e;
 if(a==0)cout<<1;
 if(b==0)cout<<2;
 if(c==0)cout<<3;
 if(d==0)cout<<4;
 if(e==0)cout<<5;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
using namespace std;
int n, s, a[100005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	for(i=1; i<n; i++) if(a[i]==i) swap(a[i], a[i+1]), s++;
	if(a[n]==n) s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

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

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


ll p(ll n)
{
	if (n == 0)
	{
		return 1;
	}
	else
	{
		ll p = 1;
		for (ll i = 1; i <= n; i++)
		{
			p *= i;
		}

		return p;
	}
}

int main()
{
	ll n;
	string s;
	cin >> n >> s;

	vector<ll> a(3, 0);
	for (char i : s)
	{
		if (i == 'R')
		{
			a[0]++;
		}
		else if (i == 'G')
		{
			a[1]++;
		}
		else if (i == 'B')
		{
			a[2]++;
		}
	}

	if (a[0] == 0 || a[1] == 0 || a[2] == 0)
	{
		println(0);
		return 0;
	}

	ll p0 =a[0] * a[1] * a[2];


	ll c = 0;
	for (ll i = 0; i < s.length(); i++)
	{
		for (ll j = 1; j < s.length(); j++)
		{
			if (i - j < 0 || i + j >= s.length())
			{
				break;
			}

			if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j])
			{
				c++;
			}
		}
	}

	println(p0 - c);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
    ll mod=998244353;
ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll fact( ll n)
{
    ll ans=1,i;
    rep(i,1,n+1)
    {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
ll in(ll x) { return  pr(x,mod-2);}

void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,y=0,a=0,b=0,d;
 cin>>a>>b>>c;
 swap(a,b);
 swap(a,c);
 cout<<a<<" "<<b<<" "<<c;


}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        // cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 256
import java.util.*;
    public class Main{
	public static void main(String[] args){
	    Scanner scan = new Scanner(System.in);
	    String numM = scan.next();
	    char targetP = '+';
	    char targetM = '-';
	    int startNum = 0;
	    int counterP = 0;
	    int counterM = 0;
		
	    for(char Ans: numM.toCharArray()){
		if(Ans==targetP){
		    counterP++;
			}else if (Ans == targetM){
		    counterM++;
		}
	    }
	    System.out.println((startNum+counterP-counterM));
	}
    }


Measured memory_bytes: 21844
n = int(input())
a = [int(x) - 1 for x in input().split()]
total = sum(map(int, input().split()))
c = [int(x) for x in input().split()]
for i, j in zip(a, a[1:]):
    if j - i == 1:
        total += c[i]
print(total)


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long double LD;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

LD D;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> D;
  LD ans = sqrt((LD)2.)*D;
  for(int x=1;x<=(int)D;++x){
	LD y = sqrt(D*D - x*x);
	if(y <= 1)
	  ans = max(ans, (LD)x+1.);
  }

  cout << fixed << setprecision(12) << ans << endl;
  
  return 0;
}

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

int main(){
  int n;
  std::cin >> n;
  int mini = 1e9, maxi = 0;
  for (int i = 0; i < n; i++){
    int tmp;
    std::cin >> tmp;
    mini = min(mini, tmp);
    maxi = max(maxi, tmp);
  }
  std::cout << maxi - mini << std::endl;
  return 0;
}


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

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

	std::vector<int> p(n), q(n);
	for (auto&& e : p)
		std::cin >> e;
	for (auto&& e : q)
		std::cin >> e;

	std::vector<int> perm(n);
	for (int i = 0; i < n; ++i)
		perm[i] = i + 1;

	int a, b;
	int count = 0;
	do {
		if (perm == p)
			a = count;
		if (perm == q)
			b = count;

		++count;
	} while (std::next_permutation(perm.begin(), perm.end()));
	
	std::cout << std::abs(a - b) << std::endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int siz;
string s;
string dream, dreamer, erase, eraser;

void dfs(int st){
	//cout<<st<<endl;
	if(st == siz){
		puts("YES");
		exit(0);
	}
	
	bool flag = 1; // dream
	if(st + 4 <= siz){ 
		//cout<<st<<" "<<"dream"<<endl;
		for(int i=0;i<=4;++i){
			if(s[st+i] != dream[i]){
				flag = 0;
				break;
			}
		}
		if(flag == 1) dfs(st+5);
	} 
	
	if(st + 6 <= siz){
		//cout<<st<<" "<<"dreamer"<<endl;
		flag = 1; // dreamer
		for(int i=0;i<=6;++i){
			if(s[st+i] != dreamer[i]){
				flag = 0;
				break;
			}
		}
		if(flag == 1) dfs(st+7);
	}
	
	if(st + 4 <= siz){
		//cout<<st<<" "<<"erase"<<endl;
		flag = 1; // erase
		for(int i=0;i<=4;++i){
			if(s[st+i] != erase[i]){
				flag = 0;
				break;
			}
		}
		//cout<<flag<<endl;
		if(flag == 1) dfs(st+5);
	}
	
	if(st + 5 <= siz){
		//cout<<st<<" "<<"eraser"<<endl;
		flag = 1; // eraser
		for(int i=0;i<=5;++i){
			if(s[st+i] != eraser[i]){
				flag = 0;
				break;
			}
		}
		if(flag == 1) dfs(st+6);
	}
}

int main(){
	cin>>s; siz = s.size();
	dream = "dream";
	dreamer = "dreamer";
	erase = "erase";
	eraser = "eraser";
	dfs(0);
	puts("NO");
} 

Measured memory_bytes: 4332
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

// solution 
use std::collections::HashSet;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        M: usize,
    }
    if N > 1 && M > 1 {
        println!("{}", N*M - ((N-1)*2 + (M-1)*2));
    } else if N == 1 && M == 1 {
        println!("1");
    } else {
        println!("{}", N*M-2);
    }
}


Measured memory_bytes: 4352
n,k= list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
b=[1]*n

    
for i in range(k+1,n+1):
    b[i-1]=a[i-1]/a[i-k-1]

    

for i in range(k,n):
    if 1<b[i]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;
	if (a == b + c ||
		b == c + a ||
		c == a + b)
	{
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main(){
  int N, sum =0;
  bool all = false;
  cin >> N;
  for (int i = 0; i<N; i++){
    int l,r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B, C, K;

  cin >> A >> B >> C >> K;

  if (A > K)
    cout << K << endl;
  else if ((A + B) >= K)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    ll r,d,x;
    cin>>r>>d>>x;
    
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k,a,dp[3001][3001],MOD=998244353;
int main(void){
    dp[0][0]=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a;
        for(int j=0;j<=k;j++){
            dp[i][j]+=dp[i-1][j]*2;
            dp[i][j]%=MOD;
            if(j-a>=0)dp[i][j]+=dp[i-1][j-a];
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 73968
def main():
    N,M = map(int, input().split())
    Xs = [int(s) for s in input().split()]

    # 目的地よりコマが多いなら操作は不要
    if N >= M:
        print(0)
        return

    Xs.sort()
    distance_list = []
    for i in range(M):
        if i == M-1:
            break
        distance = abs(Xs[i] - Xs[i+1])
        distance_list.append(distance)
    distance_list.sort(reverse=True)

    for i in range(N-1):
        distance_list.pop(0)

    print(sum(distance_list))


if __name__ == "__main__":
    main()


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll res = 0;
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      if((n - (r*i + g*j) >= 0) && ((n - (r*i+g*j)) % b == 0)){
        // cout << i << ' ' << j << ' ' << (n-(r*i+g*j))%b << endl;
        res++;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 10000010LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

ll f[MAX];

void Flash(){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += (i * f[i]);
        //debugg(f[i]);
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    for(ll i = 1; i <= MAX; i++){
        f[i] = 1;
    }
    ll temp, cnt;
    for(ll i = 2; i <= MAX; i++){
        if(f[i] == 1){
            f[i] = 2;
            for(ll j = 2 * i; j <= MAX; j += i){
                temp = j, cnt = 0;
                while((temp % i) == 0){
                    ++cnt;
                    temp /= i;
                }
                f[j] *= (cnt + 1);
            }
        }
    }
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

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

    int N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];

    int res = 1;
    int step = 1;
    bool is_up;

    for(int i = 1; i < N; ++i){

        if(step == 0){
            step = 1;
        }

        if(A[i] > A[i - 1] and step == 1){
            is_up = true;
            step = 2;
        }
        if(A[i] < A[i - 1] and step == 1){
            is_up = false;
            step = 2;
        }
        if(A[i] > A[i - 1] and not is_up and step == 2){
            res++;
            step = 0;
        }
        if(A[i] < A[i - 1] and is_up and step == 2){
            res++;
            step = 0;
        }

    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: usize = 1 << 60;

fn main() {
    input!{
        N: usize,
        M: usize,
        A: [usize; N],
    }
    let mut bh: BinaryHeap<usize> = A.into_iter().collect();
    let mut count = 0;
    while let Some(mut i) = bh.pop() {
        i /= 2;
        bh.push(i);
        count += 1;
        if count >= M {
            break;
        }
    }
    let ans: usize = bh.into_iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
#include <iomanip>
#include <queue>
#include <stdio.h>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
#define REP(i,n) for (ll i=1;i<=n;i++)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078160628620899
typedef long long ll;
typedef pair<ll, ll> PLL;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;

string S, T;
ll ans, sum, now1, now2, N, M, B[220000], C[220000];
PLL A[220000];
double a, b;
bool ANS, NOW;

ll comb(ll a) {
	if (a == 1) return 0;
	return (a - 1) * a / 2;
}

int main() {
	cin >> N;
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i;
		C[i] = A[i].first;
	}
	sort(A, A + N);
	sum = 0;
	now1 = A[0].first;
	now2 = 1;
	REP(i, N - 1) {
		if (A[i].first == now1) {
			now2++;
		}
		else {
			if (now2 >= 2) {
				sum += comb(now2);
				B[now1] = now2;
			}
			now2 = 1;
			now1 = A[i].first;
		}
	}
	if (now2 >= 2) {
		sum += comb(now2);
		B[now1] = now2;
	}
	rep(i, N) {
		ll P, Q;
		if (B[C[i]] >= 2) {
			P = comb(B[C[i]]);
			Q = comb(B[C[i]] - 1);
			cout << sum - P + Q << endl;
		}
		else cout << sum << endl;
	}
	return 0;
}


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

int Distance(int x1, int x2)
{
    int D;
	D = abs(x1-x2);
	return D;
} 
 
int main()
{
    int x1,x2,distance;
	scanf("%d %d", &x1, &x2);
	distance=Distance(x1,x2);
	printf("%d\n", distance);
	return 0;
}



Measured memory_bytes: 2096
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n,a,b;
    cin>>n>>a>>b;
    int ans=n/(a+b);
    int rem=n%(a+b);
    if(rem>a)
        rem=a;
    cout<<ans*a +rem;
    
}

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

int n;
int a[200010];
int main()
{
	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i+1];
	}
	int count = 0;int next = 1; int tmp;
	while( 1 ) {
		if( a[next] == -1 ) {
			cout << "-1" << endl;
			return 0;
		}
		tmp = next;
		next = a[next];
		a[tmp] = -1;
		count++;
		if( next == 2 ) {
			cout << count << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

typedef long long ll;

const double EPS = 1e-9;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

typedef vector<int> vi;
typedef pair<int, int> pi;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define REP(i, x, n) for(int i = (x);i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()

int main(){
  char c[30];
  scanf("%s", c);
  string str=c;
  int t = 1;
  rep(i,(int)str.size()){
    REP(j, i+1, (int)str.size()){
      if(str[i]==str[j]){
        t=0;
        break;
      }
    }
  }
  if(t==0)
    printf("no\n");
  else
    printf("yes\n");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;
ll INF = 1e18;

vector<pair<long long, long long> > res;

int main() {
	ll n;
	cin >> n;
    for (long long i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            long long ex = 0; // 指数

            // 割れる限り割り続ける
            while (n % i == 0) {
                ++ex;
                n /= i;
            }

            // その結果を push
            res.push_back({ i, ex });
        }

    }
    if(n!=1) res.pb({n,1});
    ll ans = 0;
    rep(i, sz(res)){
        ll ex = res[i].second;
        if (ex >= 66) ans+=11;
        else if (ex >= 55) ans += 10;
        else if (ex >= 45) ans += 9;
        else if (ex >=36) ans += 8;
        else if (ex >= 28) ans += 7;
        else if (ex >= 21) ans += 6;
        else if (ex >= 15) ans += 5;
        else if (ex >= 10) ans += 4;
        else if (ex >= 6) ans += 3;
        else if (ex >= 3) ans += 2;
        else if (ex >= 1) ans += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636