akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll MOD;

ll mod_pow(ll a, ll n, ll MOD) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll t = mod_pow(a, n / 2, MOD);
		return t * t%MOD;
	}
	return a * mod_pow(a, n - 1, MOD) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;
vector<ll> inv;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	inv.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i%MOD;
		inv[i] = mod_pow(i, MOD - 2, MOD);
		inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
	}
}

ll comb(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}

ll ways[3001];
ll ways2[3001][3001];

int main() {
	int N;
	cin >> N >> MOD;
	ways2[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j > 0) (ways2[i][j] += ways2[i - 1][j - 1]) %= MOD;
			(ways2[i][j] += ways2[i - 1][j] * (j + 1) % MOD) %= MOD;
		}
	}
	for (int i = 0; i <= N; i++) {
		ll sum = 0;
		for (int j = 0; j <= i; j++) {
			(sum += ways2[i][j] * mod_pow(2, j*(N - i), MOD) % MOD) %= MOD;
		}
		(sum *= mod_pow(2, mod_pow(2, N - i, MOD - 1), MOD)) %= MOD;
		ways[i] = sum;
	}
	comb_init(N);
	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ll x = ways[i] * comb(N, i) % MOD;
		if (i % 2 == 0) (ans += x) %= MOD;
		else (ans += MOD - x) %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 68992
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  bool flag = true;
  int count = 0;
  sort(a.begin(), a.end());
  rep(i, n) {
    x -= a.at(i);
    if (x < 0) {
      cout << i << endl;
      flag = false;
      break;
    }
    count++;
  }
  if ((count == n) && (flag)) {
    if (x > 0) {
      cout << count-1 << endl;
    }
    else {
      cout << count << endl;
    }
  }
  //cout << count << flag << endl;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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



ll gcd(ll a, ll b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}

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

	set<ll> s;

	rep(i, N)
	{
		ll tmp;
		cin >> tmp;
		s.insert(tmp);
	}


	if (K > * s.rbegin())
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}


	ll d = *s.begin();

	for (auto x : s)
	{
		d = gcd(d, x);
	}

	if (K % d == 0)
	{
		cout << "POSSIBLE" << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(RALL(a));
  ll ans = a[0];
  rep(i, n-2) ans += a[i/2+1];
  cout << ans << endl;
}


Measured memory_bytes: 4820
#include <iostream>
using namespace std;
typedef long long ll;

ll n,k;

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

	ll a = 0, b = 0;

	for(int i = 1; i <= n; i++) {
		if(i%k==0) a++;
		if(k%2==0 && i%k==k/2) b++;
	}

	ll ans = a*a*a+b*b*b;

	cout << ans << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
using namespace std;

int n, cnt;
int a[200002];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            swap(a[i], a[i+1]);
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define dd double
#define ld long double
#define f(i,a,b) for(ll i = a; i < b; i++)
#define fr(i,a,b) for(ll i = b;i>=a;i--)
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define VP vector< pii >
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define Sort(v) sort(v.begin(), v.end(), sortbysec)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define N 1000000

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;      
    x = x % p; 
                
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

 

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

//ll t; cin>>t; while(t--){}
ll s,w;
cin>>s>>w;

if(w >= s)
cout<<"unsafe";
else
cout<<"safe";



return 0;
}


Measured memory_bytes: 3620
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n,T; cin >> n >> T;
    vector<int> t(n);
    for(int i = 0;i < n;i ++){
        cin >> t.at(i);
    }

    int ans = 0;

    for(int i = 0;i < n-1;i ++){
        ans += min(T,t.at(i+1)-t.at(i));
    }
    ans += T;

    cout << ans << endl;

}



Measured memory_bytes: 1792
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>

using namespace std;


