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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

ll d, g;

ll get_min(const vector<pair<ll, ll>> &q, const int t,
           const vector<bool> &selected) {
  // 最深部まできたら
  if (t > d) {
    ll sum = 0;
    ll count = 0;
    FOR(i, 1, d + 1) {
      if (selected[i]) {
        sum += 100 * i * q[i].first;
        sum += q[i].second;
        count += q[i].first;
      }
    }

    if (sum >= g) {
      return count;
    }

    FORr(i, 1, d) {
      if (!selected[i]) {
        ll additional_cnt = (g - sum + 100 * i - 1) / (100 * i);
        if (additional_cnt > q[i].first) {
          return INFINITY;
        }
        return count + additional_cnt;
      }
    }
    return INFINITY;
  }

  vector<bool> s = selected;
  ll a, b;
  s[t] = 0;
  a = get_min(q, t + 1, s);
  s[t] = 1;
  b = get_min(q, t + 1, s);
  return min(a, b);
}

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

  cin >> d >> g;

  vector<pair<ll, ll>> q(d + 1);
  FOR(i, 1, d + 1) { cin >> q[i].first >> q[i].second; }

  vector<bool> selected(d + 1);
  auto min = get_min(q, 1, selected);

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,k = readInts()
    a_ = b + c
    b_ = a + c
    ab = a_ - b_
    k = k % 2
    if ab >= 10**18:
        print("Unfair")
    else:
        if k == 0:
            print(a-b)
        else:
            print(ab*(-1)**(k+1))

