akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

template<ll p, ll b>
struct FastRollingHash{
  vector<ll> h;
  vector<ll> e;
  ll n, m;
  inline ll mod(ll x){
    x = (x & m) + (x >> p);
    return (x >= m) ? (x - m) : x;
  }
  void init(const string &s){
    n = s.length();
    m = (1LL << p) - 1;
    h = vector<ll>(n+1, 0);
    e = vector<ll>(n+1, 1);
    for(int i = 0; i < n; i++){
      h[i+1] = mod(mod(h[i]*b)+s[i]);
      e[i+1] = mod(e[i]*b);
    }
  }
  FastRollingHash(){}
  FastRollingHash(const string &s){
    init(s);
  }
  ll get(int s, int t){
    ll res = h[t] - mod(h[s]*e[t-s]);
    return (res < 0) ? (res + m) : res;
  }
};

int n;
string s[310];
string t[610];

FastRollingHash<31, 31> rhs[310];
FastRollingHash<31, 31> rht[310];

int main(){

  n = in();
  REP(i, n){
    s[i] = stin();
    t[i] = s[i];
    s[i] += s[i];
  }

  REP(i, n){
    REP(j, n){
      if(i < j){
        swap(t[i][j], t[j][i]);
      }
    }
  }
  REP(i, n){
    t[i] += t[i];
  }
  
  REP(i, n){
    rhs[i].init(s[i]);
    rht[i].init(t[i]);
  }

  ll ans = 0;
  REP(i, n){
    REP(j, n){
      bool ok = true;
      REP(k, n){
        int si = (i+k)%n;
        int tj = (j+k)%n;
        if(rhs[si].get(j, j+n) != rht[tj].get(i, i+n)){
          ok = false;
          break;
        }
      }
      if(ok){
        ans++;
      }
    }
  }

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


Measured memory_bytes: 7936
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct edge {int to,w,p;};
int n,m,k,used[1002],a,b,c,cnt,A[1002];
vector<edge> v[1002];
int dfs(int s,int t,int r){
    if(s==t)return r;
    used[s]=1;
    for(int i=0;i<v[s].size();i++){
        edge &u=v[s][i];
        if(used[u.to]==0&&u.w>0){
            int F=dfs(u.to,t,min(r,u.w));
            if(F>0){
                u.w-=F;v[u.to][u.p].w+=F;return F;
            }
        }
    }
    return 0;
}
int f(int a,int b){
    if(b==0)return a;
    return f(b,a%b);
}
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    for(int i=0;i<1002;i++){
        A[i]=0;
        v[i]={};
    }
    for(int i=0;i<n;i++){
        cin>>A[i];
        a=1000,b=i;
        edge p={b,1,(int)v[b].size()};v[a].push_back(p);
        edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
    }
    for(int i=500;i<500+m;i++){
        cin>>A[i];
        a=i,b=1001;
        edge p={b,1,(int)v[b].size()};v[a].push_back(p);
        edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
    }
    for(int i=0;i<n;i++){
        for(int j=500;j<500+m;j++){
            if(f(A[i],A[j])>1){
                a=i,b=j;
                edge p={b,1,(int)v[b].size()};v[a].push_back(p);
                edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
            }
        }
    }
    int res=0;
    while(1){
        for(int i=0;i<1002;i++)used[i]=0;
        int P=dfs(1000,1001,1e9);
        if(P==0)break;
        res++;
    }
    cout<<res<<endl;
    }
}



Measured memory_bytes: 9352
#include<iostream>
#include<string>

using namespace std;

int main() {
	string O, E;
	int o, e;
	cin >> O >> E;
	o = O.size();
	e = E.size();

	for (int i = 0; i < o - 1; i++) cout << O[i] << E[i];
	cout << O[o - 1];

	if (o - e == 0)cout << E[e - 1];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())

def six_p(n) :
    temp = 0
    for i in reversed(range(7)) :
        temp += n//(6**i)
        n = n%(6**i)
    return temp

def nin_p(n) :
    temp = 0
    for i in reversed(range(6)) :
        temp += n//(9**i)
        n = n%(9**i)
    return temp

