akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int d,g;
int p[11];
int c[11];


signed main(){

    cin >> d >> g;
    rep(i,d){
        cin >> p[i+1] >> c[i+1];
    }
    cerr << "a" << endl;

    int cnt = 100000000000;
    for(int bit = 0;bit < (1<<d);bit++){
        int cnt1 = 0;
        int score = 0;
        for(int i = 1;i <= d;i++){
            if(bit & (1<<(i-1))){
                score += i*100*p[i] + c[i];
                cnt1 += p[i];
            }
        }

        if(score < g){
            for(int i = d;i >= 1;i--){
                if(!(bit & (1<<(i-1)))){
                    int x = (g-score+(i*100-100))/(i*100);
                    if(x >= p[i] || score + i*100*(p[i]-1) < g){
                        cnt1 = 1000000000000;
                    }else{
                        cnt = min(cnt,cnt1+x);
                    }
                    break;
                }
            }
        }else{
            cnt = min(cnt,cnt1);
        }
        //cerr << bit << endl;

    }
    cout << cnt <<endl;

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int k,s;
  cin >> k >> s;
  int ans = 0;
  rep(x,k+1) {
    rep(y,k+1) {
      if(s-x-y<=k&&s-x-y>=0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, l;
  cin >> n >> l;
  vs s(n);
  rep(i, n) cin >> s[i];
  sort(all(s));
  rep(i, n) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
	int a,b,n,i;
	cin >> n;
	i = 9;
	a = 10;
	while (i >= 1) {
		b = n % i;
		if (b == 0) {
			a = n / i;
			if (a < 10)
				break;
		}
		i--;
	}
	if (a < 10)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	}

Measured memory_bytes: 256
N,K = map(int,input().split())
V = list(map(int,input().split()))
V.insert(0,0)
V.append(0)

ans = -10**7
for i in range(min(N,K)+1):
    for j in range(min(N-i,K-i)+1):
        for k in range(min(i+j,K-i-j)+1):
            T = V[:i+1]
            T.extend(V[N-j+1:])
            T.sort()
            for t in range(k):
                if T[t] < 0:
                    T[t] = 0
                else:
                    break
            ans = max(ans,sum(T))

print(ans)

Measured memory_bytes: 45164
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

char s[10][10];
char res[10][10];
int n, m, k;
int ans;

int main () {
    scanf("%d %d %d", &n, &m, &k);

    for (int i = 0 ; i < n; ++ i)
        scanf("%s", s[i]);

    for (int i = 0 ; i < (1 << n) ; ++ i)
    for (int j = 0 ; j < (1 << m) ; ++ j) {

        for (int i = 0 ; i < n; ++ i)
        for (int j = 0 ; j < m; ++ j)
            res[i][j] = s[i][j];

        for (int v = 0 ; v < n ; ++ v) {
            if (i >> v & 1) {
                for (int f = 0 ; f < m ; ++ f)
                    res[v][f] = '.';
            }
        }

        for (int v = 0 ; v < m ; ++ v)
            if (j >> v & 1)
            for (int f = 0 ; f < n ; ++ f)
                res[f][v] = '.';

        int cnt = 0;
        for (int i = 0 ; i < n;  ++ i)
        for (int j = 0 ; j < m ; ++ j) {
            cnt += (res[i][j] == '#');
        }
        if (cnt == k) ++ ans;
    }

    printf("%d\n", ans);

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3780
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 1e5+5;

vector<vector<int> > v(N);
int dp[N], n, m;

int dfs(int node)
{
    if(~dp[node]) return dp[node];
    dp[node] = 0;
    for(auto i:v[node])
    {
        dp[node] = max(dp[node], dfs(i)+1);
    }
    return dp[node];
}

int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d%d", &n, &m);
    int mx = 0;
    while(m--)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
    }
    for(int i = 1 ; i <= n ; i++) mx = max(mx, dfs(i));
    printf("%d", mx);
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

void solve() {
	int n;
	cin >> n;
	vector <int > a(n);
	rep(i, 0, n) cin >> a[i];
	vector <int > dp(200000);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);

	rep(i, 2, n) {
		dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
	}

	cout << dp[n - 1] << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--)
		solve();

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; 
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    int ans=0;
    for(int i=0;i<n-2;++i){
        for(int j=i+1;j<n-1;++j){
            if(l[i]==l[j]) continue;
            for(int k=j+1;k<n;++k){
                if(l[j]==l[k] || l[k]==l[i]) continue;
                ll x=l[i],y=l[j],z=l[k];
                if((x<y+z) && (y<z+x) && (z<x+y)) ++ans;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3656
md = 10**9 + 7
N = int(input())

S1 = input()
S2 = input()

if S1[0] == S2[0]:
	res = 3
	i = 1
	form = "S"
else:
	res = 6
	i = 2
	form = "B"

while i < N:
	if S1[i] == S2[i]:
		if form == "S":
			res = res*2
		form = "S"
		i += 1
	else:
		if form == "S":
			res = res*2
		else:
			res = res*3
		form = "B"
		i += 2

print(res%md)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
int N;
int p[100010];
int dist[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  deque<int> que;
  que.emplace_front(0);
  fill_n((int*)dist, 100010, INF);
  dist[0] = 0;
  while (!que.empty()) {
    int curr = que.front(); que.pop_front();
    if (p[curr]) {
      if (dist[curr + p[curr]] > dist[curr]) {
        dist[curr + p[curr]] = dist[curr];
        que.emplace_front(curr + p[curr]);
      }
      continue;
    }
    for (int i = 1; i <= 6 && curr + i < N; i++) {
      if (dist[curr + i] > dist[curr] + 1) {
        dist[curr + i] = dist[curr] + 1;
        que.emplace_back(curr + i);
      }
    }
  }
  cout << dist[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 3996
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(n);
    int ans=0;
    for(int i=1; i<=n; i++) {
        if(i%3!=0 && i%5!=0)
            ans+=i;
    }
    cout<<ans<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
const int MX = 200010;
ll inv[MX], fact[MX], ifact[MX];

ll powmod(ll x, ll k) {
	ll res = 1;
	for (; k; k /= 2, x = x * x % MOD) {
		if (k & 1) {
			res = res * x % MOD;
		}
	}
	return res;
}

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int main() {
	init();

	int N, A, B, C;
	cin >> N >> A >> B >> C;

	ll ans = 0;
	ll pA = A * powmod(A + B, MOD - 2) % MOD;
	ll pB = B * powmod(A + B, MOD - 2) % MOD;

	for (int i = 0; i < N; ++i) { //lose
		ll b = comb(i + N-1, i) * powmod(pA, i) % MOD * powmod(pB, N) % MOD;
		ll a = comb(i + N-1, i) * powmod(pB, i) % MOD * powmod(pA, N) % MOD;
		ll t = (a + b) * (N + i) % MOD * 100 % MOD * powmod(A + B, MOD - 2) % MOD;
		ans = (ans + t) % MOD;
	}
	cout << ans << endl;

	return 0;
}

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

int main(void)
{
	string str;
	char c;
	int letters[26]={0};
	
	while (getline(cin, str)){
		for (int i=0; i<str.size(); i++){
			c = str[i];
			if (isupper(c))
				letters[c-'A']++;
			else if (islower(c))
				letters[c-'a']++;
		}
	}
	for (int i=0; i<26; i++){
		cout<<char('a'+i)<<" : "<<letters[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
  string input;

  cin >> input;

  sort(input.begin(), input.end());
  if (input == "abc"){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> a >> b >> c >> d;

    if(a!=c && d == 1)cout << 1 << endl;
    else cout << 0 << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
using namespace std;
const int N=200005;
typedef long long ll;
vector<int> q;
int head[N],nxt[N],to[N],e,n;
inline void init(){memset(head,-1,sizeof(head));e=0;}
inline void add_edge(int x,int y){to[e]=y;nxt[e]=head[x];head[x]=e++;}
int dfs(int x,int f)
{
	if(x==n){q.push_back(x);return 1;}
	Rep(i,x)if(to[i]!=f)
	{
		int ff=dfs(to[i],x);
		if(ff){q.push_back(x);return 1;}
	}
	return 0;
}
int dfs2(int x,int f)
{
	int ans=1;
	Rep(i,x)if(to[i]!=f)ans+=dfs2(to[i],x);
	return ans;
}
int main()
{
	scanf("%d",&n);init();
	rep(i,1,n-1){int x,y;scanf("%d%d",&x,&y);add_edge(y,x);add_edge(x,y);}
	dfs(1,0);
	int sz=q.size();reverse(q.begin(),q.end());
	int xjt=dfs2(q[(sz+1)/2-1],q[(sz+1)/2]);
	//printf("%d\n",xjt);
	if(xjt*2>n)puts("Fennec");
	else puts("Snuke");
	return 0;
}

Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int N,D,A;
#define rep(i,n) for(int i=0;i<n;i++)
int getid(vector<Int>&v,int id){
    Int x =v[id] - 2 * D;
    auto itr = lower_bound(v.begin(), v.end(),x);
    if(itr == v.begin()) return -1;
    return (int)(--itr - v.begin());
    
}
int main(){
    cin >> N >> D >> A;
    vector<pair<Int,Int>>input(N);
    for(auto& p : input)
        cin >> p.first >> p.second;
    sort(input.begin(),input.end());
    Int ans = 0;
    vector<Int>dp(N,0LL),grid;
    for(auto p : input) grid.emplace_back(p.first);
    for(int i = 0; i < N; ++i){
        if(i)dp[i] += dp[i-1];
        int idx = getid(grid,i);
        Int culm = dp[i];
        if(idx != -1){
            culm -= dp[idx];
        }
        if(input[i].second <= culm * A){
            
        } else {
            Int dif = input[i].second - culm * A;
            Int t = (dif / A)  + (dif % A  == 0 ? 0 : 1);
            ans += t;
            dp[i] += t;
            
        }
    }
    cout << ans << endl;
}


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

int main() {
  int N, X = 0;
  string S;
  cin >> N >> S;

  int ans = 0;

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'I') X++;
    else X--;
    ans = max(ans, X);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int a,b,m=1,ans=0;
    cin >> a >> b;
    
    while(b>m){
        m--;
        m+=a;
        ans++;
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<int> ans(100005);
  ans[0]=0;
  ans[1]=0;
  ans[2]=0;
  ans[3]=1;
  for(int i=4;i<100005;i++){
    if(i%4!=1) {
      ans[i]=ans[i-1];
      continue;
    }
    bool sosu=true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0) sosu=false;
    }
    if(!sosu) {
      ans[i]=ans[i-1];
      continue;
    }
    int m=(i+1)/2;
    sosu=true;
    for(int j=2;j*j<=m;j++){
      if(m%j==0) sosu=false;
    }
    if(sosu) ans[i]=ans[i-1]+1;
    else ans[i]=ans[i-1];
  }

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


}


Measured memory_bytes: 1024
def s(n):
    if n < 10:
        return n
    else:
        return n % 10 + s(n // 10)
n = 0
for _ in range(int(input())):
    n += 1
    minn = n
    d = 1
    while n >= d:
        d *= 10
        m = (n // d + 1) * d - 1
        if minn * s(m) > m * s(minn):
            # minn / s(minn) > m / s(m)
            minn = m
    n = minn
    print(n)

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

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 200 * 1000 + 123;



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

    int A,B;
    cin >> A >> B;
    vector<int> v;
    loop(i,n){
        int p;
        cin >> p;
        v.push_back(p);
    }


    int a1 = 0;
    int a2 = 0;
    int a3 = 0;
    for(int e : v){
//        db(e);
        if(e <= A) a1++;
        else if(e <= B) a2++;
        else a3++;
    }


//    db(a1);
//    db(a2);
//    db(a3);

    cout << min(a1, min(a2,a3)) << endl;

    return 0;
}


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

#define ll long long
#define PI acos(-1.0)
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)

int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    cout << "hon" << endl;
  } else if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3636
var
  n,k,i,j,s:longint;
  a:array[1..11,1..5] of longint;
begin
  a[1,1]:=4;a[1,2]:=2;a[1,3]:=0;a[1,4]:=9;a[1,5]:=7;
  a[2,1]:=1;a[2,2]:=10;a[2,3]:=8;a[2,4]:=6;a[2,5]:=4;
  a[3,1]:=9;a[3,2]:=7;a[3,3]:=5;a[3,4]:=3;a[3,5]:=1;
  a[4,1]:=6;a[4,2]:=4;a[4,3]:=2;a[4,4]:=0;a[4,5]:=9;
  a[5,1]:=3;a[5,2]:=1;a[5,3]:=10;a[5,4]:=8;a[5,5]:=6;
  a[6,1]:=0;a[6,2]:=9;a[6,3]:=7;a[6,4]:=5;a[6,5]:=3;
  a[7,1]:=8;a[7,2]:=6;a[7,3]:=4;a[7,4]:=2;a[7,5]:=0;
  a[8,1]:=5;a[8,2]:=3;a[8,3]:=1;a[8,4]:=10;a[8,5]:=8;
  a[9,1]:=2;a[9,2]:=0;a[9,3]:=9;a[9,4]:=7;a[9,5]:=5;
  a[10,1]:=10;a[10,2]:=8;a[10,3]:=6;a[10,4]:=4;a[10,5]:=2;
  a[11,1]:=7;a[11,2]:=5;a[11,3]:=3;a[11,4]:=1;a[11,5]:=10;
  readln(n,k);
  dec(n,2);s:=n div 11*5;
  for i:=1 to n mod 11 do
    for j:=1 to 5 do
      if a[i,j]=k then inc(s);
  writeln(s);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e21 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    vi v(2);
    REP(i, n)
    {
        cin >> k;
        v[k % 2]++;
    }
    if (v[1] == 0) {
        if (m == 0) {
            cout << (ll)pow(2, n) << endl;
        } else {
            cout << 0 << endl;
        }
    } else {
        cout << (ll)pow(2, n - 1) << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int &a:A)
        cin >> a;
    
    int ans = INF;
    for(int i=-100; i<=100; i++){
        int cost = 0;
        for(int j=0; j<N; j++){
            cost += (i-A[j])*(i-A[j]);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
S = list(input())

def flip(l, r):
    for i in range((r + l) // 2 - l + 1):
        tmp = S[l + i]

        S[l + i] = 'R' if S[r - i] == 'L' else 'L'
        S[r - i] = 'R' if tmp == 'L' else 'L'


def f(w, start):
    l_idx = -1
    for i in range(start, N - 1):
        if S[i] == w[0] and S[i + 1] == w[1]:
            l_idx = i
            break

    if l_idx < 0: return -1
    r_idx = -1

    for i in range(l_idx + 1, N - 1):
        if S[i] == w[1] and S[i + 1] == w[0]:
            r_idx = i
            break
    if r_idx < 0: return -1

    flip(l_idx + 1, r_idx)
    return l_idx + 1


cnt = 0
for LR in ['LR', 'RL']:
    l = 0
    while cnt < K and l >= 0 and l < N - 1:
        l = f(LR, l)
        if l >= 0: cnt += 1

l = 0
for i in range(N - 1):
    if cnt >= K: break

    if S[i] != S[i + 1]:
        flip(l, i)

m = 0
spl = 0
for i in range(N - 1):
    if S[i] != S[i + 1]:
        spl += 1
print(N - spl - 1)

Measured memory_bytes: 4084
s=input()
a=s.replace('x','')
for i in range(len(a)):
    if a[i]!=a[-1-i]:
        print(-1)
        exit()
l=0
r=len(s)-1
ans=0
while l<r:
    if s[l]==s[r]:
        l+=1
        r-=1
    elif s[l]=='x':
        l+=1
        ans+=1
    elif s[r]=='x':
        r-=1
        ans+=1
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  int n; cin >> n;
  int x; cin >> x;
  int a[n+1];
  for(int i=1;i<=n;i++) cin >> a[i];
  ll cnt=0;
  for(int i=1;i<=n-1;i++){
    if(a[i]+a[i+1] > x){
      cnt = cnt+(a[i]+a[i+1]-x);
      if(a[i] > x){
        a[i+1]=0;
      }else{
        a[i+1]=x-a[i];
      }
    }
  }
  // for(int i=1;i<=n;i++) cout << a[i] << " " << endl;
  cout << cnt << endl;
}

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

int a,b,c,d,x1,x2,y1,y2;

int main(){
	cin >> x1 >> x2 >> y1 >> y2 >> a >> b >> c >> d;
	int x = x1*a+(x1/10)*c + x2*b+(x2/20)*d;
	int y = y1*a+(y1/10)*c + y2*b+(y2/20)*d;
	cout << (x==y?"even":(x>y?"hiroshi":"kenjiro")) << endl;
	return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<string.h>

int a,b,c;
int l,ll,ans=0;
char str[11],str2[21];

int ring(int l,char str[21],char str2[21]){
	int c=0,d=0;
	for(c=0;c<9+l;c++){
		res:
		if(str[d]==str2[c]){
			d++;
		}else if(d>0){
			d=0;
			goto res; 
		}
		if(d==l){
			ans++;
			break;
		}
	}
	
}
int main(void){
	scanf("%s", str);
	l=strlen(str);
	scanf("%d", &a);
	for(b=0;b<a;b++){
		scanf("%s",str2);
		for(c=0;c<l;c++){
			str2[10+c]=str2[c];
		}
		ring(l,str,str2);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)
	ar := make([]int, x)
	br := make([]int, y)
	cr := make([]int, z)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	for i := range br {
		fmt.Scan(&br[i])
	}
	for i := range cr {
		fmt.Scan(&cr[i])
	}
	dr := make([]int, 0, x*y)
	for _, a := range ar {
		for _, b := range br {
			dr = append(dr, a+b)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(dr)))
	if k < len(dr) {
		dr = dr[0:k]
	}
	er := make([]int, 0, len(dr)*z)
	for _, d := range dr {
		for _, c := range cr {
			er = append(er, d+c)
		}
	}
	sort.Ints(er)
	for i := 0; i < k; i++ {
		fmt.Println(er[len(er)-1-i])
	}
}


Measured memory_bytes: 33024
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int N;
	int a[51];
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> a[i];

	int max_a = -1000001, min_a = 1000001;
	int max_index = 1, min_index = 1;
	for(int i = 1; i <= N; i++){
		if(a[i] > max_a){
			max_a = a[i];
			max_index = i;
		}
		if(a[i] < min_a){
			min_a = a[i];
			min_index = i;
		}
	}

	if(min_a >= 0){
		cout << N - 1 << endl;
		for(int i = 1; i <= N - 1; i++){
			cout << i << " " << i + 1 << endl;
		}
	}else if(max_a <= 0){
		cout << N - 1 << endl;
		for(int i = N; i >= 2; i--){
			cout << i << " " << i - 1 << endl;
		}
	}else if(abs(max_a) >= abs(min_a)){
		cout << 2 * N - 1 << endl;
		for(int i = 1; i <= N; i++){
			cout << max_index << " " << i << endl;
		}
		for(int i = 1; i <= N - 1; i++){
			cout << i << " " << i + 1 << endl;
		}
	}else{
		cout << 2 * N - 1 << endl;
		for(int i = 1; i <= N; i++){
			cout << min_index << " " << i << endl;
		}
		for(int i = N; i >= 2; i--){
			cout << i << " " << i - 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int ans = r * r * 3;
    cout << ans << endl;
    return 0;
}


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

ls_odd = []
ls_even = []

for i in range(n):
    if i % 2 == 0:
        ls_odd.append(ls[i])
    elif i % 2 == 1:
        ls_even.append(ls[i])

if n % 2 == 0:
    ls_even.reverse()
    ans = ls_even + ls_odd
elif n % 2 == 1:
    ls_odd.reverse()
    ans = ls_odd + ls_even

print(" ".join((map(str, ans))))

Measured memory_bytes: 31300
#include <iostream>
#include <cmath>

int main()
{
  int N;
  std::cin >> N;
  int ans = 0;
  for ( int i = 1; i <= N; i++ ) {
    if ( N < std::pow(2, i) ) {
      ans = std::pow(2, i-1);
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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


using namespace std;
struct nod{
    int val;
    nod *next;
};

const int MAXN = 100001;
nod *lda[MAXN];
bool vz[MAXN];
int group[MAXN];
int length[MAXN];
vector <int> blocked[MAXN];

void add(int x, int y)
{
    nod *newnod = new nod;
    newnod -> val = y;
    newnod ->next = nullptr;
    if (lda[x] == nullptr){
        lda[x] = newnod;
        return;
    }
    newnod -> next = lda[x];
    lda[x] = newnod;


}
void DFS(int ind, int grp)
{
    vz[ind] = 1;
    group[ind] = grp;
    length[grp]++;
    //cout << ind << "\n";
    for (nod *it = lda[ind]; it != nullptr; it = it ->next){
        if (!vz[it ->val]){
            DFS(it-> val, grp);
        }
    }
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        add(x,y);
        add(y,x);
    }
    for (int i = 0; i < k; i++){
        int x,y;
        cin >> x >> y;
        blocked[x].push_back(y);
        blocked[y].push_back(x);
    }
    int c = 1;
    for (int i = 1; i <= n; i++){
        if (!vz[i]){
            DFS(i, c);
            c++;
        }
    }
    for (int i = 1; i <=n ;i++){
        int out = 0;
        for (nod *it = lda[i]; it != nullptr; it = it ->next){
            out++;
        }
        for (int j = 0; j < blocked[i].size(); j++)
            if (group[blocked[i][j]] == group[i])
                out++;
        out++;
        cout << length[group[i]] - out << " ";
    }
    return 0;
}

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

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


  int money = 0;
  int A, B;
  while(1){
    A = money * 0.08;
    B = money * 0.1;
    if(A == a && B == b) break;
    money++;
    if(money > 1001){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << money << endl;

  return 0;
}

Measured memory_bytes: 256
<?php

$str = trim(fgets(STDIN));
$array = explode(' ', $str);
$total = '';
foreach ($array as $word) {
    $total = $total . substr($word, 0, 1) . substr($word, strlen($word)-1, 1);
}
if (substr($total,1,1) === substr($total, 2, 1) && substr($total,3,1) === substr($total, 4, 1)){
    echo "YES";
    exit;
}
echo "NO";


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int I[100][20];
char s[100][100];

int main() {
	vector<int>a(3);
	int even = 0;
	rep(i, 3) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	int ans = 0;
	if (a[1]%2==a[2]%2)ans = (a[0] * 2 - a[2] - a[1]) / 2;
	else {
		ans = (a[0] * 2 - a[1] - a[2] + 3) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 200100;
int n;
set<PII> secik;
int a[MAX];
int b[MAX];
void dodaj(int i){
  if(b[i] < a[i]){
    cout << "-1\n";
    exit(0);
  }
  if(b[i] != a[i])
    secik.insert({-b[i],i});
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n)cin >> a[i];
  R(i,n){
    cin >> b[i];
    dodaj(i);
  }
  int res = 0;
  while(SZ(secik)){
    int i = secik.begin()->SE;
    secik.erase(secik.begin());
    int pom = 0;
    if(i)
      pom += b[i-1];
    else
      pom += b[n-1];
    if(i != n-1)
      pom += b[i+1];
    else
      pom += b[0];
    int il = (b[i] - a[i]) / pom;
    maxi(il, 1ll);
    b[i] -= pom * il;
    res += il;
    dodaj(i);
  }
  cout << res << "\n";
}


Measured memory_bytes: 17920
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    ll N,M,ans=0,hon=0;
    cin >> N >>M;
    pair <ll,ll> p;
    vector<pair<ll,ll>> vec(N);

    REP(i,N){
        cin >> p.first >> p.second;
        vec[i] = p;
    }

    SORT(vec);
    int i=0;
    while(hon<M){
        hon += vec[i].second;
        ans += vec[i].first * vec[i].second;
        i++;
    }

    int sa = hon - M;

    ans -= sa * vec[i-1].first;

    cout << ans <<endl;


}

Measured memory_bytes: 1792
N_500 = int(input())
N_100 = int(input())
N_50 = int(input())
X = int(input())

cnt = 0

for i_500 in range(N_500 + 1):
    
    for j_100 in range(N_100 + 1):
        
        for k_50 in range(N_50 + 1):
            
            summ = 500 * i_500 + 100 * j_100 + 50 * k_50
            if (summ == X):
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B == C + D)
  cout << "Balanced" << endl;
  else if (A + B >= C + D)
  cout << "Left" << endl;
  else
  cout << "Right" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		int w,h;
		scanf("%d%d",&w,&h); if( w == 0 && h == 0 )break;
		
		int dp[102][102][2][2] = {};
		dp[3][1][0][0] = 1;
		dp[2][2][0][1] = 1;
		dp[2][2][1][0] = 1;
		dp[1][3][1][1] = 1;
		
		rep1(i,w){
			rep1(j,h){
				if(i+j <= 4)continue;
				dp[i][j][0][0] = ( dp[i-1][j][0][1] + dp[i-1][j][0][0] ) % 100000;
				dp[i][j][0][1] = dp[i-1][j][1][1];
				dp[i][j][1][0] = dp[i][j-1][0][0];
				dp[i][j][1][1] = ( dp[i][j-1][1][0] + dp[i][j-1][1][1] ) % 100000;
			}
		}
		
		printf("%d\n",(
			dp[w][h][0][0]
			+dp[w][h][0][1]
			+dp[w][h][1][0]
			+dp[w][h][1][1]
		) % 100000);
	}
}

Measured memory_bytes: 1340
package main

import (
	"fmt"
	"sort"
)

var A, B, C, M, S int
var MB, SB bool

func main() {
	fmt.Scanf("%d %d %d", &A, &B, &C)

	N := []int{A, B, C}

	sort.Ints(N)
	M = (N[2] - N[0])
	S = (N[2] - N[1])

	res := M/2 + S/2
	MB = M%2 != 0
	SB = S%2 != 0
	if MB && SB {
		res++
	} else if MB || SB {
		res += 2
	}
	fmt.Println(res)
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;

  int AtCoder[] = {a, b, c, d, e};
  int count = 0;

  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (AtCoder[i] - AtCoder[j] > k) {
        count++;
      }
    }
  }

  if (count == 0) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
X = list(input())
d = defaultdict(int)

for i in range(1, N):
    c = 0
    t = 0
    k = format(i, "b")
    for j in k:
        if j == "1":
            c += 1
    d[i] = d[i%c] + 1


n = 0
for i in X:
    if i == "1":
        n += 1

p1 = 1
p2 = 1
total1 = 0
total2 = 0
for i in X[::-1]:
    if i == "1":
        total1 += p1 % (n+1)
        if n-1 > 0:
            total2 += p2 % (n-1)
    p1 *= 2
    p1 %= n+1
    if n-1 > 0:
        p2 *= 2
        p2 %= n-1

total1 %= (n+1)
if n-1 > 0:
    total2 %= (n-1)
Ans = []
p1 = 1
p2 = 1
for i in X[::-1]:
    c = 1
    if n - 1 <= 0 and i == "1":
        Ans.append(0)
    else:
        if i == "0":
            start = total1
            start += p1
            start %= (n+1)
        else:
            start = total2
            start -= p2
            start += n - 1
            start %= (n-1)
        Ans.append(c+d[start])
    p1 *= 2
    p1 %= n+1
    if n-1 > 0:
        p2 *= 2
        p2 %= n-1

for i in Ans[::-1]:
    print(i)

Measured memory_bytes: 127224
import sys
input = sys.stdin.readline

n = int(input())
h = [int(x) for x in input().split()]

ans = 0

while h != [0]*n:
    # print(h)
    left = 0
    for right in range(left, n):
        if h[right] == 0:
            if len(h[left:right]):
                minh = min(h[left:right])
                ans += minh
                for i in range(left, right):
                    h[i] -= minh
            left = right + 1
    if left <= right:
        if len(h[left:right + 1]):
            minh = min(h[left:right + 1])
            ans += minh
            for i in range(left, right + 1):
                h[i] -= minh
print(ans)

Measured memory_bytes: 39024
import java.util.Scanner;

public class Main {

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

		int X = scan.nextInt();
		int A = scan.nextInt();
		int ans = 0 ;

		if ( X >= A ) {
			ans = 10;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    vector<int> l(q);
    vector<int> r(q);
    rep(i,q) {
        int li,ri; cin >> li >> ri;
        l[i] = li;
        r[i] = ri;
        
    }
    vector<int> a(n+1);
    a[0] = 0;

    bool isA = false;
    rep(i,n) {
        if (s[i]=='A') {
            isA = true;
            a[i+1] = a[i];
        }
        else if (isA && s[i]=='C') {
            a[i+1] = a[i] + 1;
            isA = false;
        }
        else {
            isA = false;
            a[i+1] = a[i];
        }
    }
    rep(i,q) {
        cout << (a[r[i]]-a[l[i]]) << endl;
    }
    return 0;
}













Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#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() {
	long long N, ans=10000000000000, a[200005],sum=0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		sum += a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i < N; i++) {
		ans = min(ans, abs(a[i]-(sum - a[i])));
      //cout<<ans<<endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
	int n; IN(n);
	vector<int> a(n)$in(a, n);
	rep(i, 0, n){
		int t = a[i];
		if(t%2 == 0) if(t%3 != 0 && t%5 != 0){
			cout << "DENIED" << el;
			return 0;
		}
	}
	cout << "APPROVED" << el;
    return 0;
}


Measured memory_bytes: 3124
import sys
input = sys.stdin.readline

INF = float("inf")


def f(c, pos, unused, sum_c):
    if pos == 1:
        return sum_c
    ret = INF
    l = unused[:]
    l.remove(pos)
    for next_n in l:
        res = f(c, next_n, l, sum_c + c[pos][next_n])
        if res < ret:
            ret = res
    return ret


def main():
    H, W = map(int, input().split())
    c = [None] * 10
    for i in range(10):
        c[i] = list(map(int, input().split()))
    A = [None] * H
    for i in range(H):
        A[i] = list(map(int, input().split()))

    c_min = [0] * 10
    for i in range(10):
        c_min[i] = f(c, i, list(range(10)), 0)

    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                ans += c_min[A[h][w]]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
//Akash Kumar Mondol
//Department of ICE,University of Rajshahi,Bangladesh
#include<bits/stdc++.h>
using namespace std;
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)
#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define mod 1000000007
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
//#define valid(nx,ny) nx>=0&& nx<r && ny>=0 && ny<c
//memset(a, 0, sizeof(a));
//freopen("file_name.txt","read_or_write",stdout_or_stdin);
int main()
{
    //freopen("file_name.txt","w",stdout);
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s=="SAT")
    {
        cout<<"1\n";
    }
    else if(s=="SUN")
    {
        cout<<"7\n";
    }
    else if(s=="MON")
    {
        cout<<"6\n";
    }
    else if(s=="TUE")
    {
        cout<<"5\n";
    }
    else if(s=="WED")
    {
        cout<<"4\n";
    }
    else if(s=="THU")
    {
        cout<<"3\n";
    }
    else if(s=="FRI")
    {
        cout<<"2\n";
    }
    return 0;
}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val status = BooleanArray(n){false}
    val wa = IntArray(n){0}
    var ac = 0L
    var penalty = 0L
    repeat(m) {
        val (p, s) = readLine()!!.split(' ')
        val q = p.toInt()-1
        if (!status[q]) {
            when(s) {
                "AC" -> {
                    status[q] = true
                    penalty += wa[q]
                    ac++
                }
                "WA" -> wa[q]++
            }
        }
    }
    println("$ac $penalty")
}


Measured memory_bytes: 53136
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
int main(){
	long long a[105],ans;
	int N;
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	for(int i=0;i<N;++i){
		for(int j=i+1;j<N-1;++j){
			if(a[i]<a[j]){
				long long d=a[i];
				a[i]=a[j];
				a[j]=d;
			}
		}
	}
	ans=a[0];
	long long r;
	long long c1,d1,c2,d2;
	for(int i=1;i<N;++i){
		if(ans%a[i]==0)continue;
		c1=ans;d1=a[i];
		c2=c1;d2=d1;
		r=c1%d1;
		while(r!=0){
			c1=d1;
			d1=r;
			r=c1%d1;
		}
		c2/=d1;
		ans=d2*c2;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int x,y;
  cin>>x>>y;
  
  if(y%2!=0){cout<<"No"<<endl;return 0;}
  
  int cnt=y/2;
  if(cnt==x){cout<<"Yes"<<endl;return 0;}
  while(y>=4){
    y-=4;
    cnt--;
    if(cnt==x){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
 
  return 0;
}

Measured memory_bytes: 3632