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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

//return x^y mod p
ll power(ll x,ll y, ll p)
{
    if (y < 0) return 0;
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s; cin>>s; int n = s.size();
    ll res = 0, acnt = 0, ccnt = 0, qcnt = 0, qtot = 0;
    FOR(i, 0, n) {
        ccnt += (s[i] == 'C');
        qtot += s[i] == '?';
    }
    FOR(i, 0, n) {
        if (s[i] == 'B' || s[i] == '?') {
            ll tota = (acnt * power(3, qcnt, MOD))%MOD + (qcnt * power(3, qcnt - 1, MOD))%MOD;
            ll rqcnt = qtot - qcnt - (s[i] == '?');
            ll totc = (ccnt * power(3, rqcnt, MOD))%MOD + (rqcnt * power(3, rqcnt - 1, MOD))%MOD;
            res += (tota * 1LL * totc) % MOD;
            res %= MOD;
        }
        acnt += s[i] == 'A';
        ccnt -= s[i] == 'C';
        qcnt += s[i] == '?';
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3748
English_sentence=''
try:
    while True:
        line=input()
        if line=='':
            break
        English_sentence+=line
except EOFError:
	pass
lowercase=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
uppercase=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
number=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for _ in range(26):
    for _2 in English_sentence:
        if _2==lowercase[_] or _2==uppercase[_]:
            number[_]+=1
for ans in range(26):
    print("{0} : {1}".format(lowercase[ans],number[ans]))


Measured memory_bytes: 5568
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){
    bitset<1000007> bs;
    bitset<1000007> ans;
    for(int i = 0; i < n; ++i){
        if(bs[a[i]]){
            ans.set(a[i]);
            continue;
        }
        bs.set(a[i]);
        for(int j = 2 * a[i]; j < 1000007; j += a[i])
            ans.set(j);
    }
    int sum = 0;
    for(int i = 0; i < n; ++i)
        sum += (ans[a[i]] == false);
    cout << sum << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 5108
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n,i,j,T,c[110],t[110],tm[110],cost[110],k=0;
  scanf("%d%d",&n,&T);
  for(i=0;i<n;i++){
    scanf("%d %d",&c[i],&t[i]);
    if(t[i]<=T) {tm[k]=t[i];cost[k]=c[i];k++;}
  }
  if(tm[0]=='\0') {printf("TLE");return 0;}
  int min=cost[0];
  for(i=1;i<k;i++){
    if(min>cost[i]) min=cost[i];
  }
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int nums[3];
    scanf("%d%d%d",&nums[0],&nums[1],&nums[2]);
    int min = nums[0] + nums[1];
    {
        int tmp;
        tmp = nums[0] + nums[2];
        if(min>tmp){min = tmp;}
        tmp = nums[1] + nums[2];
        if(min>tmp){min = tmp;}
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
sx,sy,tx,ty=map(int,input().split())
print('D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'*(tx-sx+1)+'D'*(ty-sy)+'R'*(tx-sx)+'U'*(ty-sy+1)+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R')

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int
main()
{
    long long n, m;
    cin >> n >> m;
    if (n == 1) {
        if (m == 1)
            cout << 1 << endl;
        else
            cout << m - 2 << endl;
    } else {
        if (m == 1)
            cout << n - 2 << endl;
        else
            cout << n * m - (n + m - 2) * 2 << endl;
    }
}


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

const int maxn = 5500;
ll dp[maxn][maxn];
int n, A, B, p[maxn], f[maxn];
// A: right, B: left

void upd(ll& x, ll y) { x = min(x, y); }
int main() {
    memset(dp, 0x3f, sizeof dp);
    scanf("%d%d%d", &n, &A, &B);
    rep(i, n) scanf("%d", &p[i]), f[p[i]] = i;
    
    memset(dp[0], 0, sizeof(dp[0]));
    for(int i = 0; i < n; ++i) {    
        for(int j = 1; j <= n; ++j) dp[i][j] = min(dp[i][j-1], dp[i][j]);
        for(int j = 1; j <= n; ++j) { // [0, j)
            if(j == f[i+1]) upd(dp[i+1][j], dp[i][j]);
            else if(j > f[i+1]) upd(dp[i+1][j], dp[i][j] + A);
            else if(j < f[i+1]) upd(dp[i+1][j], dp[i][j] + B);
        }
    }
    for(int i = 1; i <= n; ++i) dp[n][i] = min(dp[n][i-1], dp[n][i]);
    printf("%lld\n", dp[n][n]);

    return 0;
}

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

int main() {
	int a;
  	cin >> a;
  	map<string,int> mp;
	for (int i=0;i<a;i++) {
    	string s;
      	cin >> s;
      	mp[s] = 0;
    }
  	cout << mp.size() << endl;
  	
  	
}

Measured memory_bytes: 19160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))

typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
#define int long long

inline void solve(){

    int n, k;
    cin >>n >> k;
    int tmp = 0;
    if(!k){
        cout << n * n fin;
        return ;
    }
    for(int i = k+1; i <= n; i++) {
        tmp += (i - k)*(n/i);
        tmp += fmax(0,n%i-k+1);
    }

    cout << tmp fin;
}

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



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

int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  
  sort(a.begin(),a.end());
  cout<<a.at(1)+a.at(0);
}

Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	string ans="";

	while(n)
	{
		int k=n/26;
		int rem=n%26;

		if(rem==0)
		{
			k--;
			ans=(char)('z')+ans;
		}
		else
		{
			ans=(char)('a'+rem-1)+ans;
		}
		n=k;
	}

	cout<<ans<<endl;

}

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

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