int main(){

    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;

    int s[5] = {a,b,c,d,e};
    int i,j;
    int count = 0;
    for(i=0;i<5;i++) {
        for (j = 0; j < 5; j++) {
            if (j <= i) {
                continue;
            }
            if((s[j]-s[i]<=k)){
                count++;
            }
        }
    }
    if(count == 10){
        std::cout<<"Yay!";
    }else{
        std::cout<<":(";
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x[4], y[4];

    cin >> x[0] >> y[0] >> x[1] >> y[1];
    x[2] = x[1] - (y[1] - y[0]);
    y[2] = y[1] + (x[1] - x[0]);
    x[3] = x[0] - x[1] + x[2];
    y[3] = y[0] - y[1] + y[2];

    cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
}

Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]

from itertools import product
ans = float("inf")
for p in product(range(4),repeat=N):
    a = [L[i] for i in range(N) if p[i]==1]
    b = [L[i] for i in range(N) if p[i]==2]
    c = [L[i] for i in range(N) if p[i]==3]

    if a==[] or b==[] or c==[]:
        continue
    
    t = 0
    for x in [a,b,c]:
        if len(x)>=2:
            t += (len(x)-1)*10
    sumA = sum(a)
    sumB = sum(b)
    sumC = sum(c)
    t += abs(A-sumA) + abs(B-sumB) + abs(C-sumC)

    ans = min(ans,t)

print(ans)

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

using namespace std;

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

	int n;
	cin >> n;
	set<string> var;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		var.insert(s);
	}
	cout << var.size();
	return 0;
}

Measured memory_bytes: 19196
#define ioFix ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

long long madd(long long x, long long y, long long modulo) {
  return (x + y) % modulo;
}

long long mmult(long long x, long long y, long long modulo) {
  return (x * y) % modulo;
}

long long mpow(long long base, long long exponent, long long modulo) {
  long long res = 1;
  for(int i = 0; i < exponent; i++)
    res = (res * base) % modulo;
  return res;
}

long long mfac(long long n, long long modulo) {
  long long res = 1;
  for(int i = 2; i <= n; i++)
    res = (res * i) % modulo;
  return res;
}

long long mcomb(long long n, long long k, long long modulo) {
  return mfac(n, modulo) / mmult(mfac(k, modulo), mfac(n-k, modulo), modulo);
}


#define PI (2.0 * acos(0.0))
#define INF (int)1e9
#define LINF (long long)1e18
#define EPS 1e-9

#define ll long long
#define ull unsigned long long

#define pii pair<int, int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define pcc pair<char, char>
#define pbb pair<bool, bool>

#define vi vector<int>
#define vvi vector<vector<int>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vvs vector<vector<string>>

#define REP(n) for(int xix = 0; xix < (n); xix++)
#define FOR(i, from, to) for(int (i) = from; (i) < (to); (i)++)
#define RANGE(i, from, to) for(int (i) = from; (i) <= (to); (i)++)
#define ALL(x) x.begin(),x.end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

#define fillArray(arr, val) std::fill(std::begin(arr), std::end(arr), (val))

#define pow2(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchVector(v) { for(int xvx = 0; xvx < (v).size(); xvx++) { cout << (v)[xvx] << " "; } cout << endl; }
#define watchArray(arr, n) { for(int xax = 0; xax < (n); xax++) { cout << (arr)[xax] << " "; } cout << endl; }
#define watchMatrix(x, rows, cols) for(int r = 0; r < (rows); r++) { for(int c = 0; c < (cols); c++) { cout << (x)[r][c] << " "; } cout << endl; }



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

ll gcd(ll a, ll b) {
  if(a == 0)
    return b;
  return gcd(b % a, a);
}

