akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

#define NIL -1

typedef struct {
  int parent, left, right;
} Node;
Node T[100];

void preorder(int key) {
  if (key == NIL) return;

  cout << " " << key;
  preorder(T[key].left);
  preorder(T[key].right);
}
void inorder(int key) {
  if (key == NIL) return;

  inorder(T[key].left);
  cout << " " << key;
  inorder(T[key].right);
}
void postorder(int key) {
  if (key == NIL) return;

  postorder(T[key].left);
  postorder(T[key].right);
  cout << " " << key;
}

int main() {
  int n;
  cin >> n;
  // Node T[n + 10];

  REP(i, n + 10) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  REP(i, n) {
    int key, left, right;
    cin >> key >> left >> right;

    T[key].left = left;
    T[key].right= right;
    if (left != NIL) T[left].parent = key;
    if (right != NIL) T[right].parent = key;
  }

  // calc depth
  int root = NIL;
  REP(i, n) {
    if (T[i].parent == NIL) {
      root = i;
      break;
    }
  }

  cout << "Preorder" << endl;
  preorder(root);
  cout << endl;

  cout << "Inorder" << endl;
  inorder(root);
  cout << endl;

  cout << "Postorder" << endl;
  postorder(root);
  cout << endl;


  return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)


int main(){
    int a,b,c;
    ll k;
    cin>>a>>b>>c>>k;
    if(k%2){
        cout<<b-a<<endl;
    }else{
        cout<<a-b<<endl;
    }
    return 0;
}


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

int dp[3001][3001];