using pii = pair<int,int>;

vector<pii> dtile;
int minc[20][20];
int tile[30][30];


int stile[30][30];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int search(pii from,pii to){
  REP(i,30)REP(j,30){
    stile[i][j] = 0;
  }
  stile[from.first][from.second] = -1;
  queue<pii> que;
  que.push(from);
  while(que.size()){
    auto now = que.front();
    que.pop();
    REP(i,4){
      auto nh = now.first + dy[i];
      auto nw = now.second + dx[i];
      if(nh == to.first && nw == to.second){
        return max(1,stile[now.first][now.second]+1);
      }
      if(tile[nh][nw]>=0&&nh>=0&&nw>=0&&stile[nh][nw]==0){
        que.push({nh,nw});
        stile[nh][nw] = max(1,stile[now.first][now.second]+1);
      }
    }
  }
  return INT_MIN/20;
}


int main()
{
  int h,w;
  while(cin >> w >> h,w+h){
    REP(i,30)REP(j,30){
      if(i==h){
        tile[i][j] = -1;
      }else if(j == w){
        tile[i][j] = -1;
      }else{
        tile[i][j] = 0;
      }
    }
    pii s;
    dtile.clear();
    REP(i,h)REP(j,w){
      char c;
      cin >> c;
      if(c == 'o'){
        s.first = i;
        s.second = j;
      }else if(c == 'x'){
        tile[i][j] = -1;
      }else if(c =='*'){
        tile[i][j] = 1;
        dtile.push_back({i,j});
      }
    }
    int dn = dtile.size();
    REP(i,dn)REP(j,i){
      minc[i][j] = minc[j][i] = search(dtile[i],dtile[j]);
    }
    int ans = INT_MAX;
    vector<int> tod(dn);
    vector<int> index(dn);
    REP(i,dn){
      index[i]=i;
    }
    REP(i,dn){
      tod[i] = search(s,dtile[i]);
    }

    do{
      int temp = 0;
      temp += tod[index[0]];
      REP(i,dn-1){
        temp += minc[index[i]][index[i+1]];
      }
      ans = max(-1,min(ans,temp));
    }while(next_permutation(index.begin(),index.end()));
    cout << ans <<endl;
  }

}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a<b){
		cout << "a < b" << endl;
	}else if(a>b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	// your code goes here
	ll n, ans=0;
	cin >> n;
	string str;
	cin >> str;
	vector<ll> r, g;
	unordered_set<ll> b;
	for(ll i=0; i<n; i++){
		if(str[i]=='R')
			r.push_back(i);
		else if(str[i]=='G')
			g.push_back(i);
		else
			b.insert(i);
	}
	for(ll i=0; i<r.size(); i++){
		for(ll j=0; j<g.size(); j++){
			ll mi_idx=min(r[i], g[j]), ma_idx=max(r[i], g[j]);
			ans+=b.size();
			if(((ll)2*ma_idx)-mi_idx<n && b.find(((ll)2*ma_idx)-mi_idx)!=b.end())
				ans--;
			if(((ll)2*mi_idx)-ma_idx>=0 && b.find(((ll)2*mi_idx)-ma_idx)!=b.end())
				ans--;
			if((mi_idx+ma_idx)%2==0 && b.find((mi_idx+ma_idx)/2)!=b.end())
				ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

int to[200000];

int main() {

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		if (i == 0) continue;

		if (a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
			
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  
  for( int i = 0; i < M; i++ ){
    cin >> a.at(i) >> b.at(i);
  }
  
  vector<int> ans(N+1);
  for( int i = 0; i < M; i++ ){
    for( int j = 1; j < N+1; j++ ){
      if( a.at(i) == j || b.at(i) == j ){
        ans.at(j)++;
      }
    }
  }
  
  for( int i = 1; i < N+1; i++ ){
    cout << ans.at(i) << endl;
  }
}


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

using namespace std;

int main() {
    int now = 0;
    int next = 0;
    vector<string> s(3);

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

    while (!s[now].empty()) {
        next = s[now][0] -'a';
        s[now].erase(s[now].begin());
        now = next;
    }

    if(now==0) {
        cout << 'A' << endl;
    } else if(now==1) {
        cout << 'B' << endl;
    } else if(now==2) {
        cout << 'C' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
rgb_idx = {
    'R': [],
    'G': [],
    'B': [],
}
for i in range(n):
    if s[i] == 'R':
        rgb_idx['R'].append(i)
    elif s[i] == 'G':
        rgb_idx['G'].append(i)
    else:
        rgb_idx['B'].append(i)

for i in range(len(rgb_idx['R'])):
    for j in range(len(rgb_idx['G'])):
        ans += len(rgb_idx['B'])
        
        rnum = rgb_idx['R'][i]
        gnum = rgb_idx['G'][j]
        if gnum-rnum>0:
            g = gnum
            l = rnum
        else:
            g = rnum
            l = gnum
        dist = abs(gnum-rnum)
        if n > g+dist and s[g+dist]=='B':
            ans -= 1
        if 0 <= l-dist and s[l-dist]=='B':
            ans -= 1
        if (g+l)%2==0 and s[int((g+l)/2)]=='B':
            ans -= 1

print(ans)


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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int X;
    cin >> X;
    sum+=2*min(X,K-X);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	s = "0" + s;
	int n = s.size(), ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] <= '4' or (s[i] == '5' and s[i - 1] < '5'))
			ans += s[i] - '0';
		else {
			s[i - 1]++;
			ans += ('9' - s[i]) + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2308
#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() {
  vector<int> a(5); rep(i, 5) cin >> a[i];
  int k; cin >> k;
  bool f = true;
  rep(i, 5) {
    for (int j = i+1; j < 5; j++) {
      if (k < abs(a[i] - a[j])) f = false;
    }
  }
  puts(f ? "Yay!" : ":(");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int hp[100];
int mp[100];
string target[100];
int damage[100];
ll dp1[2][100010], dp2[2][100010];

int main(){
  int n, m;
  while(cin >> n, n){
    for(int i = 0; i < n; i++) cin >> hp[i];
    
    cin >> m;
    for(int i = 0; i < m; i++){
      string s;
      cin >> s >> mp[i] >> target[i] >> damage[i];
      //cout << s <<" " <<mp[i]<<" " << target[i]<<" " << damage[i] <<endl;
    }
    
    memset(dp1, 0, sizeof dp1);
    memset(dp2, 0, sizeof dp2);
    for(int i = 1; i <= 100000; i++){
      dp1[0][i] = dp2[0][i] = 1 << 30;
    }
    for(int i = 1; i <= m; i++){
      for(int j = 0; j <= 100000; j++){
        if(damage[i-1] == 0){
          dp1[i%2][j] = dp1[(i-1)%2][j];
          dp2[i%2][j] = dp2[(i-1)%2][j];
        }
        else if(target[i-1] == "All"){
            dp1[i%2][j] = min(dp1[(i-1)%2][j], dp1[i%2][max(0,j - damage[i-1])] + mp[i-1]);
            dp2[i%2][j] = dp2[(i-1)%2][j];          
        }
        else{
            dp2[i%2][j] = min(dp2[(i-1)%2][j], dp2[i%2][max(0,j - damage[i-1])] + mp[i-1]);
            dp1[i%2][j] = dp1[(i-1)%2][j];
        }
      }
    }
    
    
    ll ans = 1LL << 50;
    for(int i = 0; i <= 100000; i++){
      ll sum = dp1[m%2][i];
      //cout << i << " " << dp1[n][i] << endl;
      for(int j = 0; j < n; j++){
        if(hp[j] - i <= 0) continue;
        sum += dp2[m%2][hp[j] - i];
      }
      //cout << i << " " << sum <<endl;
      ans = min(ans, sum);
    }
    
    cout << ans <<endl;
  }
}

Measured memory_bytes: 6168
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	char ss[10];
	scanf("%s",ss);
	if (ss[0]=='S') puts("Cloudy");
	else if (ss[0]=='C') puts("Rainy");
	else puts("Sunny");
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
N = int(input())
X = input()
zero_pop = X.count('1') + 1
one_pop = X.count('1') - 1
one_mod, zero_mod = 0, 0

for b in X:
    if one_pop != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop

pop = {0:0}
def popcount(n):
    if n in pop:
        return pop[n]
    pop[n] = popcount(n // 2) + n % 2
    return pop[n]
memo = {0:0}
def f_count(n):
    if n in memo:
        return memo[n]
    memo[n] = f_count(n % popcount(n)) + 1
    return memo[n]
one_p = {0:1}
def one_pow(n):
    if n in one_p:
        return one_p[n]
    one_p[n] = one_pow(n - 1) * 2 % one_pop
    return one_p[n]
zero_p = {0:1}
def zero_pow(n):
    if n in zero_p:
        return zero_p[n]
    zero_p[n] = zero_pow(n - 1) * 2 % zero_pop
    return zero_p[n]
for i in range(N):
    if X[i] == '1' and one_pop == 0:
        print(0)
        continue
    if X[i] == '1':
        x = one_mod
        x -= one_pow(N-1-i)
        x %= one_pop
    elif X[i] == '0':
        x = zero_mod
        x += zero_pow(N-1-i)
        x %= zero_pop
    
    print(f_count(x) + 1)

Measured memory_bytes: 216176
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,mod,f[N][N],coef[N];

void inc(int &a,int b) {
	a=a+b>=mod?a+b-mod:a+b;
}

int main() {
	cin>>n>>mod;f[0][0]=1;
	for(int i=2,j=0;i<=n/2+1;i++,j++) coef[i-1]=j+1;
	for(int i=n,j=1;i>=n/2+2;i--,j++) coef[i-1]=j+1;
	for(int i=0;i<n-1;i++)
		for(int j=0;j<n;j++)
			for(int k=0;coef[i+1]*k+j<n;k++) inc(f[i+1][coef[i+1]*k+j],f[i][j]);
	int ans=0;
	for(int i=0;i<n;i++) inc(ans,1ll*(n-i)*f[n-1][i]%mod);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 98048
#include<bits/stdc++.h>
    # define loop(i,a,n) for(int i=a;i<n;++i)
    # define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
    # define ll long long int 
    using namespace std;
    int main()
    {
        fast
        string s,t;
        cin>>s>>t;
        int count=0;
        for(int i=0;i<s.length();i++)
        {
            if(s[i]!=t[i])
            {
                count++;
                break;
            }
        }
        if(count>0)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
        
        return 0;
    }

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    bool f=1;
    int i=0;
    string e="erase";
    string d="dream";
    while(i<n)
    {
        if(n-i<5)
        {
           f=0;
            break; 
        }
        if(s[i]=='e')
        {
            int x=i;
            for(int j=0;j<5;j++)
                if(e[j]!=s[x+j])
                {
                    f=0;
                    //cout<<"c1\n";
                    break;
                }
            i+=5;
            if(n-i>0&&s[i]=='r')
                i+=1;

            
        }
        else if(s[i]=='d')
        {
            int x=i;
            for(int j=0;j<5;j++)
                if(d[j]!=s[x+j])
                {
                    f=0;
                    //cout<<"c2\n";
                    break;
                }
            i+=5;
            if(n-i>1&&s[i]=='e'&&s[i+1]=='r'&&s[i+2]!='a')
                i+=2;
        }
        else
        {
            f=0;
            //cout<<"c3\n";
            break;
        }
        //cout<<i<<endl;
    }
    if(!f)
        cout<<"NO\n";
    else
        cout<<"YES\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#define endl '\n'
#define ll long long
#define NCONS 16001

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 0)
        cout << "Even";
    else
        cout << "Odd";
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>hau(n);
    for(int i=0;i<n;i++){
        cin>>hau.at(i);
    }
    sort(hau.begin(),hau.end());
    cout<<hau.at(n-1)-hau.at(0)<<endl;
}

Measured memory_bytes: 256
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap

  # def push(x)
  #   i = @node_num # 自分のノード番号
  #   @node_num += 1
  #   while i > 0
  #     par = (i - 1) / 2 # 親のノード番号
  #     break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
  #     # 親ノードを下ろして自分を上に
  #     @heap[i] = @heap[par]
  #     i = par
  #   end
  #   @heap[i] = x
  # end
  def push(x)
    i = @node_num
    @node_num += 1
    while i > 0
      p = (i - 1) / 2
      break if @comp.call(@heap[p], x)

      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    ret = @heap[0]
    @node_num -= 1
    x = @heap[@node_num]
    i = 0
    while i * 2 + 1 < @node_num
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])

      break if !@comp.call(@heap[a], x)

      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m,c;
  cin>>n>>m>>c;
  vi b(m);
  rep(i,m){
    cin>>b[i];
  }

  int ans=0;
  rep(i,n){
    int s=c;
    rep(j,m){
      int a;
      cin>>a;
      s+=a*b[j];
    }
    ans+=(s>0);
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a*b)%2 && (c+d)%2)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3080
#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)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  string s, t;
  cin >> s >> t;
  bool result = true;
  rep(i, (int)s.size()) {
    if (s.at(i) != t.at(i)) {
      result = false;
    }
  }
  if (s.size() + 1 != t.size()) {
    result = false;
  }
  if (result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

R,G,B,N=get_i
ans=0
(N/R+1).times do|r|
  (N/G+1).times do|g|
      next if r*R+g*G>N
      if ((N-(r*R+g*G))%B).zero?
          ans+=1
      end
  end
end
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int w, h, n;
    cin >> w >> h >> n;
    int ans = w * h;
    int x1 = 0, y1 = 0, x2 = w, y2 = h;
    forn(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            x1 = max(x1, x);
        }
        if (a == 2) {
            x2 = min(x2, x);
        }
        if (a == 3) {
            y1 = max(y1, y);
        }
        if (a == 4) {
            y2 = min(y2, y);
        }
    }
    cout << max(0, (x2 - x1)) * max(0, (y2 - y1)) << endl;
    return 0;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

using ll = long long;
using dbl = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    srand(time(0));
    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int DEBUG = 0;

const int maxs = 1e6 + 55;
const int maxn = 2e5 + 55;
const int inf = 1e9;
const int K = 26;

int n;
string s[maxn];
int pos[maxn][K];
ll ans;
int cnt[K];

void solve(const vector <int>& ids, int x) {
    if (ids.size() <= 1)
        return;
    memset(cnt, 0, sizeof cnt);
    for (int id : ids) {
        for (int j = 0; j < K; ++j) {
            if (pos[id][j] <= (int)s[id].size() - x) {
                ++cnt[j];
            }
        }
    }
    for (int id : ids) {
        if (x == (int)s[id].size()) {
            ans += cnt[s[id][(int)s[id].size() - x] - 'a'] - 1;
        }
    }
    vector <int> to_ids;
    for (int j = 0; j < K; ++j) {
        to_ids.clear();
        for (int id : ids) {
            if (x < (int)s[id].size() && (s[id][(int)s[id].size() - x] - 'a') == j) {
                to_ids.push_back(id);
            }
        }
        solve(to_ids, x + 1);
    }
}

void solve(bool __attribute__((unused)) read) {
    if (DEBUG) {
        n = 2;
    } else {
        cin >> n;
    }
    vector <int> vec;
    for (int i = 0; i < n; ++i) {
        vec.push_back(i);
        if (DEBUG) {
            s[i] = "";
            for (int j = 0; j < (int)5e5; ++j) {
                s[i] += 'a';
            }
        } else {
            cin >> s[i];
        }
        for (int j = 0; j < K; ++j) {
            pos[i][j] = inf;
        }
        for (int j = 0; j < (int)s[i].size(); ++j) {
            if (pos[i][s[i][j] - 'a'] == inf) {
                pos[i][s[i][j] - 'a'] = j;
            }
        }
    }
    ans = 0;
    solve(vec, 1);
    cout << ans << endl;
}


Measured memory_bytes: 32452
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;

void Xx_main_xX(const vector<char*> &args)
{
  int d;
  cin >> d;

  if (d == 25) {
    outl("Christmas");
  }
  if (d == 24) {
    outl("Christmas Eve");
  }
  if (d == 23) {
    outl("Christmas Eve Eve");
  }
  if (d == 22) {
    outl("Christmas Eve Eve Eve");
  }

}

} // {{{
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
  ios::sync_with_stdio(false); cin.tie(nullptr);
#endif
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {
  vector<int> num(5);
  for (int i = 0; i < 5; i++) cin >> num[i];
  int res = 0;
  int minus = -1;
  for (int i = 0; i < 5; i++) {
    if (num[i] % 10 != 0) {
      int tmp = ((num[i] / 10) + 1) * 10;
      minus = max(tmp - num[i], minus);
      res += tmp;
    } else {
      res += num[i];
    }
  }

  if (minus > 0) res -= minus;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
                if(a <=x && x <= (a+b)){
                    System.out.println("YES");
                }else{
                    System.out.println("NO");
                }
	}
}