ans = 10**6
for i in range(N+1):
    ans = min(ans, six_p(i)+nin_p(N-i))

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n;
  string s;
  bool is=true;
  cin >> n >> s;
  for(int i=0; i<n/2; i++){
    if(s.at(i)!=s.at(i+n/2)){
      is=false;
    }
  }
  if(n==1){
    is=false;
  }
  if(n%2==1){
    is=false;
  }
  if(is){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    ves S(N); rep(i,N) cin >> S[i];
    int cnt = 0;
    rep(A,1) rep(B,N) {
        bool flag = true;
        rep(i,N) {
            repk(j,i+1,N) {
                if(S[(i+A)%N][(j+B)%N] != S[(j+A)%N][(i+B)%N]) { flag = false; break;}
            }
            if(!flag) break;
        }
        if(flag) cnt++;
    }
    cout << cnt * N << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
ans = 0
for i in range(n):
    k = int(input())
    j = 2
    flag = 0
    while k/j >= j:
        if k % j == 0:
            flag = 1
            break
        j += 1
    if flag == 0:
        ans += 1
print(ans)

Measured memory_bytes: 7636
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A, B,C;
    cin >> A >> B >> C;
    cout << A*B/2;
}

Measured memory_bytes: 384
import math


def main():
    depth = int(input())
    leaves = [int(x) for x in input().split()]

    nodes_range = [None] * (depth + 1)
    for i in range(depth, -1, -1):
        if i == depth:
            nodes_range[i] = (leaves[i], leaves[i])
            continue
        # 枝をなるべくまとめていく。
        min_nodes = math.ceil(nodes_range[i + 1][0] / 2) + leaves[i]
        # 枝が結合せず，平行に遡る感じ。
        max_nodes = nodes_range[i + 1][1] + leaves[i]
        nodes_range[i] = (min_nodes, max_nodes)

    if nodes_range[0][0] != 1:
        # 根が1を取り得ない場合は実現不可能。
        print(-1)
        return

    max_noded_tree = [0] * (depth + 1)
    for i in range(depth + 1):
        if i == 0:
            max_noded_tree[i] = 1
            continue
        max_noded_tree[i] = min(
            (max_noded_tree[i - 1] - leaves[i - 1]) * 2,
            nodes_range[i][1])
    print(sum(max_noded_tree))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 31732
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#define PI 3.141592653589
typedef long long ll;
const int MOD = 1000000007;
const int INF = 2002002002;
const int di[] = { -1, 0, 1, 0 };
const int dj[] = { 0, -1, 0, 1 };
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 3568
n, m = map(int, input().split())
xyz = []
t = [[0, 0, 0] for _ in range(8)]
tt = [0]*8
ans = 0

for i in range(n):
  x, y, z = map(int, input().split())
  xyz.append([x, y, z])
  xyz[i].append(x+y+z)
  xyz[i].append(x+y-z)
  xyz[i].append(x-y+z)
  xyz[i].append(-x+y+z)
  xyz[i].append(x-y-z)
  xyz[i].append(-x+y-z)
  xyz[i].append(-x-y+z)
  xyz[i].append(-x-y-z)

from operator import itemgetter

for i in range(8):
  xyz.sort(key=itemgetter(i+3))
  for j in range(m):
    t[i][0] += xyz[j][0]
    t[i][1] += xyz[j][1]
    t[i][2] += xyz[j][2]
  tt[i] = abs(t[i][0]) + abs(t[i][1]) + abs(t[i][2])
  if ans < tt[i]:
    ans = tt[i]

print(ans)


Measured memory_bytes: 3700
from sys import stdin
n = int(stdin.readline().rstrip())
ab = [int(i) for i in stdin.readline().rstrip().split(" ")]
p = [int(i) for i in stdin.readline().rstrip().split(" ")]

first = len([i for i in p if i <= ab[0]])
third = len([i for i in p if i > ab[1]])
second = n - first - third
print(min([first,second,third]))

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

typedef long long ll;

