akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>

int main(int argc, char const *argv[])
{
    std::string s;
    std::stack<int> st;
    int n1, n2;

    while (std::cin >> s) {
        // if (s == "end") break;

        if (s == "+") {
            n1 = st.top();
            st.pop();
            n2 = st.top();
            st.pop();
            st.push(n2 + n1);
        } else if (s == "-") {
            n1 = st.top();
            st.pop();
            n2 = st.top();
            st.pop();
            st.push(n2 - n1);
        } else if (s == "*") {
            n1 = st.top();
            st.pop();
            n2 = st.top();
            st.pop();
            st.push(n2 * n1);
        } else if (s == "/") {
            n1 = st.top();
            st.pop();
            n2 = st.top();
            st.pop();
            st.push(n2 / n1);
        } else {
            st.push(atoi(s.c_str()));
        }
    }

    int res = st.top();
    std::cout << res << std::endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  string line;
  getline(cin, line);
  getline(cin, line);

  int counter = 0;
  int mn = 0;
  for(auto ch : line)
  {
	if(ch == '(') counter++;
	else counter--;
	mn = min(mn, counter);
  }

  if(mn < 0)
  {
	mn = abs(mn);
	for(int i = 0; i < mn; i++) cout << "(";
	counter += mn;
  }
  cout << line;

  if(counter > 0)
  {
	for(int i = 0; i < counter; i++) cout << ")";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("\n"); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 998244353;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){
	
	ll x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
 
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 3612
<?php
$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));

$a = $s;
$b = '';
for ($i = 0; $i < strlen($s); $i++) {
    $b = $a[strlen($s) - 1];
    for ($j = 0; $j < strlen($s) - 1; $j++) {
        $b .= $a[$j];
    }

    if ($b === $t) {
        echo 'Yes' . PHP_EOL;
        exit();
    }

    $a = $b;
}