Measured memory_bytes: 22996
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] c=new int[n];
		int m=0;
		for(int i=0;i<n;++i){
			int v=s.nextInt();
			if(i==0^v==0){
				System.out.println(0);
				return;
			}
			m=Math.max(m,v);
			++c[v];
		}

		System.err.println(Arrays.toString(c));

		long r=1,mod=998244353;
		for(int i=1;i<=m;++i){
			for(int j=0;j<c[i];++j){
				r*=c[i-1];
				r%=mod;
			}
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 51024
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    
    

    int A, B, M;
    cin >> A >> B >> M;

    V<int> a(A + 1), b(B + 1);

    int _minA = 1e9;
    rep (i, A) {
        cin >> a[i + 1];
        chmin(_minA, a[i + 1]);
    }
    int _minB = 1e9 + 7;
    rep (i, B) {
        cin >> b[i + 1];
        chmin(_minB, b[i + 1]);
    }

    int ans = 1e9 + 7;

    rep (i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        chmin(ans, a[x] + b[y] - c);
    }

    chmin(ans, _minB + _minA);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
  string s; cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
ll i,o,t,j,l,s,z;
int main()
{
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll r=0;
	for(ll g=0;g<=1;++g)
		if(i>=g&&j>=g&&l>=g)
			r=max(r,o+g*3+(i-g)/2*2+(j-g)/2*2+(l-g)/2*2);
	cout<<r<<"\n";
}


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

using namespace std;

const int MAX_N = 3e5 + 10;

int N, A[MAX_N];

bool check(int x) {
    int min_s = 0, s = 0;
    for (int i = 1; i < N; i += 2) {
        s += A[i];
        bool succ = s >= min_s + x;
        s -= A[i + 1];
        if (succ) min_s = min(min_s, s);
    }
    s += A[N];
    return s >= min_s + x;
}

int main() {
    scanf("%d", &N);
    int sum = 0;
    for (int i = 1; i <= N; i++) scanf("%d", &A[i]), sum += A[i];
    int ans = 0;
    if (N % 2 == 0) {
        for (int i = 1; i <= N; i += 2) ans += A[i];
        if (ans < sum - ans) ans = sum - ans;
    } else {
        for (int i = 1; i <= N; i += 2) ans += A[i];
        int base = 0;
        for (int i = 2; i <= N; i += 2) base += A[i];
        int l = 0, r = sum;
        while (l != r) {
            int m = (l + r) / 2;
            if (check(m + 1)) l = m + 1;
            else r = m;
        }
        ans = max(ans, base + l);
    }
    printf("%d %d\n", ans, sum - ans);
}


Measured memory_bytes: 1408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        string S = Console.ReadLine();
        Stack s = new Stack();
        for(int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'T')
            {
                if (s.Count == 0) {
                    s.Push('T');
                }
                else if ((char)s.Peek() == 'T')
                {
                    s.Push('T');
                }
                else
                {
                    s.Pop();
                }
            }
            else
            {
                s.Push('S');
            }
        }
        Console.WriteLine(s.Count);
    }

}

