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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
ll acc [101] [101];
const ll INF = 1e17;

int main()
{
	scanf("%d",&N);
	vector< vector<ll> > A(N,vector<ll>(N));
	FOR(i,0,N) FOR(j,0,N){
		scanf("%lld",&A [i] [j]);
	}
	FOR(i,0,N) FOR(j,0,N){
		acc [i + 1] [j + 1] = A [i] [j];
		acc [i + 1] [j + 1] += acc [i + 1] [j] + acc [i] [j + 1] - acc [i] [j];
	}

	ll ans = -INF;
	FOR(i,0,N) FOR(j,0,N) FOR(k,i + 1,N + 1) FOR(l,j + 1,N + 1){
		chmax(ans,acc [k] [l] - acc [i] [l] - acc [k] [j] + acc [i] [j]);
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 3416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;

vector<int>e[maxn];
int n;
int dis[maxn];
int f[maxn];

void dfs(int x,int fa){
  dis[x]=dis[fa]+1;
  for(int i=0;i<e[x].size();i++){
    int y = e[x][i];
    if(y==fa)continue;
    dfs(y, x);
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n;
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1,0);
  int mx=0,idx;
  for(int i=1;i<=n;i++){
    if(dis[i]>mx){
      mx = dis[i];
      idx=i;
    }
  }
  memset(dis,0,sizeof(dis));
  dfs(idx,0);
  mx=0;
  for(int i=1;i<=n;i++){
    if(dis[i]>mx){
      mx = dis[i];
    }
  }
  f[2]=0,f[1]=1;
  for(int i=3;i<=mx;i++){
    if(f[i-1]==0||f[i-2]==0)f[i]=1;
    else f[i]=0;
  }
  if(f[mx])cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;
}

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

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

    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << "-1";
        return 0;
    }
    cout << a * b;
}

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

using namespace std;

typedef long long ll;
typedef pair<string,int> P;

int main(){
    vector<P> rest;
    int n;
    cin >> n;
    int num[105];
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int p;
        cin >> p;
        num[100-p] = i+1;
        rest.push_back(P(s, 100-p));
    }
    sort(rest.begin(), rest.end());
    for(int i = 0; i < n; i++)cout << num[rest[i].second] << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 5005;
int n, a, b;
int p[maxn];