int main()
{
    string s, t;
    cin>>s>>t;
    memset(dp, 0, sizeof(dp));
    int l1=s.size(), l2=t.size();
    for(int i=1;i<=l1;i++)
    {
        for(int j=1;j<=l2;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string ans="";
    int i=l1, j=l2;
    while(1)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;j--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
        if(dp[i][j]==0)
        {
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 35456
///In the name of Almighty Allah(swt).

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,result,i,j;
    cin>>a;
    i = a*a;
    j = i*a;
    result = a+i+j;
    cout<<result<<endl;

    return 0;
}


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

using namespace std;

int main()
{
	string S;
	cin >> S;

	string T = "CODEFESTIVAL2016";

	int count = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			count++;
		}
	}
	cout << count << endl;

}


Measured memory_bytes: 3572
#include<stdio.h>

int main()
{
  int a,b,c,x,y;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  if(a+b<2*c){
    printf("%d",a*x+b*y);
    return 0;
  }
  if(a+b>=2*c){
    if(x>=y){
      if(a<=2*c){
        printf("%d",y*2*c+a*(x-y));
        return 0;
      }
      if(a>2*c){
        printf("%d",x*2*c);
        return 0;
      }
    }
    if(x<y){
      if(b<=2*c){
        printf("%d",x*2*c+b*(y-x));
        return 0;
      }
      if(b>2*c){
        printf("%d",y*2*c);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
long i,j,k,n,m,P,f[303][303][303];main(){std::cin>>n>>m>>P;for(f[i=0][1][0]=1;i<=n;i++)for(j=0;m/++j;)for(k=i;~k;k--)((k?f[i][j][k-1]:f[i][j+1][i])+=f[i][j][k])%=P,(f[i+1][j][k]+=f[i][j][k]*(1+k)%P)%=P;std::cout<<f[n][m][0];}

Measured memory_bytes: 217344
S=input()


c=0
m=0
for i in range(len(S)):
	if(S[i]=="A" or S[i]=="T" or S[i]=="G" or S[i]=="C"):
		c+=1
	else:
		if(m<=c):
			m=c
		c=0
if(m<=c):
	m=c
print(m)





Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = int64_t;

int main(){
    string s; cin >> s;
    deque<char> dq;
    for(char c : s) dq.push_back(c);
    int q; cin >> q;
    bool rev = false;
    rep(i, q){
        int t; cin >> t;
        if(t == 1){
            rev = !rev;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if(f == 1){
                if(rev) dq.push_back(c);
                else dq.push_front(c);
            } else {
                if(rev) dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
    if(rev) reverse(all(dq));
    for(char c : dq) cout << c;
    cout << endl;

    return 0;
}

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

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

    vector<int> A(N+2);
    A[0] = 0;
    for(int i=1;i<N+1;i++){
        cin >> A[i];
    }
    A[N+1] = 0;

    vector<int> dist(N+1);
    unsigned long long sum_dist = 0;
    for(int i=0;i<N+1;i++){
        dist[i] = abs(A[i+1]-A[i]);
        sum_dist += dist[i];
    }

    for(int i=1;i<N+1;i++){
        unsigned long long d = sum_dist;
        d = d - dist[i-1] - dist[i];
        d = d + abs(A[i+1]-A[i-1]);
        cout << d << endl;
    }
    return 0;
}


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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3, y3, x4, y4;
	int dx = x2 - x1;
	int dy = y2 - y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x3 - dx;
	y4 = y3 - dy;
	cout << x3<<" "<< y3<<" " << x4 << " " << y4 <<endl;
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int x = inp.nextInt();
        int y = inp.nextInt();
        int g1[] = {1, 3, 5, 7, 8, 10, 12};
        int g2[] = {4, 6, 9, 11};
        int g3[] = {2};
        int xg = 0; int yg = 0;
        for (int i = 0; i < 7; i++) {
            if (g1[i] == x) {
                xg = 1;
            }
            if (g1[i] == y) {
                yg = 1;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (g2[i] == x) {
                xg = 2;
            }
            if (g2[i] == y) {
                yg = 2;
            }
        }
        if (2 == x) {
            xg = 3;
        }
        if (2 == y) {
            yg = 3;
        }
        System.out.println(xg == yg ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

const ll INF = 1E18+5;
const ll mod = 1E9+7;

int main(){
    ll n;
    double d;
    cin>>n>>d;
    vector<double> x(n),y(n);
    int i;
    for(i=0;i<n;i++)
        cin>>x[i]>>y[i];
    int ans = 0;
    for(i=0;i<n;i++)
    {
        double length = sqrt(x[i]*x[i]+y[i]*y[i]);
        if(length<=d)
            ans++;
    }
    cout<<ans;
}




Measured memory_bytes: 6492
#include <cstdio>

long long a[222222], cnt[222222];

int main(void)
{
	long long ans = 0, n, i;

	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}

	for (i = 1; i <= n; i++)
		ans += cnt[i] * (cnt[i] - 1) / 2;

	for (i = 1; i <= n; i++)
		printf("%lld\n", ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2);
	return 0;
}

Measured memory_bytes: 4608
K = int(input())

g2 = [[0]*(K+1) for _ in range(K+1)]
def gcd(a, b):
    if g2[a][b] > 0:
        return g2[a][b]
    tmpa = a
    tmpb = b
    while b > 0:
        a,b = b, a%b
    g2[tmpa][tmpb] = a
    g2[tmpb][tmpa] = a
    return a

def gcd_3(a,b,c):
    g = gcd(a,b)
    g = gcd(g,c)
    return g

sm = 0
for a in range(1, K+1):
    sm += a
    for b in range(a+1, K+1):
        for c in range(b+1, K+1):
            sm += gcd_3(a,b,c) * 6
    for b in range(1, K+1):
        if a != b:
            sm += gcd(a,b) * 3

print(sm)


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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    long A,B,C;
    cin >>A>>B>>C;
    
    
    
    
    
    
    
    //計算
    long ans=0;
    if(A%2==1 &&B%2==1 &&C%2==1){
        ans=min(A*B,min(A*C,B*C));
    }
    
    //出力
    cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){

int N;
int n[11]={};
char ch;
cin>>N;
for(int iii=0;iii<N;iii++){
for(int i=0;i<9;i++){
cin>>n[i];
}
for(int i=0;i<9;i++){
cin>>ch;
if(ch=='G')n[i]+=10;
if(ch=='B')n[i]+=20;
}
sort(n,n+9);
bool f1=false,f2=false,f3=false,f4;
/*
for(int i=0;i<9;i++)
	cout<<n[i];
cout<<endl;
*/
if(n[0]==n[1]&&n[0]==n[2])f1=true;
if(n[1]==n[0]+1&&n[2]==n[1]+1)f1=true;

if(n[3]==n[4]&&n[3]==n[5])f2=true;
if(n[4]==n[3]+1&&n[5]==n[4]+1)f2=true;

if(n[6]==n[7]&&n[6]==n[8])f3=true;
if(n[7]==n[6]+1&&n[8]==n[7]+1)f3=true;


if(n[0]==n[1]&&n[2]==n[3]&&n[4]==n[5])f4=true;
if(n[2]==n[0]+1&&n[4]==n[2]+1&&f4==true){f1=true;f2=true;}

if(n[3]==n[4]&&n[5]==n[6]&&n[7]==n[8])f4=true;
if(n[5]==n[3]+1&&n[7]==n[5]+1&&f4==true){f2=true;f3=true;}


int g=0;
if(f1&&f2&&f3)g=1;
cout<<g<<endl;
}
return 0;
}

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

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

int main() {
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b});
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << " ";
    }
    return os;
}

vector<vector<ll>> tree;
vector<ll> ans;

void dfs(ll i, ll p) {
    FOREACH(x, tree[i]) {
        if (x != p) {
            // cout << i << x << endl;
            ans[x] += ans[i];
            // cout << ans << endl;
            dfs(x, i);
        }
    }
}

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

    tree.resize(N+1);
    ans.resize(N+1);

    REP(i, N-1) {
    	ll a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    REP(i, Q) {
    	ll p, x;
        cin >> p >> x;
        ans[p] += x;
    }

    // cout << ans << endl;
    dfs(1, -1);

    for (int i = 1; i < N+1; ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e+6;

int n,m;
vector<int> adj[N];
bool vis[N];
int dp[N];

int dfs(int i)
{
	if(dp[i]!=-1)
	{
		return dp[i];
	}

	vis[i]= true;

	int ans = 0;
	for(int j=0;j<adj[i].size();j++)
	{
		ans  = max(dfs(adj[i][j])+1,ans);
	}

	return dp[i] = ans;
}
int32_t main()
{
	cin>>n>>m;
	memset(vis,false,sizeof(vis));
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;

		adj[u].push_back(v);
	}

	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}

	int ans = -1;
	for(int i=1;i<=n;i++)
	{
		ans = max(ans,dp[i]);
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 37632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc100/tasks/abc100_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll D,N; cin >> D >> N;
    res = pow(100,D) * (N==100?101:N);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define P pair
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
int main()
{
	ins(n);ins(t);
    V<P<int,int> > c(n);
    rep(i,n){
    	cin >> c.at(i).first >> c.at(i).second;
    }
    sortall(c);
    rep(i,n){
    	if(c.at(i).second<=t){
    		print(c.at(i).first);
    		return 0;
    	}
    }
    print("TLE");
    return 0;
}

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

int a[]={1868,1912,1926,1989};
char b[]={'M','T','S','H'};
  
int main(){
  int E,Y;
  cin>>E>>Y;
  if(E==0){
    int i=upper_bound(a,a+4,Y)-a-1;
    cout<<b[i]<<Y-a[i]+1<<endl;
  }else{
    cout<<a[E-1]+Y-1<<endl;
  }
  return 0;
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

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

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
       ll n,m;
       cin>>n>>m;
       ll p[m];
       string s[m];
       map<ll,ll>m1;
       ll ans1=0,ans2=0;
       for(ll i=0;i<m;i++)
       {
           cin>>p[i]>>s[i];
           if(s[i]=="AC")
           {
              if(m1[p[i]]!=-1)
              {
                  ans2+=m1[p[i]];
                  m1[p[i]]=-1;
                  ans1++;
              }
           }
           else
           {
               if(m1[p[i]]!=-1)
                 m1[p[i]]++;
           }
       }
       cout<<ans1<<" "<<ans2<<endl;
    }
}


Measured memory_bytes: 13836
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  _, k = map(int, input().split())
  vs = [int(v == 'L') for v in input().strip()]
  h = sum(int(a == b) for a, b in zip(vs[:-1], vs[1:]))
  print(min(h + 2 * k, len(vs) - 1))


if __name__ == '__main__':
  main()


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

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
  {
    cin >> a[i];
    a[i] /= 2;
  }
  bool ok = true;
  i64 s = 1;
  for (i64 i = 0; i < n; i++)
    s = s / __gcd(s, a[i]) * a[i];
  i64 t = 1, ans = 0;
  while (s * t <= m)
  {
    ans++;
    t += 2;
  }
  for (i64 i = 0; i < n; i++)
    if ((s / a[i]) % 2 == 0)
      ok = false;
  if (ok)
    cout << ans << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j;
int main()
{
    ll n;
    scanf("%lld",&n);
    ll a[n];
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    ll m;
    scanf("%lld",&m);
    ll b[m];
    for(i=0;i<m;i++)
        scanf("%lld",&b[i]);
    sort(a,a+n);
    sort(b,b+m);
    for(i=0;i<m;i++)
    {
        ll key=b[i];
        ll lo=0,hi=n-1,mid;
        while(hi-lo>1)
        {
            mid=(lo+hi)/2;
            if(a[mid]>=key)
                hi=mid;
            else
                lo=mid;
        }
        if(a[lo]!=key&&a[hi]!=key)
        {
            printf("NO\n");
            return 0;
        }

        ll p1;
        if(a[lo]==key)
            p1=lo;
        else
            p1=hi;
        lo=0,hi=n-1;
        while(hi-lo>1)
        {
            mid=(lo+hi)/2;
            if(a[mid]<=key)
                lo=mid;
            else
                hi=mid;
        }
        ll p2;
        if(a[hi]==key)
            p2=hi;
        else
            p2=lo;
        ll tot=p2-p1+1;
        ll tmp=0;
        for(j=i;j<m;j++)
        {
            if(b[j]==key)
                tmp++;
            else
                break;
        }
        if(tmp>tot)
        {
            printf("NO\n");
            return 0;
        }
        else
            i=i+tmp-1;
    }
    printf("YES\n");
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define LINF LLONG_MAX
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define P pair<int,int>
#define prique priority_queue
#define F first
#define S second
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s.substr(0,4)=="YAKI") puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] d = new int[n];
      	for (int i = 0; i < n; i++) {
        	d[i] = sc.nextInt();
        }
      
      	int ans = 0;
		for (int k = 0; k < d.length - 1; k++) {
			for (int l = k + 1; l < d.length; l++) {
            	ans += d[k] * d[l];
            }
        }
      
      	System.out.println(ans);
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> B(N);
  B = A;
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int M1 = B.at(0);
  int M2 = B.at(1);
  for(int i = 0; i < N; i++){
    if(A.at(i) == M1) cout << M2 << endl;
    else cout << M1 << endl;
  }
}

Measured memory_bytes: 3200
#include <stdio.h>

double kyori(double x, double y)
{
	return  	x * x + y * y;
}

int main(void)
{
  	int n;
  	int d;
  	int x[200002];
  	int y[200002];
  	int	i;
  	int cnt;
  	double dd;
  
  	scanf("%d %d\n", &n, &d);
  	for(i=0; i<n; i++)
    {
      	scanf("%d %d\n", &x[i], &y[i]);
    }
  	
  	cnt = 0;
  	dd = (double)d * d;
  	for(i=0; i<n; i++)
    {
      	if(dd >= kyori(x[i], y[i]))
          	cnt++;
    }
  
  	printf("%d", cnt);
  	return (0);
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main(){
    int n,q;
    ll ans=0;
    map<int,int> cnt;
    cin >> n;
    vector<int> retu(n);
    vector<pair<int,int>> sousa;
    rep(i,n) cin >> retu[i];
    cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        sousa.push_back(make_pair(a,b));
    }

    rep(i,n) ans += retu[i];
    
    rep(i,n) cnt[retu[i]]++;
    
    rep(i,q){
        int a,b;
        tie(a,b) = sousa[i];
        int k = b-a;
        ans += k*cnt[a];
        cout << ans << endl;
        cnt[b] += cnt[a];
        cnt[a] = 0;
    }
    
}

Measured memory_bytes: 8784
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n",d,r,f);
    return 0;
    
}



Measured memory_bytes: 2732
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 1005;
int dp[MAXN], x[MAXN];

int n, p;

vector<vector<int>> adj;

set<int> knapsack, t_knapsack;

bool ok;

void dfs(int u, int par) {
    for (auto& v : adj[u]) if (v != par) dfs(v, u);

    knapsack.clear();
    knapsack.insert(0);

    int sum = 0;

    for (auto& v : adj[u]) {
        if (v != par) {
            sum += x[v] + dp[v];

            t_knapsack.clear();

            for (auto& k : knapsack)
            {
                t_knapsack.insert(k + x[v]);
                t_knapsack.insert(k + dp[v]);
            }

            swap(knapsack, t_knapsack);
        }
    }

    auto it = knapsack.upper_bound(x[u]);

    if (it == knapsack.begin()) {
        ok = false;
    }
    else {
        it--;
        dp[u] = sum - *it;
    }
}

int main() {
    GI(n);

    adj.resize(n+1);

    for (int i = 2; i <= n; i++) {
        GI(p);

        adj[i].PB(p);
        adj[p].PB(i);
    }

    FOR1(i, n) {
        GI(x[i]);
    }

    memset(dp, 0, sizeof dp);

    ok = true;
    dfs(1, -1);

    if (ok) {
        printf("POSSIBLE\n");
    }
    else {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int a[10000],b[10000];
int s;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++) s+=b[i]-a[i]+1;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18

void solve()
{
   int n;
   cin>>n;
   if(n%1000==0) cout<<"0"<<endl;
   else
   {
       int num=(n/1000)+1;
       cout<<num*1000-n<<endl;
   }
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}


Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0)break;
		int count=0;
		bool na=true;
		int k;
		for(int i=0;i<n;i++){
			cin>>k;
			if(k>1)
				na=false;
			if(k>0)
				count++;
		}
		if(na==true)
			cout<<"NA"<<endl;
		else
			cout<<count+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 10'000;
int opt[2][N/2+1][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n);
    for(int i = 1; i < n; i++) {
        cin >> t[i];
    }
    for(int a = n / 2; a >= 0; a--) {
        for(int b = n / 2; b >= 0; b--) {
            for(bool last_a : {0, 1}) {
                int i = a + b;
                if(i == n) {
                    opt[a&1][b][last_a] = 0;
                } else {
                    opt[a&1][b][last_a] = min(
                        a + 1 <= n / 2 ? opt[(a+1)&1][b][1] + (1 - last_a) * t[i] : lim<int>::max(), 
                        b + 1 <= n / 2 ? opt[a&1][b+1][0] + last_a * t[i] : lim<int>::max()
                    );
                }
            }
        }
    }
    cout << opt[0][0][0] << endl;
    return 0;
}



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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m,x,y;
	cin >> n >> m;
	vector<ll> adjlist[n+1];
	for(ll i=0; i<m; i++){
		cin >> x >> y;
		adjlist[x].emplace_back(y);
		adjlist[y].emplace_back(x);
	}
	for(ll i=1; i<=n; i++)
		cout << adjlist[i].size() << "\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0, sum = 0, num = 0, tot = 0;
  cin >> n;
  vector<ll> a(n), b(n), p;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  rep(i, n) {
    ll d = a[i] - b[i];
    tot += d;
    if (d < 0)
      sum += d, num++;
    else
      p.push_back(d);
  }

  if (tot < 0) {
    puts("-1");
    return 0;
  }

  sort(p.rbegin(), p.rend());

  if (sum < 0) {
    rep(i, p.size()) {
      sum += p[i];
      num++;
      if (sum >= 0) break;
    }
  }

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 2936
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,d;
	cin>>n>>d;
	int answer=0;
	int j;
	for(j=0;j<n;j++)
	{
		int x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
		   answer++;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  ll sum = a[0];
  rep(i, n-2){
    sum += a[i/2+1];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
constexpr ll MOD = 1e9+7;

int N, seg[4000004] = { 0 }, tmp[4000004] = { 0 }, ans = 0;
inline int fast_mod(int i) { return i >= MOD ? i - MOD : i; }
void pull(int n) { seg[n] = fast_mod(seg[n << 1] + seg[n << 1 | 1]); }
void push(int l, int r, int n) {
	seg[n] = ((ll)(r - l + 1) * tmp[n] + seg[n]) % MOD;
	if (l != r) tmp[n << 1] = fast_mod(tmp[n] + tmp[n << 1]), tmp[n << 1 | 1] = fast_mod(tmp[n] + tmp[n << 1 | 1]);
	tmp[n] = 0;
}
void update_range(int a, int b, int v, int l = 0, int r = -1, int n = 1) {
	if (r == -1) r = N - 1;
	push(l, r, n);
	if (l > b || r < a) return;
	if (l >= a && r <= b) {
		tmp[n] = fast_mod(v + tmp[n]);
		push(l, r, n);
	}
	else {
		int m = (l + r) >> 1;
		update_range(a, b, v, l, m, n << 1), update_range(a, b, v, m + 1, r, n << 1 | 1);
		pull(n);
	}
}
int query(int a, int b, int l = 0, int r = -1, int n = 1) {
	if (r == -1) r = N - 1;
	if (a > b || l > b || r < a) return 0;
	push(l, r, n);
	if (l >= a && r <= b) return seg[n];
	int m = (l + r) >> 1;
	return fast_mod(query(a, b, l, m, n << 1) + query(a, b, m + 1, r, n << 1 | 1));
}

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

	cin >> N;
	update_range(0, 0, 1);
	for (int i = 0; i < N - 1; ++i) {
		int v = query(i, i);
		update_range(i + 1, i + 1, v);
		update_range(i + 3, N - 1, v);
		ans = (((min(i + 2, N - 1) + (ll)(N - 1) * (N - 1)) % MOD) * v + ans) % MOD;
	}
	cout << (ans + (ll)N * query(N - 1, N - 1)) % MOD << '\n';
	/*dp[0] = 1;
	for (int i = 0; i < n - 1; ++i) {
		dp[i + 1] += dp[i];
		for (int j = 2; j <= n; ++j) {
			if (i + j + 1 > n - 1) ans += dp[i];
			else dp[i + j + 1] += dp[i];
		}
		ans += (n - 1) * (n - 1) * dp[i];
	}
	cout << ans + n * dp[n - 1] << '\n';*/
}

Measured memory_bytes: 20736
import java.util.*;

public class Main {

   public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int l = sc.nextInt();
      int r = sc.nextInt();
      int d = sc.nextInt();
      int ans = r/d - (l-1) / d;

      System.out.println(ans);

   }  
}


Measured memory_bytes: 35484
using System;
using System.Linq;

namespace ABC
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            ABC104_B();
        }


        static void ABC104_B()
        {
            var S = Console.ReadLine();

            var cCount = 0;
            var cIndex = 0;
            for (var i = 2; i < S.Length-1; i++)
            {
                if (S[i] == 'C')
                {
                    cCount++;
                    cIndex = i;
                }
            }

            var komoji = true;
            for (var i = 1; i < S.Length; i++)
            {
                if (cIndex == i)
                    continue;

                if (char.IsUpper(S[i]))
                {
                    komoji = false;
                    break;
                }
            }

            if (cCount != 1 || S[0] != 'A' || !komoji)
            {
                Console.WriteLine("WA");
                return;
            }

            Console.WriteLine("AC");
        }
    }
}

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