int main() {
  ioFix;
  ll N, P;
  cin >> N >> P;

  if(N > log2(P)) {
    cout << 1 << endl;
    return 0;
  }

  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; // <val, index>
  FOR(i, 0, N)
    pq.push(mp(1, i));

  ll divCounter = 0;
  ll div = 2;
  ll big = P;
  ll sqrtP = ceil(sqrt(P));
  while(big > 1) {
    auto p = pq.top();

    while(big % div != 0 && div <= sqrtP) {
      div++;
    }

    if(div > sqrtP)
      div = big;

    big /= div;
    p.first *= div;
    divCounter++;

    pq.pop();
    pq.push(p);
  }

  if(divCounter < N) {
    cout << 1 << endl;
    return 0;
  }

  ll res = pq.top().first;
  while(!pq.empty()) {
    res = gcd(res, pq.top().first);
    pq.pop();
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    int n, q;
    vector<int> cnt(100005);
    long long sum = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        sum += tmp;
        ++cnt[tmp];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        long long b, c;
        cin >> b >> c;

        sum += cnt[b] * (c - b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    n, m = map(int, readline().split())
    to = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, readline().split()) 
        a-=1
        b-=1
        to[a].append(b)
        to[b].append(a)

    dq = deque()    
    dq.append(0)
    done = [-1 for _ in range(n)]
    done[0] = 1 
    while len(dq)>0:
        v = dq.popleft()
        for nx in to[v]:
            if done[nx] != -1:
                continue
            done[nx] = v
            dq.append(nx)

    print('Yes')
    for i in done[1:]:
        print(i+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 92060
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w,k = readline() |> split |> parseMap
	a = String["" for i in 1:h]
	fs = 0
	ls = 0
	v = [Int[0] for i in 1:h]
	for i in 1:h
		a[i] = readline() |> chomp
		for j in 1:w
			if a[i][j]=='#'
				if fs == 0
					fs = i
				end
				ls = i
				push!(v[i],j)
			end
		end
	end
	x = 1
	o = zeros(Int,h,w)
	ho = 0
	for i in 1:h
		if length(v[i])>1
			ho = i
			for j in 2:length(v[i])-1
				for k in v[i][j-1]+1:v[i][j]
					o[i,k]=x
				end
				x += 1
			end
			for k in v[i][length(v[i])-1]+1:w
				o[i,k]=x
			end
			x += 1
		elseif i>fs
			for j in 1:w
				o[i,j] = o[ho,j]
			end
		end
	end
	for i in 1:fs-1
		for j in 1:w
			o[i,j] = o[fs,j]
		end
	end
	for i in ls+1:h
		for j in 1:w
			o[i,j] = o[ls,j]
		end
	end
	for i in 1:h
		for j in 1:w-1
			print(o[i,j]," ")
		end
		println(o[i,w])
	end
end
main()

Measured memory_bytes: 173832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, K;
ll H[305];
ll Prev[305][305], Next[305][305];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for(int i = 1; i <= N; i++) {
        cin >> H[i];
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            for(int timer = 0; timer <= K; timer++) {
                Next[j][timer] = 1e18;
            }
        }
        for(int timer = 0; timer <= K; timer++) {
            for(int j = 0; j < i; j++) {
                chmin(Next[i][timer], Prev[j][timer] + max(0LL, H[i] - H[j]));
                if(timer > 0) {
                    chmin(Next[j][timer], Prev[j][timer-1]);
                }
            }
        }
        swap(Prev, Next);
        for(int j = 0; j <= i; j++) {
            for(int k = 0; k <= K; k++) {
                //cerr << i << " " << j << " " << k << " " << Prev[j][k] << endl;
            }
        }
    }
    ll ans = 1e18;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= K; j++) {
            chmin(ans, Prev[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			while (true)
			{
				var input = Console.ReadLine();
				if (input == "-1 -1 -1")
					break;
				var arr_test_result = input.Split(' ').Select(int.Parse).ToArray();
				if (arr_test_result[0] == -1 || arr_test_result[1] == -1) { Console.WriteLine("F"); continue; }
				var m_f_sum = arr_test_result[0] + arr_test_result[1];
				if (m_f_sum < 30) { Console.WriteLine("F"); continue; }
				else if (30 <= m_f_sum && m_f_sum < 50)
				{
					if (arr_test_result[2] >= 50) { Console.WriteLine("C"); continue; }
					else { Console.WriteLine("D"); continue; }
				}
				else if (50 <= m_f_sum && m_f_sum < 65) { Console.WriteLine("C"); continue; }
				else if (65 <= m_f_sum && m_f_sum < 80) { Console.WriteLine("B"); continue; }
				else if (80 <= m_f_sum) { Console.WriteLine("A"); continue; }
			}
		}
	}
}



Measured memory_bytes: 16244
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%ld", &x); return x;}


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}