echo 'No' . PHP_EOL;

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a,bef;
    cin>>n>>bef;
    ll ans=0;
    for(int i=0;i<n-1;i++){
	cin>>a;
	ans+=(bef<a);
	bef=a;
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 3216
s = str(input())
t = str(input())
g = len(s)
h = len(t)
ans = 10000
for i in range(g-h+1):
  k = 0
  for j in  range(h):
    if(s[i+j]!=t[j]):
      k += 1
  ans = min(ans,k)
print(ans)

Measured memory_bytes: 8948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
	int t;
	//cin >> t;
	t = 1;
	while(t--) {
		ll n;
        cin >> n;
        
        string s = "";
        while(n) {
            --n;
            int rem = n % 26;
            s = (char)(rem+'a') + s;
            n /= 26;
        }
        
        cout << s << endl;
	}

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, mini = 1000000000000;
  cin >> n;
  
  rep(i, 1, (ll)sqrt(n)+2) {
    if(n % i == 0) {
      ll x = n/i;
      mini = min(mini, x+i-2);
    }
  }
  cout << mini << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 30030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m,x,y;
	cin>>n>>m;
	string ss="snuke";
	rep(i,0,n)
	{
		rep(j,0,m)
		{
			string s;
			cin>>s;
			if(ss==s)
			{

			  x=i;
			  y=j;
			}
		}
	}

	char c='A';
	c+=y;
	cout<<c<<x+1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s1,s2; cin>>s1>>s2;
  rep(i,3){
    if(s1[i]!=s2[2-i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 256
data = []

for i in range(3):
    l = list(map(int,input().split()))
    data.append(l)

#check row

if data[0][1]-data[0][0] == data[1][1]-data[1][0] and data[1][1]-data[1][0]==data[2][1]-data[2][0] and data[0][2]-data[0][1]==data[1][2]-data[1][1] and data[1][2]-data[1][1]==data[2][2]-data[2][1]:
    x= 1
else:
    print("No")
    exit(0)

#check col

if data[1][0]-data[0][0]==data[1][1]-data[0][1] and data[1][1]-data[0][1]==data[1][2]-data[0][2] and data[2][0]-data[1][0] == data[2][1]-data[1][1] and data[2][2]-data[1][2]==data[2][1]-data[1][1]:
    x=1
else:
    print("No")
    exit(0)
print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int gcd(int a, int b) {
  return b==0 ? a : gcd(b, a%b);
}

int main() {
  map<ll,int> mp;
  for (int i=0; i*i<1000000000LL; ++i) {
    mp[i*i] = i;
  }
  int a, b, c;
  while(cin>>a>>b>>c,a||b||c) {
    ll D = b*b-4*a*c;
    int sqD;
    int g1, g2;
    int A = a;
    int p,q,r,s;
    if (!mp.count(D)) goto ng;
    
    sqD = mp[D];
    //cout <<sqD << endl;
    g1 = abs(gcd(-b+sqD, 2*a));
    g2 = abs(gcd(-b-sqD, 2*a));
    //cout << ":" << g1 << " " << g2 << endl;
    if (A % (2*a / g1) == 0) {
      A /= 2*a/g1;
      p = 2*a/g1;
      q = -(-b+sqD)/g1;
    } else goto ng;
    if (A % (2*a / g2) == 0) {
      A /= 2*a/g2;
      r = 2*a/g2;
      s = -(-b-sqD)/g2;
    } else goto ng;
    p *= A;                     // ¢çÈ¢©à
    q *= A;
    if (p<r||(p==r&&q<s)) {
      swap(p,r);
      swap(q,s);
    }
    printf("%d %d %d %d\n", p,q,r,s);
    continue;
  ng:;
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define M 1000000007
using namespace std;
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int a,b;cin>>a>>b;
	if(a/10==0&&b/10==0)
		cout<<a*b<<endl;
	else
		cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;

	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
tmp = input().split()
N = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])

ans = 0

tmp = B - A
if tmp % 2 == 0:
    print(tmp // 2)

else:
    # if tmp == 1:
    #     print(tmp // 2 + 2)
    # else:
    #     print(tmp // 2 + 1)
        
    MIN = min(A, B)
    MAX = max(A, B)

    if MIN - 1 < N - MAX:
        ans = MIN - 1
    
    else:
        ans = N - MAX
    
    print(ans + (tmp+1) // 2)
    #     if tmp == 1:
    #         print(MAX - 1)
    #     else:
    #         print(MAX - 2)
    # else:
    #     if tmp == 1:
    #         print(N - MIN)
    #     else:
    #         print(N - MIN - 1)

# 25 35 44



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

using namespace std;

int main()
{
  int k, a, b; cin >> k >> a >> b;
  int x = b/k;
  if(a <= x*k and x*k <= b)
    cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b"); 
		} else if (a > b) {
			System.out.println("a > b"); 
		} else {
			System.out.println("a == b"); 
		} 
	} 
}


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


int n,m;
long long X[1001],Y[1001],Z[1001],ans=-100000000000000;
vector<long long> v1,v2,v3,v4,v5,v6,v7,v8;

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>X[i]>>Y[i]>>Z[i];
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=X[i]+Y[i]+Z[i];
		v1.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=X[i]+Y[i]-Z[i];
		v2.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=X[i]-Y[i]+Z[i];
		v3.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=X[i]-Y[i]-Z[i];
		v4.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=-X[i]+Y[i]+Z[i];
		v5.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=-X[i]+Y[i]-Z[i];
		v6.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=-X[i]-Y[i]+Z[i];
		v7.push_back(tmp);
	}
	
	for(int i=1;i<=n;i++){
		long long tmp=-X[i]-Y[i]-Z[i];
		v8.push_back(tmp);
	}
	
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	sort(v3.begin(),v3.end());
	sort(v4.begin(),v4.end());
	sort(v5.begin(),v5.end());
	sort(v6.begin(),v6.end());
	sort(v7.begin(),v7.end());
	sort(v8.begin(),v8.end());
	long long tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v1[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v2[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v3[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v4[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v5[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v6[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v7[i];
	}
	ans=max(ans,tmp);
	tmp=0;
	for(int i=n-1;i>=n-m;i--){
		tmp+=v8[i];
	}
	ans=max(ans,tmp);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int, readline().split())
A = sorted(list(map(int, readline().split())), reverse=True)
B = sorted(list(map(int, readline().split())), reverse=True)
C = sorted(list(map(int, readline().split())), reverse=True)

def f(thres:int)->bool:
    """return (おいしさが thres 以上の組み合わせ) >= K
    """
    global K
    cnt = 0
    for a in range(X):
        if A[a]+B[0]+C[0]<thres:
            break
        for b in range(Y):
            if A[a]+B[b]+C[0]<thres:
                break
            for c in range(Z):
                if A[a]+B[b]+C[c]<thres:
                    break
                cnt += 1
                if cnt >= K:
                    return True
    return False

def binary_search(f, s:int, t:int)->int:
    """f: function(x:int)->bool
    f(s)=False, f(t)=True，f は広義単調増加
    return : [s, t) での f(x)=True なる最小のx
    """
    ok = s-1
    ng = t
    while ng - ok > 1:
        mid = (ok + ng)//2
        if f(mid): ok = mid
        else:      ng = mid
        # print(ng, ok, ok-ng)

    if ok==s-1:
        raise(ValueError("For all x, f(x)=False"))
    return ok

M = A[0]+B[0]+C[0]
m = A[-1]+B[-1]+C[-1]
# print(f(m), f(M))
thres = binary_search(f, m, M+1)-1
# print("thres:",thres)
ans = []
for a in range(X):
    if A[a]+B[0]+C[0]<thres:
        break
    for b in range(Y):
        if A[a]+B[b]+C[0]<thres:
            break
        for c in range(Z):
            if A[a]+B[b]+C[c]<thres:
                break
            ans.append(A[a]+B[b]+C[c])

ans.sort(reverse=True)
print("\n".join(map(str, ans[:K])))


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    int ans = 1;
    n -= k;
    while(n > 0){
        n = n - (k-1);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	int size = s.size();
	cout << s.substr(0, size-8) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

vector<ll> s, t, x;

ll s_left_dist(ll key) {
    ll tar = s[lower_bound(all(s), key) - s.begin() - 1];
    return abs(key - tar);
}

ll s_right_dist(ll key) {
    ll tar = *upper_bound(all(s), key);
    return abs(tar - key);
}

ll t_left_dist(ll key) {
    ll tar = t[lower_bound(all(t), key) - t.begin() - 1];
    return abs(key - tar);
}

ll t_right_dist(ll key) {
    ll tar = *upper_bound(all(t), key);
    return abs(tar - key);
}

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

    int A, B, Q;
    cin >> A >> B >> Q;
    s.resize(A), t.resize(B), x.resize(Q);

    rep(i, A) { cin >> s[i]; }

    rep(i, B) { cin >> t[i]; }

    s.push_back(-INF), s.push_back(INF);
    t.push_back(-INF), t.push_back(INF);

    sort(all(s)), sort(all(t));

    rep(i, Q) {
        cin >> x[i];
        ll tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, sl, sr, tl, tr, ans = INF;
        sl = s_left_dist(x[i]);
        sr = s_right_dist(x[i]);
        tl = t_left_dist(x[i]);
        tr = t_right_dist(x[i]);

        tmp1 = max(sl, tl);
        ans = min(ans, tmp1);
        tmp2 = max(sr, tr);
        ans = min(ans, tmp2);

        ll key3 = x[i] - sl;
        tmp3 = sl + t_right_dist(key3);
        ans = min(ans, tmp3);
        ll key4 = x[i] + sr;
        tmp4 = sr + t_left_dist(key4);
        ans = min(ans, tmp4);
        ll key5 = x[i] - tl;
        tmp5 = tl + s_right_dist(key5);
        ans = min(ans, tmp5);
        ll key6 = x[i] + tr;
        tmp6 = tr + s_left_dist(key6);
        ans = min(ans, tmp6);

        cout << ans << endl;
    }
}

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

#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *h=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  int *dp=(int *)calloc(n,sizeof(int));
  for(i=1;i<n;i++){
    dp[i]=1000000000;
    for(int j=1;j<=k && i-j>=0;j++){
      dp[i]=MIN(dp[i],dp[i-j]+ABS(h[i]-h[i-j]));
    }
  }
  printf("%d\n",dp[n-1]);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//shuffle(permutation.begin(), permutation.end(), rng);
//uniform_int_distribution<int>(l, r)(rng);

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	vi v;
	REP(i, n) {
		int x, y;
		cin >> x;
		v.pb(x);
		cin >> y;
		v.pb(y);
	}
	sort(v.begin(), v.end());
	int j = 0;
	int res = 0;
	REP(i, n) {
		res += v[j];
		j += 2;
	}
	cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
std::vector<bool> IsPrime;
void sieve(size_t max){
   if(max+1 > IsPrime.size()){
       IsPrime.resize(max+1,true);
   }
   IsPrime[0] = false;
   IsPrime[1] = false;

   for(size_t i=2; i*i<=max; ++i)
       if(IsPrime[i])
           for(size_t j=2; i*j<=max; ++j)
               IsPrime[i*j] = false;
}
int main(){
  int x,i;
  sieve(1000000);
  cin >> x;
  for (i = x; i < 1000000; i++) {
    if(IsPrime[i])break;
  }
  cout << i << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>

using namespace std;

#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

long long sum;
int sol[11];
int N;
char s[11];
bool a[11];

void eval()
{
    long long nr = 0;
    for(int i = 1; i <= N; ++i)
        if(a[i])
        {
            nr = nr*10 + s[i] - 48;
            sum += nr;
            nr = 0;
        }
        else
            nr = nr*10 + s[i] - 48;
    sum += nr;
}

void plus_set(int k)
{
    memset(a,0,sizeof(a));
    for(int i = 1; i <= k; ++i)
        a[sol[i]] = 1;
}

void bt(int k)
{
    for(int i = sol[k-1] + 1; i < N; ++i)
    {
        sol[k] = i;
        plus_set(k),eval();
        bt(k + 1);
    }
}


int main()
{
    cin >> (s + 1);
    N = strlen(s + 1);
    eval();
    bt(1);
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[10009], dp[5009][2];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]);
	for (int i = 0; i <= n >> 1; i++) dp[i][0] = dp[i][1] = 999999999;
	dp[0][0] = dp[1][1] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = n >> 1; j >= 1; j--) {
			dp[j][0] = min(dp[j][0], dp[j][1] + a[i]);
			dp[j][1] = min(dp[j - 1][1], dp[j - 1][0] + a[i]);
		}
	}
	printf("%d\n", dp[n >> 1][0]);
	return 0;
}

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

bool isCorrect();

int main()
{
	if (isCorrect()) puts("correct");
	else puts("error");

	return 0;
}

bool isCorrect()
{
	constexpr int mod{1 << 8};
	std::map<std::string, std::pair<int, int>> lub;
	int m;
	scanf("%d", &m);
	for (int i{}; i < m; i++)
	{
		std::string name;
		int lb, ub;
		std::cin >> name >> lb >> ub;
		lub[name] = {lb, ub};
	}
	using i8b = std::array<bool, mod>;
	std::stack<i8b> st;
	int n;
	scanf("%d", &n);
	for (int i{}; i < n; i++)
	{
		std::string expression;
		std::cin >> expression;
		int size{(int)expression.size()};
		if (isdigit(expression.front()))
		{
			int num{std::stoi(expression)};
			i8b tmp{};
			tmp[num] = true;
			st.push(tmp);
		}
		else if (size == 1 && expression.front() == '+')
		{
			i8b next{};
			i8b rhs{st.top()};
			st.pop();
			i8b lhs{st.top()};
			st.pop();
			for (int i{}; i < mod; i++)
			{
				if (!lhs[i]) continue;
				for (int j{}; j < mod; j++)
				{
					if (!rhs[j]) continue;
					next[(i + j) % mod] = true;
				}
			}
			st.push(next);
		}
		else if (size == 1 && expression.front() == '-')
		{
			i8b next{};
			i8b rhs{st.top()};
			st.pop();
			i8b lhs{st.top()};
			st.pop();
			for (int i{}; i < mod; i++)
			{
				if (!lhs[i]) continue;
				for (int j{}; j < mod; j++)
				{
					if (!rhs[j]) continue;
					next[(i - j + mod) % mod] = true;
				}
			}
			st.push(next);
		}
		else if (size == 1 && expression.front() == '*')
		{
			i8b next{};
			i8b rhs{st.top()};
			st.pop();
			i8b lhs{st.top()};
			st.pop();
			for (int i{}; i < mod; i++)
			{
				if (!lhs[i]) continue;
				for (int j{}; j < mod; j++)
				{
					if (!rhs[j]) continue;
					next[(i * j) % mod] = true;
				}
			}
			st.push(next);
		}
		else if (size == 1 && expression.front() == '/')
		{
			i8b next{};
			i8b rhs{st.top()};
			st.pop();
			i8b lhs{st.top()};
			st.pop();
			if (rhs[0]) return false;
			for (int i{}; i < mod; i++)
			{
				if (!lhs[i]) continue;
				for (int j{}; j < mod; j++)
				{
					if (!rhs[j]) continue;
					next[i / j] = true;
				}
			}
			st.push(next);
		}
		else
		{
			i8b next{};
			int lb{lub[expression].first}, ub{lub[expression].second};
			for (int i{lb}; i <= ub; i++)
				next[i] = true;
			st.push(next);
		}
	}
	return true;
}


Measured memory_bytes: 3260
#include<iostream>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

int main(){
    int A,B,H,M;
    cin >>A>>B>>H>>M;

    long double hourangle=2*M_PI*H/12+2*M_PI/12*M/60;
    long double miniteangle=2*M_PI*M/60;
    //cout<<hourangle<<"°, "<<miniteangle<<"°"<<endl;
    cout<<fixed<<setprecision(15)<<sqrtl(A*A+B*B-2*A*B*cosl(fabs(hourangle-miniteangle)))<<endl;
    //cout<<sqrt(3*3+4*4-2*3*4*cos(5.23599-4.18879))<<endl;
    //cout<<3*3+4*4-2*3*4*cos(5.23599-4.18879)<<endl;
    //cout<<fabs(4.18879-5.23599)<<endl;
    return 0;
}

Measured memory_bytes: 4164
n, m = map(int, input().split())
li_X = list(map(int, input().split()))

li_X.sort()
li_X_delta = []
for i in range(len(li_X)-1):
    li_X_delta.append(li_X[i+1]-li_X[i])
li_X_delta.sort(reverse=True)
cnt = 0

ans = li_X[-1] - li_X[0]
for i in range(min(n-1, len(li_X_delta))):
    ans -= li_X_delta[i]
print(ans)

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {

	int n;
	cin >> n;

	if (n % 2 == 0) {
		cout << n * (n - 1) / 2 - n / 2 << endl;

		FOR(i, 1, n + 1) {
			FOR(j, i + 1, n + 1) {
				if (i + j == n + 1)continue;
				cout << i << ' ' << j << endl;
			}
		}
		return 0;
	}

	cout << n * (n - 1) / 2 - n / 2 << endl;

	FOR(i, 1, n + 1) {
		FOR(j, i + 1, n + 1) {
			if (i + j == n)continue;
			cout << i << ' ' << j << endl;
		}
	}


}

Measured memory_bytes: 256
import           Control.Monad.Trans.State.Strict
import           Data.Foldable
import           Data.Sequence

main :: IO ()
main = interact solve

solve :: String -> String
solve = toList . flip execState empty . mapM_ pressKey

pressKey :: Char -> State (Seq Char) ()
pressKey 'B' = modify delete
pressKey key = modify (|> key)

delete :: Seq Char -> Seq Char
delete console = case viewr console of EmptyR -> empty
                                       s :> c -> s

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

#define MAX (1000000000)

int min(int a,int b){
    return (a<b)?a:b;
}

int main(void){
    int H,N;
    int A[1111],B[1111];
    int ans=0;
    int HP_jittai[22222];
    int *HP=&HP_jittai[11111]; //HP[i]=>iを減らすのに必要なMPの最小値

    scanf("%d",&H);
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        scanf("%d",&B[i]);
    }

    for(int i=0;i<22222;i++){
        if(i<=11111){
            HP_jittai[i] = 0;
        }else{
            HP_jittai[i]=MAX;
        }
    }

    for(int i=0;i<11111;i++){
        for(int mahouNo=0;mahouNo<N;mahouNo++){
            HP[i] = min(HP[i],HP[i-A[mahouNo]]+B[mahouNo]);
        }
    }

    printf("%d",HP[H]);

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;

int N;
ll K;
int A[MAX];
vi lis[MAX];

void input(){
  cin>>N>>K;
  rep(i,N){
    cin>>A[i];
    A[i]--;
    lis[A[i]].pb(i);
  }
}
int nex[MAX];
int up[MAX];
vi loop, ct;
int t;
int start;
void solve(){
  rep(j,MAX){
    int s=sz(lis[j]);
    rep(i,s){
      int ind=lis[j][i];
      int nexto=i+1;
      if(nexto==s){
        up[ind]++;
        nexto=0;
      }
      int nextind=lis[j][nexto]+1;
      nex[ind]=nextind%N;
    }
  }
  int tmpind=0;
  int tmpct=0;
  while(true){
    loop.pb(tmpind);
    ct.pb(tmpct);
    tmpct+=up[tmpind];
    tmpind=nex[tmpind];
    if(tmpind==0)break;
  }
  t=tmpct+1;
  ll r=K%(ll)t;
  if(r==0)start=N;
  else{
    rep(i,sz(ct)){
      if((ll)ct[i]>=r)break;
      start=loop[i];
    }
  }
}

deque<int> ans;
bool in[MAX];
void output(){
  for(int i=start; i<N; i++){
    if(in[A[i]]){
      while(true){
        int p=ans.back();
        ans.pop_back();
        in[p]=false;
        if(p==A[i])break;
      }
    }
    else{
      ans.push_back(A[i]);
      in[A[i]]=true;
    }
  }
  while(!ans.empty()){
    cout<<ans.front()+1<<" ";
    ans.pop_front();
  }
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 17388
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

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

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL long long
#define ll long long
#define LD double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int main()
{
    HabdModeActive
    int n,x;
    cin>>n;
    int arr[n+2] = {};
    for(int i=0 ; i<n-1; i++)
        cin>>x, arr[x]++;
    for(int i=1 ; i<=n; i++)
        cout<<arr[i]<<endl;
    return 0;
}


Measured memory_bytes: 4388
# include <iostream>
# include <stack>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	stack<int> s1,s3;
	
	stack<pair<int,int> > s2;
	
	char ch;
	int max = 0;
	for(int i = 1;cin >> ch; i++)
	{
		if(ch=='\\')	s1.push(i);
		if(ch=='/'&&s1.size()>0)
		{
			int j = s1.top();
			s1.pop();
			int tem = i - j;
			max +=tem;
			while(s2.size()!=0&&j<s2.top().first)
			{
				tem += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j,tem));
		}
	}
	cout<<max<<endl;
	cout<<s2.size();
	int b = s2.size();
	for(int m = 1;m <= b;m++)
	{
		s3.push(s2.top().second);
		s2.pop();
	
 	} 
 	int v=s3.size();
 	for(int m = 1;m <=v;m++)
 	{
 		
	 	cout<<' '<<s3.top();
	 	s3.pop();

 	}
 	cout<<endl;
}


Measured memory_bytes: 3120
package main
import "fmt"

func deleteAryLeft(oAry []int, len int) []int{
	return oAry[len:]
}

func execMain4(num int, sAry []int) int {
	search_num := 1
	var ans_ary []int
	bcnt := 0
	for ; ; {
		isHit := false
		for i := 0; i < len(sAry); i++ {
			if sAry[i] == search_num {
				tAry := sAry[0:i+1]
				sAry = deleteAryLeft(sAry, len(tAry))
				ans_ary = append(ans_ary, tAry[i])
				if len(tAry) > 1 {
					bcnt += len(tAry) - 1
				}
				search_num++
				isHit = true
				break
			}
		}

		if !isHit {
			bcnt += len(sAry)
			break
		}
	}

	if len(ans_ary) < 1 {
		return -1
	}

	return bcnt
}

func main() {
	var num int

	fmt.Scanf("%d", &num)
	sAry := make([]int, num)
	for i := 0; i < num; i++ {
		fmt.Scan(&sAry[i])
	}

	fmt.Print(execMain4(num, sAry))
}




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


using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}

double const eps = 1e-10;
ll const modulo = 1e9+7;

int a[100100];


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

    int n;
    int result = 1;
    cin >> n;
    for ( int i = 1; i <= n; i++ )
        result = (result%modulo * i%modulo)%modulo;
    cout << result;

    return 0;

    // 274751WM
}


Measured memory_bytes: 256
N,K=map(int,input().split())
snuke=[0 for i in range(0,N)]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        snuke[A[j]-1]+=1

ans=0
for i in range(N):
    if snuke[i]==0:
        ans+=1
print(ans)

Measured memory_bytes: 67872
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int D, N;
int t[200], a[200], b[200], c[200]; //0-
int dp[201][201] = {};

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

	for (int i = 0; i < D; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];


	}


	for (int i = 1; i < D; i++) {
		for (int j = 0; j < N; j++) {
			if (t[i-1] < a[j] || b[j] < t[i-1]) continue;
			for (int k = 0; k < N; k++) {
				if (t[i] < a[k] || b[k] < t[i]) continue;
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + abs(c[j] - c[k]));
			}
		}
	}

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


	cout << ans << endl;


	return 0;
}



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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define quicker ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;