int main(){
 
  int change=0;
  string s;
  cin>>s;
  int len = s.length();
  int half_len = len/2;
  
  for(int i=0;i<half_len;i++){
    if(s.at(i)!=s.at(len-i-1)){
      change++;
    }
  }
  
  cout<<change<<endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <iterator>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N;
	cin >> S;
	int sum = 0;
	int c_r = 0;
	int c_g = 0;
	int c_b = 0;

	for(int i=0;i<N;i++){
		if(S.at(i)=='R') {
			c_r++;
		}else if(S.at(i)=='G'){
			c_g++;
		}else{
			c_b++;
		}
	}
	
	sum = c_r*c_g*c_b;
	
	int res = 0;
	for(int i=0;i<N;i++){
		for(int d=1;d<N/2+1;d++){
			if(i+2*d>=N){
				break;
			}
			if(S.at(i)!=S.at(i+d) && S.at(i+d)!=S.at(i+2*d) && S.at(i)!=S.at(i+2*d)){
				res++;
			}
		}		
	}

	cout << sum - res << endl;
	
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(short i = 0; i < n; i++)



int main() {
    int n;
    
    cin >> n;
    
    cout << n * 800 - n / 15 * 200 << endl;
}



Measured memory_bytes: 256
S = input()
word5 = ['dream','erase']
word6 = ['dreamer',]

i = len(S)

while True:
	if i - 5 < 0:
		break

	if S[i-5:i] in word5:
		i -= 5

	elif i - 6 >= 0 and S[i-6:i] == 'eraser':
		i -= 6

	elif i - 7 >= 0 and S[i-7:i] == 'dreamer':
		i -= 7

	else:
		break

if i == 0:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;cin>>q;
    vector<ull> a(q), b(q);
    ull m,n;
    rep(i,q) cin>>a[i]>>b[i];
    rep(i,q) {
        m = min(a[i],b[i]);
        n = max(a[i],b[i]); 
        ull tmp = sqrtl(m*n-1), res=tmp*2;
        if (m == n) {
            cout << max(m*2-2,0ULL) << endl;
        } else if(m+1==n) {
            cout << max(2*m-2,0ULL) << endl;
        }
        else if (tmp*(tmp+1)>=m*n) {
            cout << max(res-2,0ULL) << endl;
        }else {
            cout << max(res-1,0ULL) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
xy = input()
XY = xy.split()
X = int(XY[0])
Y = int(XY[1])

a = True
i = 1

if X < Y:
    print(X)
    a = False
elif X > Y and X % Y != 0:
    while X * i <= X * Y:
        if (X * i) % Y != 0:
            print(X * i)
            a = False
            break
        else:
            i += 1
if a:
    print(-1)

Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $k);
$a_div = [];
$b_div = [];
$ab_div = [];
for ($i = 1; $i <= $a; $i++) {
    if ($a%$i == 0) {
        $a_div[] = $i;
    }
}
for ($i = 1; $i <= $b; $i++) {
    if ($b%$i == 0) {
        $b_div[] = $i;
    }
}
$a_count = count($a_div);
$b_count = count($b_div);
for($i = 0; $i < $a_count; $i++){
    for($j = 0; $j < $b_count; $j++){
        if($a_div[$i] == $b_div[$j]){
            $ab_div[] = $a_div[$i];
        }
    }
}

echo $ab_div[count($ab_div)-$k];
?>

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    cout<<((n*(n-1)/2)+(m*(m-1)/2));

    return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

string S;
ll alph[26] = {};

signed main()
{
    cin >> S;
    REP(i, S.length()) {
        ll ind = S[i] - 'a';
        alph[ind]++;
    }
    string ans = S;
    char add_c[2] = {0, 0};
    if(S.length() < 26) {
        REP(i, 26) {
            if(alph[i] == 0) {
                add_c[0] = (char)i + 'a';
                string add_s(add_c);
                ans += add_s;
                cout << ans << endl;
                return 0;
            }
        }
    }
    if(S == "zyxwvutsrqponmlkjihgfedcba") {
        printf("-1\n");
        return 0;
    }
    if(S == "abcdefghijklmnopqrstuvwxyz") {
        printf("abcdefghijklmnopqrstuvwxz\n");
        return 0;
    }
    ans = "";
    REP(i, 26) {
        char cur = S[i];
        bool isAllDown = true;
        for(ll j = i + 1; j < 26; ++j) {
            if(cur < S[j]) {
                isAllDown = false;
                break;
            }
            cur = S[j];
        }
        if(isAllDown) {
            ans.pop_back();
            char cand = S[i];
            for(ll j = i+1; j < 26; ++j) {
                if(S[i-1] < S[j] && cand > S[j]) { cand = S[j]; }
            }
            add_c[0] = cand;
            string add_s(add_c);
            ans += add_s;
            cout << ans << endl;
            return 0;
        } else {
            add_c[0] = S[i];
            string add_s(add_c);
            ans += add_s;
        }
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
def solve(P, C, K, Checked, s):
    B = []
    B.append( C[s])
    now = P[s]
    Checked[s] = True
    while now != s:
        B.append(C[now])
        Checked[now] = True
        now = P[now]
    sumB = sum(B)
    L = len(B)
    accB = [0] + list( accumulate(B))
    ret = B[0]
    for i in range(L):
        for j in range(i+1,L+1):
            if j - i > K:
                continue
            if accB[j] - accB[i] > ret:
                ret = accB[j] - accB[i]
    accRB = [0] + list( accumulate(B[::-1]))
    # print(B, accB, accRB)
    # print(ret)
    for i in range(L+1):
        for j in range(L+1):
            if i==0 and j==0:
                continue
            if i + j > K:
                continue
            t = accB[i] + accRB[j]
            if sumB > 0:
                t += (K-(i+j))//L*sumB
            if t > ret:
                ret = t
                # print(i,j,ret)
    return ret
        
    
def main():
    N, K = map( int, input().split())
    P = list( map( lambda x: int(x)-1, input().split()))
    C = list( map( int, input().split()))
    Checked = [False]*N
    ans = C[0]
    for s in range(N):
        if Checked[s]:
            continue
        ans_s = solve(P, C, K, Checked, s)
        if ans_s > ans:
            ans = ans_s
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 69084
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
using namespace std;

int nCk(int n, int k)
{
    if (k == 0)
    {
        return 1;
    }
    else if (k == 1)
    {
        return n;
    }
    else if (k == 2)
    {
        return n * (n - 1) / 2;
    }
    else if (k == 3)
    {
        return n * (n - 1) * (n - 2) / 6;
    }
    else
    {
        return 0;
    }
}

int DP(string n, int k)
{
    if (n.size() == 1)
    {
        if (k == 1)
        {
            return n[0] - '0';
        }
        else
        {
            return 0;
        }
    }
    if (k == 0)
    {
        return 1;
    }
    if (n[0] == '0')
    {
        return DP(n.substr(1), k);
    }

    int part = nCk(n.size() - 1, k) * pow(9, k) + nCk(n.size() - 1, k - 1) * pow(9, k - 1) * (n[0] - '0' - 1);
    return part + DP(n.substr(1), k - 1);
}

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

    int ans = DP(n, k);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int INF = 10000;

int solve(int N){
  for(int i = 1; i < INF; i++){
    int cnt = 0;
    for(int j = 1; j <= i; j++) if(i % j == 0) ++cnt;
    if(cnt == N) return i;
  }
  return -1;
}

int main(){
  int N; cin >>N;
  cout <<solve(N) <<endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		if (N == 1) {
			System.out.println("Hello World");
		} else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A + B);
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long
#define llf __float128
#define lld long double
using namespace std;
const int NR= 2e5 + 20 ,oo = 1e5 + 10, MOD = 1e9 + 7 ;
const long double pi = 2*acos(0.0);



int main () {
    int i , n , x , cnt ;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0) ;
    cin >> n ;
    cnt = 0 ;
    for ( i = 1 ; i <= n ; ++ i )   {
        cin >> x ;
        if ( x % 2 == i % 2 && i % 2 )
            cnt ++ ;
    }
    cout << cnt << '\n' ;
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  int x[N], y[M];
  FOR(i,0,N) cin >> x[i];
  FOR(i,0,M) cin >> y[i];
  FOR(Z,X+1,Y+1) {
    bool ok = true;
    FOR(i,0,N) if(Z <= x[i]) ok = false;
    FOR(i,0,M) if(Z > y[i]) ok = false;
    if(ok) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

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

using namespace std;
int main(void) {

  int k,a,b,ans=0;cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){ans=1;break;}
  
  }
  if (ans==1) cout<<"OK";
  else cout<<"NG";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int q,a,b,c,d,n,k;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&q);
	while (q--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		n=a+b;
		k=(max(a,b)-1)/(min(a,b)+1)+1;
		int l=0,r=n+1,A,B;
		while (l<r){
			int mid=(l+r)>>1;
			A=a-(mid/(k+1)*k+mid%(k+1));
			B=b-(mid/(k+1));
			if (B<=1ll*A*k) l=mid+1;
			else r=mid;
		}
		A=a-(l/(k+1)*k+l%(k+1));
		B=b-(l/(k+1));
		r=l+B-A*k+1;
		for (int i=c;i<=min(l,d);i++){
			if (i%(k+1)) printf("A");
			else printf("B");
		}
		for (int i=max(l+1,c);i<=d;i++){
			if ((i-r)%(k+1)) printf("B");
			else printf("A");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std; 
ll N = pow(10,10);
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	string s;cin>>s;
	int count1=0; int count2=0;
	for(int i=0;i<n;i++){
		if(s[i]=='.'){
			count1++;
		}
		else{
			count2++;
		}
	}
	ll mini = N;int counter1=0;int counter2=0;
	for(int i=0;i<=n;i++){
		if(i>0){
			if(s[i-1]=='.'){
				counter1++;
			}
			else{
				counter2++;
			}
		}
		mini = min(mini,ll(counter2+count1-counter1));
	} 
	cout<<mini<<endl;
}


Measured memory_bytes: 720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;

    void solveA() throws IOException {
        int x = nextInt();
        int a = nextInt();
        int b = nextInt();
        int diff1 = Math.abs(x - a);
        int diff2 = Math.abs(x - b);
        if (diff1 < diff2) {
            outln("A");
        }
        else {
            outln("B");
        }
    }

    void solveB() throws IOException {
        String str = nextString();
        boolean[] exist = new boolean[26];
        for (int i = 0; i < str.length(); i++) {
            exist[str.charAt(i) - 'a'] = true;
        }

        for (int i = 0; i < exist.length; i++) {
            if (!exist[i]) {
                outln((char) ('a' + i));
                return;
            }
        }

        outln("None");
    }

    void solveC() throws IOException {

    }

    void solveD() throws IOException {

    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        solveB();

        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 23124