Measured memory_bytes: 15832
import copy
def solve():
    S_d = list(input())
    T = list(input())

    end = len(S_d) - 1
    first = end - len(T) + 1
    while first >= 0:
        t_i = 0 
        for s_i in range(first, end+1):
            if T[t_i] != S_d[s_i] and S_d[s_i] != '?':
                break
            t_i += 1
        else:
            break

        first -= 1
        end -= 1

    else:
        print('UNRESTORABLE')
        exit(0)
    
    ans = copy.deepcopy(S_d)
    t_i = 0
    for i in range(first, end+1):
        ans[i] = T[t_i]
        t_i += 1
    
    ans = ''.join(ans).replace('?','a')
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
<?php



fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%s",$S);

$count = 0;

for($i=0;$i<$N;$i++){
    if($S[$i] == 'A'){
        if($S[$i+1] == 'B'){
            if($S[$i+2] == 'C'){
                $count++;
            }
        }
    }
}

echo $count."\n";



Measured memory_bytes: 4604
#include <iostream>                                                       
                                                                          
int main(){                                                               
  int x,S;                                                                
                                                                          
  std::cin >> x;                                                          
  S = x*x*x;                                                              
  std::cout << S <<"\n";                                                  
                                                                          
  return 0;                                                               
} 

Measured memory_bytes: 3092
a = int(input())

