akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n,K,Q;
    scanf("%d%d%d", &n, &K, &Q);
    vector<int> a(n);
    vector<pair<int, int> > z;
    int i,j;
    map<int, int> cnt;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        z.push_back(make_pair(a[i], i));
        cnt[a[i]]++;
    }
    sort(z.begin(), z.end());

    ll ans = LINF;
    auto it = cnt.begin();
    for(; it!=cnt.end(); ++it) {
        int tmp0=it->first;
        vector<int> save;
        int cnt = 0;
        for (i = 0; i < n; i++) {
            int val = z[i].first;
            int id = z[i].second;
            if (val < tmp0) {
                save.push_back(id);
            }
            else {
                break;
            }
        }
        save.push_back(-1);
        save.push_back(n);
        sort(save.begin(), save.end());
        int siz = (int)save.size();

        ll ans0 = -INF;
        vector<int> num(siz);
        int cnt0 = 0;
        for (; i < n; i++) {
            int val = z[i].first;
            int id = z[i].second;
            int k=lower_bound(save.begin(), save.end(), id) - save.begin();
            k--;
            int tmp=save[k+1] - save[k] - 1;
            if (tmp - num[k] >= K) {
                cnt0++;
                ans0 = MAX(ans0, val);
                num[k]++;
                if (cnt0 == Q) {
                    break;
                }
            }
        }
        if (i == n) {
            continue;
        }
        ans=MIN(ans,ans0 - tmp0);
    }
    printf("%lld\n", ans);


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=200011;
typedef long long ll;