bool read() {
  if (scanf("%d%d%d", &n, &a, &b) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  return true;
}

long long dp[maxn][maxn];

void solve() {
  for (int i = 0; i <= n; i++) {
    dp[0][i] = 0;
    dp[i][0] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int mx = -1;
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (p[j] < i) {
        if (mx == -1 || p[j] > p[mx]) {
          mx = j;
          cnt = 0;
        } else {
          cnt++;
        }
      }
      auto &cur = dp[i][j + 1];
      if (mx == -1) {
        cur = 0;
        continue;
      }
      if (cnt == 0) {
        cur = dp[i][mx];
        continue;
      }
      cur = a + dp[p[mx]][j + 1];
      cur = min(cur, dp[i][mx] + (long long) b * cnt);
    }
  }
  printf("%lld\n", dp[n][n]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
template<typename T>
struct BIT{
    vector<T> bit;
    int size;
    BIT(int _size) : bit(vector<T>(_size+1,0)),size(_size){}
    void add(int index, T value){
        for(int i=index+1 ; i<=size ; i+=(i&-i)) bit[i]+=value;
    }
    T sum(int a,int b){//sum of[a,b)
        return sum(b)-sum(a);
    }
    T sum(int a){ // sum of[0,a) = sum of bit[0]~bit[a]
        T ret=0;
        for(int i= a ; i>0; i-=(i&-i)) ret+=bit[i];
        return ret;
    }
};
struct Problem{
    LL n,k;
    vector<LL> a,sum,pos;
    vector<pair<LL,LL>> s;
    BIT<LL> bit;
    Problem(LL n):n(n),a(n+1),sum(n+1),pos(n+1),bit(n){};

    void solve(){
        cin >> k;
        for(int i=1; i<=n; ++i){
            cin >> a[i];
            a[i]-=k;
        }
        for(int i=1; i<=n; ++i){
            sum[i]=sum[i-1]+a[i];
        }
        for(int i=1; i<=n; ++i){
            s.emplace_back(sum[n]-sum[i-1],i);
        }
        sort(s.begin(),s.end());
        for(int i=0; i<n; ++i){
            pos[s[i].second]=i;
        }
        LL ans =0;
        for(int i=1; i<=n; ++i){
            LL tmp=sum[n]-sum[i];
            int it= lower_bound(s.begin(),s.end(),make_pair(tmp,0ll))-s.begin();
            bit.add(pos[i],1);
            ans+=bit.sum(it,n);
            /*LL lb=-1,ub=i;
            while(ub-lb>1){
                LL mid = (lb+ub)/2;
                if(check(i,mid)) ub=mid;
                else lb=mid;
            }
            ans+=ub;*/
            DBG(i,ans)
        }
        cout << ans << "\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 12656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


 
int main() {
    ll N, P; cin >> N >> P;
    string S; cin >> S;
    vector<ll> rem(S.size()+1);
    rem[N] = 0;
    ll ans = 0;
    if(P == 2 || P == 5){
        if(P == 2){
            for(ll i = N-1; i >= 0; i--){
                if(((int)S[i]-48) % 2 == 0) ans += i+1;
            }
        }
        else{
            for(ll i = N-1; i >= 0; i--){
                if(((int)S[i]-48) % 5 == 0) ans+= i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    else{
        for(ll i = N-1; i >= 0; i--){
            ll tmp = ((S[i]-48) * modpow(10, N-i-1, P)) % P;
            rem[i] = (rem[i+1]+tmp)%P;
        }
        vector<set<ll>> R(P+1);
        for(ll i = 0; i <= N; i++){
            R[rem[i]].insert(i);
        }
        for(ll i = 0; i < R.size(); i++) ans += (R[i].size()*(R[i].size()-1))/2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 11780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main(){
  string S; cin>>S;
  string b = "AKIHABARA";
  REP(i,2) REP(j,2) REP(k,2) REP(l,2) {
    string a = b;
    if(i) a[0]='.';
    if(j) a[4]='.';
    if(k) a[6]='.';
    if(l) a[8]='.';
    string c;
    for(auto p:a) if(p!='.') c+=p;
    if(c==S) {
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}


Measured memory_bytes: 764
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = k + 1;
    if (b > a && a <= k) {
        ll more = (k - a + 1);
        ll ad = (more / 2) * (b - a);
        ll cans = a + ad;
        if (more % 2) {
            cans++;
        }
        ans = max(ans, cans);
    }

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



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin >> s;
    lli ans = INF;
    rep(i, s.size() - 2) {
        int num = stoi(s.substr(i, 3));
        ans = min(ans, (lli)abs(753 - num));
    }
    out(ans);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int bst[100000], n, x[100000], md = 1e9 + 7;

int main(){
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	int first = x[0], b = 1;
	bst[0] = 1;
	f(i, 1, n){
		if (first <= 0)first += 2, ++b;
		bst[i] = b;
		if (x[i] > x[i - 1] + 1)x[i] = x[i - 1] + 2;
		else --first;
	}
	int an = 1;
	for (int i = n - 1; i >= 0; --i){
		int s = i + 1;
		an = (ll)an * (s - bst[i] + 1) % md;
	}
	printf("%d\n", an);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size<=k)
	{
		cout<<s<<endl;
	}
	else
	{
		string p = s.substr(0,k);
		p=p+"...";
		cout<<p<<endl;
	}
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    ll N; cin >> N;
    string S, T; cin >> S >> T;
    
    ll max = 0;
    REP(i, N) {
        if (S.substr(i, N - i) == T.substr(0, N - i)) {
            cout << 2 * N - (N - i) << endl;
            return 0;
        }
    }
    cout << 2 * N << endl;
    
    return 0;
}


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

int main(){
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;
    if(S == U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
using namespace std;
const int N=110000;
int head[N],np[N<<1],p[N<<1],tot;
int key[N];
int n,K;
int root;
int fa[N];
int dep[N];
int dx[2]={-1,1};
int seg[N],cl[N*35],cr[N*35],segtot,mi[N*35][2];
void copy(int x,int y){
	if(!y){
		rep(i,0,1)mi[x][i]=(1e9);
	}
	else{
		cl[x]=cl[y];
		cr[x]=cr[y];
		rep(i,0,1)mi[x][i]=mi[y][i];
	}
}
void insert(int &me,int l,int r,int x,int v){
	++segtot;
	copy(segtot,me);
	me=segtot;
	if(l==r){
		rep(i,0,1)mi[me][i]=v+dx[i]*x;
		return;
	}
	int mid=(l+r)>>1;
	if(x<=mid)insert(cl[me],l,mid,x,v);
	else insert(cr[me],mid+1,r,x,v);

	rep(i,0,1)mi[me][i]=min(mi[cl[me]][i],mi[cr[me]][i]);
}
int merge(int a,int b,int l,int r){
	if(!a||!b)return a+b;
	int d=++segtot;

	if(l==r){
		rep(i,0,1)mi[d][i]=min(mi[a][i],mi[b][i]);
		return d;
	}
	int mid=(l+r)>>1;
	cl[d]=merge(cl[a],cl[b],l,mid);
	cr[d]=merge(cr[a],cr[b],mid+1,r);
	rep(i,0,1)mi[d][i]=min(mi[cl[d]][i],mi[cr[d]][i]);
	return d;
}
void dfs(int x){
	for(int u=head[x];u;u=np[u])if(p[u]^fa[x]){
		fa[p[u]]=x;dep[p[u]]=dep[x]+1;dfs(p[u]);
		seg[x]=merge(seg[x],seg[p[u]],0,100000);
	}
	if(key[x]>=0){
		insert(seg[x],0,100000,key[x],dep[x]);
	}
}
int ask(int k,int me,int l,int r,int x,int y){
	if((x>y)||(!me))return 1000000000;
	if(x<=l&&r<=y)return mi[me][k];
	int ret=1000000000;
	int mid=(l+r)>>1;
	if(x<=mid){
		int D=ask(k,cl[me],l,mid,x,y);
		if(D<ret)ret=D;
	}
	if(y>mid){
		int D=ask(k,cr[me],mid+1,r,x,y);
		if(D<ret)ret=D;
	}
	return ret;
}
void work(int x,int fav){
	//printf("%d %d\n",x,fav);
	if(key[x]>=0){
		fav=key[x];
		for(int u=head[x];u;u=np[u])if(p[u]^fa[x])work(p[u],fav);
		return;
	}
	//1
	bool flag=1;
	fav++;
	int dj=ask(1,seg[x],0,100000,0,fav);
	if(dj<dep[x]+fav)flag=0;
	//printf("__+ %d\n",dj);
	dj=ask(0,seg[x],0,100000,fav,100000);
	//printf("__+ %d\n",dj);
	if(dj<dep[x]-fav)flag=0;
	if(flag){
		key[x]=fav;
		for(int u=head[x];u;u=np[u])if(p[u]^fa[x])work(p[u],fav);
		return;
	}
	//-1
	fav-=2;
	flag=1;
	dj=ask(1,seg[x],0,100000,0,fav);
	if(dj<dep[x]+fav)flag=0;
	//printf("__- %d\n",dj);
	dj=ask(0,seg[x],0,100000,fav,100000);
	if(dj<dep[x]-fav)flag=0;
	//printf("__- %d\n",dj);
	if(flag){
		key[x]=fav;
		for(int u=head[x];u;u=np[u])if(p[u]^fa[x])work(p[u],fav);
		return;
	}
}
int main(){
	rep(i,0,1)mi[0][i]=1e9;
	scanf("%d",&n);
	rep(i,1,n-1){
		int a,b;scanf("%d%d",&a,&b);
		++tot;p[tot]=b;np[tot]=head[a];head[a]=tot;
		++tot;p[tot]=a;np[tot]=head[b];head[b]=tot;
	}
	scanf("%d",&K);
	rep(i,1,n)key[i]=-10000000;
	rep(i,1,K){
		int v,p;scanf("%d%d",&v,&p);
		key[v]=p;
		root=v;
	}
	dfs(root);
	work(root,10086);
	rep(i,1,n)if(i!=root)if(abs(key[i]-key[fa[i]])!=1){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	rep(i,1,n)printf("%d\n",key[i]);
	return 0;
}






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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}

int main(void){
    int n; ll k;
    cin >> n >> k;
    int a[60][n];
    rep(i, n){
        cin >> a[0][i];
        a[0][i]--;
    }
    for(int i = 1; i < 60; i++){
        for(int j = 0; j < n; j++){
            a[i][j] = a[i-1][a[i-1][j]];
        }
    }
    int now = 0;
    for(int i = 59; 0 <= i; i--){
        ll l = (1ll << i);
        if(l <= k){
            now = a[i][now];
            k -= l;
        }
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 50540
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  ll ans = 0;
  if(p == 2 || p == 5){
  	for(int i = n - 1; i >= 0; --i){
  		if((s[i] - '0') % p == 0)ans += i + 1;
  	}
  }
  else{
  	vector<ll> cnt(p, 0);
  	int tens = 1;
    int mods = 0;
  	for(int i = n - 1; i >= 0; --i){
  		(mods += (s[i] - '0') * tens) %= p;
  		(tens *= 10) %= p;
  		++cnt[mods];
  	}

  	for(int i = 0; i < p; ++i){
  		ans += cnt[i] * (cnt[i] - 1) / 2;
  		if(i == 0)ans += cnt[i];
  	}
  }

  cout << ans << endl;
  return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n);
	for(int i=0;i<n;++i)
		cin>>v[i];
	ll lo=1,hi=2e9;
	ll ans=-1;
	auto f=[&](ll m){

		ll val=0;
		for(int i=0;i<n;++i)
			val+=ceil(v[i]*1.0/m)-1;
		return val<=k;
	};	
	while(lo<=hi)
	{
		ll mid=(lo+hi)/2;
		if(f(mid))
		{
			ans=mid;
			hi=mid-1;
		}
		else
			lo=mid+1;
	}
	cout<<ans;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


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

int main() {
  long long int N = 0;
  long long int X = 0;
  long long int Y = 0;
  cin >> N >> X >> Y;
  vector<long long int> k(N);
  for (int i = 1; i <= N-1; i++){
    for (int j = i + 1; j <= N; j++){
      long long int mn = j - i;
      mn = min(abs(i - X) + abs(j - Y) + 1, mn);
      k.at(mn - 1)++;
    }
  }
  for (int i = 0; i < N - 1; i++) cout << k.at(i) << endl;  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
///////////////////////////////////////


int main() {
	int n;
	int x[110];
	cin >> n;
	REP(i, n)cin >> x[i];
	int ans = INF;
	for (int i = 1; i <= 100; ++i) {
		int key = 0;
		for (int j = 0; j < n; ++j) {
			key += (i - x[j])*(i - x[j]);
		}
		ans = min(ans, key);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
int dp[11][1024][341];
int main(){
    dp[0][0][0]=1;
    for(int i=0;i<10;i++){
        for(int j=0;j<1024;j++){
            for(int k=0;k<331;k++){
                if(dp[i][j][k]==0)continue;
                for(int l=0;l<10;l++){
                    if(!((j>>l)&1)){
                        dp[i+1][j|(1<<l)][(i+1)*l+k]+=dp[i][j][k];
                    }
                }
            }
        }
    }
    int n,s;
    while(cin>>n>>s){
        int sum=0;
        if(n>10||s>330){
            cout<<0<<endl;
            continue;
        }
        for(int i=0;i<1024;i++){
            sum+=dp[n][i][s];

        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 13484
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}
int ww ,hh;

vvi tate(vvi v,int h) {
  rep(k,hh) {
    if(h>>k&1) rep(i,ww) v.at(k).at(i) = 0;
  }
  return v;
}

vvi yoko(vvi v,int w) {
  rep(k,ww) {
    if(w>>k&1) rep(i,hh) v.at(i).at(k) = 0;
  }
  return v;
}

int cnt(vvi v) {
  int ans=0;
  rep(i,hh) rep(j,ww) if(v.at(i).at(j)) ans++;
  return ans;
}


int main() {
  int k;
  cin >> hh >> ww >> k;
  vvi maze(hh,vi(ww,0));

  rep(i,hh) {
    string s;cin >> s;
    rep(j,ww) {
      char c;
      c=s.at(j);
      if(c=='.') maze.at(i).at(j) = 0;
      else maze.at(i).at(j) = 1;
    }
  }

  int ans = 0;

  rep(i,1<<hh) {
    vvi copy = maze;
    copy=tate(copy,i);
    rep(j,1<<ww) {
      vvi copy2 = copy;
      copy2=yoko(copy2,j);
      if(cnt(copy2)==k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
N = input()
S = input()
a = 0
nums = list(N[i:i+len(S)] for i in range(len(N)) if i+len(S)-1 < len(N))
nums_max  = 0
for i in nums:
  tmp = 0
  for j in range(len(S)):
    if i[j] == S[j]:
      tmp += 1
  if nums_max < tmp:
    nums_max = tmp
print(len(S)-nums_max)

Measured memory_bytes: 9168
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut a:[i64;n],
    }
    // let mut a = vec![0];
    // a.append(&mut b);
    let mut anss = vec![false; n + 1];
    let mut z = vec![];
    for i in (0..n).rev() {
        let j = divisor(i + 1);
        if ((a[i] == 1) ^ anss[i + 1]) {
            for divs in j {
                anss[divs] = !anss[divs];
            }
            z.push(i + 1);
        }
    }
    println!("{}", z.len());
    for &x in z.iter() {
        println!("{}", x);
    }
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}


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


void solve(){

}

int main(){
    long long N;
    cin >> N;
    vector<long long>v(N);
    long long m = 0;
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
        m += v.at(i);
    }
    m = m / N;

    long long m0 = m;
    long long m1 = m-1;
    long long m2 = m+1;
    long long s0 = 0;
    long long s1 = 0;
    long long s2 = 0;
    for(auto x: v){
        s0 += (x - m0)*(x-m0);
        s1 += (x - m1)*(x-m1);
        s2 += (x - m2)*(x-m2);
    }
    cout << min(s0, min(s1,s2)) << endl;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;


int main() {
	int x1, x2, y1, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	P v1 = P(x2 - x1, y2 - y1);

	int x3, y3, x4, y4;

	P v2 = P(-v1.second, v1.first);

	x3 = x2 + v2.first;
	y3 = y2 + v2.second;

	P v3 = P(-v2.second, v2.first);

	x4 = x3 + v3.first;
	y4 = y3 + v3.second;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,count=0;
  cin>> N;
  vector<int> num(N);
  for(int i=0; i<N; i++){
    cin>>num.at(i);
  }
  for(int i=0; i<N; i++){
    if(num.at(i) %2 ==1){
      count ++;
    }
  }
  if(count%2 ==1){
    cout<< "NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }

}

Measured memory_bytes: 640
import sys
def main():
    while True:
        ipt=raw_input()
        if str.isdigit(ipt):
            n=int(ipt)
            if n==0:    break;
            solve(n)
        else:
            sys.stderr.write(ipt)
def solve(n):
    a=[]
    for _ in range(n):
        tmp=map(int,raw_input().split(" "))
        a.append(Pair(tmp[0],tmp[1]+tmp[2]))
    a.sort()
    print a[-1].x, a[-1].y
class Pair:
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __cmp__(self,a):
        return self.y-a.y
if __name__=="__main__":    main()

Measured memory_bytes: 8724
#include <stdio.h>

int main(){
	
  	int a[5],i,j,k;
    for(i=0;i<5;i++){
      scanf("%d",&a[i]);
    }
  	scanf("%d",&k);
  	
  	for(i=0;i<5;i++){
      for(j=i+1;j<5;j++){
        if(a[j]-a[i]>k){
          printf(":(\n");
          return 0;
        }
      }
    }
   
  	printf("Yay!\n");
  
	return 0;
  	
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}


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

  int cnt[100100] = {};
  cnt[0] = 0;
  for(int i = 1; i <= 100000; i++) {
    cnt[i] = cnt[i-1] + (isprime(i) && isprime((i+1)/2));
  }

  int q;
  cin >> q;
  rep(i,q) {
    int l, r;
    cin >> l >> r;
    int ans = cnt[r] - cnt[l-1];
    cout << ans << endl;
  }
}

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

int N;
int a[110];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> a[i];

  sort(a, a + N, greater<int>());

  int A = 0, B = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2)
      B += a[i];
    else
      A += a[i];
  }

  int res = A - B;
  cout << res << '\n';
}

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

int main(){
	int n,ans=0;
	
	cin>>n;
	int a[n],b,c[n-1];

	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b;
		ans+=b;
	}
	for(int i=0;i<n-1;i++){
		cin>>c[i];
	}

	
	for(int i=1;i<n;i++){
		if(a[i-1]+1==a[i]){
			ans+=c[a[i-1]-1];
		}
		
	}



	cout<<ans;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
const ll INF = 1e15 + 5;

vector<int> toposort;
vi visited;
vector<vector<int>> adj;
void ts(int u){
	visited[u] = true;
	for (int i = 0; i < adj[u].size(); i++){
		int v = adj[u][i];
		if (!visited[v]) ts(v);
	}
	toposort.push_back(u);
}

int main() {
	int n, m; cin >> n >> m;
	adj.resize(n);
	visited.assign(n, 0);
	for (int i = 0; i < m; i++){
		int x, y; cin >> x >> y; x--; y--;
		adj[x].push_back(y);
	}
	for (int i = 0; i < n; i++){
		if (!visited[i]) ts(i);
	}
	reverse(toposort.begin(), toposort.end());

	assert(toposort.size() == n);
	vi dp(n);
	for (int i = 0; i < n; i++){
		int u = toposort[i];
		for (int j = 0; j < adj[u].size(); j++){
			int v = adj[u][j];
			dp[v] = max(dp[v], dp[u] + 1);
		}
	}
	int mx = 0;
	for (int i = 0; i < n; i++){
		mx = max(mx, dp[i]);
	}
	cout << mx << endl;
}


Measured memory_bytes: 8440
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k;
	int a[55], i;
	while (cin >> n >> k)
	{
		int sum1 = 0, sum2 = 0;
		for (i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		sort(a, a + n+1);
		for (i = n-k+1; i <= n; i++)
		{
//			cout << a[i] << " ";
			sum2 += a[i];
		}
		cout << sum2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    if (k == 1) {
        cout << 0 << endl;
    }
    else {
        cout << (n - k) << endl;
    }
    
    return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

map< vector<int>,int > mp;

int main()
{
	queue< pair< vector<int>,int > > q;
	q.push(make_pair(vector<int>{0,1,2,3,4,5,6,7},0));

	mp [q.front().first] = 0;
	while(q.empty() == false){
		vector<int> v = q.front().first;
		int c = q.front().second;
		q.pop();

		int pos = 0;
		FOR(i,0,8) if(v [i] == 0){
			pos = i;
			break;
		}
		if(pos >= 4){
			swap(v [pos],v [pos - 4]);
			if(mp.count(v) == 0){
				mp [v] = c + 1;
				q.push(make_pair(v,c + 1));
			}
			swap(v [pos],v [pos - 4]);
		}
		else{
			swap(v [pos],v [pos + 4]);
			if(mp.count(v) == 0){
				mp [v] = c + 1;
				q.push(make_pair(v,c + 1));
			}
			swap(v [pos],v [pos + 4]);
		}
		if(pos != 3 && pos != 7){
			swap(v [pos],v [pos + 1]);
			if(mp.count(v) == 0){
				mp [v] = c + 1;
				q.push(make_pair(v,c + 1));
			}
			swap(v [pos],v [pos + 1]);
		}
		if(pos != 0 && pos != 4){
			swap(v [pos],v [pos - 1]);
			if(mp.count(v) == 0){
				mp [v] = c + 1;
				q.push(make_pair(v,c + 1));
			}
			swap(v [pos],v [pos - 1]);
		}
	}

	vector<int> v(8);
	while(~scanf("%d",&v [0])){
		FOR(i,1,8){
			scanf("%d",&v [i]);
		}
		printf("%d\n",mp [v]);
	}

	return 0;
}

Measured memory_bytes: 5852
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
 
int n;
 
int main(void){
    stack<int> s;
    char c;
    while(scanf("%c",&c)!=EOF){
        if(c=='+'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(a+b);
        }
        if(c=='-'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(b-a);
        }
        if(c=='*'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(a*b);
        }
        if(c>='0' && c<='9'){
            int d=c-'0';
            while(1){
                scanf("%c",&c);
                if(c>='0' && c<='9')d=d*10+(c-'0');
                else break;
            }
            s.push(d);
        }else scanf("%*c");
    }
    printf("%d\n",s.top());
    return 0;
}


Measured memory_bytes: 2760
// ---------- begin SegmentTree Point update Range query ----------
mod segment_tree {
    pub struct PURQ<T: Clone, F: Fn(T, T) -> T> {
        n: usize,
        a: Vec<T>,
        id: T,
        op: F,
    }
    #[allow(dead_code)]
    impl<T: Clone, F: Fn(T, T) -> T> PURQ<T, F> {
        pub fn new(n: usize, id: T, op: F) -> PURQ<T, F> {
            let mut k = 1;
            while k < n {
                k *= 2;
            }
            PURQ {
                n: k,
                a: vec![id.clone(); 2 * k],
                id: id,
                op: op,
            }
        }
        pub fn update(&mut self, x: usize, v: T) {
            let mut k = self.n + x;
            let a = &mut self.a;
            a[k] = v;
            k >>= 1;
            while k > 0 {
                a[k] = (self.op)(a[2 * k].clone(), a[2 * k + 1].clone());
                k >>= 1;
            }
        }
        pub fn update_tmp(&mut self, x: usize, v: T) {
            self.a[x + self.n] = v;
        }
        pub fn update_all(&mut self) {
            for k in (1..(self.n)).rev() {
                self.a[k] = (self.op)(self.a[2 * k].clone(), self.a[2 * k + 1].clone());
            }
        }
        pub fn find(&self, mut l: usize, mut r: usize) -> T {
            let mut p = self.id.clone();
            let mut q = self.id.clone();
            l += self.n;
            r += self.n;
            while l < r {
                if (l & 1) == 1 {
                    p = (self.op)(p, self.a[l].clone());
                    l += 1;
                }
                if (r & 1) == 1 {
                    r -= 1;
                    q = (self.op)(self.a[r].clone(), q);
                }
                l >>= 1;
                r >>= 1;
            }
            (self.op)(p, q)
        }
    }
}
// ---------- end SegmentTree Point update Range query ----------

use proconio::*;
use proconio::marker::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let mut a = vec![vec![]; n];
    for (i, &c) in c.iter().enumerate() {
        a[c].push(i);
    }
    let mut seg = segment_tree::PURQ::new(n, 0, |a, b| a + b);
    for a in a.iter_mut() {
        a.reverse();
        if let Some(k) = a.pop() {
            seg.update(k, 1);
        }
    }
    let mut query = vec![vec![]; n];
    for (i, (l, r)) in ask.into_iter().enumerate() {
        query[l].push((r, i));
    }
    let mut ans = vec![0; q];
    for (l, (query, c)) in query.into_iter().zip(c.into_iter()).enumerate() {
        for &(r, k) in query.iter() {
            ans[k] = seg.find(l, r);
        }
        seg.update(l, 0);
        if let Some(k) = a[c].pop() {
            seg.update(k, 1);
        }
    }
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 79752
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n;
struct node{
	double x,y;
}rec[N];
bool cmp(node a,node b){
	return atan2(a.y,a.x) < atan2(b.y,b.x);
}
int main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> rec[i].x >> rec[i].y;
	sort(rec,rec+n,cmp);
	double ans = 0;
	for(int i = 0;i < n;i++){
		double a,b;
		a = 0;
		b = 0;
		int k = i;
		do{
			a += rec[k].x;
			b += rec[k].y;
			ans = max(ans,a*a+b*b);
			k = (k+1) % n;
		}while(i != k);
	}
	cout << setprecision(15) << (long double)sqrt(ans) << endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
	int a,b,c,x;
	std::cin >> a >> b >> c >> x;
	int count = 0;
	int now = x;
	for (size_t ia = 0; ia < a+1; ia++) {
		for (size_t ib = 0; ib < b+1; ib++) {
			if ((x - ia * 500 - ib * 100) >= 0 && (x - ia * 500 - ib * 100)/50 <= c) {
				count++;
			}
		}
	}
	std::cout << count << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    def solve_negative():
        ok = -1
        ng = -(10 ** 18)
        a_neg_desc = a_neg[::-1]
        a_pos_desc = a_pos[::-1]

        while abs(ng - ok) > 1:
            mid = (ok + ng) // 2
            pidx = 0
            count = 0
            for elem_neg in a_neg_desc:
                while pidx < pos_cnt:
                    elem_pos = a_pos_desc[pidx]
                    prod = elem_neg * elem_pos
                    if prod > mid:
                        break
                    else:
                        pidx += 1
                count += pidx
            if count >= k:
                ok = mid
            else:
                ng = mid

        print(ok)

    def solve_positive():
        kp = k - (prod_neg_cnt + prod_zer_cnt)
        ok = 10 ** 18
        ng = 0
        a_neg_desc = a_neg[::-1]
        a_pos_desc = a_pos[::-1]

        while abs(ng - ok) > 1:
            mid = (ok + ng) // 2
            pidx = 0
            nidx = 0
            count = 0
            for i, elem_pos1 in enumerate(a_pos_desc):
                while pidx < pos_cnt:
                    elem_pos2 = a_pos[pidx]
                    prod = elem_pos1 * elem_pos2
                    if prod > mid:
                        break
                    else:
                        pidx += 1
                count += min(pidx, pos_cnt - (i + 1))

            for i, elem_neg1 in enumerate(a_neg):
                while nidx < neg_cnt:
                    elem_neg2 = a_neg_desc[nidx]
                    prod = elem_neg1 * elem_neg2
                    if prod > mid:
                        break
                    else:
                        nidx += 1
                count += min(nidx, neg_cnt - (i + 1))

            if count >= kp:
                ok = mid
            else:
                ng = mid

        print(ok)

    import bisect
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()

    neg_cnt = bisect.bisect_left(a, 0)
    zer_cnt = bisect.bisect_left(a, 1) - neg_cnt
    pos_cnt = n - (neg_cnt + zer_cnt)

    prod_neg_cnt = neg_cnt * pos_cnt
    prod_pos_cnt = (neg_cnt * (neg_cnt - 1) + pos_cnt * (pos_cnt - 1)) // 2
    prod_zer_cnt = ((n * (n - 1)) // 2) - (prod_neg_cnt + prod_pos_cnt)

    a_neg = a[:neg_cnt]
    a_pos = a[(n - pos_cnt):]

    if k <= prod_neg_cnt:
        solve_negative()
    elif k <= (prod_neg_cnt + prod_zer_cnt):
        print(0)
    else:
        solve_positive()


if __name__ == '__main__':
    main()


Measured memory_bytes: 81748
#include<iostream>
using namespace std;
int X1, Y1, X2, Y2, W, H, n, x, y, p, sum;
int main() {
	cin >> p;
	for (int i = 0; i < p;i++) {
		cin >> X1 >> Y1 >> W >> H;
		X2 = W + X1;
		Y2 = H + Y1;
		cin >> n;
		sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			if (X1 <= x && x <= X2) {
				if (Y1 <= y && y <= Y2) {
					sum++;
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1160
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	ull x;
	cin >> x;
	cout << (x / 11) * 2 + (x % 11 + 6 - 1) / 6 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//In wrong answers we believe//
#define db 				double
#define ll 				long long int
#define ld				long long double
//#define int 			long long int
#define ull 			unsigned long long
#define vii 			vector <int>
#define vll 			vector < ll >
#define pii 			pair <int, int>
#define fi 				first
#define se 				second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define endl 			'\n'
#define mem(a,b) 		memset(a, b, sizeof a)
#define mkp 			make_pair
#define pb 				push_back
#define max3(a,b,c) 	max(a,max(b,c))
#define min3(a,b,c) 	min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)			a.begin(), a.end()
using namespace std;
db pi		 =			2*acos(0.0);
db eps       =			0.000001;
ll mod       =			(1e9+7);   //998244353
const ll INF =			1000000000000000LL;
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=100001;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}


int main(){	
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
//  ios_base::sync_with_stdio(false);
//  cin.tie(NULL);
//  cout.tie(NULL);
//  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true){
		
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			exit(0);
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			exit(0);
		}
	}
	
    return 0;
    }

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

int main() {
  string s;
  cin >> s;
  bool f = 1;
  for(int i = 0; i < s.size(); i++) {
    for(int j = 1; j < s.size(); j++) {
      if(i != j && s[i] == s[j]) f = 0;
    }
  }
  if(f) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


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

int n,ans;
string s;

main()
{
        cin>>n>>s;

        rep2(i,0,10)
        {
                rep2(j,0,10)
                {
                        rep2(k,0,10)
                        {
                                char a='0'+i,
                                     b='0'+j,
                                     c='0'+k;
                                string t="";
                                t.push_back(a);
                                t.push_back(b);
                                t.push_back(c);
                                if(s.find(a)!=string::npos)
                                {
                                        if(s.find(b,s.find(a)+1)!=string::npos)
                                        {
                                                if(s.find(c,s.find(b,s.find(a)+1)+1)!=string::npos)
                                                {
                                                        ans++;
                                                        //cout<<t<<endl;
                                                }
                                        }
                                }
                        }
                }
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

SA = list(input())
SB = list(input())
SC = list(input())

nxt = "a"
while True:
    if nxt == "a":
        if not SA:
            print("A")
            exit()
        nxt = SA[0]
        del SA[0]
    elif nxt == "b":
        if not SB:
            print("B")
            exit()
        nxt = SB[0]
        del SB[0]
    elif nxt == "c":
        if not SC:
            print("C")
            exit()
        nxt = SC[0]
        del SC[0]

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

int main(){
  int n,m,i,j,sum=0;
  cin>>n;
  int t[n];
  for(i=0;i<n;i++){
    cin>>t[i];
  }
  cin>>m;
  int p[m],x[m];
  for(i=0;i<m;i++){
    cin>>p[i]>>x[i];
  }
  for(i=0;i<n;i++){
    sum+=t[i];
  }
  for(i=0;i<m;i++){
    cout<<(sum+(x[i]-t[p[i]-1]))<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		String result = "No";
		if(max(a, max(b, c))*2 == a+b+c) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 22612