akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int n, a, b, c, d;
vector<int> num;
int ans = 0;

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class combination{
    public:
        vector<int> t;
        combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }

        }

        int comb(int n, int k){
            if(n < k){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }
};

signed main(){
    cin >> n >> a >> b >> c >> d;
    num = vector<int>(b+1);
    combination comb(n);

    vector<vector<int>> dp(b+1, vector<int>(n+1));
    dp[a-1][0] = 1;
    for(int i = a; i <= b; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; j - i * k >= 0; k++){
                if(k != 0 && (k < c || d < k)){
                    continue;
                }
                int tmp = factM(n-j+i*k) * comb.t[n-j] % MOD * powM(comb.t[i], k) % MOD * comb.t[k] % MOD;
                dp[i][j] = (dp[i][j] + dp[i-1][j-i*k] * tmp % MOD) % MOD;
            }
        }
    }
    cout << dp[b][n] << endl;

    return 0;
}


Measured memory_bytes: 8192
#include<stdio.h>
#include<iostream>
#include<string>
#include <cstdlib>
using namespace std;

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

  int sum = 0;
  int len = 0;
  while(N.length() > 0)
  {
    len = N.length();
    sum +=  std::atoi(&N[len-1]);
    N.pop_back();
  }
  
  if(sum%9 == 0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define dump(x) cerr << " [L" << __LINE__ << "] " << #x << " = " << (x) << endl;

template<typename T>string join(vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream& operator<<(ostream& o, vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, vector<vector<T> >&vv)
{int l=vv.size();if(l){rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N;
vi a;

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

int can_win(){
    rep(round, N){
        int odd = 0, even = 0, idx = 0;
        rep(i, N)
            if(a[i] & 1) odd++, idx = i;
            else even++;
        if(even & 1) return 1 ^ (round&1);
        else if(odd > 1 || a[idx] == 1) return 0 ^ (round&1);
        else{
            a[idx]--;
            int g = a[0];
            REP(i, 1, N) g = gcd(g, a[i]);
            rep(i, N) a[i] /= g;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    cin >> N;
    a = vi(N);
    rep(i, N) cin >> a[i];
    cout << (can_win() ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
 
int A, B, X ;


int main()
{
	int A;
	std::cin >> A;
	int B;
	std::cin >> B;
	X = A * B;
	X = std::max(X, A - B);
	X = std::max(X, A + B);
	std::cout << X;
}

Measured memory_bytes: 256
from collections import defaultdict

n, a = map(int, input().split())
x = list(map(int, input().split()))
y = [xi - a for xi in x]

# 解説AC
dp = [defaultdict(int) for i in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in dp[i]:
        dp[i + 1][j + y[i]] += dp[i][j]
        dp[i + 1][j] += dp[i][j]
print(dp[n][0] - 1)


Measured memory_bytes: 10864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
typedef pair<int, int> P;
int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	if (n % 2 == 1 || n <= 9) {
		cout << 0;
		return(0);
	}
	while (n) {
		ans += (n / 5) / 2;
		n /= 5;
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#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 MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100

void solve(){
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	int sum = a+b+c;
	int mx = max(a, max(b,c));
	sum -= mx;
	sum += mx * pow(2, k);
	cout<<sum<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long x = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {}
		else if (i % 5 == 0) {}
		else x += i;

	}

	cout << x << endl;

	return 0;



}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<ll> d;

void dfs(const wgraph &g,int v,int p){
  for(auto i:g[v]){
    if(i.first==p)continue;
    d[i.first]+=i.second+d[v];
  }
  for(auto i:g[v]){
    if(i.first==p)continue;
    dfs(g,i.first,v);
  }
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  wgraph g(n);
  for(i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    g[a-1].push_back(pll(b-1,c));
    g[b-1].push_back(pll(a-1,c));
  }
  int q;
  cin>>q>>k;
  int x[q],y[q];
  for(i=0;i<q;i++)cin>>x[i]>>y[i];
  d.assign(n,0);
  dfs(g,k-1,-1);
  for(i=0;i<q;i++)cout<<d[x[i]-1]+d[y[i]-1]<<endl;
}


Measured memory_bytes: 15104
import sys
readline = sys.stdin.readline
write = sys.stdout.write

mod = 10**9 + 9; p = 13; q = 19

p_table = q_table = None
def prepare(L):
    global p_table, q_table
    p_table = [1]*(L+1); q_table = [1]*(L+1)
    for i in range(L):
        p_table[i+1] = p_table[i] * p % mod
        q_table[i+1] = q_table[i] * q % mod

def rolling_hash(S, W, H):
    D = [[0]*(W+1) for i in range(H+1)]
    for i in range(H):
        su = 0
        dp = D[i]
        di = D[i+1]
        si = S[i]
        for j in range(W):
            v = si[j] # v = ord(si[j]) if si[j] is str
            su = (su*p + v) % mod
            di[j+1] = (su + dp[j+1]*q) % mod
    return D
def get(S, x0, y0, x1, y1):
    P = p_table[x1 - x0]; Q = q_table[y1 - y0]
    return (S[y1][x1] - S[y1][x0] * P - S[y0][x1] * Q + S[y0][x0] * (P * Q) % mod) % mod

def solve():
    prepare(1001)
    H, W = map(int, readline().split())
    M = [list(map(ord, readline().strip())) for i in range(H)]
    R, C = map(int, readline().split())
    M0 = [list(map(ord, readline().strip())) for i in range(R)]

    rh = rolling_hash(M, W, H)
    rh0 = rolling_hash(M0, C, R)
    v = rh0[-1][-1]
    for i in range(H-R+1):
        for j in range(W-C+1):
            if v == get(rh, j, i, j+C, i+R):
                write("%d %d\n" % (i, j))
solve()



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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

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

Measured memory_bytes: 256
import heapq

N = int(input())

works = []
for i in range(N):
    a, b = map(int, input().split())
    heapq.heappush(works, (b, a,))

time = 0
can = True
for i in range(N):
    work = heapq.heappop(works)
    time += work[1]
    if time > work[0]:
        can = False
        break

if can:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 28768
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $x);
$ans = 0;
for($i = 0; $i <= $a; $i++){
  for($j = 0; $j <= $b; $j++){
    for($k = 0; $k <= $c; $k++){
      if($i * 500 + $j * 100 + 50 * $k == $x) $ans++;
    }
  }
}
echo $ans, "\n";

Measured memory_bytes: 4856
import math
A,B,H,M =map(int, input().split())
s1 = math.radians(30*H + 0.5*M)
s2 = math.radians(6*M)
x1 = A* math.cos(s1)
y1 = A* math.sin(s1)
x2 = B* math.cos(s2)
y2 = B* math.sin(s2)
L = ((x1-x2)**2 + (y1-y2)**2)**0.5
print(L)


Measured memory_bytes: 9508
#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    string S; cin >> S;
    vector<string> w = {"Sunny", "Cloudy", "Rainy"};
    unordered_map<string, int> w_number;
    for (int i = 0; i < 3; i++) w_number[w[i]] = i;
    int x = (w_number[S] + 1) % 3;
    cout << w[x] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    if (n >= k) cout << n-k+1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
  long num; 
  cin >> num;
  
  long sqrt_num = int(sqrt(num));
  
  int i;
  for(i = sqrt_num; i > 1; i --)
  {
    if(num % i == 0)
    {
      cout << i + num / i - 2 << endl;
      break;
    }
  }
  if(i == 1)
    cout << num - 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#126_E
n,m=map(int,input().split())

#Union-Find
par=[i for i in range(n)]
size=[1 for _ in range(n)]
rank=[0 for _ in range(n)]
 
def find(x):#木の根を求める
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
    
def unite(x,y):#併合
    x=find(x)
    y=find(y)
    if x==y:
        return
    if rank[x]>rank[y]:
        par[y]=x
        size[x]+=size[y]
    else:
        par[x]=y
        size[y]+=size[x]
        if rank[x]==rank[y]:
            rank[y]+=1
            
def same(x,y):
    return find(x)==find(y)

for _ in range(m):
    x,y,z=map(int,input().split())
    unite(x-1,y-1)
    
print(len(set([find(i) for i in range(n)])))

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // 採用されうる問題数
  // ASを降順にした時、上位P-1番目までは確定
  // P番目以降にについて、スコアごとに二分探索していく
  ll N,M,V,P;cin>>N>>M>>V>>P;
  vector<ll> AS(N);
  REP(i,N) cin>>AS[i];

  // ASの降順取得
  sort(ALL(AS));
  reverse(ALL(AS));
  // DUMP(AS);

  vector<ll> dupas(AS);
  sort(ALL(dupas));
  auto checker = [&](ll x) {
    // Mを足してもP番目の数に到達できない場合
    if (x+M<AS[P-1]) return false;

    // x以降の数6|55...0
    ll smaller_cnt = upper_bound(ALL(dupas),x)-dupas.begin();
    ll tmp = 0;
    FOR(i,P-1,N-smaller_cnt) tmp += x+M-AS[i];
    ll baffer = ((P-1)+smaller_cnt)*M+tmp;
    return baffer>=M*V;
  };

  // スコアが最小でもOKの場合
  if (checker(AS.back())) {
    OUT(N);
    return 0;
  }

  ll left=AS.back(),right=AS[P-1];
  while (left<right) {
    ll mid = (left+right)/2;
    checker(mid) ? right=mid : left=mid+1;
  }
  // OUT(left);

  ll imp_cnt = lower_bound(ALL(dupas),left)-dupas.begin();
  OUT(N-imp_cnt);

  return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n, m, sum, cnt int
	var line float64
	fmt.Scan(&n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}
	line = float64(sum) / (4 * float64(m))
	for i := 0; i < n; i++ {
		if float64(a[i]) >= line {
			cnt++
		}
	}
	if cnt >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int A, B;
		cin >> A >> B;
		if (H <= A && W <= B) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
	if(k==0) return 1;
    else return COM(n,k-1)*(n-k+1)/k;
}
int main(){
	int N,A,B;
	ll v[50];
	vll vsort;
	ll sum=0;
	ll kazumax=0;
	double ave=0;
	map<ll,int> vnum;
	scan(N);scan(A);scan(B);
	rep(i,N){
		scan(v[i]);
		vsort.push_back(v[i]);
		kazumax=max(kazumax,v[i]);
		if(vnum[v[i]]==0) vnum[v[i]]=1;
		else vnum[v[i]]++;
	}
	sort(vsort.rbegin(),vsort.rend());
	int maxindex;
	ll maxkazu=vsort[A-1];
	rep(i,N){
		if(vsort[i]==maxkazu){
			maxindex=i;
			break;
		}
	}
	if(kazumax!=maxkazu){
		rep(i,A){
			ave+=vsort[i];
		}
		ave/=A;
		printf("%f\n",ave);
		prin(COM(vnum[maxkazu],A-maxindex));
	}
	else{
		for(int i=A;i<=B&&vsort[i-1]==maxkazu;i++){
			sum+=COM(vnum[maxkazu],i);
		}
		printf("%f\n",(double)maxkazu);
		prin(sum);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>

using namespace std;

#define int long long

int solve(int s, int d) {
    int ret = abs(s)%2 + abs(d)%2;

    if (s == d) return 0;

    s += abs(s)%2;
    d -= abs(d)%2;

    ret += solve(s/2, d/2);

    return ret;
}

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

    for (int i = 0; i < N; i++) {
	int s, d;
	cin >> s >> d;

	cout << solve(s, d) << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

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

int main(){ 
    string s;
    cin >> s;
    ll n = (ll)s.size();
    ll cnt = 0;
    rep(i,0,n){
        if(i > n-i-1) break;
        if(s[i] != s[n-i-1]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,x,t,cnt;
	scanf("%d %d %d",&n,&x,&t);
	cnt=n/x;
	if(n%x!=0)	cnt++;
	printf("%d\n",cnt*t);
	return 0;
}

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

int main()
{
  int n;
  static long long a[10000],b[10000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  for(int j=0;j<n;j++){
    scanf("%lld",b+j);
  }
  long long T=0;
  for(int i=0;i<n;i++){
    T+=b[i]-a[i];
  }
  long long S=0;
  for(int i=0;i<n;i++){
    if(a[i]<=b[i]){
      if((b[i]-a[i])%2==1){
	S++;
      }
    }
    else{
      S+=a[i]-b[i];
    }
  }
  puts(S<=T?"Yes":"No");
  return 0;
}


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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

const int N = 2e5 + 9, M = 1e4 + 9, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


ll cumu[N];

int main(){
    init();

    ll n, d, a; cin >> n >> d >> a;
    pll m[n];
    for(int i = 0;i < n;i++)    cin >> m[i].F >> m[i].S;

    sort(m, m + n);

    ll ans = 0;
    for(int i = 0;i < n;i++){
        if(i)   cumu[i] += cumu[i - 1];

        ll x = m[i].F + 2 * d;

        int l = i, r = n - 1;
        while(l <= r){
            int mid = (l + r) >> 1;
            if(m[mid].F <= x)   l = mid + 1;
            else r = mid - 1;
        }

        ll moves = max(0.0, ceil(1.0 * (m[i].S) / a) - cumu[i]);
        cumu[i] += moves;
        if(r + 1 < n)   cumu[r + 1] -= moves;

        ans += moves;

    }

    cout << ans;
}

Measured memory_bytes: 4992
"use strict";

const main = arg => {
    const H = parseInt(arg.split("\n")[0].split(" ")[0]);
    const W = parseInt(arg.split("\n")[0].split(" ")[1]);
    const pixel = arg.split("\n").slice(1, H + 1);
    
    let answer = [];
    
    answer[0] = [];
    answer[0].push("#".repeat(W + 2));
    
    for(let i=1; i<=H; i++) {
        answer[i] = [];
        answer[i].push("#" + pixel[i - 1] + "#");
    }

    answer[H + 1] = [];
    answer[H + 1].push("#".repeat(W + 2));
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
N = int(input())
H=list(map(int,input().split()))
#print(H)
INF=1000000000
dp=[INF]*(N+1)
#print(dp)
dp[0]=0
#print(dp[0])
#print(H[1],H[0])
dp[1]=dp[0]+abs(H[1]-H[0])
for i in range(2,N):
  dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))
print(dp[N-1])
  

Measured memory_bytes: 13976
#include<iostream>

using namespace std;

template<typename T> inline void chmax(T& t, T f){if(t < f)t = f;}

int compound(int A, int year, double rate, int charge){
    int res = A;
    while(year--){
        int B = res * rate;
        res += B - charge;
    }
    return res;
}

int simple(int A, int year, double rate, int charge){
    int res1 = A, res2 = 0;
    while(year--){
        int B = res1 * rate;
        res2 += B;
        res1 -= charge;
    }
    return res1 + res2;
}

int main(){
    int m;
    cin >> m;
    while(m--){
        int init, year, n;
        cin >> init >> year >> n;
        int ans = 0;
        while(n--){
            int k, charge; double rate;
            cin >> k >> rate >> charge;
            chmax(ans, k? compound(init, year, rate, charge): simple(init, year, rate, charge));
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 1232
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[derive(Eq, PartialEq, Clone, Debug)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

const M: u64 = 1000000007;

fn main() {
    let (n, w) = get!(usize, usize);
    let mut ws = get!(usize; n);

    ws.sort_by_key(|&x| Rev(x));

    let mut sum = ws.iter().sum::<usize>();
    let mut dp = vec![0; w + 1];
    dp[0] = 1;

    let mut ans = 0;

    if sum <= w {
        println!("{}", 1);
        return;
    }

    for &x in &ws {
        sum -= x;
        for k in 0..w + 1 {
            if k + sum <= w && k + sum + x > w {
                ans += dp[k];
                ans %= M;
            }
        }

        for i in (x..w + 1).rev() {
            if dp[i - x] > 0 {
                dp[i] = (dp[i] + dp[i - x]) % M;
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string a,b,c;
cin >> a >> b >> c;
cout << a[0] << b[0] << c[0] << endl;
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
struct UnionFind {
	vector<int> r;
 
	UnionFind(int N) {
		r = vector<int>(N, -1);
	}
	int root(int x) {
		if (r[x] < 0)return x;
		return r[x] = root(r[x]);
	}
 
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return false;
		if (r[x] > r[y])swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}
 
	int size(int x) {
		return -r[root(x)];
	}
};
 
 
int main() {
	int n, m;
	int a, b;
	int i, j;
	int index = 0;
	int ans = 0;
	cin >> n >> m;
	
	UnionFind UF(n);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		a--;	b--;
		UF.unite(a, b);
	}
 
 
	for (i = 0; i < n; i++) {
		ans = max(ans, UF.size(i));
	}
 
	cout << ans << endl;
 
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;


vector<string> ans;
vector<int> p;


int main()
{
	double p = 3.1415926;
	int R;
	cin>>R;
	double ans = p * R * 2;
	printf("%f\n",ans); 
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 1){
        cout << b - a << endl;
    }else {
        cout << a - b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
K = int(input())
ans = 0
cnt = 9
start = 0
X = deque([[[9],[8],[7],[6],[5],[4],[3],[2],[1]]])
if K <= 9:
  print(K)
  exit()
for _ in range(10000):
    X.append(deque([]))
for i in range(1,10000):
    now_cnt = cnt
    for x in list(X[i-1]):
        for j in range(10,0,-1):
            if abs(x[len(x)-1]-j+1) <= 1:
                X[i].append(x+[j-1])
                cnt += 1
    if cnt >= K:
        X[i].reverse()
        lun = X[i][K-now_cnt-1]
        
        N = []
        
        for n in lun:
          N.append(str(n))
        
        print(''.join(N))
        exit()

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

int main(){
		int n,count=0,keta[100];
		scanf("%d",&n);
		if(n==0){
				puts("0");
				return 0;
		}
		while(n!=0){
				if(abs(n)%2==0){
						keta[count]=0;
				}
				if(abs(n)%2==1){
						if(count%2==0)n--;
						else n++;
						keta[count]=1;
				}
				n=n/2;
				count++;
		}
		count--;
		while(count>=0){
				printf("%d",keta[count]);
				count--;
		}
		return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    string S;
    cin>>S;
    if(S=="SSS") cout<<0<<endl;
    if(S=="SSR" || S=="RSS" || S=="RSR" || S=="SRS") cout<<1<<endl;
    if(S=="RRS" || S=="SRR") cout<<2<<endl;
    if(S=="RRR") cout<<3<<endl;
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
全探索　数列生成

N,M,Qと4つの整数の組{ai, bi, ci, di}Q組が与えられる。
長さNの正数列であり、1<=A1<=A2<=...<=AN<=Mとなる数列Aに対して、
数列の得点を、
Abi - Aai = ciを満たすときdiが付加される。

数列の得点の最大値を求めたい。
N,M <= 10, Q<=50

N,Mが少ないので、全探索が可能？
20C10は100000程度

全探索の際の数列はfdsで生成

*/

struct query {
    int a,b,c,d;
    query(int a, int b, int c, int d) : a(a), b(b),c(c), d(d) {}
    bool operator<(const query& other) const {
        auto tmp = *this;
        if (tmp.a == other.a){
            return tmp.b < other.b;
        } else {
            return tmp.a < other.a;
        }
    }
};
vector<int> dp(10);

vector<vector<int>> num_array;
int n, m;
void fds(vector<vector<int>> &arr, vector<int> tmp = vector<int>()){
    // cout << tmp.size() << endl;
    // show(tmp);
    if (tmp.size() >= n){
        arr.push_back(tmp);
        return;
    }
    int st = 1;

    if (tmp.size() != 0){
        st = tmp[tmp.size()-1];
    }

    for (int i = st; i <= m; i++)
    {
        vector<int> t = tmp;
        t.push_back(i);
        fds(arr, t);
    }
    
    return;
}


int main()
{
    int q;
    cin >> n >> m >> q;
    vector<query> que;
    rep(i, q){ 
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--; b--;
        que.push_back({a, b, c, d});
    }

    fds(num_array);
    // rep(i, num_array.size()){
    //     show(num_array[i]);
    // }

    ll ans = 0;
    rep(i, num_array.size()){
        auto x = num_array[i];
        ll tans = 0;
        rep(j, q){
            if (x[que[j].a] + que[j].c == x[que[j].b]){
                tans += que[j].d;
            }
        }
        ans = max(tans, ans);
    }
    cout << ans << endl;
}



Measured memory_bytes: 9840
#include <iostream>

using namespace std;

int main(){
  int d, n, p=1;
  cin >> d >> n;
  
  for (int i=0; i<d; i++) {
    p*=100;
  }
  if (n==100) n+=1;
  printf("%d\n", p*(n));
  return 0;
}

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

int main() {
    string a,b; cin >> a >> b;
    if (a.length() > b.length())
    {
        cout << "GREATER\n";
        return 0;
    }
    if (a.length() < b.length()) {
        cout << "LESS\n";
        return 0;
    }

    if (a > b) {
        cout << "GREATER\n";
    } else if (a == b) {
        cout << "EQUAL\n";
    } else {
        cout << "LESS\n";
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist

h,w = map(int,input().split())
C = [list(map(int,input().split())) for i in range(10)]
G = [[] for i in range(10)]
for i,ci in enumerate(C):
  for j,vj in enumerate(ci):
    G[j].append((i,vj))
dist = disktra(G,1)
for i in range(h):
  for number in map(int,input().split()):
    if number == -1: continue
    ans += dist[number]
print(ans)
    

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

int main(){
 int N;
 cin >> N;
 
 vector <int> A(N-1),B(N);
 
 for(int i=0; i<N-1; i++){
   cin >> A.at(i); 
   B.at(A.at(i)-1)++;
 }
 for(int i=0; i<N; i++){cout << B.at(i) << endl;}
}

Measured memory_bytes: 4844
n = int(input())
A = list(map(int, input().split()))

counter = 0
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            counter += 1

for i in range(n):
    if i == n-1:
        print(A[i])
    else:
        print(A[i],end=' ')
print(counter)


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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in();
    vector<int> d(n);
    for (int i=0;i<n;i++) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1] << endl;
}

Measured memory_bytes: 640
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	string S;
	cin >> N >> S;

	int cnt = 0;
	for (auto c : S)if (c == '1')cnt++;

	vector<vector<int>> MO(2, vector<int>(N, 0));
	vector<int> SMO(2);
	if (cnt > 1)
	{
		cnt--;

		int mo = 1;
		rep(i, 0, N)
		{
			mo %= cnt;
			MO[0][N - 1 - i] = mo;
			mo <<= 1;
		}

		mo = 0;
		rep(i, 0, N)
		{
			mo <<= 1;
			if (S[i] == '1')mo++;
			mo %= cnt;
		}
		SMO[0] = mo;

		cnt++;
	}

	{
		cnt++;

		int mo = 1;
		rep(i, 0, N)
		{
			mo %= cnt;
			MO[1][N-1-i] = mo;
			mo <<= 1;

		}

		mo = 0;
		rep(i, 0, N)
		{
			mo <<= 1;
			if (S[i] == '1')mo++;
			mo %= cnt;
		}
		SMO[1] = mo;

		cnt--;
	}

	rep(i, 0, N)
	{
		if (S[i] == '1')
		{
			if (cnt == 1)
			{
				cout << 0 << endl;
			}
			else
			{
				cnt--;

				int n = (SMO[0] - MO[0][i] + cnt) % cnt;

				int res = 1;
				while (n != 0)
				{
					int b = 1;
					int c = 1;
					while (n > b)
					{
						b *= 2;
						c++;
					}
					c++;
					int tcnt = 0;
					rep(j, 0, c)
					{
						if ((n >> j) & 1)tcnt++;
					}
					n %= tcnt;
					res++;
				}
				cout << res << endl;

				cnt++;
			}
		}
		else
		{
			cnt++;

			int n = (SMO[1] + MO[1][i] + cnt) % cnt;

			int res = 1;
			while (n != 0)
			{
				int b = 1;
				int c = 1;
				while (n > b)
				{
					b *= 2;
					c++;
				}
				c++;
				int tcnt = 0;
				rep(j, 0, c)
				{
					if ((n >> j) & 1)tcnt++;
				}
				n %= tcnt;
				res++;
			}
			cout << res << endl;

			cnt--;
		}
	}

	return 0;
}

Measured memory_bytes: 8324
#include <stdio.h>
#include <cmath>
int judge(int n){
	return n%2;
}
int main(){
	int n;
	scanf("%d",&n);
	int cnt = 0;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		if(judge(i+1)&&judge(t)){
			cnt++;
		}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 1700
str=input()
str_list=str.split()
W=int(str_list[0])
H=int(str_list[1])
x=int(str_list[2])
y=int(str_list[3])
r=int(str_list[4])
in_rec=True

if (x-r)<0 or (x+r)>W or  (y+r) > H or (y-r)<0:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 5596
n = int(input())

for i in range(n):
    b = [False,False,False]
    o = 0
    p = 0
    while o < 3:
        e = input()
        if e == "HIT":
            if b[2]:
                p += 1
            b[1], b[2] = b[0], b[1]
            b[0] = True
        elif e == "HOMERUN":
            p += b.count(True) + 1
            b = [False,False,False]
        else:
            o += 1
    print(p)



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	long long ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] + a[j] > a[k]) {
					ans++;
				}
				else {
					break;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; 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 gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  double s = 0;
  rep(i, n) {
    int x;
    cin >> x;
    s += 1.0 / x;
  }
  printf("%.8f", 1.0 / s);
  return 0;
}

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

int main(){
	string s; cin >> s;
	bool vis[26] = {};
	for(int i = 0 ; i < s.size() ; ++i) vis[s[i] - 'a'] = 1;
	for(int i = 0 ; i < 26 ; ++i) if(!vis[i]){cout << (s + (char)('a' + i)); return 0;}
	string str = s;
	if(next_permutation(str.begin() , str.end()))
		for(int i = 0 ; i < str.size() ; ++i){
			putchar(str[i]); if(s[i] != str[i]) break;
		}
	else puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t N, K;
    int64_t ans = 0;

    scanf("%"PRId64"%"PRId64, &N, &K);

    if ((N / 2 + (N % 2)) >= K) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
     
    using namespace std;
    typedef long long ll;
    ll mod = 1e9+7;
     
    int main(void)
    {
      int A,B,C;
      cin>>A>>B>>C;
      int p=0;
      int q=0;
      int r=0;
      if(A==B)p=1;
      if(A==C)q=1;
      if(B==C)r=1;
      int result = p+q+r;
      if(result==1)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }

Measured memory_bytes: 256
use std::io;

fn read_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return line;
}


fn main() {
    let line = read_line();
    let line: Vec<i64> = line.split_whitespace().map(|word| word.parse::<i64>().unwrap()).collect();
    let (n, a, b) = (line[0], line[1], line[2]);
    println!("{}", [n * a, b].iter().min().unwrap());
}

Measured memory_bytes: 4352
import collections

n = int(input())
s = input()

c = collections.Counter(s)
r = c['R'] * c['G'] * c['B']

for i in range(n):
    for k in range(i, n):
        j = (i + k) // 2
        if (i + k) % 2 == 0 and 0 < 2 < n:
            if s[i] != s[k] and s[k] != s[j] and s[i] != s[j]:
                r -= 1

print(r)


Measured memory_bytes: 68740
n,k,q=[int(j) for j in input().split()]
l=[0]*n
for i in range(q):
    a=int(input())
    l[a-1]+=1
s=sum(l)
ans=0
for i in range(n):
    if k-s+l[i]>0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4700
#include <iostream>

using namespace std;

static const int MAX = 200000;


int MaxProfit(int *R,int n)
{
	
	int min_num = R[0];
	int maxv = R[1] - R[0];
	
	for(int j=1; j < n; j++)
	{
		if ((R[j] - min_num) > maxv)
		{
			maxv = R[j]- min_num;
		}
		if(R[j] < min_num)
		{
			min_num = R[j];
		}
			
	}
	
	return maxv;
}


int main(void) {
	int R[MAX], n;
	int maxv;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];
	maxv = MaxProfit(R, n);
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3880
def to_fizzbuzz(num: int) -> str:
    if num % 15 == 0:
        return 'FizzBuzz'
    if num % 3 == 0:
        return 'Fizz'
    if num % 5 == 0:
        return 'Buzz'
    return str(num)


N = int(input())
answer = 0
for i in range(1, N + 1):
    fb_str = to_fizzbuzz(i)
    if fb_str.isdecimal():
        answer += int(fb_str)
print(answer)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  string s;
  cin>>s;
  string ans="Good";
  for(i=0;i<3;i++){
    if(s[i]==s[i+1]) ans="Bad";
  }
  cout<<ans<<endl;

  return 0;  
}

Measured memory_bytes: 256