int main(){
    int n; cin >> n;
    ll d;
    cin >> d;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
int main(){
    list<int>L;
    int x,n;string s;cin>>n;
    rep(i,0,n){
        cin>>s;
        if(s=="insert"){
            cin>>x;
            L.push_front(x);
        }
        else if(s=="delete"){
            cin>>x;
            for(list<int>::iterator it=L.begin(); it!=L.end();it++){
                if(*it==x){
                    L.erase(it);break;
                }
            }
        }
        else if(s=="deleteFirst")L.pop_front();
        else if(s=="deleteLast")L.pop_back();
    }
    int i=0;
    for(list<int>::iterator it=L.begin(); it!=L.end();it++){
        if(i++)cout<<" ";
        cout<<*it;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 34308
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    cin>>n;
    int maxnum=-1,maxi=-1;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(b>maxi || (a<maxnum && maxi==b)){
            maxi=b;
            maxnum=a;
        }
    }
    cout<<maxnum<<" "<<maxi<<endl;
    
    return 0;
}

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

vector<string> split_string(string);

int C[15];

int main()
{
   int n, m, x;
   cin >> n >> m >> x;

   vector <vector <int> > vec(n);

   for(int i = 0; i < n; i++){
       cin >> C[i];
       vec[i].resize(m);
       for(int j = 0; j < m; j++){
           cin >> vec[i][j];
       }
   }
   int ans = 1e9;
   for(int mask; mask < (1<<n); mask++){
       vector <ll> vec1(m, 0);
       int cost = 0;
       for(int i = 0; i < n; i++){
           if((1<<i)&mask){
               cost += C[i];
               for(int j = 0; j < m; j++) vec1[j] += 1LL*vec[i][j];
           }
       }
       int cond = 1;
       for(int j = 0; j < m; j++) if(vec1[j] < x) cond = 0;
       if(cond) ans = min(ans, cost);
   }
   if(ans == 1e9) ans = -1;
   cout << ans;
}


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

int main() {
    string symbol;
    
    stack<int> S;
    
    while(cin >> symbol){
        if(symbol == "+"){
            int a = S.top();
            S.pop();
            int b = S.top();
            S.pop();
            S.push(b+a);
        }else if(symbol == "-"){
            int a = S.top();
            S.pop();
            int b = S.top();
            S.pop();
            S.push(b-a);
        }else if(symbol=="*"){
            int a = S.top();
            S.pop();
            int b = S.top();
            S.pop();
            S.push(b*a);
        }else{
            int i = stoi(symbol);
            S.push(i);
        }
    }
    
    cout << S.top()<<endl;
    
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 13)
    {
        cout << B << "\n";
    }
    else if (A >= 6 && A <= 12)
    {
        cout << B / 2 << "\n";
    }
    else
    {
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


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

    int X=0;

    int ans=0;

    for(int i=0;i<N;++i){
        int tmp;
        if(S[i]=='I'){
            tmp=1;
        }else{
            tmp=-1;
        }

        X+=tmp;

        ans=max(ans,X);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



ll comb(ll num){
  return num*(num-1)/2;
}


ll idx[1000000];
ll cnt[1000000];

int main(){
  int N , K;
  cin >> N >> K;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  int ans = 0;
  rep(i,K) ans += a[N-i-1];
  cout << ans << endl;
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), ball(n, 0), ans(0);
  int cnt = 0;
  for (int i = 0; i < n; i++) cin >> a.at(i);
  if (n % 2 == 0)
    for (int i = 0; i < n / 2; i++) {
      ball.at(n - 1 - i) = a.at(n - 1 - i);
      if (ball.at(n - 1 - i) == 1) ans.push_back(n - i);
    }
  else
    for (int i = 0; i < n / 2 + 1; i++) {
      ball.at(n - 1 - i) = a.at(n - 1 - i);
      if (ball.at(n - 1 - i) == 1) ans.push_back(n - i);
    }
  int sum;
  for (int i = n / 2 - 1; i >= 0; i--) {
    sum = 0;
    for (int j = i; j < n; j += i + 1) sum += ball.at(j);
    if (sum % 2 != a.at(i)) {
      ball.at(i) = 1;
      ans.push_back(i + 1);
    }
  }
  if (ans.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size() - 1; i++)
    cout << ans.at(i) << " ";
  cout << ans.at(ans.size() - 1) << endl;
}

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

int main()
{
    string o, e;
    cin >> o;
    cin >> e;

    string ans;
    rep(i, 0, min(o.size(), e.size()))
        {
            ans.push_back(o[i]);
            ans.push_back(e[i]);
        }
    if(o.size() > e.size())
        ans.push_back(o[o.size() - 1]);
    else if (o.size() < e.size())
        ans.push_back(e[e.size() - 1]);
        
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

def func(x)
  mod = x % 4
  if mod == 0
    return x
  elsif mod == 1
    return 1
  elsif mod == 2
    return x + 1
  else
    0
  end
end

a, b = input_a
puts func(b) ^ func(a - 1)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int n,a,x=0,y=0;
	cin>>n;
	f(i,n){
		cin>>a;
		if(a%4==0) x++;
		else if(a%2==0) y++;
	}
	if(x*2+1+max((int)(0),y-1)>=n) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1) 

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll H, A;
    cin >> H >> A;

    if (H % A == 0)
    {
        cout << H / A << endl;
    }
    else
    {
        cout << (H / A + 1) << endl;
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Bits
import Debug.Trace

main :: IO ()
main = readContents 2 >>= main'
    where
        main' [[n, k], as] = print $ solve n k as

solve :: Int -> Int -> [Int] -> Int
solve n k as = maximum $ map (\x -> sum $ map (xor x) as) res
    where
        res = filter (<= k) $ map edit [0..40]

        edit i = hv + lv
            where
                lv = l .&. lm
                hv = h .&. hm
                lm = complement $ shiftL (shiftR oneBits j) j
                hm = shiftL (shiftR oneBits i) i
                j = max 0 $ i - 1

        oneBits = complement zeroBits

        l = build $ map count es
        h = foldl' ff l es
            where
                ff acc e
                    | e .&. k == 0 && e .&. l > 0 = acc - e
                    | otherwise = acc

        build = foldl' ff 0 . zip es
            where
                ff acc (e, b)
                    | b = acc + e 
                    | otherwise = acc

        count e = br $ foldl' ff (0, 0) as
            where
                br (a, b) = a < b
                ff (a, b) x
                    | e .&. x > 0 = (a + 1, b)
                    | otherwise = (a, b + 1) 

        es = map (2 ^) [39, 38..0]


readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 24956
//AtCoder ABC116 C - Grand Garden
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<ll> hn(N+1,0);
    ll lowest=-1;
    ll hid=0;
    for(ll i=1;i<=N;++i){
        ll h; cin>>h;
        hn[i]=h;
        if(lowest<h){
            lowest=h;
            hid=i;
        }
    }
    ll ans=0;
    for(ll i=2;i<=hid;++i){
        ans += max<ll>(hn[i-1]-hn[i],0);
    }
    for(ll i=N-1;i>=hid;--i){
        ans += max<ll>(hn[i+1]-hn[i],0);
    }
    cout<<ans+lowest<<endl;
    return 0;
}


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

#define ll             long long
#define sf             scanf
#define pf             printf
#define nl             printf("\n")
#define TEST           int Test;cin>>Test;for(int _t=1;_t<=Test;_t++)

using namespace std;



int main()
{
	ll d,s,t;
	sf("%lld %lld %lld",&d,&s,&t);
	if((s*t)>=d) pf("Yes\n");
	else pf("No\n");
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
#define umap unordered_map<int, int>
#define F first
#define S second
#define pii pair<int, int>
#define endl "\n"
using namespace std;
struct activity
{
	int swim, bug, hw;
};
int max_happiness(struct activity* a, int i, int n, struct activity *dp, int fl=0){

	if(i==n) return 0;
	// if(dp[i]!=-1) return dp[i];
	if(i==0) {

		int one = max_happiness(a, i + 1, n, dp, 1) + a[i].swim;
		int two = max_happiness(a, i + 1, n, dp, 2) + a[i].bug;
		int three = max_happiness(a, i + 1, n, dp, 3) + a[i].hw;
		return max(one, max(two, three));
	}

	if(fl==1) {
		if(dp[i].bug and dp[i].hw) return max(dp[i].bug, dp[i].hw);
		int one = dp[i].bug = max_happiness(a, i + 1, n, dp, 2) + a[i].bug;
		int two = dp[i].hw = max_happiness(a, i + 1, n, dp, 3) + a[i].hw;

		return max(one, two);
	}

	if(fl==2) {
		if(dp[i].swim and dp[i].hw) return max(dp[i].swim, dp[i].hw);
		int one = dp[i].swim= max_happiness(a, i + 1, n, dp, 1) + a[i].swim;
		int two = dp[i].hw = max_happiness(a, i + 1, n, dp, 3) + a[i].hw;

		return max(one, two);
	}

	if(fl==3) {
		if(dp[i].swim and dp[i].bug) return max(dp[i].swim, dp[i].bug);
		int one =dp[i].swim= max_happiness(a, i + 1, n, dp, 1) + a[i].swim;
		int two = dp[i].bug = max_happiness(a, i + 1, n, dp, 2) + a[i].bug;

		return max(one, two);
	}

	return -1;

}
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	// int t; cin >> t; while(t--)
	{
		int n;
		cin >> n;
		struct activity a[n];
		for(int i=0; i<n; i++) {
			cin >> a[i].swim >> a[i].bug >> a[i].hw;
		}

		struct activity dp[100005];
		memset(dp, 0, sizeof(dp));
		cout << max_happiness(a, 0, n, dp) << endl;
		// for(int i=0; i<n; i++) {
		// 	cout << max(dp[i].swim, max(dp[i].bug, dp[i].hw)) << " ";
		// }
		// cout << endl;


	}

	return 0;
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        int [] B = new int [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }
        long ans = 0;
        for(int i=N-1; i>=0; i--){
            long t = (A[i]+ans)%B[i];
            if(t!=0){
                long num=B[i]-t;
                ans+=num;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64456
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<int,int>> when(N);
	for (int i = 0; i < N; i++) {
		cin >> when.at(i).first;
		when.at(i).second = i+1;
	}
	sort(when.begin(), when.end());
	for (int i = 0; i < N; i++) {
		cout << when.at(i).second<<endl;
	}
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h, w;
    vector<P> data;

    while(true) {
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        data.push_back(P(h, w));

    }
    for(auto d : data){
        for(int i = 0; i < d.first; i++){
            for(int k = 0; k < d.second; k++){
                if(i == 0 || i == d.first-1) cout << '#';
                else if(k == 0 || k == d.second-1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

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

    int sum = 0;
    if(a < b){
        sum += a; 
    } else {
        sum += b;
    }

    if(c < d){
        sum += c;
    } else {
        sum += d;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
# abc088_b.py
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
alice = []
bob = []
for i,v in enumerate(A):
    if i%2==0:
        alice.append(v)
    else:
        bob.append(v)
print(sum(alice)-sum(bob))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int n,m;
  cin >> n >> m;
  map<ll,ll,greater<ll>>mp;
  rep(i,n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  rep(i,m){
    ll b,c;
    cin >> b >> c;
    mp[c]+=b;
  }
  ll ans = 0;
  ll sum = 0;
  for(auto p:mp){
    ll f=p.first;
    ll s=p.second;
    ll num = min(n-sum,s);
    ans+=f*num;
    sum+=min(n-sum,s);
    if(sum==n)break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
N,M = map(int,input().split())
KS = [list(map(int,input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  switch_pattern = bin(i)[2:].zfill(N)
  succes = 1
  for j in range(M):
    switch_on = 0
    for k in KS[j]:
      if switch_pattern[k-1] == '1':
        switch_on += 1
    if switch_on % 2 != P[j]:
      succes = 0
      break
  if succes == 1:
      ans += 1
print(ans)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500 + b*100 + c*50 == X:
                count += 1
print(count)


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

#define i64 long long int
#define ran 202202

int n;
int a[ran];
i64 f[ran][3];

void upd(i64 &a, i64 b) {
	if(a<b) a = b;
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++)
		scanf("%d", &a[i]);
	
	int emp = 1+n%2;
	for(int i=0;i<=3;i++)
		for(int j=0;j<=emp;j++)
			f[i][j] = -1e18;
	f[0][0] = 0;
	f[1][0] = a[1];
	f[2][1] = a[2];
	f[3][0] = f[1][0] + a[3];
	f[3][2] = a[3];
	for(int i=4;i<=n;i++) {
		for(int j=0;j<=emp;j++) {
			f[i][j] = -1e18;
			if(f[i-2][j]>-1e18)
				upd(f[i][j], f[i-2][j] + a[i]);
			if(j>=1 && i>3 && f[i-3][j-1]>-1e18)
				upd(f[i][j], f[i-3][j-1] + a[i]);
			if(emp>1 && j==2 && i>4 && f[i-4][j-2]>-1e18)
				upd(f[i][j], f[i-4][j-1] + a[i]);
			
			//printf("%d %d %lld\n", i, j, f[i][j]);
		}
	}

	i64 ans = -1e18;
	for(int i=0;i<=emp;i++)
		ans = max(ans, f[n-i][emp-i]);
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    N %= 10;
    if (N == 3)
        cout << "bon";
    else if (N == 0 || N == 1 || N == 6 || N == 8)
        cout << "pon";
    else
        cout << "hon";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3648
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.clear();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut v: Vec<u32> = s.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    v.sort();
    let s = (v[0] + v[1]) as f64 * 0.5;
    let ans = v[2..].iter().fold(s, |s, x| (s + *x as f64) * 0.5);
    println!("{:.6}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<pair<int, int>> as(n);
	vector<int> a(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		as[i].ff = a[i];
		as[i].ss = i;
	}
	RSRT(as);
	for(int i = 0; i < n; ++i) cout << as[(as[0].ss == i)].ff << '\n';
}

Measured memory_bytes: 5540
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    int n;  cin>>n;
    vector<int> num(n);
    int num1;
    rep(i,n) cin>>num[i];
    rep(i,n){
        cout<<num[n-1-i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
}


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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<int> A;
    int now = S[0], cnt = 0;
    if (now == '0') A.emplace_back(0);
    for (int i = 0; i < N; i++) {
        if (S[i] == now) {
            cnt++;
        } else {
            now = S[i];
            A.push_back(cnt);
            cnt = 1;
        }
    }
    A.push_back(cnt);
    if (S[N-1] == '0') A.emplace_back(0);
    int n = A.size();
    vector<int> sum(n+1, 0);
    for (int i = 0; i < n; i++) sum[i+1] = sum[i] + A[i];
    int ans = 0;
    int k = K * 2 + 1;
    for (int i = k; i <= n; i+= 2) {
        int res = sum[i]-sum[i-k];
        //cout << i << " " << res << endl;
        ans = max(res, ans);
    }
    if (n < k) ans = sum[n];
    cout << ans << endl;
    
    //for (auto a : A) cout << a << " "; cout << endl;
    //for (auto a : sum) cout << a << " ";
    return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
using namespace std;
 
int main () {
  int n, m;
  cin >> n >> m;
  int ac[n] = {0};
  int wa[n] = {0};
  int p;
  string s;
  int ca = 0;
  int cw = 0;
  for (int i = 0; i < m; i++){
    cin >>p >> s;
    if (s == "AC" && ac[p-1]==0){
      ac[p-1]++;
      ca++;
      cw = cw + wa[p-1];
    }
    if (s == "WA" && ac[p-1]==0){
      wa[p-1]++;
    }
  }
  cout << ca << " " << cw;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
const int N=15;
int dp[15][15],f[N],k;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>k;
    for(int i=0;i<=9;i++) dp[1][i]=1;
    f[1]=9;
    for(int i=2;i<=10;i++)
    {
        for(int j=0;j<=9;j++)
        {
            dp[i][j]+=dp[i-1][j+1];
            dp[i][j]+=dp[i-1][j];
            if(j) dp[i][j]+=dp[i-1][j-1];
            if(j) f[i]+=dp[i][j];
        }
    }
    int cur=0,num;
    for(int i=1;i<=10;i++)
    {
        cur+=f[i];
        if(cur>=k)
        {
            k-=(cur-f[i]);
            num=i;
            break;
        }
    }
    string res;
    int pre;
    for(int i=1;i<=num;i++)
    {
        int l=pre-1,r=pre+1;
        if(i==1) l=1,r=9;
        int cur=0;
        for(int j=max(l,0ll);j<=r;j++)
        {
            if(k<=cur+dp[num-i+1][j])
            {
                res+=('0'+j);
                pre=j;
                break;
            }
            cur+=dp[num-i+1][j];
        }
        k-=cur;
    }
    cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};

int main(){
    int N, M; cin >> N >> M;
    vector<int> p(N+1,0);
    for(int i=1; i<=N; i++) cin >> p[i];
    
    UnionFind uni(N+1);
    for(int i=0; i<M; i++){
        int x, y; cin >> x >> y;
        uni.connect(p[x], p[y]);
    }

    int ans = 0;
    for(int i=1; i<=N; i++) if(uni.root(p[i]) == uni.root(i)) ans++;
    cout << ans << endl;

}


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

#define P pair<int, int>
#define PP pair<P, int>
#define tPP pair<int, P>
#define mp make_pair
#define pb push_back
#define fn fill_n
#define llong long long 

using namespace std;

vector<string> s[5];

string in;

unsigned llong int ncr(int n, int r){
	unsigned llong int ans = 1;
	for(int i = 0; i < r; i++){
		ans *= n - i;
	}
	for(int i = 1; i <= r; i++){
		ans /= i;
	}

	return ans;
}

int main(){
	unsigned llong int ans = 0;
	int n;
	cin >> n;
	string in;
	for(int i = 0; i < n; i++){
		cin >> in;
		char c = in[0];
		if(c == 'M') s[0].pb(in);
		else if(c == 'A') s[1].pb(in);
		else if(c == 'R') s[2].pb(in);
		else if(c == 'C') s[3].pb(in);
		else if(c == 'H') s[4].pb(in); 
	}

	for(int i = 0; i < 3; i++){
		for(int j = i + 1; j < 4; j++){
			for(int k = j + 1; k < 5; k++){
				ans += s[i].size() * s[j].size() * s[k].size();
			}
		}
	}

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

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

int main(){
    ll n;
    scanf("%lld",&n);
    ll sum=0;
    for(ll i=1;i<=n;i++){
        sum+=n/i;
        if(n%i==0) sum--;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B;
  cin>>A>>B;
  int ans=A-1;
  if(A<=B)
    ans++;
  cout<<ans;
  }


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

using namespace std;


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


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

    int counter = 0;
    while(true) {
        bool breakFlug = false;

        bool isEvenAll = true;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 == 0) {
                A[i] = A[i] / 2;
            } else {
                isEvenAll = false;
            }
        }

        if (isEvenAll) {
            ++counter;
        } else {
            break;
        }
    }
    cout << counter << endl;
}


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

using namespace std;


int main(void){

    long long n;
    cin >> n;

    vector<string> s_i(n);
    for(int i=0; i<n; i++) {
        cin >> s_i[i];
    }

    vector<int> alpha_count;
    for(char c='a'; c<='z'; c++) {
        int min = 100;
        for(int i=0; i<s_i.size(); i++) {
            size_t count = std::count(s_i[i].begin(), s_i[i].end(), c);
//              cout << i << " " << c << " " << count << endl;
            if((int)count == 0) min = -1;
            if(min > (int)count) min = (int)count;
        }
//        cout << min << endl;
        alpha_count.push_back(min);
    }


    for(char c='a'; c<='z'; c++) {
        if(alpha_count[c-'a'] != 100) {
            for(int i=0; i<alpha_count[c-'a']; i++) {
                cout << c;
            }
        }
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
mons = [int(i) for i in input().split()]
yusya = [int(i) for i in input().split()]
sum = 0
for i in range(n + 1):
    if i >= 1:
        if yusya[i - 1] < mons[i]:
            mons[i] -= yusya[i - 1]
            sum += yusya[i - 1]
            yusya[i - 1] = 0
        else:
            yusya[i - 1] -= mons[i]
            sum += mons[i]
            mons[i] = 0
    if i < n:
        if yusya[i] < mons[i]:
            mons[i] -= yusya[i]
            sum += yusya[i]
            yusya[i] = 0
        else:
            yusya[i] -= mons[i]
            sum += mons[i]
            mons[i] = 0

print(sum)


Measured memory_bytes: 19648
using System;

class Program
{
    static void Main(string[] args)
    {
        var abx = Console.ReadLine().Split(' ');
        var x = int.Parse(abx[0]);
        var a = int.Parse(abx[1]);
        var b = int.Parse(abx[2]);

        if (b <= a)
        {
            Console.WriteLine("delicious");
        }
        else if (b <= a + x)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("dangerous");
        }
    }
}


Measured memory_bytes: 11092
#include <vector>
#include <iostream>

using namespace std;

int N, K;
vector<int> stones, dp;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> K;
	stones.assign(N, 0);
	
	for (int i =0 ; i < N; i++){
		cin >> stones[i];
	}

	dp.assign(K+1, 0);

	for(int i = 1; i <= K; i++){
		int canWin = 1;
		for(int x : stones){
			canWin &= (i-x < 0? 1 : dp[i-x]);
		}
		dp[i] = 1 - canWin;
	}

	// for(int x : dp) cout << x << " "; cout << endl;

	cout << (dp[K] == 1? "First" : "Second") << endl;

	return 0;
}

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

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

  int n, a[100100], b;
  cin >> n;
  for (int i = 0; i <= n; i++)
    cin >> a[i];

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> b;
    int kill = min(a[i], b);
    b -= kill;
    ans += kill;
    kill = min(a[i + 1], b);
    a[i + 1] -= kill;
    ans += kill;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int n, s, b[105];

int f(int p) {
	int i, d;
	for(i=d=0; i<n; i++) d += (b[i]-p) * (b[i]-p);
	return d;
}

int main() {
	cin>>n;
	for(int i=0; i<n; i++) cin>>b[i], s += b[i];
	cout<<min(f(s/n), f(s/n+1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> v(3);
    for (int i = 0; i < 3; i++) cin >> v[i];
    int k;
    cin >> k;
    for (int i = 0; i < 2; i++) {
        while (k > 0 && v[i] >= v[i+1]) {
            v[i+1] *= 2;
            k--;
        }
    }
    if (v[0] < v[1] && v[1] < v[2]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3628
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let s: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = {
        let mut T = std::collections::HashSet::new();
        let mut a = s;
        let mut m = 1;
        while !T.contains(&a) {
            T.insert(a);
            a = if a % 2 == 0 {
                a / 2
            } else {
                3 * a + 1
            };
            m += 1;
        }
        m
    };

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  vector<pair<ll, ll>> C(N);
  vector<pair<ll, ll>> D(N);
  rep(i, N){
    cin >> A.at(i) >> B.at(i);
  }
  sort(all(A));
  sort(all(B));
  if(N % 2 == 1){
    cout << B.at((N-1)/2) - A.at((N-1)/2) + 1 << endl;
  }
  else{
    cout << (B.at(N/2-1) + B.at(N/2)) - (A.at(N/2-1) + A.at(N/2)) + 1 << endl;
  }
}


Measured memory_bytes: 12692
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    string s;
    cin >> s;
    if (s.find('7') != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 998244353;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n>>k;
    vector<pair<ll,ll>> v;
    
    rep(i,k){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    //sort(ALL(v));
    //v.erase(unique(v.begin(), v.end()), v.end());
    //debug(v);
    vector<ll> dp(n,0);
    vector<ll> sum(n+1,0);
    dp[0]=1;
    sum[1]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<k;j++){
            int r=v[j].second;
            int l=v[j].first;
            int kk=max(i-l+1,0);
            int rr=max(0,i-r);
            ll temp=sum[kk];
            ll temp1=sum[rr];
            //cout<<kk<<" "<<rr<<" "<<i<<"\n";
            //cout<<l<<" "<<r<<" "<<temp<<" "<<temp1<<"\n";
            dp[i]+=temp-temp1;
            dp[i]=(dp[i]+MOD)%MOD;
        }
        sum[i+1]=dp[i]+sum[i];
        sum[i+1]%=MOD;
    }
    cout<<dp[n-1]<<"\n";
    //debug(dp);
    //debug(sum);
}

Measured memory_bytes: 6364