s = input().split()

lis = [int(s[0]),int(s[a-2])]

for i in range(a-1)[1:]:
    inp = min(int(s[i]),int(s[i-1]))
    
    lis.append(inp)

count = 0
for p in lis:
    count += p
    
print(count)

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

a = int(input().rstrip())
c = list(map(int,input().split()))

ms = c[0]
ans = 0

for i in range(1, a):
  ans += max(0, ms-c[i])
  if c[i]>ms:
    ms = c[i]
    
print(ans)

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

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    
    //-----------------------------------
    int ans=0,max=0;
    rep(i,N) if(max<=A[i]){
        ans++;
        max=A[i];
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

LL sum[200010] ;
LL a[200010] ;

int main()
{
	int n ;
	scanf ("%d", &n) ;
	
	for (int i=0; i<n; i++)
		scanf ("%lld", a + i) ;
	
	sum[0] = a[0] ;
	for (int i=1; i<n; i++)
		sum[i] = (sum[i-1] + a[i]) % MOD ;
	
	LL ans = 0 ;
	for (int i=n-1; i>0; i--)
		ans = (a[i] * sum[i-1] % MOD + ans) % MOD ;
		
	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 6316
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int q;cin>>q;
    set<int> st;
    rep(i,0,q){
        int a,b;cin>>a>>b;
        if(a==0){
            st.insert(b);
            cout<<st.size()<<endl;
        }else if(a==1){
            cout<<((st.find(b)==st.end())?0:1)<<endl;
        }else if(a==2){
            st.erase(b);
        }else {
            int r;cin>>r;
            auto it=st.lower_bound(b);
            for(;it!=st.end()&&*it<=r;it++){
                cout<<*it<<endl;
            }
            
        }
    }
    
    
}



/*

*/



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

int main() {
  int N; cin >> N;
  vector<int> B(N-1); rep(i, N-1) cin >> B[i];
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(i == 0) ans += B[0];
    else if(i == N-1) ans += B[N-2];
    else ans += min(B[i-1],B[i]);
  }
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
#define fir first
#define sec second

ll q, h, s, d, n; 

int main() {
	cin>>q>>h>>s>>d>>n; 
	h = min(h, q*2); 
	s = min(s, h*2); 
	d = min(d, s*2); 
	cout<<n/2*d+n%2*s<<endl; 
	return 0;
}


Measured memory_bytes: 256