ll N, M;
vector<ll> u, v;
vector<vector<ll>> adjList;
vector<ll> flg;



int main(void){
	cin >> N >> M;
	adjList = vector<vector<ll>>(N);
	flg = vector<ll>(N, -1);
	for(int i=0;i<M;i++){
		u.pb(nextLL() - 1);
		v.pb(nextLL() - 1);
		adjList[u[i]].pb(v[i]);
		adjList[v[i]].pb(u[i]);
	}

	set<ll> unreached; for(int i=0;i<N;i++) unreached.insert(i);
	ll bp = 0, nbp = 0, pt = 0;
	while(!unreached.empty()){
		ll s = *unreached.begin();
		queue<ll> q; q.push(s); flg[s] = 0;
		ll siz = 0;
		bool isBP = true;
		while(!q.empty()){
			ll now = q.front(); q.pop();
			siz++;
			unreached.erase(now); // ?
			for(int i : adjList[now]){
				if (flg[i]==-1){
					q.push(i); flg[i] = 1 - flg[now];
				}else{
					if (flg[now] == flg[i]) isBP = false;
				}
			}
		}
		if (siz==1) pt++;
		else if (isBP) bp++; else nbp++;
	}

	ll ans = 2 * bp * bp + nbp * nbp + 2 * nbp * bp + pt * pt + 2 * pt * (N - pt);
	cout << ans << endl; 


    return 0;
}




Measured memory_bytes: 17504
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, M;
vv<bool> edge;
vector<int> bw;
vector<bool> visited;

bool dfs(int v, int k) {
    rep(u, N) {
        if (edge[v][u] || u == v) continue;
        if (visited[u]) {
            if ((bw[v] ^ bw[u]) == 0) return true;
            else continue;
        }
        visited[u] = true;
        bw[u] = bw[v] ^ 1;
        if (dfs(u, k)) return true;
    }
    return false;
}

int main() {
    cin >> N >> M;
    edge = vvec(N, N, false);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a][b] = edge[b][a] = true;
    }

    visited.resize(N);
    bw.resize(N);
    int k = 0;
    bool ng = false;
    rep(v, N) {
        if (visited[v]) continue;
        visited[v] = true;
        bw[v] = k;
        ng |= dfs(v, k);
        k += 2;
    }
    if (ng) {
        write(-1);
    }
    else {
        vector<int> cnt(k);
        rep(v, N) {
            cnt[bw[v]]++;
        }
        vv<bool> dp = vvec(k / 2 + 1, 2 * N + 1, false);
        dp[0][0] = true;
        rep(i, k / 2) {
            rep(j, N + 1) {
                dp[i + 1][j + cnt[2 * i]] = dp[i + 1][j + cnt[2 * i]] | dp[i][j];
                dp[i + 1][j + cnt[2 * i + 1]] = dp[i + 1][j + cnt[2 * i + 1]] | dp[i][j];
            }
        }
        int b = N, w = 0;
        rep(j, N + 1) {
            if (dp[k / 2][j] && abs(j - (N - j)) < abs(b - w)) {
                b = j;
                w = N - j;
            }
        }
        write(b * (b - 1) / 2 + w * (w - 1) / 2);
    }
}

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

int n;