if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int main(){
    int l,r,ans = 2000000000;
    cin >> l >> r;

    if(r-l >= 2019)ans = 0;

    l %= 2019;
    r %= 2019;

    if(l > r) r += 2019;


    for(int i = l;i < r;i++){
        for(int j = i+1;j <= r;j++){
            ans = min(ans,(i*j)%2019);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long 
signed main() 
{
	int n;
	cin>>n;
	vector<int>v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end(),greater<int>());
	int ans=0;
	ans+=v[0];
	int cnt=1;
	int j=1;
	while(cnt!=n-1){
		ans+=v[j];
		cnt++;
		if(cnt==n-1)break;
		ans+=v[j];
		cnt++;
		j++;
	}
	cout<<ans;
    return 0; 
} 

Measured memory_bytes: 5364
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}
bool check(string s)
{
	for (int i=0; i<sz(s); i++)
	{
		if (s[i]!=s[sz(s)-i-1])
			return false;
	}
	return true;
}
void solve()
{
//Read Comments below main
	double l;
	cin>>l;
	double temp=l/3;
	double ans=temp*temp*temp;
	cout<<setprecision(20)<<fixed;
	cout<<ans<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// BITMASK:
// 1)When some constraint is of the order of 15-20, think of bitmask DP.
// 2)When some constraint is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algo

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vi a(n);
    vi ans(n,0);
    int s=0;
    FOR(i,0,n){
        cin>>a[i];
        s^=a[i];
    }
    if(n&1){

    }else{
        FOR(i,0,n){
            cout<<(a[i]^s)<<" ";
        }
    }

}


Measured memory_bytes: 4616
#include <stdio.h>

int main(){
  int n,m,i;
  scanf("%d %d",&n,&m);
  int A[n+1],sum=0,count=0;
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
  }
  for(i=1;i<=n;i++){
    A[i]=A[i]*4*m/sum;
    if(A[i]!=0){
      count++;
    }
  }
  if(count>=m){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

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

#define pb push_back
#define S second
#define F first
#define sz size()
#define eps 0.000001
#define oo 2000000007
#define endl '\n'
#define bg begin()
#define nd end()
#define up upper_bound
#define lw lower_bound
#define debug(x) #x << " = " << x << "; "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAX = 305;
double dp[MAX][MAX][MAX];
int N;

double f(int a, int b, int c){
	if(a + b + c == 0) return 0;
	double &ans = dp[a][b][c];
	if(ans > -0.5) return ans;
	ans = 0;
	if(a) ans += f(a - 1, b, c)*a + a;
	if(b) ans += f(a + 1, b - 1, c)*b + b;
	if(c) ans += f(a, b + 1, c - 1)*c + c;
	ans += N - a - b - c;
	ans/= (double) (a + b + c);
	//cout << a << " " << b << " " << c << " " << ans << endl;
	return ans;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	int arr[4];
	memset(arr, 0, sizeof(arr));
	cin >> n;
	N = n;
	for(int i = 0; i < n; i++){
		cin >> k;
		arr[k]++;
	}
	for(int i = 0; i <= arr[1] + arr[2] + arr[3] + 1; i++){
		for(int j = 0; j <= arr[2] + arr[3] + 1; j++){
			for(int k = 0; k <= arr[3] + 1; k++){
				dp[i][j][k] = -0.5;
			}
		}
	}
	double ans = f(arr[1], arr[2], arr[3]);
	cout << fixed << setprecision(12) << ans << endl;
}

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

using namespace std;

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

    vector<string> subs;
    for ( int si = 0; si < s.size(); si++ ) {
        for ( int len = 1; len <= k; len++ )
            subs.push_back(s.substr(si, len));
    }

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

    auto n = unique(subs.begin(), subs.end());
    subs.erase(n, subs.end());

    cout << subs.at(k-1) << endl;
    return 0;
}


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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    string s;
    cin >> s;
    if (c < d) {
        bool check1 = true;
        rep(i, a + 1, c - 1) {
            if (s[i] == s[i + 1] and s[i] == '#') {
                check1 = false;
            }
        }
        bool check2 = true;
        rep(i, b + 1, d - 1) {
            if (s[i] == s[i + 1] and s[i] == '#') {
                check2 = false;
            }
        }
        dump(check1 and check2 ? "Yes" : "No");
    } else {
        bool check1 = true;
        rep(i, a + 1, c - 1) {
            if (s[i] == s[i + 1] and s[i] == '#') {
                check1 = false;
            }
        }
        bool check2 = false;
        rep(i, b - 1, d) {
            if (s[i] == s[i + 1] and s[i + 1] == s[i + 2] and s[i] == '.') {
                check2 = true;
            }
        }
        dump(check1 and check2 ? "Yes" : "No");
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[202020], k;
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	
	if(k <= n){
		int now = 0;
		for(int i = 0; i < k; i++){
			now = a[now];
		}
		cout << now+1 << endl;
		return;
	}
	
	i64 used[202020] = {};
	i64 cnt = 1;
	i64 now = a[0];
	used[0] = 1;
	while(!used[now]){
		cnt++;
		used[now] = cnt;
		now = a[now];
	}
	
	k -= used[now]-1;
	k %= cnt-used[now]+1;
	while(k--){
		now = a[now];
	}
	cout << now+1 << endl;
}

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

Measured memory_bytes: 6796
#include<iostream>
using namespace std;
int main(){

    int i,n[10000],m[10000],l,x=10000;
    
    for(i = 0;i < 10000;i++){
        cin >> n[i] >> m[i];
        if(n[i] == 0 && m[i] == 0){
            x = i;
            i = 10000;
        }
    }
    
    for(i = 0;i < x;i++){
        if(n[i] > m[i]){
            l = n[i];
            n[i] = m[i];
            m[i] = l;
        }
        cout <<n[i]<<" "<<m[i]<<"\n";
        
        
    }
    
    return 0;

}



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

int main() {
  int D, N;
  cin >> D >> N;
  int temp = 1;
  for (int i = 0; i < D; ++i) {
    temp *= 100;
  }
  if (N == 100) {
    ++N;
  }
  cout << temp * N << endl;
}


Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=1
d={x:0 for x in range(n)}
for i in range(n):
    if a[i]==0:
        d[0]+=1
    else:
        m=a[i]
        ans=(ans*(d[m-1]-d[m]))%mod
        if ans<=0:
          print(0)
          exit()
        d[m]+=1
    if d[a[i]]>3:
      print(0)
      exit()
if d[0]==1:
  print(ans*3%mod)
elif d[0]==2:
  print(ans*6%mod)
elif d[0]==3:
  print(ans*6%mod)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<string> a(n);
	for (auto &i : a)
		cin >> i;

	vector<vector<string>> t(4);
	for (auto i : a)
	{
		if (i[0] == 'B')
		{
			if (i.back() == 'A')
				t[1].push_back(i);
			else
				t[2].push_back(i);
		}
		else if (i.back() == 'A')
		{
			t[0].push_back(i);
		}
		else
			t[3].push_back(i);
	}

	string s = "";
	if (!t[0].empty())
		s += t[0].back(), t[0].pop_back();

	for (auto i : t[1])
		s += i;

	t[1].clear();

	if (!t[2].empty())
		s += t[2].back(), t[2].pop_back();

	while (!t[0].empty() && !t[2].empty())
	{
		s += t[0].back(), t[0].pop_back();
		s += t[2].back(), t[2].pop_back();
	}

	for (auto &i : t)
		for (auto j : i)
			s += j;

	int sz = s.length(), ans = 0;
	for (int i = 1; i < sz; ++i)
		if (s[i-1] == 'A' && s[i] == 'B')
			++ans;

	cout << ans << "\n";

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}




Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  ll n,k,i,j,mod=998244353;
  cin>>n>>k;
  vector<ll> l(k),r(k),dp(n),d(n);
  for(i=0;i<k;i++) cin>>l[i]>>r[i];
  dp[0]=1;
  d[1]=-1;
  for(i=0;i<n;i++){
    if(i>0) dp[i]=(dp[i-1]+d[i]+mod)%mod;
    if(i<n-1){
      for(j=0;j<k;j++){
        if(i+l[j]<n){
          d[i+l[j]]=(d[i+l[j]]+dp[i]+mod)%mod;
          if(i+r[j]+1<n) d[i+r[j]+1]=(d[i+r[j]+1]-dp[i]+mod)%mod;
        }
      }
    }
  }
  cout<<dp[n-1]<<endl;
}

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