int main()
{
    quicker
    #ifdef HALO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
      cout << "Yes";
    else cout << "No";
}

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

ll N;

int main(void) {
  cin >> N;

  REP(h, 1, 3501) REP(w, 1, 3501) {
    ll p = h * w * N;
    ll q = 4 * h * w - N * (h + w);
    if(q != 0 && p % q == 0 && p / q > 0) {
      cout << h << " " << p / q << " " << w << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

// combination
// O(n)

const ll MOD = 1e9 + 7;
const ll max_n = 101010;
ll fact[max_n];
bool fact_init = false;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2; i < max_n; i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}

ll powmod(ll a, ll b){
  if(b == 0) return 1;
  if(b & 1) {
    return a * powmod(a, b - 1) % MOD;
  } else {
    ll d = powmod(a, b / 2) % MOD;
    return d * d % MOD;
  }
}

ll sub(ll a, ll b){
  a %= MOD, b %= MOD;
  a -= b;
  return a < 0 ? a + MOD : a;
}

ll inv(ll a){
	return powmod(a, MOD - 2);
}

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

	ll n;
	cin >> n;

	vector<ll> x(n);
	rep(i, n) cin >> x[i];

	ll _ = comb(1, 0);
	ll fct = fact[n-1];

	ll invs[n-1];
	invs[0] = 1;
	rep(i, n - 2){
		invs[i+1] = invs[i] + inv(i+2);
		invs[i+1] %= MOD;
	}
	
	ll ans = 0;
	rep(i, n-1) {
		ll t = (x[i+1] - x[i]) * fct;
		t %= MOD;
		t *= invs[i];
		t %= MOD;

		ans += t;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	int n;	cin >> n;	double arr[n];	for(int i=0; i<n; i++)	cin >> arr[i];	sort(arr,arr+n);
	int i=1;
	while(i<n){
		arr[i] = (arr[i-1]+arr[i])/2;
		i++;
	}
	cout<<arr[n-1];
	return 0;
}

Measured memory_bytes: 256
n = [int(x) for x in input()]
op_cnt = len(n) - 1

tmp = 0
for i in range(2**op_cnt):
    tmp = n[0]
    for j in range(op_cnt):
        if (i >> j) & 1:
            tmp += n[j+1]
        else:
            tmp -= n[j+1]
    if tmp == 7:
        print(
            "{}{}{}{}{}{}{}=7".format(
                n[0], "+" if (i >> 0) & 1 else "-",
                n[1], "+" if (i >> 1) & 1 else "-",
                n[2], "+" if (i >> 2) & 1 else "-",
                n[3]
            )
        )
        exit()


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

ll n;

ll ans;

inline void Work(){
    scanf("%lld",&n);
    for(REG ll i=2;i*i<n;++i)
        if(!((n-1)%i)) ans+=(i*i==n-1)?1:2;
    for(REG ll i=2;i*i<=n;++i){
        if(n%i) continue;
        ll tmp=n;
        while(!(tmp%i)) tmp/=i;
        if(tmp%i==1) ++ans;
    }
    printf("%lld",ans+2-(n==2));
}

int main(){Work();}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
cumulative_sum = [0]
ans = 1 << 40
n.times do |i|
    cumulative_sum << a[i] + cumulative_sum[i]
end
cumulative_sum.shift

(n-1).times do |i|
    tmp = (cumulative_sum[n-1] - cumulative_sum[i] * 2).abs
    ans = ans > tmp ? tmp : ans
end

puts ans

Measured memory_bytes: 18820
n, k = map(int, input().split())
xlis = list(map(int, input().split()))
ret = 10 ** 100
for i in range(n-k+1):
    min_val = xlis[i]
    max_val = xlis[k+i-1]
    if min_val * max_val >= 0:
        tmp = max(abs(min_val), abs(max_val))
        ret = min(ret, tmp)
    else:
        fst = min(abs(min_val), abs(max_val))
        lst = max(abs(min_val), abs(max_val))
        tmp = fst * 2 + lst
        ret = min(ret, tmp)

print(ret)


Measured memory_bytes: 62576
import math

def comb(n, m) :
    fact = math.factorial
    return fact(n) // fact(m) // fact(n-m)

N, A, B = map(int, input().split())
val = list(reversed(sorted(map(int, input().split()))))

ret = 0
prev = [0, 1]
for i in range(A, B + 1):
    cur = [sum([val[j] for j in range(i)]), i]
    if i > A and prev[0] * cur[1] > prev[1] * cur[0]:
        break
    ret += comb(val.count(val[i-1]), val[:i].count(val[i-1]))
    prev = cur

print(format(prev[0] / prev[1], '.12f'))
print(ret)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, ans = "NO";
  cin >> s;
  int n = s.size();
  if (n < 5 || n > 9) {
    cout << ans << endl;
    return 0;
  }
  s += "aaaaa";
  if (s[0] == 'A' && s[1] == 'K' && s[2] == 'I' && s[3] == 'H') {
    if (s[4] == 'A' && s[5] == 'B') {
      if (s[6] == 'A' && s[7] == 'R') {
        if ((s[8] == 'A' || s[8] == 'a') && s[9] == 'a') ans = "YES";
      }
      if (s[6] == 'R') {
        if ((s[7] == 'A' || s[7] == 'a') && s[8] == 'a') ans = "YES";
      }
    }
    if (s[4] == 'B') {
      if (s[5] == 'A' && s[6] == 'R') {
        if ((s[7] == 'A' || s[7] == 'a') && s[8] == 'a') ans = "YES";
      }
      if (s[5] == 'R') {
        if ((s[6] == 'A' || s[6] == 'a') && s[7] == 'a') ans = "YES";
      }
    }
  }
  if (s[0] == 'K' && s[1] == 'I' && s[2] == 'H') {
    if (s[3] == 'A' && s[4] == 'B') {
      if (s[5] == 'A' && s[6] == 'R') {
        if ((s[7] == 'A' || s[7] == 'a') && s[8] == 'a') ans = "YES";
      }
      if (s[5] == 'R') {
        if ((s[6] == 'A' || s[6] == 'a') && s[7] == 'a') ans = "YES";
      }
    }
    if (s[3] == 'B') {
      if (s[4] == 'A' && s[5] == 'R') {
        if ((s[6] == 'A' || s[6] == 'a') && s[7] == 'a') ans = "YES";
      }
      if (s[4] == 'R') {
        if ((s[5] == 'A' || s[5] == 'a') && s[6] == 'a') ans = "YES";
      }
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int K, X;
  cin >> K >> X;
  print((K * 500 >= X) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
import sys
import copy
N=int(input())
a=[int(c) for c in input().split()]
D=a[0]
X=a[1]
a = [int(input()) for i in range(N)]

choco = 0
for i in range(N):
    cnt=0
    while cnt*a[i]+1<=D:
        choco+=1
        cnt+=1

print(choco+X)


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

namespace AGC034
{
    class B
    {
        static void Main(string[] args)
        {
            long numBC = 0;
            string s = Console.ReadLine();

            long sum = 0;
            char p1 = '0', p2='0';
            for(int i = 0; i < s.Length; i++)
            {
                int j = s.Length - i - 1;
                if (s[j] == 'B')
                {
                    if (p1 == 'C') numBC++;
                    else numBC = 0;
                }
                else if (s[j] == 'A')
                {
                    if (p1 == 'C') numBC = 0;
                    sum += numBC;
                }
                else
                {
                    if (!(p1 == 'A') && !(p1 == 'B' && p2 == 'C')) numBC = 0;
                }
                p2 = p1;
                p1 = s[j];
            }
            Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 13112
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let s = a + b;
    if s % 2 == 0 {
        println!("{}", s / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}


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

int main()
{
	int n, a;
	scanf("%d%d", &n, &a);
	std::vector<int> x(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &x[i]);
	long long dp[64][4096]{};
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		const int& num{x[i]};
		for (int j = i; j >= 0; j--)
			for (int k = 0; k + num <= 2500; k++)
				dp[j + 1][k + num] += dp[j][k];
	}
	long long sum{};
	for (int i = 1; i <= n; i++)
		sum += dp[i][a * i];
	printf("%lld\n", sum);

	return 0;
}

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

int lcs(string x, string y) {
	int m = x.size();
	int n = y.size();
	//cout<<m<<n<<endl;
	int maxl = 0;
	int A[1001][1001]={};
	x = ' ' + x;
	y = ' ' + y;
//	cout<<x<<y;
	for (int i = 0;i <= m;i++) {
		A[i][0] = 0;
	}
	for (int j = 0;j <= n;j++) {
		A[0][j] = 0;
	}

	for (int i = 1;i <= m;i++) {
		for (int j = 1;j <= n;j++) {
		//	cout<<x[i]<<y[j]<<endl;
			if (x[i] == y[j]) {
					A[i][j] = A[i-1][j-1] + 1;
			}
	     	else {
					A[i][j] = max(A[i - 1][j], A[i][j - 1]);
			}

			maxl = max(maxl, A[i][j]);
		}
		
	}
	return maxl;
}

int main() {
	int n;
	string x, y;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> x >> y;
		cout<<lcs(x, y)<<endl;
		//lcs(x,y);

	}
	return 0;
}


Measured memory_bytes: 7100
N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1
for i in range(1, int(M**(1/2))+1):
    if M % i != 0:
        continue
    j = M // i  # jはどんどん小さくなる
    if j >= N:
        ans = max(ans, i)
    if i >= N:
        ans = max(ans, j)

print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

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

int main(){

    int N;
    cin >> N;

    vector<int> input_array(N);
    vector<int64_t> sum_array(N);
    vector<int64_t> c_array(N);
    vector<int64_t> ans_array(N);
    int i;
    int64_t temp = 0;
    int64_t sum = 0;
    int64_t c_temp = 0;
    int64_t sum_buf = 0;
    
    //  入力と同じ数値の回数を記録する配列を確保
    for (i=0; i<N; i++){
        cin >> input_array.at(i);
        sum_array.at(input_array.at(i)-1)++;
    }

    //  組み合わせ数の配列を確保し、組み合わせ数の総和を計算
    for (i=0; i<N; i++){
        if (sum_array.at(i)<2){
            c_array.at(i) = 0;
        }
        else{
            c_array.at(i) = (sum_array.at(i)*(sum_array.at(i)-1))/2;
        }
        sum += c_array.at(i);
    }

    for (i=0; i<N; i++){
        sum_buf = sum;
        temp = sum_array.at(input_array.at(i)-1) - 1;
        // cout << "temp = " << temp << endl;
        if (temp<2){
            c_temp = 0;
        }
        else{
            c_temp = ((temp)*(temp-1))/2;
        }
        /*
        cout << "c_array,at(input_array.at(i)) = " << c_array.at(input_array.at(i)) << endl;
        cout << "c_temp = " << c_temp << endl; 
        */
        sum_buf -= c_array.at(input_array.at(i)-1) - c_temp;
        ans_array.at(i) = sum_buf;
    }

    /*
    cout << "---sum_array--" << endl; 
    for (i=0; i<N; i++){
        cout << sum_array.at(i) << endl;
    }
    cout << "sum = " << sum << endl;
    */

    for (i=0; i<N; i++){
        cout << ans_array.at(i) << endl;
    }

    return 0;
}

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


Measured memory_bytes: 2076
// --------------
// Tejas Pandey  |
// 01 - 09 - 19  |
// ABC #139      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		string s,t;
		cin >> s >> t;
		int ans = 0;
		for(int i = 0;i < 3;i++)
		if(s[i] == t[i])
		ans++;
		cout << ans << "\n";
		
	}
	return 0;
}

Measured memory_bytes: 256