stack<int>q;
int l[N],r[N],a[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        while(!q.empty()&&a[i]<a[q.top()])q.pop();
        if(q.empty())l[i]=1;
        else l[i]=q.top()+1;
        q.push(i);
    }
    while(!q.empty())q.pop();
    for(int i=n;i>=1;i--){
        while(!q.empty()&&a[q.top()]>a[i])q.pop();
        if(q.empty())r[i]=n;
        else r[i]=q.top()-1;
        q.push(i);
    }
    //for(int i=1;i<=n;i++)cout<<l[i]<<" ";cout<<endl;
    //for(int i=1;i<=n;i++)cout<<r[i]<<" ";cout<<endl;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(ll)(i-l[i]+1)*(r[i]-i+1)*a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3456
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
inline int read()
{
	int x=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0'; c=getchar();}
	return x*f;
}
using namespace std;
int vis[100010],p[100010],sum[100010];
int n,cnt=0;
int main()
{
	int i,j;
	n=read();
	vis[1]=1;
	for(i=2;i<=100005;i++)
	{
		if(!vis[i])
		p[++cnt]=i;
		for(j=1;j<=cnt&&i*p[j]<=100005;j++)
		{
			vis[i*p[j]]=1;
			if(i%p[j]==0)
			break;
		}
	}
	sum[0]=0;
	for(i=1;i<=100005;i++)
	{
		sum[i]=sum[i-1];
		if(i&1 && !vis[i] && !vis[(i+1)>>1])
		sum[i]++;
	}
	for(i=1;i<=n;i++)
	{
		int l=read(),r=read();
		cout<<sum[r]-sum[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*#ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan*/

    int a; cin >> a;

    cout << a+(a*a)+(a*a*a) << endl;



    #ifdef TarekHasan
        main();
    #endif // TarekHasan

    return 0;
}


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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 764
eval"A,B,Q,*I="+`dd`.split*?,
s,t=[A,B].map{|a|[-F=1e15,*I.shift(a),F]}
eval"I.map{|x|p s[s#{a='.bsearch_index{|y|y>x}-1,2].map{|'}s|t[t#{a}t|[(s-x).abs,(t-x).abs].min+(t-s).abs}.min}.min}"

Measured memory_bytes: 66688
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  if (a == b)
    if (b == c)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  else
    if (b == c)
      cout << 2 << endl;
    else if (a == c)
      cout << 2 << endl;
    else
      cout << 3 << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>

#include <set>
#include <utility>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s;
    for (int i = 0; i < m; i++){
        int k;    cin >> k;
        vector<int> bufs;
        for (int i = 0; i < k; i++){
            int buf;
            cin >> buf;
            bufs.push_back(buf);            
        }
        s.push_back(bufs);
    }
    vector<int> p;
    for (int i = 0; i < m; i++){
        int bufp;
        cin >> bufp;
        p.push_back(bufp);
    }
    int res = 0;
    for (int bit = 0; bit < (1<<n); ++bit){
        bool ch = true;
        for(int i = 0; i < m; i++){
            int tentonum = 0;
            for(int j = 0; j < s[i].size(); j++){
                if(bit &( 1<<s[i][j]-1)){
                    tentonum++;
                }
            }
            if(tentonum%2!=p[i]){
                ch = false;
                break;
            }
    }
    if(ch) res++;
}
cout << res;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  print(max(a*b, c*d));
}


Measured memory_bytes: 888
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 111;
     
using namespace std;
 
int n, q, dp[maxn], a[maxn], b[maxn], t[4 * maxn];
set <int> s;
 
void upd(int v, int tl, int tr, int pos, int val){
	if (tl == tr){
		t[v] = val;
		return;
	}
	int tm = (tl + tr) >> 1;
	if (pos <= tm)
		upd(v * 2, tl, tm, pos, val);
	else
		upd(v * 2 + 1, tm + 1, tr, pos, val);
	t[v] = max(t[v * 2], t[v * 2 + 1]);
}
 
int get(int v, int tl, int tr, int l, int r){
	if (tr < l || r < tl)
		return 0;
	if (tl >= l && tr <= r)
		return t[v];
	int tm = (tl + tr) >> 1;
	int x = get(v * 2, tl, tm, l, r);
	int y = get(v * 2 + 1, tm + 1, tr, l, r);
	return max(x, y);
}
 
void solve(){
	cin >> n;  
 
	for (int i = 1; i <= n; i++)
		cin >> a[i];
 
	for (int i = 1; i <= n; i++)
		cin >> b[i];
 
	for (int i = 1; i <= n; i++){
		upd(1, 1, n, a[i], get(1, 1, n, 1, a[i]-1) + b[i]);
	}
 
	cout << t[1];
}
 
main(){
    boost;
	    
	q = 1;
 
	while (q--){
		solve();
	}
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[10005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll x=0,y=0,z=0,ans=0;
    for(ll i=1;i<=n;++i){
        cin>>s[i];
        ll len=s[i].length();
        if(s[i][0]=='B'&&s[i][len-1]=='A')z++;
        else if(s[i][0]=='B')y++;
        else if(s[i][len-1]=='A')x++;
        for(int j=0;s[i][j+1];++j){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                ans++;
                s[i][j]='$';
            }
        }
    }
    if(z&&x&&y){
        cout<<ans+z+1+min(x-1,y-1)<<endl;
    }
    else if(z){
        if(x||y)
            cout<<ans+z<<endl;
        else
            cout<<ans+z-1<<endl;
    }
    else{
        cout<<ans+min(x,y)<<endl;
    }
}


Measured memory_bytes: 768
lst = list(map(int,input().split()))
lst2 = list(map(lambda x: max(lst) - x, lst))
lst2.remove(0)
if lst2[0] % 2 == 0 and lst2[1] % 2 == 0:
    print(sum(lst2) // 2)
elif lst2[0] % 2 != 0 and lst2[1] % 2 != 0:
    _sum = (lst2[0] - 1) + (lst2[1] - 1)
    print(_sum // 2 + 1)
else:
    print((sum(lst2) + 1) // 2 + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll unsigned long long int
#define loop(i,a,b) for(int i=a;i<b;i++)

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    loop(i,0,n)
    cin>>a[i]>>b[i]>>c[i];

    int dp1[n],dp2[n],dp3[n];

    dp1[0]=a[0];
    dp2[0]=b[0];
    dp3[0]=c[0];

    loop(i,1,n)
    {
        dp1[i] = a[i]+ max(dp2[i-1],dp3[i-1]);
        dp2[i] = b[i]+ max(dp1[i-1],dp3[i-1]);
        dp3[i] = c[i]+ max(dp2[i-1],dp1[i-1]);
    }

    int ans = max(dp1[n-1],dp2[n-1]);
    cout<<max(ans,dp3[n-1])<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
int main() {
	char s[100010] = {};
	int ans, len, t;
	scanf("%s", s);
	len = strlen(s);
	ans = len;
	for (int i = 1; i < len; i++) {
		if(s[i - 1] != s[i]) {
			t = (i > (len - i)) ? i : (len - i);
			ans = (ans < t) ? ans : t;
		}
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

prev = h[0]
flag = True
for i in range(len(h) - 1):
    if prev > h[i+1]:
        if flag and prev - h[i+1] == 1:
            flag = False
            prev = h[i+1]
        else:
            print('No')
            break
    elif prev == h[i+1]:
        prev = h[i+1]
    else:
        flag = True
        prev = h[i+1]
else:
    print('Yes')



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

using namespace std;

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

int n, m;
vector<int> G[100000];
int id[100001];
int visit[100001] = {0};
int s, t;

void check(int x, int u) {
    visit[x] = 1;
    id[x] = u;

    int v;
    REP(i, G[x].size()) {
        v = G[x][i];
        if (visit[v] == 0) check(v, u);
    }
}

int main() {
    cin >> n >> m;
    int a, b;
    REP(i, m) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    REP(i, n) {
        if (visit[i] == 0) check(i, i);
    }

    int q;
    cin >> q;
    REP(i, q) {
        cin >> s >> t;
        if (id[s] == id[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14008
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=1e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int an,l,r;
char a[MAX];
int main()
{
    scanf("%s",a);
    int len=strlen(a);
    l=0;r=len-1;
    while(l<r)
    {
        if(a[l]==a[r])
        {
            ++l;--r;
        }
        else
        {
            if(a[l]=='x')
            {
                ++an;++l;
            }
            else if(a[r]=='x')
            {
                ++an;--r;
            }
            else
                return 0*printf("-1\n");
        }
    }
    printf("%d\n",an);
    return 0;
}
/*
5
5 6
1 2 1
2 3 2
2 4 3
3 4 4
3 5 3
4 5 2
*/


Measured memory_bytes: 384
if __name__ == '__main__':
    n, k = map(int, input().split())
    total = 0
    data = []
    
    for i in range(n):
        data.append(int(input()))
        total += data[i]

    def check(weight):
        i = 0
        for j in range(k):
            s = 0
            while s + data[i] <= weight:
                s += data[i]
                i += 1
                if i == n:
                    return n
        return i

    def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

    print(solve())



Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    rep(i,ty-sy) cout << 'U';
    rep(i,tx-sx) cout << 'R';
    rep(i,ty-sy) cout << 'D';
    rep(i,tx-sx) cout << 'L';
    cout << 'L';
    rep(i,ty-sy+1) cout << 'U';
    rep(i,tx-sx+1) cout << 'R';
    cout << "DR";
    rep(i,ty-sy+1) cout << 'D';
    rep(i,tx-sx+1) cout << 'L';
    cout << 'U';
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,k;cin>>n>>k;
    vector<double> v(n);
    rep(i,n)cin>>v[i];
    rep(i,n)v[i]=(1+v[i])/2;
    double sum=0;
    rep(i,k)sum+=v[i];
    double ans=sum;
    REP(i,k,n){
        sum+=v[i];
        sum-=v[i-k];
        chmax(ans,sum);
    }
    cout<<fixed<<setprecision(10);
    out(ans);
}

Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
"""
http://abc066.contest.atcoder.jp/tasks/abc066_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    rings = [int(x) for x in input().split()]
    rings.sort()
    print(rings[0] + rings[1])


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n,a[maxn];

int main() {
//  freopen("in.cpp","r",stdin);
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  vector<int>ans;
  for(int i=n-1;i>=0;i--){
    if(ans.size()==2)break;
    if(i&&a[i]==a[i-1]){
      ans.push_back(a[i]);
      i--;
    }
  }
  if(ans.size()<2)cout<<0<<endl;
  else cout<<ans[0]*(ll)ans[1]<<endl;
  return 0;
}



Measured memory_bytes: 640
H,W,D=map(int,input().split())
A=[list(map(lambda x:int(x)-1,input().split())) for _ in [0]*H]
Q=int(input())
LR=[list(map(lambda x:int(x)-1,input().split())) for _ in [0]*Q]
dic=[None]*(H*W)
dic2=[None]*(H*W)

for i in range(H):
    for j in range(W):
        dic[A[i][j]]=(i,j)

for i in range(H*W):
    if i<D:
        dic2[i]=0
    else:
        dic2[i]=dic2[i-D]+abs(dic[i][0]-dic[i-D][0])+abs(dic[i][1]-dic[i-D][1])

for i in range(Q):
    print(dic2[LR[i][1]]-dic2[LR[i][0]])

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

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

    // 3以下は素数
    if(X < 4)
    {
        cout << X << endl;
        return 0;
    }

    vector<int> v_prime;
    v_prime.push_back(2);
    v_prime.push_back(3);
    int judge_line = sqrt(X);
    // 5以上√X未満の素数を出す
    for(int i=4; i < X; i++)
    {
        // 今までの素数で割り切れるか判定する
        bool flag = true;
        for(auto it = v_prime.begin(); it != v_prime.end(); it++)
        {
            if(i % (*it) == 0)
            {
                flag=false;
            }
        }

        // 今までの素数で割り切れない→素数なので素数vectorに追加
        if(flag)
        {
            v_prime.push_back(i);
        }
    }

  // 次の素数が出るまで永久ループ
    int next_prime = X;
    while(1)
    {
    	bool flag = true;
        for(auto it = v_prime.begin(); it != v_prime.end(); it++)
        {
            if(next_prime % (*it) == 0)
            {
                next_prime++;
                flag = false;
            }
        }
      if(flag)
      {
        // 素数チェックを通過→次の素数
        cout << next_prime << endl;
        return 0;
      }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
#define mod 998244353
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
typedef unsigned long long ull;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}
inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}
inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;y >>= 1;
	}
	return res;
}

const int N = 18;
const ull base = 28;

ull mi[N];
char s[N];
int n , cnt[26];
lnt answer;
map<ull,ll> exi;


void dfs(int cur,ull sb,ull sr){
	if (cur == (n << 1 | 1) ){
//		printf("%llu %llu\n",sb,sr);
		exi[(sb << 30) + sr]++;
		return; 
	}
	dfs(cur + 1 , sb * base + s[cur] - 'a' + 1 , sr);
	dfs(cur + 1 , sb , sr * base + s[cur] - 'a' + 1);
}

int a[N] , b[N] , acnt , bcnt;

void dfs(int cur){
	if (cur == n + 1){
		ull sb = 0 , sr = 0;
		for (int i = bcnt;i >= 1;i--) sr = sr * base + b[i];
		for (int i = acnt;i >= 1;i--) sb = sb * base + a[i];
		
//		for (int i = 1;i <= acnt;i++) printf("%c",a[i]+'a'-1);enter;
//		for (int i = 1;i <= bcnt;i++) printf("%c",b[i]+'a'-1);enter;
//		printf("  %llu %llu\n",sb,sr);
		if (exi.count((sb << 30) + sr))answer += exi[(sb << 30) + sr];
		return;
	}
	a[++acnt] = s[cur] - 'a' + 1;dfs(cur + 1);--acnt; 
	b[++bcnt] = s[cur] - 'a' + 1;dfs(cur + 1);--bcnt; 
	
}
int main(){
	scanf("%d",&n);
	scanf("%s",s + 1);
	mi[0] = 1;for (int i = 1;i <= 2 * n;i++) mi[i] = base * mi[i-1];
	
	for (int i = 1;i <= 2 * n;i++){
		cnt[s[i]-'a']++;
	}
	for (int i = 0;i < 26;i++){
		if (cnt[i] & 1) return puts("0") , 0;
	}
	
	dfs(n + 1 , 0 , 0);
	dfs(1);
	
	cout<<answer<<endl;
	return 0;
}

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

int main() {
    int n, z, w;
    std::cin >> n >> z >> w;

    std::vector< int > as(n);
    for (auto &a: as) std::cin >> a;

    int ans = abs(w - as.back());
    if (n > 2) ans = std::max(ans, abs(as[n - 2] - as[n - 1]));

    std::cout << ans << std::endl;
}



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

void Main() {
  int N, K;
  cin >> N >> K;

  vector<int> x(N), y(N);
  vector<int> xx(N), yy(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    xx[i] = x[i];
    yy[i] = y[i];
  }

  sort(xx.begin(), xx.end());
  sort(yy.begin(), yy.end());

  long long ans = (long long)(xx[N - 1] - xx[0]) * (yy[N - 1] - yy[0]);
  for (int xi = 0; xi < N; xi++) {
    for (int xj = xi + 1; xj < N; xj++) {
      for (int yi = 0; yi < N; yi++) {
        for (int yj = yi + 1; yj < N; yj++) {
          int num = 0;

          for (int i = 0; i < N; i++) {
            if (xx[xi] <= x[i] && x[i] <= xx[xj] && yy[yi] <= y[i] && y[i] <= yy[yj]) num++;
          }

          if (num >= K) ans = min(ans, (long long)(xx[xj] - xx[xi]) * (yy[yj] - yy[yi]));
        }
      }
    }
  }

  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

struct q{
    char name[10];
    int t;
    struct q *next;
    struct q *prev;
};

typedef struct q * Q;

void enqueue(Q);
void dequeue();
void moveBack();
void printstate();

Q head;

int main(){
    
    int i, n, qt, time = 0;
    Q x;
    
    head = malloc(sizeof(struct q));
    head->next = head;
    head->prev = head;
    
    //input
    scanf("%d%d",&n,&qt);
    
    for (i = 0; i < n; i++){
        x = malloc(sizeof(struct q));
        scanf("%s", x->name);
        scanf("%d", &x->t);
        enqueue(x);
    }
    
  //process
    while(head->prev != head){
        if((head->next)->t > qt){
            (head->next)->t -= qt;
            moveBack();
            time += qt;
        }
        
        else{
            time += (head->next)->t;
            printf("%s %d\n",(head->next)->name, time);
            dequeue();
        }
        
        //printstate();
    }
    free(head);
    
    return 0;
}

    void enqueue(Q x){
        x->next = head;
        x->prev = head->prev;
        head->prev = x;
        (x->prev)->next = x;
    }
    
    void dequeue(){
        Q d = head->next, x = (head->next)->next;
        head->next = x;
        x->prev = head;
        
        free(d);
    }

    void moveBack(){
        Q x = (head->next)->next;
        if(x != head){
            enqueue(head->next);
            head->next = x;
            x->prev = head;
        }
    }

void printstate(){
    int i;
    Q x = head;
    
    for(i = 0; i < 5; i++){
        printf("%s %d\n",x->name,x->t);
        x=x->next;
    }
    
}



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


int main(){
	int n;
	int dx[]={1,0,-1,0};
	int dy[]={0,1,0,-1};
	double nxt[3][3],cur[3][3];
	while(cin>>n,n){
		memset(cur,0,sizeof(cur));
		int xs[3],ys[3];
		for(int i=0;i<3;i++){
			char c;
			int a;
			cin>>c;
			a=c-'A';
			xs[i]=a%3;
			ys[i]=a/3;
		}
		cur[xs[0]][ys[0]]=1;
		for(int i=0;i<n;i++){
			memset(nxt,0,sizeof(nxt));
			for(int x=0;x<3;x++){
				for(int y=0;y<3;y++){
					for(int i=0;i<4;i++){
						if(x+dx[i]==xs[2]&&y+dy[i]==ys[2]||x+dx[i]<0||2<x+dx[i]||y+dy[i]<0||2<y+dy[i])
							nxt[x][y]+=cur[x][y]/4;
						else
							nxt[x+dx[i]][y+dy[i]]+=cur[x][y]/4;
					}
				}
			}
			memcpy(cur,nxt,sizeof(cur));
		}
		printf("%.8f\n",cur[xs[1]][ys[1]]);
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int x[1000000];
signed main(){
	int a;
	cin>>a;
	int z=1;
	while(z<=a)z*=2;
	cout<<z-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#include<map>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}


int main() {
	string manji;
	int ans = 0,counto=0;
	cin >> manji;
	for (int i = 0; i < manji.size()-1; i++) {
		if (manji[i] != manji[i + 1]) {
			counto++;
		}
		else {
			ans += counto;
			counto = 0; }
		
	}
	ans += counto;
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N, W; cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) cin >> w.at(i) >> v.at(i);
  const long long INF = 1LL << 60;
  // dp[i][j] := i 番目の品物までで、価値の総和 j を実現するのに要する容量の最小値
  vector<vector<long long>> dp(N+1, vector<long long>(100001, INF));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 100000; j++) {
      // i 番目を選ばない
      dp.at(i+1).at(j) = min(dp.at(i+1).at(j), dp.at(i).at(j));
      // i 番目を選ぶ
      if (j - v.at(i) >= 0) {
        dp.at(i+1).at(j) = min(dp.at(i+1).at(j), dp.at(i).at(j - v.at(i)) + w.at(i));
      }
    }
  }
  long long ans = 0;
  for (int j = 0; j <= 100000; j++) {
    if (dp.at(N).at(j) <= W) ans = j;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>
using namespace std;
const long double EPS=1e-8;
bool maziwatteruno(complex<long double>a1,complex<long double>a2,complex<long double>b1,complex<long double>b2 ){
	a2-=a1;
	b1-=a1;
	b2-=a1;
	a1-=a1;
	b1/=a2;
	b2/=a2;
	a2/=a2;
	long double kouten=(abs(b1.imag())*b2.real()+abs(b2.imag())*b1.real());
	
	if(abs(b1.imag())+abs(b2.imag())<EPS&&(b1.real()<0&&b2.real()<0)||(b1.real()>1&&b2.real()>1))
	{
		return false;
	}else if(abs(b1.imag())+abs(b2.imag())<EPS){return true;}
	
	if(b1.imag()*b2.imag()>0){
		
		cout<<b1<<" "<<b2<<endl;
		return false;
	}else if(kouten<0||kouten>(abs(b1.imag())+abs(b2.imag()))){
		
		
		cout<<b1<<" "<<b2<<endl;
		return false;
	}else{
		return true;
	}
}


int main(){
	cout << fixed << setprecision(10);
	
	long double Re,Im;
	int q;
	complex<long double>p1,p2;
	
	cin>>q;
	
	for(int i=0;i<q;i++){
		
		
		complex<long double>p1,p2,p3,p4;
		
		cin>>Re>>Im;
		p1.real(Re);
		p1.imag(Im);
		cin>>Re>>Im;
		p2.real(Re);
		p2.imag(Im);
		cin>>Re>>Im;
		p3.real(Re);
		p3.imag(Im);
		cin>>Re>>Im;
		p4.real(Re);
		p4.imag(Im);
		
		p2-=p1;
	p3-=p1;
	p4-=p1;
	p1-=p1;
	p3/=p2;
	p4/=p2;
	p2/=p2;
		if(abs(p3.imag()-p4.imag())<EPS){
			cout<<2<<endl;
		}else if(abs(p3.real()-p4.real())<EPS)
		 {
		 	cout<<1<<endl;
		 }
		 else{
		cout<<0<<endl;	
		}
	}
	
}


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

int main(){
  string s,t;
  cin>>s>>t;
  t.erase(t.size()-1,1);
  if(s==t){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
  return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll h,w;
  cin >> w >> h;
  vector<pair<ll,int>> p(w+h);
  rep(i,w){
    cin >> p[i].first;
    p[i].second = 0;
  }
  rep(i,h){
    cin >> p[i+w].first;
    p[i+w].second = 1;
  }  

  sort(p.begin(), p.end());
  ll cntw=0,cnth=0;
  ll res = 0;
  rep(i,h+w){
    //    cout << p[i].first << ":" << p[i].second << "\n";
    if(p[i].second==0){
      res += p[i].first*(h+1-cnth);
      cntw++;
    }
    else{
      res += p[i].first*(w+1-cntw);
      cnth++;
    }
  }

  cout << res << "\n";
  
  
  
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  
  int larcount = 0;
  int count = 0;
  queue<string> q;
  for(int i=0;i<N-1;i++){
    
    if(a.at(i)==a.at(i+1)){
      count++;
      
    }
    if (a.at(i)!=a.at(i+1) || i == N-2){
      if(count>larcount){
        while(!q.empty()){
          q.pop();
        }
        q.push(a.at(i));
        larcount = count;
        
      }
      else if(count == larcount){
        q.push(a.at(i));
      }
      count = 0;
      if(larcount == 0 && i == N-2){
        q.push(a.at(i+1));
      }
    }
  }
  while(!q.empty()){
    cout << q.front() << endl;
    q.pop();
  }
      
      
   
 
  
}




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

int main() {
    int X;
    std::cin >> X;

    std::vector<int> v(X + 1);

    v[1] = 1;
    for (int b = 2; b <= X; ++b) {
        int num = b * b;
        while (num <= X) {
            v[num] = 1;
            num *= b;
        }
    }

    const auto it = std::find(v.crbegin(), v.crend(), 1);
    const auto ret = static_cast<int>(v.crend() - it) - 1;

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

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

            // in
            int N = Integer.parseInt(sc.next());
            long A[] = new long[N];
            long Ac[] = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = Integer.parseInt(sc.next());
                if (i == 0) {
                    Ac[i] = A[i];
                } else {
                    Ac[i] = A[i] + Ac[i - 1];
                }
            }

            // solve
            long sum = 0;
            for (int i = N - 1; i > 0; i--) {
                sum += (A[i] % MOD) * (Ac[i - 1] % MOD) % MOD;
            }
            sum %= MOD;
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 62800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n,h,w;
    cin>>n>>h>>w;
    int result=0,tmph,tmpw;
    while(n--){
        cin>>tmph>>tmpw;
        if(h<=tmph&&w<=tmpw){
            result++;
        }
    }
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var a = new long[N][];
            for (var i = 0; i < N; ++i)
                a[i] = Sarray();
            var states = (long)(1 << (int)N);

            var dp = new long[states];
            var points = new long[states];
            for (int t = 0; t < states; ++t)
                for (int i = 0; i < N; ++i)
                    if ((t & (1 << i)) != 0)
                        for (int j = i + 1; j < N; ++j)
                            if ((t & (1 << j)) != 0)
                                dp[t] += a[i][j];
            for (int i = 1; i < states; ++i)
            {
                for (int j = i; 0 < j; j = (j - 1) & i)
                    dp[i] = Max(dp[i], dp[i - j] + dp[j]);

            }
            WriteLine(dp[states - 1]);
        }
        static bool bit(long n, int k) => 0 != ((n >> k) & 1);
    }
}

Measured memory_bytes: 14176
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


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

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    int c = 0;
    sort(all(a));
    rep(i, 0, k) c += a[i];
    put(c);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}





Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 1;i++){
        int cnt = 0;
        map<char, int> mp;
        for (int j = i + 1; j < n;j++){
            for (int k = 0; k <= i;k++){
                if(s[j] == s[k]){
                    mp[s[j]]++;
                }
            }
        }
        for (int j = i + 1; j < n;j++){
            if(mp[s[j]]){
                mp[s[j]] = 0;
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from math import gcd
K = int(input())

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        tmp = gcd(i, j)
        if tmp == 1:
            ans += K
        else:
            for k in range(1, K + 1):
                ans += gcd(tmp, k)

print(ans)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n;
bool flag;
string s;
int main()
{
    cin>>s;
    rep(i,1,s.size())printf("%c",'x');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e5+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int N,M;
char S[MAXN];
int trace[MAXN];
pii dp[MAXN];
set<pii> D;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    cin >> S;

    D.insert({0,N});
    ford(i,N-1) {
        if(S[i] == '0') {
            auto p = *D.begin();
            if(p.fi == 1e9) RETURN(-1);
            dp[i] = {p.fi+1,p.se};
            D.insert({p.fi+1,i});
        } else {
            D.insert({1e9,i});
        }

        if(i+M <= N) {
            D.erase({dp[i+M].fi,i+M});
        }
    }

    for(int i = 0; i < N; i = dp[i].se) 
        cout << dp[i].se - i << ' ';
    cout << endl;
    return 0;
}



Measured memory_bytes: 5632
import sys
sys.setrecursionlimit(10**6)

def main():
	n, m, t = map(int, input().split())
	diff_sum = 0
	mini_diff = 0
	a = [-1*m] + [i for i in map(int, input().split())]
	for i in range(n):
		diff = (2 * m) - (a[i+1] - a[i])
		if diff > 0:
			diff_sum += diff
	if t-m < a[n]:
		mini_diff = a[n] + m - t
	print( t - (2*m*n - diff_sum - mini_diff) )
	return

main()


Measured memory_bytes: 5608
N,*H=`dd`.split.map &:to_i;
B=[0]*-~N;
U=->i,w{(B[i]=[B[i],w].max;i+=i&-i)while i<=N};
Q=->i{r=0;(r=[r,B[i]].max;i-=i&-i)while i>0;r};
A=H.pop N;
N.times{|i|
k=H[i];
U[k,Q[k]+A[i]]
};
p Q[N]


Measured memory_bytes: 55316
#include<iostream>
#include<algorithm>

int main() {
	size_t arr[3];
	std::cin >> arr[0] >> arr[1] >> arr[2];
	std::sort(std::begin(arr), std::end(arr));
//	std::cout << arr[0] << "\n";
	if (arr[0] + arr[1] == arr[2]) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
	return 0;
}

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


using ll = long long int;

using namespace std;

bool has_digit(string a, string d)
{
    /*
    bool ans = false;
    while(a)
    {
        ans = ans || ((a % 10) == d);
        a /= 10;
    }
    return ans;*/
    //bool res = (a.find(d) != std::string::npos);
    bool res = a == d;
    return res;

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, n, d, k;
    
    cin >> n;
    
    
    vector<string> a(n);
    
    int l, r, m;
    l = 0;
    r = n;
    
    for(i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    
    
    while (l < r)
    {
         vector<char> destroyed(n);
         m = (l + r) / 2;
         k = 0;
         d = 1;
         
         if (m != k)
         {
             for(i = 0; i < n; ++i)
             {
                 if (has_digit(a[i], to_string(d)))
                 {
                     ++d;
                 }
                 else
                 {
                     destroyed[i] = 1;
                     ++k;
                 }
                 if (m == k)
                     break;
             }
         }
             
         bool flag = (m >= k); //true;
         d = 1;
         
         for(i = 0; i < n; ++i)
         {
             if (!destroyed[i])
             {
                 if (!has_digit(a[i], to_string(d)))
                 {
                     flag = false;
                     break;
                 }
                 ++d;
             }
         }
         
         if (flag)
         {
             r = m;
         }
         else
         {
             l = m + 1;
         }

    }
    
    int ans = r;
    if (ans == n)
        ans = -1;
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 13500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> inline void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  vector<ll> v(n);
  rep(i,0,n)cin>>v[i];
  vector<ll> zero(60,0);
  vector<ll> iti(60,0);
  rep(i,0,n){
    ll x=v[i];
    int cnt=0;
    while(x>0){
      if(x%2)iti[cnt]++;
      cnt++;
      x/=2;
    }
  }

  rep(i,0,60)zero[i]=n-iti[i];

  ll ans=0;
  rep(i,0,60){
    ll c=zero[i]*iti[i];
    c%=mod;

    ans+=(modpow(2,i,mod)*c)%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int amount = 100 * r + 10 * g + b;
  
  if (amount % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3600
def main():
    import sys
    input = sys.stdin.readline

    A, B, C, D = map(int, input().split())

    while True:
        C -= B
        if C <= 0:
            print('Yes')
            exit()
        A -= D
        if A <= 0:
            print('No')
            exit()


if __name__ == "__main__":
    main()


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s;
  cin >> t;
  if (s.size() + 1 == t.size()){
    bool equ = true;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] != t[i])
      {
        equ = false;
        break;
      }
    }
    if (equ)
      cout << "Yes\n";
    else
      cout << "No\n";
  }else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3596
package main

import (
	"fmt"
)

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}
func main() {
	var N int
	var R [9]int

	fmt.Scanf("%d", &N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scanf("%d", &a)
		switch {
		case a < 400:
			R[0] += 1
		case a < 800:
			R[1] += 1
		case a < 1200:
			R[2] += 1
		case a < 1600:
			R[3] += 1
		case a < 2000:
			R[4] += 1
		case a < 2400:
			R[5] += 1
		case a < 2800:
			R[6] += 1
		case a < 3200:
			R[7] += 1
		default:
			R[8] += 1
		}
	}
	ret := 0
	for i := 0; i < 8; i++ {
		if R[i] > 0 {
			ret += 1
		}
	}
	if 0 < R[8] && ret == 0 {
		fmt.Println(1,  R[8])
	} else {
		fmt.Println(ret, ret+R[8])
	}

}


Measured memory_bytes: 512