akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


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

int main() {
  int N, A, B, hito, kokugai;
  string S;
  cin >> N >> A >> B >> S;
  hito =0; kokugai =0;
  
  for(int i= 0; i<N; i++){
    if(S.at(i)=='a' && hito < A+B){
      cout << "Yes" << endl;
      hito ++;
    }
    else if(S.at(i)=='b' && hito < A+B && kokugai <B){
      cout << "Yes" << endl;
      hito ++;
      kokugai ++;
    }
    
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
static const ll INFTY = (1LL << 32);

const int MAX_N = 1000000;
int N;
int dist[MAX_N];
int ok[MAX_N];

int main() {

    cin >> N;
    rep(i, N){
        cin >> dist[i];
    }

    int order = 0;
    rep(i, N){
        int d = dist[i];
        if (d > (i-order) * 2){
            ok[order]++;
        }
        else{
            ok[order]++;
            order++;
        }
    }

    rep(i, N){
        // cout << ok[i] << " ";
    }

    ll ret = 1;
    ll oks = 0;
    rep(i, N){
       oks += ok[i];
       ret *= oks;
       ret %= 1000000007;
       oks--;
    }
    cout << ret << endl;
}

Measured memory_bytes: 4480
/*silu1:dp
ba bLue rengdiaohou n-k+1 gekong,chakong,fencheng i fen;
ba k ge blueball fencheng i-1 fen,gong k-1 gekong;
Step1:zai redballs zhongxuancharu blueballs deweizhi;
Step2:zai blueballs zhongxuancharu redballs deweizhi;
Step3:qu i cidefanganshuji c[n-k+1][i]*c[k-1][i-1] zaiqu mod
*/
#include<iostream>

using namespace std;

const long long mod = 1e9+7;

long long c[2010][2010];

int n,k;

int check(int n,int m)
{
	if(n > m)
		return 0;
	return c[n][m];
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 0;i <= n;i ++)
		c[i][0] = c[i][i] = 1;//cong 0 kaishi
	for(int i = 1;i <= n;i ++)
		for(int j = 1;j <= i-1;j ++)
			c[i][j] = (c[i-1][j]+c[i-1][j-1])%mod;
	for(int i = 1;i <= k;i ++)
		cout << (c[n-k+1][i]*c[k-1][i-1])%mod << endl; 
	return 0;
}

Measured memory_bytes: 30208
#include<bits/stdc++.h>
#define shreyans ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define mod 1000000007 
#define MINI LLONG_MIN
using namespace std;
typedef long long ll;

ll dp[1000007],a[1000001];
int main(){
	
	shreyans
	ll n,k;cin>>n>>k;
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll i=1;i<n;i++)dp[i] = LLONG_MAX;
	dp[0]=0;
	for(ll i=1;i<n;++i){
		for(ll j=1;j<=k && i>=j;++j){
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1];
	
	return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



int main() {
    int a, b, q; cin >> a >> b >> q;
    vll s(a + 2, INF), t(b + 2, INF);
    s[0] = t[0] = -INF;
    rep(i, a) cin >> s[i + 1];
    rep(i, b) cin >> t[i + 1];

    vll f(2), g(2);

    rep(i, q) {
        ll x;
        ll res = INF;
        ll tmp1, tmp2;
        cin >> x;
        auto itrs = lower_bound(all(s), x);
        auto itrt = lower_bound(all(t), x);
        f[0] = *(itrs); f[1] = *(--itrs);
        g[0] = *(itrt); g[1] = *(--itrt);
        rep(k, 2) {
            rep(l, 2) {
                tmp1 = abs(f[k] - x) + abs(g[l] - f[k]);
                tmp2 = abs(g[l] - x) + abs(g[l] - f[k]);
                res = min({res, tmp1, tmp2});
            }
        }
        cout << res << endl;

    }
}

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

int main(){
    int a_i, b_i, n, temp, a1;
    int r, l = 0, u, d = 0, x1, y1, h, w, area;

    cin>>r>>u>>n;

    while( n-- ){
        cin>>x1>>y1>>a1;
        switch( a1 ){
        case 1:
            l = max( l, x1 );
            break;
        case 2:
            r = min( r, x1 );
            break;
        case 3:
            d = max( d, y1 );
            break;
        case 4:
            u = min( u, y1 );
            break;
        }

        //cout<<"l : "<<l<<endl<<"r : "<<r<<endl<<"u :"<<u<<endl<<"d :"<<d<<endl;

    }

        w = r - l;
        h = u - d;

        area = w*h;

        if( w < 0 || h < 0 ) area = 0;

        cout<<area<<endl;

}


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

const int mod = (int) 1e9+7;

int canPass[111111];
int x[111111];

int main(void) {

    int n = 0; scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &x[i]);
    }


    canPass[1] = 0;
    canPass[2] = 1;
    for (int i = 3; i <= n; ++i) {
        if (x[i-1] >= canPass[i-1]*2+1) {
            canPass[i] = canPass[i-1]+1;
        } else {
            canPass[i] = canPass[i-1];
        }
    }
    // for (int i = 1; i <= n; ++i) {
    //     printf("%d ", canPass[i]);

    // }
    // puts("");
    int ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans = (long long) ans * (canPass[i]+1) % mod;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Era {
  string eraName;
  int firstYear;
  int endYear;
};

int checkEra(const vector<Era> &eraVec, int year, string& era)
{
  
  for (int i = 0; i < eraVec.size(); i++) {
    if (year >= eraVec[i].firstYear &&
        year <= eraVec[i].endYear) {
      era = eraVec[i].eraName;
      return year - eraVec[i].firstYear + 1;
    }
  }
  era = "Unknown";
  return 0;     
}

int main()
{
  int n, q;
  string eraName;
  int eraBasedYear, westernYear;
  vector<Era> eraVec;
  int query;
  
  while (1) {
    cin >> n >> q;
    if (n == 0 && q == 0) break;
    eraVec.clear();
    for (int i = 0; i < n; i++) {
      cin >> eraName >> eraBasedYear >> westernYear;
      cin.ignore();
      Era tempEra;
      tempEra.eraName = eraName;
      tempEra.firstYear = westernYear - eraBasedYear + 1;
      tempEra.endYear = westernYear;
      eraVec.push_back(tempEra);
    }
    for (int i = 0; i < q; i++) {
      cin >> query;
      string era;
      int year;
      year = checkEra(eraVec, query, era);
      if (year) {
        cout << era << " " << year << endl;
      } else {
        cout << era << endl;
      }
    }
  }
}



Measured memory_bytes: 3148
import collections

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=[0]+[collections.deque(arr[i]) for i in range(n)]
ans=0
cand=set(range(1,n+1))
while 1:
  check=set()
  for i in cand:
    if not arr[i]:
      continue
    pair=arr[i][0]
    if arr[pair][0]==i:
      check.add(i)
      check.add(pair)
  if not check:
    break
  cand=set()
  for i in check:
    cand.add(i)
    arr[i].popleft()
    if arr[i]:
      cand.add(arr[i][0])
  ans+=1
for i in range(1,n+1):
  if arr[i]:
    print(-1)
    break
else:
  print(ans)

Measured memory_bytes: 81116
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
}