int main(){
  string x;
  cin >> x;
  stack<char> st;
  st.push(x[0]);
  for(int i = 1; i < x.length(); i++){
    if(st.empty()){
      st.push(x[i]);
      continue;
    }
    if(st.top() == 'S' && x[i] == 'T'){
      st.pop();
    }else{
      st.push(x[i]);
    }
  }
  cout << st.size() << endl;
} 

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003;

int x[N], y[N], c[N];
int a[N], b[N];

int main()
{
	//File("");
    int A = gi(), B = gi(), m = gi();
    for (int i = 1; i <= A; i+=1) a[i] = gi();
    for (int i = 1; i <= B; i+=1) b[i] = gi();
    for (int i = 1; i <= m; i+=1) x[i] = gi(), y[i] = gi(), c[i] = gi();
    int ans = INF;
    for (int i = 1; i <= m; i+=1)
    {
        if (a[x[i]] + b[y[i]] - c[i] < ans) ans = a[x[i]] + b[y[i]] - c[i];
    }
    sort(a + 1, a + 1 + A); sort(b + 1, b + 1 + B);
    cout << min(ans, a[1] + b[1]) << endl;
	return 0;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

ll A[202020];
ll L[202020];
ll R[202020];

int main(){

    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++){
        cin >> A[i];
        L[i] = A[i] + L[i - 1];
    }
    for(ll i = N; i >= 1; i--){
        R[i] = A[i] + R[i + 1];
    }
    ll ans = abs(L[1] - R[2]);
    for(ll i = 1; i + 1 <= N; i++){
        chmin(ans, abs(L[i] - R[i + 1]));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
N,M=map(int,input().split())
H=list(map(int,input().split()))
tunagari=[[] for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  tunagari[A-1]+=[B-1]
  tunagari[B-1]+=[A-1]
ans=0
for i in range(N):
  tmpl=tunagari[i]
  n=len(tmpl)
  if n==0 :
    ans+=1
  else:
    for j in range(n):
      tmpl[j]=H[tmpl[j]]
    maxh=max(tmpl)
    if maxh<H[i]:
      ans+=1
print(ans)


Measured memory_bytes: 29268
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include<vector>
#include<queue>
#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<x<<" "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  998244353;

int n, m, k;

void solve()
{
    printf("%.10f\n", 2.0*PI*n);
}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d%d", &n, &d))
    while(~scanf("%lld", &n))
    solve();
    return 0;
}


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

using ll = long long;

const int mod = 1e9 + 7;

bool AC[100000];
int WA[100000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int p;
        string S;
        cin >> p >> S;
        p--;
        if (S == "AC") {
            AC[p] = 1;
        } else if (!AC[p]) {
            WA[p]++;
        }
    }
    int all_AC = 0;
    int all_WA = 0;
    for (int i = 0; i < N; i++) {
        if (AC[i]) {
            all_AC++;
            all_WA += WA[i];
        }
    }
    cout << all_AC << " " << all_WA << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,d,a,x,h,ans;
vector<PII> v;
int t[400010];
int get_h(int i)
{
    int res=0;
    for(i+=n;i>0;i>>=1)res+=t[i];
    return res;
}
void upd(int l,int r,int val)
{
    for(l+=n,r+=n;l<r;l>>=1,r>>=1)
    {
        if(l&1)t[l++]+=val;
        if(r&1)t[--r]+=val;
    }
}
void solve()
{
    cin>>n>>d>>a;
    for(int i=0;i<n;i++)
    {
        cin>>x>>h;
        v.pb({x,h});
    }
    sort(all(v));
    for(int i=0;i<n;i++)t[i+n]=v[i].se;
    for(int i=0;i<n;i++)
    {
        int cur=get_h(i);
        if(cur<=0)continue;
        int t=cur/a+(cur%a!=0);
        ans+=t;
        PII pi=make_pair(v[i].fi+2*d,1e10);
        int last=upper_bound(all(v),pi)-v.begin();
        //cout<<cur<<" "<<t<<" "<<last<<" "<<-t*a<<'\n';
        upd(i,last,-t*a);
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 7276
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 5005;
const LL MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, siz[MAXN];
LL g[MAXN], dp[MAXN][MAXN], tmp[MAXN], ans;

struct Edge {
	int v, nxt;
}e[MAXN<<1];
int first[MAXN], eCnt;

inline void AddEdge(int u, int v) {
	e[++eCnt].v = v;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

void DFS(int u, int fa) {
	siz[u] = dp[u][1] = 1;
	for (int i=first[u];i;i=e[i].nxt) {
		int v = e[i].v;
		if (v == fa) continue;
		DFS(v, u);
		int x = siz[u], y = siz[v];
		for (int j=1;j<=x;++j) {
			for (int k=1;k<=y;++k) {
				(tmp[j+k] += dp[u][j] * dp[v][k]) %= MOD;
				if (!(k&1)) {
					(tmp[j] -= dp[u][j] * dp[v][k] % MOD * g[k]) %= MOD;
					if (tmp[j] < 0) tmp[j] += MOD;
				}
			}
		}
		x = (siz[u] += siz[v]);
		for (int j=1;j<=x;++j) {
			dp[u][j] = tmp[j];
			tmp[j] = 0;
		}
	}
}

void init() {
	read(n);
	for (int i=1,u,v;i<n;++i) {
		read(u); read(v);
		AddEdge(u, v);
		AddEdge(v, u);
	} 
}

void solve() {
	g[2] = 1;
	for (int i=4;i<=n;i+=2) {
		g[i] = g[i-2] * (i-1) % MOD;
	}
	DFS(1, 0);
	for (int i=2;i<=n;++i) {
		ans = (ans + dp[1][i] * g[i]) % MOD;
	}
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 194944
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 5e5 + 5;
const int oo = 1e9 + 5;
const int MOD = 1e9 + 7;

LL A[N], B[N];
void solve() {
    int n;
    cin >> n;
    LL a = 0, b = 0, x = 0, s = 0;
    for (int i=0;i<n;++i) {
        LL inp; 
        cin >> inp;
        if (i == 0) a = inp;
        else if (i == 1) b = inp;
        else x ^= inp;
    }
    s = a + b;
    for (LL j=59;j>=0;--j) {
        if (x & (1LL<<j)) {
            s -= (1LL<<j);
        }
    }
    LL u = 0, v = 0;
    for (LL j=59;j>=0;--j) {
        if (!(x & (1LL<<j))) {
            if (s & (1LL<<(j+1))) {
                u += (1LL<<j);
                v += (1LL<<j);
                s -= (1LL<<(j+1));
            }
        } 
    }
    if (s != 0) {
        cout << "-1\n";
        return;
    }
    if (u > a) {
        cout << "-1\n";
        return;
    }
    for (LL j = 59;j>=0;--j) {
        if (x & (1LL<<j)) {
            if (u + (1LL<<j) <= a) {
                u += (1LL<<j);
            } else {
                v += (1LL<<j);
            }
        }
    }
    if (u == 0) {
        cout << "-1\n";
    } else {
        cout << a - u << '\n';
    }
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long N;
	long len;
	bool flag = true;
	string A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N-1;i++) {
		len = A[i].size();
		if (A[i][len-1] == A[i+1][0]);
		else flag = false;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			if (A[i] == A[j]) {
				flag = false;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<vector<ll>> edge;

pll dfs(ll w,ll p){
    pll ret={1,1};
    for(auto &i:edge[w]){
        if(i==p){continue;}
        pll k=dfs(i,w);
        (ret.F*=(k.F+k.S)%MOD)%=MOD;
        (ret.S*=k.F)%=MOD;
    }
    return ret;
}



int main(){
    cin>>n;
    edge.resize(n);
    for(int i=1;i<n;i++){
        ll x,y;
        cin>>x>>y;
        x--; y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    pll ans=dfs(0,-1);
    cout<<(ans.F+ans.S)%MOD<<endl;
    
    
    return 0;
}


Measured memory_bytes: 12672
#include<cstdlib>
#include<iostream>
#include<cmath>
using namespace std;
constexpr long long int LLINT_MAX = 1e18;

void Multiplication1() {
	int A, B;
	cin >> A >> B;
	cout << A * B;
}

void Multiplication2() {
	int N;
	bool isOverflow = false;
	long long int ans = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		long long int num;
		cin >> num;
		if (num == 0) {
			cout << 0 << endl;
			return;
		}
		if (isOverflow || num > LLINT_MAX / ans) {
			isOverflow = true;
		}
		ans *= num;
	}
	if (isOverflow) cout << -1 << endl;
	else cout << ans;
}

void Multiplication3() {
	long long int A, ans;
	double B;
	cin >> A >> B;
	ans = B * 100+0.5;
	ans *= A;
	ans /= 100;
	cout << ans;
}

bool IsPrime(long int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	long double sqrtNum = sqrt(num);
	for (long int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0) return false;
	}
	return true;
}

void DivGame() {
	long long int N;
	int e = 1;
	int ans = 0;
	cin >> N;
	if (N == 1) {
		cout << ans;
		return;
	}
	if (IsPrime(N)) {
		cout << 1;
		return;
	}
	for (long long int p = 2; p <= (long double)sqrt(N); p++) {
		if (IsPrime(p)) {
			long int z = p;
			while (N % z == 0) {
				N /= z;
				z *= p;
				ans++;
			}
		}
	}
	cout << ans;
}

int main() {
	Multiplication3();
	//DivGame();
}

Measured memory_bytes: 3124
from collections import deque
N, M = map(int, input().split())

X = [[] for i in range(N*3)]
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y+N-1)
    X[x+N-1].append(y+N*2-1)
    X[x+N*2-1].append(y-1)

S, T = map(int, input().split())
S -= 1
T -= 1
Q = deque([S])
D = [999999] * N * 3

D[S] = 0
while Q:
    x = Q.popleft()
    for c in X[x]:
        if D[c] == 999999:
            D[c] = D[x]+1
            Q.append(c)
print(-1 if D[T] == 999999 else D[T]//3)

Measured memory_bytes: 60100
#include<iostream>
#include<string>

long long search()
{
	std::string s, t, x;
	long long n, m, l, g, g2;
	std::cin >> n >> m >> s >> t;

	g = n;
	g2 = m;

	while (g2 % g)
	{
		g2 %= g;
		std::swap(g2, g);
	}
	l = n * m / g;
	n /= g;
	m /= g;

	for (long long i = 0; i < g; i++)
	{
		if (s[i * n] != t[i * m]) return -1;
	}
	return l;

}

int main()
{
	std::cout << search() << std::endl;
	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  cout<<a+b/2<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
times_a = list(map(int, input().split()))
times_b = list(map(int, input().split()))
read_time = 0
read_time_a = [0]
read_time_b = [0]
for i in range(N):
    read_time_a.append(read_time_a[i]+times_a[i])
for i in range(M):
    read_time_b.append(read_time_b[i]+times_b[i])

ans = 0
for i in range(N+1):
    t = read_time_a[i]
    l = 0
    r = len(read_time_b)
    while l + 1 < r:
        c = (l + r) // 2
        if t + read_time_b[c] <= K:
            l = c
        else:
            r = c
    if read_time_a[i] + read_time_b[l] <= K:
        ans = max(ans, i + l)
print(ans)


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

using namespace std;

int main() {
  int N;
  cin >> N;
  int max_count = 0;
  unordered_map<string, int> map;

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (!map[s]) {
      map[s] = 0;
    }
    map[s]++;
    max_count = max(max_count, map[s]);
  }

  vector<string> ans;
  for (auto &it : map) {
    if (it.second == max_count) {
      ans.push_back(it.first);
    }
  }

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

  for (auto& v: ans) {
    cout << v << endl;
  }

  return 0;
}


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

int solve(int N, int M)
{
  int wn[20]={0}, twn[20]={0}, res = 0;
  wn[0] = N;
  
  while(wn[M] <= 0) {
    memcpy(twn, wn, sizeof(twn));
    memset(wn, 0, sizeof(wn));

    ++res;
    for(int i=0; i<M; i++) {
      wn[i+1] +=twn[i]/2;
      wn[i] += twn[i]%2;
      wn[0] += twn[i]/2;
    }
  }

  return res;
}

int main()
{
  int N, M, T=1;
  while(cin >> N >> M, (N||M)) {
    
    cout << "Case " << T++ << ": " << solve(N,M) << endl; 
  }
}

Measured memory_bytes: 868
n=int(input())
A=[0]*105
for i in range(1,n+1):
    x=str(i)
    A[int(x[0]+x[len(x)-1])]+=1
ans=0
for i in range(11,100):
    y=str(i)
    if '0' in y:
        continue
    ans+=A[i]*A[int(y[1]+y[0])]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

long long n, a, b;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld %lld",&n ,&a ,&b);
		printf("%lld\n", (((n - 1)*b + a) - ((n - 1)*a + b) + 1) * ((((n - 1)*b + a) - ((n - 1)*a + b) + 1) > 0)  );
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define INF 1e9

int main(){
  int n;
  cin >> n;
  string ss;
  int s[n][n];
  for(int i=0;i<n;i++){
    cin >> ss;
    for(int j=0;j<ss.length();j++){
      if(ss[j] == '0') s[i][j] = 0;
      else s[i][j] = 1;
    }
  }

  stack<int> q;
  q.push(0);
  int r;
  int color[n];
  for(int i=0;i<n;i++) color[i] = -1;
  color[0] = 0;
  int c;
  bool flag = false;
  while(!q.empty()){
    r = q.top();
    q.pop();
    c = 1 - color[r];
    for(int i=0;i<n;i++){
      if(s[r][i] == 1){
        if(color[i] == -1){
          color[i] = c;
          q.push(i);
        }
        else{
          if(color[i] != c){
            flag = true;
          }
        }
      }
    }
  }

  if(flag){
    cout << -1 << endl;
    return 0;
  }



  int a[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(s[i][j]) a[i][j] = 1;
      else a[i][j] = INF;
    }
    a[i][i] = 0;
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
      }
    }
  }

  int ma = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i][j] != INF) ma = max(ma,a[i][j]);
    }
  }
  cout << ma+1 <<endl;

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_V 10
using namespace std;
int E, V;
int dp[MAX_V][MAX_V];

void warshall_floyd(){
	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
}

int main(){
	while(~scanf("%d", &E) && E){
		V = 0;
		memset(dp, 0x3f, sizeof(dp));
		for(int i = 0; i < E; i++){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			dp[a][b] = dp[b][a] = min(dp[a][b], c);
			V = max(V, max(a, b));
		}
		++V;
		for(int i = 0; i < V; i++) dp[i][i] = 0;
		warshall_floyd();
		int idx, minsum = INF;
		for(int i = 0; i < V; i++){
			int sum = 0;
			for(int j = 0; j < V; j++) sum += dp[i][j];
			if(sum < minsum) minsum = sum, idx = i;
		}
		printf("%d %d\n", idx, minsum);
	}
	return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      while (true){
         int a = Integer.parseInt(sc.next());
         String op = sc.next();
         int b = Integer.parseInt(sc.next());
         if ("?".equals(op)) break;
         if ((a >= 0 && a <= 20000) && (b >= 0 && b <= 20000)) {
            if ("+".equals(op)) {
               System.out.println(a + b);
            } else if ("-".equals(op)) {
               System.out.println(a - b);
            } else if ("*".equals(op)) {
               System.out.println(a * b);
            } else if ("/".equals(op)) {
               System.out.println(a / b);
            }
         }
      }
   }
}