vector<int> v;
vector<int> r;
int main(){
	cin >> n;
	long long int ans = 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		ans += a - 1;
	
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 18 00:01:41 2018

@author: Yuya
"""

n, m=map(int, input().split())

ans = []
c = 0

for i in range(n):
    tmp=list(input())
    f = 1
    for j in range(m):
        if tmp[j]=="#":
            f = -1
    if f<0:
        ans.append(tmp)
        c+=1


ans2 = [["0" for i in range(c)] for j in range(m)]

for i in range(m):
    for j in range(c):
        ans2[i][j] = ans[j][i]


d = m

for i in range(m-1, -1, -1):
    f = 1
    for j in range(c):
        if ans2[i][j]=="#":
            f = -1
    if f>0:
        del ans2[i]
        d-=1
        


ans3 = [["0" for i in range(d)] for j in range(c)]

for i in range(d):
    for j in range(c):
        ans3[j][i] = ans2[i][j]



for i in range(c):
    print(''.join(ans3[i]))

Measured memory_bytes: 3316
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy

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

    int N; ll M; cin >> N >> M;
    ll lm = 1;
    ll data[N];
    F0R(i, N) {
        ll cur; cin >> cur; data[i] = cur;
        ll g = __gcd(lm, cur);
        lm = lm * cur / g;
        if (lm >= MX) {
            cout << 0 << endl; return 0;
        }
    }

    ll res = lm / 2;
    F0R(i, N) {
        if (res % data[i] != data[i] / 2) {
            cout << 0 << endl; return 0;
        }
    }
    //cout << lm << endl;
    ll ans = M / lm;
    ll val = M % lm;
    if (val >= lm / 2) ans++;
    cout << ans << endl;

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i, r) for(int i = 0; i < r; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back

int main()
{
    fastIO
    ll a, b, n;
    cin >> a >> b >> n;

    ll ans1, ans2;
    ll num, val;

    if(b <= n) {
        num = n / b;
        val = num * b - 1;
    }
    else{
        val = n;
    }
    ans1 = (a *(val)) / b;
    ans2 = a * ((val) / b);
    cout << ans1 - ans2 << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define mod (ll)(1e9 + 7)
using namespace std;

ll sub(ll a, ll b){
	ll r = (a - b)%mod;
	r += mod;
	r %= mod;
	return r;
}

ll add(ll a, ll b){
	return (a + b)%mod;
}

ll mul(ll a, ll b){
	return a * b % mod;
}

ll my_pow(ll a, ll b){
	// a^b
	ll res = 1LL;
	while(b){
		if(b&1) res = mul(res,a);
		a = mul(a,a);
		b = b / 2;
	}
	return res;
}

int main() {
	// your code goes here
	ll S;
	cin>>S;
	vector <ll> dp(S+1,1LL); 
	if(S<3){
		cout<<"0\n";
		return 0;
	}
	
	dp[0] = 0; dp[1] =0; dp[2] = 0;
	
	//dp[i] = sum {dp[i - j]} j>=3
	dp[3] = 1LL;
	for(int i=3;i<=S;++i){
		for(int j=3;j+i<=S;++j){
			dp[i+j] = add(dp[i+j],dp[i]);
		}
	}
	cout<<dp[S]<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,q,s[100010],i,t,ans=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  s[n]=1000000001;
  scanf("%d\n",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    int min=-1,max=n,mid;
    while(abs(max-min)>1){
      mid=(min+max)/2;
      if(t<=s[mid]){
        max=mid;
      }
      else{
        min=mid;
      }
    }
    if(t==s[max]){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(void){
	int i,j,v,n,A[200];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<=n-1;i++){
		for(j=0;j<n;j++){
			printf("%d",A[j]);
		if(j<n-1){
			printf(" ");
		}
		}
		printf("\n");
		v = A[i];
		j=i-1;
		while(j>= 0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] =v;
	}
	for(j=0;j<n;j++){
		printf("%d",A[j]);
		if(j<n-1){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1812
#include <iostream>

using namespace std;

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

    if (R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pint pair<int,int>

int n,m;
int dist[201010];

int ans[201010];

vector<vector<int>> to;

const int inf = 1LL << 60;

void Dijkstra(int a){ 
  
  for(int i = 0; i < n; i++){ 
    dist[i] = inf;
  } 
  
  
  dist[a] = 0;
  
  priority_queue<pint,vector<pint>,greater<pint>> Q;
  
  Q.push({0LL,0LL});
  //重さ、ノード
  
  while(!Q.empty()){ 
    
    auto p = Q.top(); Q.pop();
    
    int w = p.first; int pos = p.second;
    
    if( w > dist[pos] ){ continue;} 
    
    for(auto next : to[pos]){ 
      
      if( dist[next] > dist[pos]+1 ){ 
        dist[next] = dist[pos]+1;
        ans[next] = pos;
        Q.push({dist[next],next});
        
      }
    }
    
  }//while-閉じ
  
  
  return ;
} 
           

signed main(void){ 
  
  cin >> n >> m;
  to.resize(n);
  for(int i = 0; i < m; i++){ 
    int a,b; cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  for(int i = 1; i < n; i++){ 
    ans[i] = -1;
  } 
  
  Dijkstra(0);
  
  for(int i = 1; i < n; i++){ 
    if( ans[i] == -1 ){ 
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  for(int i = 1; i < n; i++){ 
    cout << ans[i]+1 << endl;
  }
  
  return 0;
} 

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


int main()
{   
    int n;
    cin>>n;
    bool t=0;
    for(int i=1; i<10; i++)
    if(n%i==0&&n/i<10)
    t=1;
    cout<<(t?"Yes":"No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 17:15-
const int MAX_M=2e5+1,MAX_N=1e5+1;
int N,M;
const string yes="Yes",no="No";
int L[MAX_M],R[MAX_M];
LL D[MAX_M];
unordered_map<int,LL> IN[MAX_N],OUT[MAX_N];
LL dist[MAX_N];
bool solve() {
  MINUS(dist);
  REP(i,M) {
    int u=L[i],v=R[i];
    LL d=D[i];
    OUT[u][v]=d,IN[v][u]=d;
  }
  
  queue<int> Q;
  REP(i,N) if(IN[i].empty()&&SZ(OUT[i])) Q.emplace(i),dist[i]=0;
  while(SZ(Q)) {
    int u=Q.front(); Q.pop();
    FORR(kvp,OUT[u]) {
      int v=kvp.first; LL d=kvp.second;
      LL d2=dist[u]+d;
      if(dist[v]!=-1&&d2!=dist[v]) return false;
      dist[v]=d2;
      IN[v].erase(u);
      if(IN[v].empty()) Q.push(v);
    }
  }
  REP(i,N) if(SZ(IN[i])) return false;
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,M) cin>>L[i]>>R[i]>>D[i];
  string res=solve()?yes:no;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 37632
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
 
typedef pair< int, int > Pi;
typedef pair< int, Pi > Pii;

bool hoge(const Pii& a,const Pii& b) {
  return a.first < b.first; 
}


int main(){
  int N, d;
  Pii data[200000];
  multiset< int > X, Y;
  scanf("%d %d", &N, &d);
  for(int i = 0; i < N; i++){
    scanf("%d %d %d", &data[i].second.first, &data[i].second.second, &data[i].first);
  }
  sort( data, data + N, hoge);
  int64 ret = 0, low = 0;
  for(int i = 0; i < N; ++i){
    while(data[low].first < data[i].first - d){
      X.erase( X.find(data[low].second.first));
      Y.erase( Y.find(data[low].second.second));
      low++;
    }
    X.insert( data[i].second.first);
    Y.insert( data[i].second.second);
    ret = max( ret, (int64)(*--X.end() - *X.begin()) * (*--Y.end() - *Y.begin()));
  }
  printf("%lld\n", ret);
}

Measured memory_bytes: 22280
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int T;
ll A,B,C,D;

ll divi(ll a, ll b) {
    if (a % b == 0) return a/b-1;
    if (a > 0) return a/b;
    return a/b-1;
}

bool solve() {
    cin >> A >> B >> C >> D;
    if (A-B < 0) return 0;
    if (B > D) return 0;
    ll g = __gcd(B,D); B /= g, D /= g;
    // A-x*g > C 
    // A-C > x*g
    ll x = divi(A-C,g);
    ll tmp = A-g*x-B*g;
    // cout << A << " " << B << " " << C << " " << D << " " << g << " " << x << " " << tmp << "\n";
    return tmp >= 0;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> T;
    F0R(i,T) {
        if (solve()) cout << "Yes\n";
        else cout << "No\n";
    }
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  string s; cin >>s;
  string t = "keyence";
  if (s.size()<7){
    cout <<"NO" <<endl; return 0;
  }
  int ai = 0, bi = t.size()-1;
  for (int i=0; i<t.size(); i++){
    if (s[i] == t[i]) ai++;
    else break;
  }
  ai--;
  for (int i=0; i<t.size(); i++){
    if (ai == bi) break;
    if (s[s.size()-1-i] == t[t.size()-1-i]) bi--;
    else break;
  }
  bool ok = ai == bi;
  cout <<(ok ? "YES" : "NO") <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

vector<ll> dijkstra(const vector<vector<pair<int,int>>> &graph,int s){
    int n=(int)graph.size();
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    vector<ll> dist(n,linf);
    dist[s]=0;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            int w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                pq.push({dist[u],u});
            }
        }
    }
    return dist;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,int>>> g(n+n+n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        g[a].push_back({b+n,1});
        g[a+n].push_back({b+n+n,1});
        g[a+n+n].push_back({b,1});
    }
    int s,t;
    cin>>s>>t;
    --s,--t;
    vector<ll> d=dijkstra(g,s);
    cout<<(d[t]!=linf?d[t]/3:-1)<<endl;
}


Measured memory_bytes: 18944
// https://atcoder.jp/contests/arc074/tasks/arc074_d
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;

#define MAX_V 205
const int INF = 1e9;
struct EDGE{int to,cap,rev;}; // revはノードtoの逆方向エッジのインデックス
vector<EDGE> es[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
	// from から to へ容量 cap のエッジを追加
	es[from].push_back(EDGE{to,cap,(int)es[to].size()});
	es[to].push_back(EDGE{from,0,(int)es[from].size()-1});
}

int dfs(int i,int t,int f){
	// ノードiからノードtに流量fを入力したときに実際にtに届く流量を返す
	if(i==t) return f;
	used[i] = true;
	rep(j,es[i].size()){
		EDGE &e = es[i][j];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				es[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	// s から t までの最大流量を求める
	int flow = 0;
	while(true){
		memset(used,0,sizeof(used));
		int d = dfs(s,t,INF);
		if(d==0)return flow;
		flow += d;
	}
	return -1;
}

int main() {
	int H,W;
	cin >> H >> W;
	int s=H+W,t=H+W+1;
	rep(i,H){
		string row;
		cin >> row;
		rep(j,W){
			char c = row[j];
			if(c=='S'){
				add_edge(s,i,INF);
				add_edge(s,H+j,INF);
			}else if(c=='T'){
				add_edge(i,t,INF);
				add_edge(H+j,t,INF);

			}else if(c=='o'){
				add_edge(i,H+j,1);
				add_edge(H+j,i,1);
			}
		}
	}
	int ans = max_flow(s,t);
	if(ans>=INF)ans=-1;
	outl(ans);
    return 0;
}



Measured memory_bytes: 896
#include <iostream>

int main(int argc, char const* argv[])
{
	int x;

	for (int i=1; ; i++) {
		std::cin >> x;
		if (x == 0) {
			break;
		} else {
			std::cout << "Case " << i << ": " << x << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){//
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) cin >> p[i];

    int ans = 0;
    for(int i = 0; i<= 101; i++){
        bool flag = true;
        for(int j=0; j<N; j++){
            if(i == p[j]) flag = false;
        }
        if(flag == false ) continue;
        int a = abs(i -X);
        int b = abs(ans - X);
        if(a < b) ans = i;
        
    }

    cout << ans << endl;

}

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

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long nCr(long n, long r){
  long ans = 1;
  for(long i = n; i > n - r; i--){
    ans = ans*i;
    ans %= 1000000007;
  }
  for(long i = 1; i < r + 1; i++){
    ans *= modinv(i, 1000000007);
    ans %= 1000000007;
  }
  return ans;
}

long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main(){
	long n, a, b;
	cin >> n >> a >> b;
	long ans;
	ans = myPow((long)2, n, 1000000007);
	ans -= 1 + nCr(n, a) + nCr(n, b);
	while (ans < 0) ans += 1000000007;
	cout << ans << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    char op = '.';
    int res = 0;
    rep(i, N)
    {
        if (i > 0)
        {
            if (A[i] > A[i - 1] && op == '-')
            {
                res++;
                op = '.';
                continue;
            }
            else if (A[i] < A[i - 1] && op == '+')
            {
                res++;
                op = '.';
                continue;
            }
            if (A[i] > A[i - 1])
            {
                op = '+';
            }
            else if (A[i] < A[i - 1])
            {
                op = '-';
            }
        }
        else
            res++;
    }
    cout << res << endl;
    return 0;
}

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

const int INF = 1e9;

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

	int resp = 0;
	for (int i = 1; i <= 5; i++) {
		int a;
		cin >> a;
		if (a == 0)
			resp = i;
	}
	cout << resp << endl;

	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;
# define maxn 20 

int main(){
  int n,v[maxn],c[maxn],sum(0);
  cin >> n;
  for (int i(0);i < n; i++){
     cin >> v[i];
  }
  for (int i(0);i < n; i++){
     cin >> c[i];
  }
  for (int i(0);i < n; i++){
    if (v[i] > c[i]){
      sum += v[i] - c[i];
    }
  }
  cout << sum;
  // int kouho_1 = sum / n, kouho_2 = sum / n + 1, kouho_3 = sum / n - 1;
  // int sum_1(0),sum_2(0),sum_3(0);

  // for (int i(0);i < n; i++){
  //   sum_1 += (kouho_1 - a[i]) * (kouho_1 - a[i]);
  //   sum_2 += (kouho_2 - a[i]) * (kouho_2 - a[i]);
  //   sum_3 += (kouho_3 - a[i]) * (kouho_3 - a[i]);
  // }
  // cout << min(sum_1,min(sum_2,sum_3));
  return 0;
}


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

int main() {
int N,a;
cin >> N;
cin >> a;
int b;
  while ( a % 2 == 0 ) {
    a = a / 2;
    b++;
  }
  for ( int i = 0; i < N - 1; i++ ) {
	int c,d=0;
    cin >> c;
    while ( c % 2 == 0 ) {
      c = c / 2;
      d++;}
    b = min( b, d);
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    string S;
    cin>>S;
    cout<<S.at(0)<<S.at(1)<<S.at(2)<<endl;
}

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

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N, M;
    cin >> N >> M;

    vector<ll> v(N + 1);
    for(int i = 0; i < M; i++){
        ll l , r;
        cin >> l >> r;
        v[l] ++;
        v[r + 1] --;
    }

    vector<ll> sumV(N + 2);
    sumV[0] = 0;
    for(int i = 1; i <= N+1; i++){
        sumV[i] = sumV[i-1] + v[i-1];
    }

    ll ans = 0;
    for(int i = 1; i <=N+1; i++){
        if(sumV[i] == M) ans++;
    }
    cout << ans << endl;

}

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


int main(){
    ll X;
    cin >> X;
    vector<ll> N(X,0);
    map<ll,ll> cnt;
    vector<ll> sum(X + 1,0);

    cnt[0]++;

    for(int i = 0; i < X; i++){
        cin >> N[i];
        sum[i + 1] = sum[i] + N[i];
        cnt[sum[i + 1]]++;
    } 
    
    ll ans = 0;

    for(auto it:cnt){
        ans += (it.second) * (it.second - 1) / 2;
    }

    cout << ans << endl;

}





Measured memory_bytes: 15872