Measured memory_bytes: 23468
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,f,g,h[N],arr[N];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin >> a >> b >> c;
	if(a+b>c) cout << "No" << endl;
	else if((4*a*b)<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int R = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int[][] v = new int[R][C];
		
		for(int i=0; i<K; i++) {
			v[sc.nextInt()-1][sc.nextInt()-1] = sc.nextInt();
		}

		long[][][] dp = new long[R][C][4];
		if(v[0][0]>0)
			dp[0][0][1] = v[0][0];
		for(int i=0; i<R; i++) {
			for(int j=0; j<C; j++) {
				if(i>0) {
					for(int k=0; k<4; k++)
						dp[i][j][0] = Math.max(dp[i][j][0], dp[i-1][j][k]);
					if(v[i][j]>0) {
						for(int k=0; k<4; k++)
							dp[i][j][1] = Math.max(dp[i][j][1], dp[i-1][j][k]+v[i][j]);
					}
				}
				if(j>0) {
					for(int k=0; k<4; k++)
						dp[i][j][k] = Math.max(dp[i][j][k], dp[i][j-1][k]);
					if(v[i][j]>0) {
						for(int k=0; k<3; k++)
							dp[i][j][k+1] = Math.max(dp[i][j][k+1], dp[i][j-1][k]+v[i][j]);
					}
				}
			}
		}
		long ans = 0;
		for(int i=0; i<4; i++)
			ans = Math.max(ans, dp[R-1][C-1][i]);
		System.out.println(ans);
		
		sc.close();
	}
	
}



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