Measured memory_bytes: 17156
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
int N,a[maxn],ans[maxn];
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read()*2;
	long long tmp=a[1];
	for(int i=2;i<=N-1;i++)
		tmp=a[i]-tmp;
	tmp+=a[N];
	tmp/=2;
	ans[N]=tmp;
	for(int i=N-1;i>=1;i--)
		ans[i]=a[i]-ans[i+1];
	for(int i=1;i<N;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[N]);
	return 0;
}



Measured memory_bytes: 2048
R, G, B, N = list(map(int, input().split()))
m = 0
NN = N
for r in range(N//R + 1) :
  if r != 0 :
    NN -= R
  for g in range(NN//G + 1) :
    if g == 0 :
      NNN = NN
    else :
      NNN -= G
    if NNN%B == 0 :
      m += 1

print(m)

Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 100
int adj[MAX+1][MAX+1];
int time=0,n;
int d[MAX+1],f[MAX+1];
void search(int p){
	int i;
	if(d[p]==0){
		time++;
		d[p]=time;
		for(i=1;i<=n;i++){
			if(adj[p][i]==1)search(i);
		}
		time++;
		f[p]=time;
	}
}
int main(void){
	int i,j,u,k,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		d[i]=0;f[i]=0;
		for(j=1;j<=n;j++)adj[i][j]=0;
	}
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			adj[u][v]=1;
		}
	}
	for(i=1;i<=n;i++)search(i);
	for(i=1;i<=n;i++)printf("%d %d %d\n",i,d[i],f[i]);
	return 0;
}




Measured memory_bytes: 2036
// panasonic2020_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    print(arr[K-1]);




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  ll temp;
  std::vector<ll> odd;
  std::vector<ll> even;
  for(ll i=1;i<=n;i++)
  {
    cin >> temp;
    if(i%2==0){
      odd.push_back(temp);
    }
    else{
      even.push_back(temp);
    }
  }
  if(n%2!=0){
    for(ll i=even.size()-1;i>=0;i--)
    {
      cout << even[i] << ' ';
    }
    for(ll i=0;i<odd.size();i++)
    {
      cout << odd[i] << ' ';
    }
  }
  else{
    for(ll i=odd.size()-1;i>=0;i--)
    {
      cout << odd[i] << ' ';
    }
    for(ll i=0;i<even.size();i++)
    {
      cout << even[i] << ' ';
    }
  }
  return 0;
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<string>> a(n,vector<string>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void debug(auto a);

signed main(){
    string a;
    cin >> a;
    int n = a.size();
    n--;
    bool ans=true;
    if(a[0] !='k'){
        ans = false;
    }
    if(a[n] != 'e'){
        ans = false;
    }
    if(a[1] != 'e' && a.substr(n-5,6) != "eyence"){
        ans = false;
    }
    if(a[2] != 'y' && a.substr(n-4,5) != "yence"){
        ans = false;
    }
    if(a[3] != 'e' && a.substr(n-3,4) != "ence"){
        ans = false;
    }
    if(a[4] != 'n' && a.substr(n-2,3) != "nce"){
        ans = false;
    }
    if(a[5] != 'c' && a.substr(n-1,2) != "ce"){
        ans = false;
    }
    if(ans){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}
void debug(auto a){
    cout << "{ ";
    int len = a.size();
    REP(i,len){
        cout << a[i] << " ";
    }
    
    cout << "}" << endl;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int mult(int a, int b)
{
    return (a * 1LL * b) % MOD;
}

const int N = 2e5 + 1;

char s[N];

int main()
{
    int n;
    scanf("%d %s", &n, s);
    vector<int> zero, one;
    for (int i = 0; i < 2 * n; ++i)
    {
        if ((s[i] == 'W') ^ (i & 1))
            one.push_back(i);
        else
            zero.push_back(i);
    }
    
    if ((int)one.size() != n)
    {
        printf("0");
        return 0;
    }

    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        static int pos = 0;
        while(pos < n && one[i] > zero[pos]) ++pos;
        ans = mult(ans, pos - i);
        ans = mult(ans, i + 1);
    }

    printf("%d", ans);
}


Measured memory_bytes: 1912
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LL long long

LL baai(int x){
  if(x==0) return 1;
  LL r=1;
  REP(i, x-1) r*=2;
  return r;
}

int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(n==1){
    cout<<s<<endl;
    return 0;
  }

  LL ans=0;
  for(int i=1; i<=n; ++i){
    for(int j=0; j<n-i+1; ++j){
      ans += stoll(s.substr(j, i)) * baai(j) * baai(n-i-j);
      //cout<<stoll(s.substr(j, i))<<" "<<ans<<endl;;
    }
  }
  cout<<ans<<endl;




  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, n, m[100][100], p[100], a, l, k, q=0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    if(i < n - 1) scanf("%d%d", &p[i], &a);
    else scanf("%d%d", &p[i], &p[i + 1]);
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      m[i][j] = 0;
    }
  }

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = 100000;
      for(k = i; k < j; k++){
	q = m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j];
	if(m[i][j] > q) m[i][j] = q;
      }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}