int a[10000];

int main(){
    
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            a[i*j] = 1;
        }
    }
    
    int n;
    cin>>n;
    if(a[n])cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int s;cin>>s;
    set<int>st;
    int x=s;
    while(st.count(x)==0){
        st.insert(x);
        if(x%2==0)x/=2;
        else x=x*3+1;
    }
    cout<<(st.size()+1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define VJ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair()
#define vi(x) vector<int>x
#define vl vector<long long int>
#define vc vector<char> 
using namespace std;


void solve(){
	
		int n;
		cin>>n;
		vector<int>v(n);
		for(int i=0;i< n;i++){
			cin>>v[i];
		}
		ll height=0;
		for(int i=1;i<n;i++){
			if(v[i-1]>v[i]){
				int curr=v[i-1]-v[i];
				v[i]+=curr;
				height+=curr;
			}
		}
		cout<<height;
	
}

int main(){
	 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	 #endif
	VJ
	solve();
	return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
using ull = unsigned long long;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<ll>> vvl;
typedef vector<vector<string>> vvs;
typedef vector<bool> vb;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

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

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int n = s.size();
    if(t.substr(0, n) == s && t.size() == s.size()+1) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0; 
}

Measured memory_bytes: 18644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    for(char c='a'; c<='z'; c++){
        bool flg = true;
        for(int i=0; i<s.size(); i++){
            if(s[i] == c) flg = false;
        }

        if(flg){
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<queue>
#define ll long long
#define INF 1000000000
#define Maxn 105
#define Maxm 2005
using namespace std;
struct Line
{int nxt,t;ll cap;}l[Maxm];
int tl=1,fir[Maxn];
void adl(int f,int t,ll cap){
  l[++tl]=(Line){fir[f],t,cap};fir[f]=tl;
  l[++tl]=(Line){fir[t],f,0};fir[t]=tl;
}
int S,T,dis[Maxn],cur[Maxn];
queue<int> q;
bool bfs()
{
  for (int i=1;i<=T;i++)
    {cur[i]=fir[i];dis[i]=0;}
  q.push(S);dis[S]=1;
  while(!q.empty()){
  	int u=q.front();q.pop();
  	for (int i=fir[u];i;i=l[i].nxt)
  	  if (l[i].cap&&!dis[l[i].t]){
  	  	dis[l[i].t]=dis[u]+1;
  	  	if (l[i].t==T){
  	  	  while(!q.empty())q.pop();
  	  	  return 1;
        }q.push(l[i].t);
	    }
  }return 0;
}
ll dfs(int u,ll flow)
{
  if (u==T)return flow;
  ll sum=0;
  for (int &i=cur[u];i;i=l[i].nxt)
  	if (dis[l[i].t]==dis[u]+1&&l[i].cap){
  	  ll sav=dfs(l[i].t,min(flow,l[i].cap));
  	  if (sav){
  	    l[i].cap-=sav;
  	    l[i^1].cap+=sav;
  	  	sum+=sav;flow-=sav;
  	  	if (!flow)return sum;
	    }else dis[l[i].t]=-1;
	  }
  return sum;
}
int n,a[Maxn];
#define P(x,y) (((x)-1)*m+(y))
int main()
{
  scanf("%d",&n);S=n+1;T=S+1;
  ll sum=0,ans=0;
  for (int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
    a[i]=-a[i];
    if (a[i]>0)
      {adl(S,i,a[i]);ans+=a[i];}
    else adl(i,T,-a[i]);
    for (int j=i+i;j<=n;j+=i)
      adl(i,j,INF);
  }while(bfs())ans-=dfs(S,INF);
  printf("%lld",sum+ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s;
    while(cin>>s){
        int l=s.length();
        for(int i=0;i<l;i++){
            if(i==0) cout<<'2';
            else if(i==1) cout<<'0';
            else if(i==2) cout<<'1';
            else if(i==3) cout<<'8';
            else cout<<s[i];
        }
        cout<<endl;
    }
    return 0;
}


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


Measured memory_bytes: 3068
#include<iostream>

using namespace std;

bool is_prime[246912];
bool is_prime_small[497];

void segment_sieve(long long a, long long b) {
	for(int i = 0; (long long)i * i < b; i++) { is_prime_small[i] = true; }
	for(int i = 0; i < b - a; i++) { is_prime[i] = true; }
	for(int i = 2; (long long)i * i < b; i++) {
		if(is_prime_small[i]) {
			for(int j = 2 * i; (long long)j * j < b; j += i) { is_prime_small[j] = false; }
			for(long long j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) { is_prime[j - a] = false; }
		}
	}
}

int main(void) {
	int in, count;
	int i;

	segment_sieve(1, 246912);

	while(true) {
		cin >> in;
		if(in == 0) { break; }
		count = 0;
		for(i = in; i < 2 * in; i++) {
			if(is_prime[i]) { count++; }
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 0
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h, w = map(int, input().split())
    cc = [list(map(int, input().split())) for _ in range(10)]
    # 数字ごとにカウント
    cnt = [0] * 10
    for _ in range(h):
        for a in map(int, input().split()):
            if a == -1: continue
            cnt[a] += 1
    # print(cnt)

    # ダイクストラで各数から1までの最小コストを求める
    cto1 = [-1] * 10
    hp = []
    heappush(hp, [0, 1])
    while hp:
        cost, u = heappop(hp)
        if cto1[u] != -1: continue
        cto1[u] = cost
        for v in range(10):
            if cto1[v] != -1: continue
            heappush(hp, [cost + cc[v][u], v])
    # print(cto1)

    # 個数とコストの積を合計して答え
    ans = sum(an * ac for an, ac in zip(cnt, cto1))
    print(ans)

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    long long int x;
    long long int a[n+1],b[m+1];
    a[0] = b[0] = 0;
    for(int i=1;i<=n;i++){
        cin >> x;
        a[i] = a[i-1] + x;
    }
    for(int i=1;i<=m;i++){
        cin >> x;
        b[i] = b[i-1] + x;
    }
    long long int ans = 0;
    int j = m;
    for(int i=0;i<=n;i++){
        if(a[i]>k){
            break;
        }
        while( b[j] > k - a[i]){
            j--;
        }
        ans = max(ans, (long long int)i + j);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6748
def ketasu(N):
    count=1
    while N>=10:
        N//=10
        count+=1
    return count
N=int(input())
keta=10**10
for i in range(1,int(N**.5)+1):
    if N%i==0:
        keta=min(keta,max(ketasu(i),ketasu(N//i)))
print(keta)

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

int main() {
    string t;
    char nt='a';
    map<char,string> S;
    map<char,int> rc;

    cin >> t; S['a']=t; rc['a']=0;
    cin >> t; S['b']=t; rc['b']=0;
    cin >> t; S['c']=t; rc['c']=0;

    while(1) {
        if(++rc.at(nt) == S.at(nt).size()+1)
            break;
        nt = S.at(nt).at(rc.at(nt)-1);
    }

    cout << (char)('A'+nt-'a') << endl;
}

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

long long func(int a) {
  long long s = 1;
  for (int i = 1; i <= a; i++) s = s*i%1000000007;
  return s;
}

int main() {
  int N, M; cin >> N >> M;
  if (abs(N-M) >= 2) cout << 0 << endl;
  else if (N == M) cout << 2*func(N)*func(M)%1000000007 << endl;
  else cout << func(N)*func(M)%1000000007 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int a,b,c,d;
  cin >> a >> b >> c >> d;
  int flag = 1;
  while(a >0 && b > 0){
    if(flag) {
      c -= b;
    }else{
      a -= d;
    }
    flag = 1 - flag;
  }
  if(c > 0){
    cout << "No" << endl;
  }else{
    cout <<  "Yes" << endl;
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i=0; i<n-1; i++) {
    if (s[i] == s[i+1]) {
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  for (int i=0; i<n-2; i++) {
    if (s[i] == s[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << endl;
  return 0;
}

Measured memory_bytes: 3748
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let v = [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];
    let k: usize = read();

    println!("{}", v[k-1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    deque <char> s;
    string h;
    cin >> h;
    for (auto &i : h) {
        s.pb(i);
    }
    int q;
    cin >> q;
    bool rev = false;
    int t;
    char c;
    int l;
    while (q--) {
        cin >> t;
        if (t == 1) {
            rev ^= 1;
        }
        else {
            cin >> l >> c;
            bool beg = rev;
            if (l != 2) {
                beg ^= 1;
            }
            if (beg) {
                s.push_front(c);
            }
            else {
                s.pb(c);
            }
        }
    }
    if (rev) {
        while (!s.empty()) {
            cout << s.back();
            s.pop_back();
        }
    }
    else {
        while (!s.empty()) {
            cout << s.front();
            s.pop_front();
        }
    }
    cout << '\n';
}


Measured memory_bytes: 4028
#include<cstdio>
using namespace std;
typedef long long ll;
ll a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c-a-b>0&&(c-a-b)*(c-a-b)>4ll*a*b)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	/*string str,str2;
	cin>>str>>str2;
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	(str==s)?cout<<a-1<<" "<<b:cout<<a<<" "<<b-1;*/
	
	string str;
	cin>>str;
	int n = str.size();
	for(int i = 0;i<n;i++)
		cout<<'x';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

struct UF{
    vl par;
    UF(ll N):par(N){
        rep(i,N)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    void unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
};

int main() {
ll n,a,b;
  cin >>n>>a>>b;
  
  ll x=powmod(2,n,MOD);
  x=x-1;
  //cout<<x<<endl;

  
  ll Na=1;
rep(i,a) {
  Na*=n-i;
  Na=Na%MOD;
}

 ll Nb=1;
rep(i,b) {
  Nb*=n-i;
  Nb=Nb%MOD;
}


ll A=fac(a);
ll B=fac(b);

ll aa=powmod(A,MOD-2,MOD);
ll bb=powmod(B,MOD-2, MOD);

ll fina=(Na*aa)%MOD;
ll finb=(Nb*bb)%MOD;
ll z=x-fina-finb;
  if(z<0) {
    while(z<0) {
      z=z+MOD;
    }
  }
  
cout<<z<<endl;
}

  
  

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.next();
        if((s.length() % 2) != 0) {
            System.out.println("No");
            return;
        }
        for(int i = 0; i < s.length(); i+=2) {
            String a = s.substring(i, i+2);
            if(!a.equals("hi")) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;


//ABC150_b
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int cnt = 0;
	for (int i=0; i<n-2; i++) {
		string sub_str = s.substr(i, 3);
		if (sub_str=="ABC") cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int a = 0, z = 0;
		
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i) == 'A'){
				a = i;
				break;
			}
		}
		for(int i = str.length()-1; a < i ; i--){
			if(str.charAt(i) == 'Z'){
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
	}
}

Measured memory_bytes: 26652
import java.util.*;
import java.io.*;
public class Main {
    public static void main (String [] args) throws IOException 
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        int len = Integer.parseInt(in.readLine());

        StringTokenizer s = new StringTokenizer(in.readLine());

        boolean isZero = false;
        boolean tooLong = false;
        long[] nums = new long[len];
        for(int i = 0; i < len; i++)
        {
            nums[i] = Long.parseLong(s.nextToken());
            if(nums[i] == 0)
            {
                isZero = true;
            }
        }
        long result = 1;
        
        for(int i = 0; i < len && !isZero; i++)
        {
            if(1000000000000000000L/nums[i] >= result)
            {
                result *= nums[i];
            }
            else
            {
                tooLong = true;
                break;
            }
        }

        if(isZero)
        {
            System.out.println(0);
        }
        else if(tooLong)
        {
            System.out.println(-1);
        }
        else
        {
            System.out.println(result);
        }
        in.close();
    }
}

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

namespace ABC097B
{
    class Program
    {
        static void Main(string[] args)
        {
            int X, b = 1, p = 2;
            double  max=0;
            X = int.Parse(Console.ReadLine());
            if(X==1)
            {
                max = 1;
            }
            for (b = 2; b*b<=X; b++)
            {
                for(p=2;Math.Pow(b,p)<=X;p++)
                {
                     if(Math.Pow(b,p)<=X&&max<Math.Pow(b,p))
                    {
                        max = Math.Pow(b, p);
                    }
                }
            }
            Console.WriteLine(max);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
N=int(input())
x,y=0,0
A,B=[],[]
for i in range(N):
  x,y=map(int,input().split())
  A.append(x)
  B.append(y)
x=sum(A)
for i in range(N):
  if A[i]>B[i]:
    x=min(x,B[i])
print(sum(A)-x)

Measured memory_bytes: 75676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c; cin>>a>>b>>c;
    if (a == b)
    {
        cout << c;
    } else if (a == c) {
        cout << b;
    } else {
        cout << a;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double dd;

int main() {
	int N;
	cin >> N;
	int n = N;
	int count = 0;
	while (n!=0)
	{
		n /= 10;
		if (n != 0) count++;
	}
	int ans=0;
	for (int i = 0; i < count;i+=2) {
		ans += 9 * pow(10,i);
	}
	if (count%2==0) {
		ans += N - pow(10, count)+1;
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
li = [input()[0] for _ in range(n)]
count = [0, 0, 0, 0, 0]
name_index = ["M", "A", "R", "C", "H"]
li = [i for i in li if i in name_index ] 
for i in li:
    count[name_index.index(i)]+= 1
ans = 0

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            
            ans += count[i]*count[j]*count[k]
print(ans)

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

#define MAX 500001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0; 

int main(){
  int n,i;
  int S[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);

  return 0;
}

//Conquer
void merge(int *A,int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int i,j,k;
  int *L,*R;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0;i<=n1-1;i++){
    L[i]=A[l+i];
  }

  for(j=0;j<=n2-1;j++){
    R[j]=A[m+j];
  }

  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  j=0;

  for(k=l;k<=r-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }

    count++;
  }

  free(L);
  free(R);
}

//Solve
void mergeSort(int *A,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4480
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n+2);
  rep(i, n) cin >> a[i+1];
  int base = 0;
  loop(i, 1, n+2) base += abs(a[i]-a[i-1]);
  loop(i, 1, n+1) cout << base - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;

  return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main
{
	public static void main(String[] args)
	{
		try{
			StringBuilder sb = new StringBuilder();
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
			int n = Integer.parseInt(br.readLine());
			String[] str1 = br.readLine().split(" ");
			String[] str2 = Arrays.copyOf(str1,str1.length);
			bubbleSort(str1);
			selectionSort(str2);
			sb.append(appS(str1)).append("Stable\n");
			sb.append(appS(str2));
			sb.append(Arrays.equals(str1,str2) ? "Stable" : "Not stable");
			System.out.println(sb);
			
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void bubbleSort(String[] s)
	{
		boolean boo = true;
		for(int i = 0 ; boo ; i++)
		{
			boo = false;
			for(int j = s.length-1; j > i ; j--)
			{
				if(toInt(s[j]) < toInt(s[j-1]))
					swap(s,j,j-1);
					boo = true;
			}
		}
		
	}
	public static void selectionSort(String[] s)
	{
		int min;
		for(int i= 0 ; i< s.length-1; i++)
		{
			min = i;
			for(int j = i+1 ; j<s.length; j++)
			{
				if(toInt(s[j]) < toInt(s[min]))
				min = j;
			}
			if(min != i){
					swap(s,i,min);
			}
		}
	}
	public static int toInt(String s)
	{
		int ans;
		try{
			ans = (int)(s.charAt(1));
		}catch(NumberFormatException e){
			e.printStackTrace();
			//e.getMessage();
			return -1;
		}
		return ans;
		
	}
	public static void swap(String[] st,int z1,int z2)
	{
		String stemp = st[z2];
		st[z2] = st[z1];
		st[z1] = stemp;
	}
	public static String appS(String[] s)
	{
		StringBuilder sb2 = new StringBuilder();
		sb2.append(s[0]);
		for(int i = 1 ; i < s.length ; i++)
		{
			sb2.append(" ").append(s[i]);
		}
		sb2.append("\n");
		return sb2.toString();
		
	} 
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a[3];

int main() {
	inc(i, 3) { cin >> a[i]; }
	
	int ans = 0;
	inc(i, 3) { ans ^= a[i]; }
	
	cout << ans << endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int n,k;
string str;
cin>>n>>k>>str;
if (str.at(k-1)=='A')
{
    str.at(k-1)='a';
}
else if (str.at(k-1)=='B')
{
    str.at(k-1)='b';

}
else if (str.at(k-1)=='C')
{
    str.at(k-1)='c';

}

cout<<str<<endl;

    return 0;
}

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

#define st              first
#define nd              second
#define pb              push_back
#define lwb             lower_bound
#define upb             upper_bound
#define all(a)          (a).begin(), (a).end()
#define Reset(s, n)     memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       (a).resize(unique(all(a)) - (a).begin())
#define bit(n, i)       (((n) >> (i)) & 1)
#define cntbit(n)       __builtin_popcountll(n)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-12;
inline bool isPrime (ll x){ if(x <= 1) return 0; if(x <= 3) return 1; if (!(x % 2) || !(x % 3)) return 0; ll s = sqrt(1.0 * x) + EPS; for(ll i = 5; i <= s; i += 6){if (!(x % i) || !(x % (i + 2))) return 0;}return 1;}
inline ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline void onbit(ll &a, int i){a |= 1LL << i;}
inline void offbit(ll &a, int i){onbit(a, i), a -= (1LL << i);}

const int N = 1e6 + 5;

ll n, m, k;
ll a[N], b[N];

void solve(){
   cin >> n >> k;
   ll res = 0;
   n++;
   for(int i = 1; i <= n; i++){
      a[i] = i;
      a[i] = a[i - 1] + a[i];
   }
   for(int i = k; i <= n; i++){
      res += a[n] - a[n - i] - a[i] + 1;
      res %= MOD;
   }
   cout << res << "\n";

}

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   cout << fixed << setprecision(10);
   //    freopen("input.txt", "r", stdin);
   //    freopen("output.txt", "w", stdout);
   int query = 1;
   // cin >> query;
   int start = 1000 * clock() / CLOCKS_PER_SEC;
   while(query--) solve();
   cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC  - start << "ms\n";
}


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

int main() {
string s;
cin>>s;
stack<char> a;
string ans="";
for(int i=0;i<s.size();i++){
  if(s[i]=='1' || s[i]=='0') a.push(s[i]);
  else if(s[i]=='B'&&a.empty()) continue;
  else if(s[i]=='B'&&a.empty()!=1) a.pop();
}

while(!a.empty()){
  ans.push_back(a.top());

  a.pop();
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

bool isok(string s) {
	int len = s.size();
	bool flag = true;
	FOR(i, 0, len - 2) {
		if (s[i] == '#'&&s[i + 1] == '#') {
			flag = false;
		}
	}
	return flag;
}

int main() {
	int a, b, c, d,n;
	string s;
	cin >>n>> a >> b >> c >> d >>s;
	if ((a < b&&c < d) || (a > b&&c > d)) {
		string tmp = s.substr(a - 1, d - a + 1);
		if (isok(tmp)) {
			ps(Yes)
		}
		else {
			ps(No);
		}
	}
	else {
		string tmp = s.substr(a - 1, d - a + 1);
		if (!isok(tmp)) {
			ps(No);
		}
		else {
			bool flag = false;
			FOR(i, b - 2, d - 2) {
				if (s[i] == '.'&&s[i + 1] == '.'&&s[i + 2] == '.') {
					flag = true;
				}
			}
			if (flag) {
				ps(Yes);
			}
			else {
				ps(No);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, k, ans=INF;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    cout << (n-1+k-1-1)/(k-1) << endl;
    return 0;
}

Measured memory_bytes: 3988
fun main(args: Array<String>) {
    val (n, y) = readLine()!!.split(" ").map(String::toInt)

    for (a in 0..n) {
        for (b in 0..(n - a)) {
            val c = n - a - b
            if (calc(a, b, c) == y) {
                println("$a $b $c")
                return
            }
        }
    }
    println(Array(3) { -1 }.joinToString(" "))
}

fun calc(a: Int, b: Int, c: Int): Int = 10000 * a + 5000 * b + 1000 * c



Measured memory_bytes: 38124
N,K = map(int,input().split())

def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False
#(l,r]
def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)

ans = 0
for dice in range(1,N+1):
    ans += 1 / pow(2,bisec(-1,100))
print(ans/N)


Measured memory_bytes: 75156
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int main()
{
	int a, b, c, d;
	string ans = "No";
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d)) ans = "Yes";

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256