Measured memory_bytes: 632
import collections

N = int(input())

n_AC = 0
n_WA = 0
n_TLE = 0
n_RE = 0

lst = []
for _ in range(N):
  lst.append(input())
  
c = collections.Counter(lst)

print("AC x ",c["AC"])
print("WA x ",c["WA"])
print("TLE x ",c["TLE"])
print("RE x ",c["RE"])


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

int main(){
  int a, b, x;
  cin >> a >> b;
  x = (a * b) % 2;
  if (x == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<pair<int, int> > > data(n);
  for (int i = 0; i < n; i++) {
    int sz;
    cin >> sz;
    data[i].resize(sz);
    for (int j = 0; j < sz; j++) {
      cin >> data[i][j].first >> data[i][j].second;
      data[i][j].first--;
    }
  }
  int mask = (1 << n) - 1;
  while (mask > 0) {
    int ppl = mask, i = n - 1;
    bool poss = true;
    while (ppl) {
      if (ppl & 1) {
        for (pair<int, int> p : data[i]) {
          int id = n - 1 - p.first;
          if (p.second && !((1 << id)&mask) || !p.second && (1 << id)&mask)
            poss = false;
        }
      }
      ppl /= 2;
      i--;
    }
    if (poss)
      break;
    mask--;
  }
  cout << __builtin_popcount(mask);
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		if(N % 2 == 1)
		System.out.println(N / 2 + 1);
		else
		System.out.println(N / 2);
	}
}

Measured memory_bytes: 35780
#include <cstdio>
#include <algorithm>

long long A[201000], sum[201000];
int n;
long long check(int x, int l, int r)
{
	return (sum[x] - sum[l - 1]) - (sum[r] - sum[x]);
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &A[i]), sum[i] = sum[i - 1] + A[i];
	long long ans = 1e18;
	for(int i = 1; i <= n - 1; i++)
	{
		int l = 1, r = i + 1;
		while(l < r)
		{
			int mid = l + r >> 1;
			if(check(mid, 1, i) >= 0) r = mid;
			else l = mid + 1; 
		}
		//r, r - 1
		int L = i + 1, R = n + 1;
		while(L < R)
		{
			int mid = L + R >> 1;
			if(check(mid, i + 1, n) >= 0) R = mid;
			else L = mid + 1; 
		}
		// R, R - 1;
		for(int a = r; a >= r - 1; a--)
			for(int b = R; b >= R - 1; b--)
			{
				long long s1 = sum[a];
				long long s2 = sum[i] - sum[a];
				long long s3 = sum[b] - sum[i];
				long long s4 = sum[n] - sum[b];
				long long Min = std::min(std::min(s1, s2), std::min(s3, s4));
				long long Max = std::max(std::max(s1, s2), std::max(s3, s4));
				ans = std::min(ans, Max - Min);
			}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  map<int, int> mp;
  int tmp;
  REP(i,n){
    cin >> tmp;
    mp[tmp] ++;
  }
  // for(auto itr = mp.begin(); itr != mp.end(); ++itr){
  //   cout <<setw(4)<<right<< itr->first <<itr->second << endl;
  // }
  int ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++ itr){
    int key = itr->first;
    int num = itr->second;
    if(key < num){
      ans += num - key;
    }
    if(key > num){
      ans += num;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4736
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class Program
{

    static int MAX = 0;
    static List<long> hp = null;
    static Func<int, int> left = (v) => v * 2;
    static Func<int, int> right = (v) => v * 2 + 1;


    static void Main(string[] args)
    {

        long n = long.Parse(Console.ReadLine());
        long[] inp = null;
        inp = Console.ReadLine().Split(' ').Select(z => long.Parse(z)).ToArray();

        MAX = (int)n;
        hp = new List<long>(new long[MAX + 1]);


        for (int i = 0; i < inp.Length; i++)
        {
            hp[i + 1] = inp[i];
        }

        buildMaxHeap();

        var s = new StringBuilder();
        for (int i = 1; i < hp.Count; i++)
        {
            s.Append(" ");
            s.Append(hp[i].ToString());
        }

        Console.WriteLine(s.ToString());
    }


    static void maxHeapify(int i)
    {
        int l = left(i);
        int r = right(i);
        int largest = i;

        if (l <= MAX && hp[l] > hp[i])
        {
            largest = l;
        }

        if (r <= MAX && hp[r] > hp[largest])
        {
            largest = r;
        }

        if (largest != i)
        {
            long sw = hp[i];
            hp[i] = hp[largest];
            hp[largest] = sw;

            maxHeapify(largest);
        }
    }

    static void buildMaxHeap()
    {
        for (int i = MAX / 2; i > 0; i--)
        {
            maxHeapify(i);
        }
    }
}



Measured memory_bytes: 72860
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        String s = "NG";
        for (int i = a;i<=b;++i)
        {
            if (i%k == 0)
            {
                s = "OK";
                break;
            }
        }
        System.out.println(s);

        sc.close();
    }
}

Measured memory_bytes: 35708
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
using mint=modint998244353;
struct S{mint a,b;};
S op(S a,S b){return S{a.a+b.a,a.b+b.b};}
S e(){return S{0,0};}
struct F{mint m,s;};
S mapping(F f,S x){return S{x.a*f.m+x.b*f.s,x.b};}
F composition(F f,F g){return F{g.m*f.m,g.s*f.m+f.s};}
F id(){return F{1,0};}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    vec A(n);
    rep(i,n) cin>>A[i];
    lazy_segtree<S,op,e,F,mapping,composition,id> B(n);
    rep(i,n) B.set(i,{A[i],1});
    rep(query,q){
        int x;
        cin>>x;
        if(x==0){
            ll l,r,b,c;
            cin>>l>>r>>b>>c;
            B.apply(l,r,F{b,c});
        }
        else{
            ll l,r;
            cin>>l>>r;
            cout<<B.prod(l,r).a.val()<<"\n";
        }
    }
}

Measured memory_bytes: 23284