akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <list>
    #include <string>
    #include <numeric>
    #include <math.h>
    #include <set>
    #include <map>
    #include <fstream>
    #include <sstream>
    #include <iterator>
    #include <complex>
    using namespace std;
     
    int main()
    {
    	int N;
    	cin>>N;
    	vector<int> a(N+1);
    	vector<int> b(N);
     
    	for(int i=0; i<=N; i++)
    	{
    		cin>>a[i];
    	}
     
    	for(int i=0; i<N; i++)
    	{
    		cin>>b[i];
    	}
     
    	//貪欲法
    	long long count = 0;
    	for(int i=0; i<N; i++)
    	{
    		count += min(a[i]+a[i+1],b[i]);
    		a[i+1] = max(0, a[i+1]-max(0,b[i] - a[i]));
    	}
    	cout<<count<<endl;
    	return 0;
    }

Measured memory_bytes: 1024
using namespace std;
#define ll long long
#include<bits/stdc++.h>
int main()
{
		ll n;
		cin>>n;
		ll k;
		cin>>k;
		ll arr[n];
		for(ll i=0;i<n;i++)
		cin>>arr[i];
		ll dp[k+1];
		for(ll i=0;i<=k;i++)
		dp[i]=0;
		for(ll i=0;i<=k;i++)
		{
			for(ll j=0;j<n;j++)
			{	
				if(i-arr[j]>=0)
				{
					if(dp[i-arr[j]]==1)
					dp[i]=0;
					else
					{
						dp[i]=1;break;
					}
				}
			}
		}
	if(dp[k]==0)
	cout<<"Second"<<endl;
	else
	cout<<"First"<<endl;
		return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){return a=min(a,b);}
template<typename T> T chmax(T &a,T b){return a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}

int main(){
    ll h,w; cin >> h >> w;
    v<string> s(h+1,string(w+1,'.'));
    rep(i,h) cin >> s[i];
    auto dp = vv<>(h+1,v<>(w+1,INF));
    dp[0][0]=(s[0][0]=='#')?1:0;

    rep(i,h){
        rep(j,w){
            chmin(dp[i][j+1],dp[i][j]+((s[i][j]=='.'&&s[i][j+1]=='#')?1LL:0LL));
            chmin(dp[i+1][j],dp[i][j]+((s[i][j]=='.'&&s[i+1][j]=='#')?1LL:0LL));      	
        }
    }
  
    cout << dp[h-1][w-1];

    return 0;
}

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

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

int main(){
  int n; cin>>n;
  ll k; cin>>k;
  vector<ll> num(n);
  ll ans=0;
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  vector<ll> c(n,0);
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(num[i]<num[j]){
        c[i]++;
      }
    }
  }
  vector<ll> b(n);
  ll sum=(((k-1)*k)/2)%MOD;
  for(int i=0;i<n;i++){
    ll count=0;
    for(int j=0;j<n;j++){
      if(num[j]>num[i]){
        count++;
      }
    }
    b[i]=count;
  }
  
  for(int i=0;i<n;i++){
    ans+=b[i]*sum%MOD;
    ans+=k*c[i]%MOD;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef int64_t 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; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

int dp[101][4][4][4];

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

  int n;
  cin >> n;

  dp[0][3][3][3] = 1;

  // A: 0, G: 1, C: 2, T: 3
  rep(i, n) rep(c1, 4) rep(c2, 4) rep(c3, 4) rep(c, 4) {
    if (c2 == 0 && c3 == 1 && c == 2) continue;  // "AGC"
    if (c2 == 0 && c3 == 2 && c == 1) continue;  // "ACG"
    if (c2 == 1 && c3 == 0 && c == 2) continue;  // "GAC"
    if (c1 == 0 && c2 == 1 && c == 2) continue;  // "AG*C"
    if (c1 == 0 && c3 == 1 && c == 2) continue;  // "A*GC"
    dp[i+1][c2][c3][c] += dp[i][c1][c2][c3];
    dp[i+1][c2][c3][c] %= mod;
  }

  ll ans = 0;
  rep(c1, 4) rep(c2, 4) rep(c3, 4) {
    ans += dp[n][c1][c2][c3];
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,i;
	cin>>n>>i;
	cout<<n-i+1;
	return 0;
}

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

int main(){
	int H,W;
	cin >> H;
	cin >> W;
	char c[55][55];
	int cnt,i,j;
	cnt = 0;
	for( i=1; i <= H; ++i){
		for( j=1; j <= W; ++j){
			cin >> c[i][j];
		}
	}
	for( i=1; i <= H; ++i){
		for( j=1; j <= W; ++j){
			if(c[i][j]=='#' 
			&& c[i-1][j] != '#'
			&& c[i][j-1] != '#'
			&& c[i+1][j] != '#'
			&& c[i][j+1] != '#'
			) ++cnt;
		}
	}
	if (cnt > 0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N, T;
  std::cin >> N >> T;

  int cost = INF;
  for (auto i = 0; i < N; ++i) {
    int ci, ti;
    std::cin >> ci >> ti;

    if (ti > T)
      continue;
    else
      cost = std::min(ci, cost);
  }

  if (cost == INF)
    std::cout << "TLE" << std::endl;
  else
    std::cout << cost << std::endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int A, B, C, X;
    int comb=0;
    int a, b, c;

    cin >> A >> B >> C >> X;

    c = X/50;

    b = X/100;

    a = X/500;

    for(int i=0;i<a+1;++i){
        for(int j=0;j<b+1;++j){
            for(int k=0;k<c+1;++k){
                if(i<=A && j<=B && k<=C && 500*i+100*j+50*k==X){
                    comb += 1;
                }
            }
        }
    }

    cout << comb;
}



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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
int main() {
    ll n, m;
    cin >> n >> m;
    if (n < m) {
        swap(n, m);
    }
    if(n > m + 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;

    for (ll i = 1; i <= n; i++) {
        ans = (ans * i) % mod;
    }
      for (ll i = 1; i <= m; i++) {
        ans = (ans * i) % mod;
    }

    if(n == m) {
        ans = (2 * ans) % mod;
    }

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


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

A, B = MAP()

def tap(n, a):
	return n+a-1

n = 1
count = 0
while n<B:
	n = tap(n,A)
	count += 1

print(count)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = (201LL * 201LL / 2LL * 100001LL);
LL N, M, R, r[10], A[100000], B[100000], C[100000];
LL d[212][212], ans = inf * 201LL;

void warshall_floyd(LL V)
{
	for (LL k = 1LL; k <= V; ++k)
	{
		for (LL i = 1LL; i <= V; ++i)
		{
			for (LL j = 1LL; j <= V; ++j)
			{
				d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main()
{
	in >> N >> M >> R;
	rep(i, R) { in >> r[i]; }
	rep(i, N) { rep(j, N) { d[i + 1][j + 1] = inf * 201LL; } }
	rep(i, M)
	{
		in >> A[i] >> B[i] >> C[i];
		d[A[i]][B[i]] = C[i];
		d[B[i]][A[i]] = C[i];
	}
	
	warshall_floyd(N);
  	std::sort(r, r + R);
	do
	{
		LL res = 0;
		rep(i, R - 1)
		{
			res += d[r[i]][r[i + 1]];
		}
		ans = std::min(ans, res);
	} while (std::next_permutation(r, r + R));

	out << ans << std::endl;
	return 0;
}


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

using namespace std;

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

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

	ll N, M;
	cin >> N >> M;

	vector<pll> v(N);
	rep(i, N) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());

	ll ans = 0;
	ll p = 0;
	while(M > 0){
		ll t = min(M, v[p].second);
		M -= t;
		ans += v[p].first * t;
		p++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
# define ll long long
# define pb push_back
# define mod 1000000007
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	int c[100005]={0};
	c[0]=3;
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		ans=ans*c[a[i]]%mod;
		c[a[i]]--;
		c[a[i]+1]++;	
	}
	cout<<ans;
	return 0;
}

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

 
int main(){
  
 int n,d;
 cin >> n >> d;
 int l = (d*2) +1;
 if(n%l==0){
  cout << n/l << endl;
  return 0;
 }
 else{
  cout << n/l + 1 << endl;
  return 0; 
 }




}

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

#define endl '\n'
#define rep(n)      for (int i = 0 ; i < n ; i++)
#define all(a)      a.begin(),a.end()
#define NumofDigits(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())



void quick ()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

void time()
{
#ifndef ONLINE_JUDGE
    cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

const double Pi = acos(-1.0);

const int MAX = 2e5 ;
int sum [MAX+1];
int freq [MAX+1];

int main()
{
    quick(); // readFromText();
    int n ; cin >> n ; set <string> st ;
    for (int i = 0 ; i < n ; i++){
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size();
    return 0;
}


Measured memory_bytes: 19248
#include <stdio.h>

#define MAX_N 100002

typedef struct {char *p;int tm; } Q;
Q que[(MAX_N<<1)+2]; int top,end;
char name[MAX_N][20];

char buf[20],*p;
int in()
{
	int n = 0;
	while(*p >= '0'){
	    n = 10*n + (*p++ & 0xf);
	}
	p++;
	return n;
}

int main(){
	int  n, q, tm, i;
	Q  t;

	fgets(p=buf, 20, stdin);
	n = in(), q = in();
	for (i = 0; i < n; i++) {
		fgets(p=name[i], 20, stdin);
		while (*p > ' ') p++; *p++ = 0;
		que[i].p = name[i], que[i].tm = in();
	}

	tm = 0, top = 0, end = n;
	while (top != end) {
		t = que[top]; if (++top == MAX_N) top = 0;
		if (t.tm <= q) {
			printf("%s %d\n", t.p, tm+t.tm);
			tm += t.tm;
		} else {
			t.tm -= q;
			que[end] = t; if (++end == MAX_N) end = 0;
			tm += q;
		}
	}
	return 0;
}


Measured memory_bytes: 4344
num = int(input())
height_raw = input().split()
height = []
for a in range(num):
  height.append(int(height_raw[a])) 

counter = 0
max_height = 0

for b in range(num):
  if height[b]>=max_height:
    max_height = height[b]
    counter += 1

print(counter)
    
  

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

using namespace std;
typedef long long ll;
int matrix[1010][1010];

int main() {
    int h,w,a,b;
    scanf("%d %d %d %d",&h,&w,&a,&b);
    //vector<int> row_flag(w,0);
    //for (int i = 1; i <= h; i++) {
    //    int norma = 0;
    //    for (int j = 1; j <= w; j++) {
    //      if (norma < a && (row_flag[j] < b | b == 0)) {
    //          matrix[i][j] = 1;
    //          norma++;
    //          row_flag[j]++;
    //      }  
    //    }
    //    if (norma < a) {
    //        printf("No\n");
    //        return 0;
    //    }
    //}
    for (int i = 1; i <= h; i++) {
        if (i <= h - b) {
            for (int j = 1; j <= w; j++) {
                if (j <= a) printf("%d",1);
                else printf("%d",0);
            }
        } else {
            for (int j = 1; j <= w; j++) {
                if (j <= a) printf("%d",0);
                else printf("%d",1);
            }
        }
        printf("\n");
    }
}

Measured memory_bytes: 1280
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
char s[maxn];int len;

map<int,int> mp;
void solve(){
	ll ans = 0;
	mp[0] = 1;
	int pre = 0;
	int Pow = 1;
	for(int i = len;i>=1;i--){
		pre = (pre + Pow * (s[i] -'0')%2019)%2019;
		ans += mp[pre];
		mp[pre]++;
		Pow = (Pow*10)%2019;
	}
	printf("%lld\n",ans);
}	
int main(){
	// debug;
	
	scanf("%s",s+1); len = strlen(s+1);
	solve();
	
	return 0;
}


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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum = 0;
  if (N <= K){
  sum += N * X;
  }
  
  else {
  sum += K * X + (N - K) * Y;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long ans = 0;
		for(int i=1; i<=N; i++) {
			if(i % 3 != 0 && i % 5 != 0) {
				ans += i;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 35776
s = input().rstrip().split(' ')
h = int(s[0])
n= int(s[1])

A = []
B = []

for i in range(n):
    AB = list(map(int, input().rstrip().split(' ')))
    A.append(AB[0])
    B.append(AB[1])

dp = [[float('inf')] * (h+1)] * (n+1)
dp[0][0] = 0

def min(a, b):
    if a < b:
        return a
    else:
        return b

for i in range(n):
    for j in range(h):
        dp[i+1][j] = dp[i][j]
        dp[i+1][min(j + A[i], h)] = min(dp[i + 1][min(j + A[i], h)], dp[i + 1][j] + B[i])

print(dp[n][h])


Measured memory_bytes: 51676
import java.util.*;

public class Main {
    public static void main(String args[]) {
       //値の取得
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int[] P = new int[N];
       for (int i = 0; i < N; ++i) {
            P[i] = sc.nextInt();
       }
       
       int count = 0; //条件を満たす整数のカウント
       int Pj = P[0]; //P[j]を設定　はじめはP[0]の値から
       
       for(int i = 0; i < N; ++i) {
             if(P[i] <= Pj) {
               ++count;
               Pj = P[i]; //P[j]にP[i]の値を代入
           }
       }
       
       //出力
       System.out.println(count);
       
    }
}

Measured memory_bytes: 60240
#include <iostream>
#include <cmath>
#include <set>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  set<int> A;
  int a;
  REP(i, N) {
    cin >> a;
    if(A.find(a) == A.end()) {
      A.insert(a);
    } else {
      A.erase(a);
    }
  }
  cout << A.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
}

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

  for (int i = 0; i < 60; i++) {
    for (int p = 0; p < 60; p++) {
      int tmp = 4 * i + 7 * p;
      if (n == tmp) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  // solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
X = input()
Xi = int(X, 2)

c0 = X.count('1')
Xp = Xi % (c0 + 1)

if c0 != 1:
    Xm = Xi % (c0 - 1)

for i, x in enumerate(X):
    if x == '1':
        if c0 == 1:
            print(0)
            continue
        y = (Xm - pow(2, N - 1 - i, c0 - 1)) % (c0 - 1)
    else:
        y = (Xp + pow(2, N - 1 - i, c0 + 1)) % (c0 + 1)

    ans = 1
    while y:
        y %= bin(y).count('1')
        ans += 1
    print(ans)


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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

struct use
{
    int nex[26],cnt;
};

const int N=2e6+5,mod=1e9+9;
int n;
int tot;use trie[N];
int mx=-1;
vector<char> ans;

void dfs(int x)
{
    if(trie[x].cnt==mx)
    {
        for(int i=0;i<ans.size();i++)
            printf("%c",ans[i]);
        printf("\n");
    }
    for(int i=0;i<26;i++)
    {
        if(trie[x].nex[i]==0)continue;
        ans.push_back((char)(i+'a'));
        dfs(trie[x].nex[i]);
        ans.pop_back();
    }
}

int main()
{
    n=read();
    for(int i=1;i<=n;i++)
    {
        char s[15];
        scanf("%s",s+1);
        int len=strlen(s+1),p=0;
        for(int j=1;j<=len;j++)
        {
            if(trie[p].nex[s[j]-'a']==0)
                trie[p].nex[s[j]-'a']=++tot;
            p=trie[p].nex[s[j]-'a'];
        }
        ++trie[p].cnt;
    }
    for(int i=1;i<=tot;i++)mx=max(mx,trie[i].cnt);
    dfs(0);
    return 0;
}


Measured memory_bytes: 102272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx = 2e5;
vector<ll> lazy(4*mx+5);
vector<ll> segtree(4*mx+5);

void push(int k, int l, int r)
{
	if (l != r)
	{
		lazy[2*k] += lazy[k];
		lazy[2*k+1] += lazy[k];
	}
	segtree[k] += lazy[k];
	lazy[k] = 0;
}

void pull(int k)
{
	segtree[k] = max(segtree[2*k], segtree[2*k+1]);
}

void update(int a, int b, int k, int x, int y, ll inc)
{
	push(k,x,y);
	if (x > b || y < a)
	{
		return;
	}
	if (a <= x && y <= b)
	{
		lazy[k]=inc;
		push(k,x,y);
		return;
	}
	int m = (x+y)/2;
	update(a,b,2*k,x,m,inc);
	update(a,b,2*k+1,m+1,y,inc);
	pull(k);
}

ll get(int a, int b, int k, int x, int y)
{
	push(k,x,y);
	if (x > b || y < a)
	{
		return LLONG_MIN;
	}
	if (a <= x && y <= b)
	{
		return segtree[k];
	}
	int m = (x+y)/2;
	return max(get(a,b,2*k, x, m), get(a,b,2*k+1,m+1,y));
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> inc[n+1];
	vector<pair<ll, ll>> rem[n+1];
	for (int q = 0; q < m; q++)
	{
		ll l,r,a;
		cin >> l >> r >> a;
		inc[l].push_back(a);
		rem[r].push_back({l,a});
	}
	ll ans = 0;
	for (int q = 1; q <= n; q++)
	{
		for (ll w : inc[q])
		{
			update(0,q-1,1,0,n,w);
		}
		ll best = get(0,q-1,1,0,n);
		update(q,q,1,0,n,best);
		for (pair<ll,ll> w : rem[q])
		{ 
			update(0,w.first-1,1,0,n,-1 * w.second);
		}
		ans = max(ans, best);
	}
	cout << ans << "\n";
	return 0;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll x[100005], a, b;
int main()
{
	std::cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
		std::cin >> x[i];

	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		auto cost = (x[i] - x[i - 1])*a;
		if (cost > b)
			ans += b;
		else
			ans += cost;
	}

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


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"os"
)

func main() {
	var n, q, l, r int
	var s string
	fp := os.Stdin

	fmt.Fscan(fp, &n, &q)
	fmt.Fscan(fp, &s)

	acCounts := make([]int, n)
	acCount := 0

	for i := 1; i < n; i++ {
		if s[i-1:i+1] == "AC" {
			acCount++
		}
		acCounts[i] = acCount
	}

	for i := 0; i < q; i++ {
		fmt.Fscan(fp, &l, &r)
		fmt.Println(acCounts[r-1] - acCounts[l-1])
	}
}

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

const ll INF = 1001001001;

int main(){
    string s; cin >> s;
    int sz = s.size();
    int cnt = 1;
    int ans = 0;
    for(int i = 1; i < sz; i++){
        if(cnt > 0){
            if(s[i] == 'g') ans++;
            cnt--;
        }
        else{
            if(s[i] == 'p') ans--;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3704
import math

def cal(H,M):

    H = 360/12*H + 1/12 * (M/60) *  360
    M = 360/60*M
    H_M = abs(H-M)

    if H_M > 180:
        H_M = 360 - H_M
    
    return H_M

def main():
    A, B, H, M = map(int,input().split())
    
    angle = cal(H,M)
    
    if angle == 180:
        print(A+B)
    
    else:
        print(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(angle))))
              
main()

Measured memory_bytes: 9432
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;
  
 

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      
      int n,k;
      cin>>n;
      // n++;
      cin>>k;
      ll ans = 0;
      ll pis = 0;
      ll v_sum = 0;
      for (ll kk = 1;kk<=n+1;kk++){
        if (kk>=k) ans= (ans+ n*kk-v_sum+1)%mod;
         // cout<<v_sum<<endl;
       

        pis++;
         v_sum= (v_sum + 2*pis)%mod;
      }
      cout<<ans<<"\n";


}
  

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, H, W);
  VEC(string, A, H);
  int c = 0;
  rep(i, 0, H) {
    int d = A[i].find('#');
    if (c != d) {
      print("Impossible");
      return;
    }
    c = A[i].find_last_of('#');
  }
  print("Possible");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> hw(m);
    rep(i, m) cin >> hw[i];
    
    int ans = n - accumulate(hw.begin(), hw.end(), 0);
    ans = ans <= -1 ? -1 : ans;

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,p,q,m,x,c1,c2,c3;
    string s;
    vector<ll>v;
    cin>>n;
    m=p=0;
    for(ll i=0; i<n; i++)
    {
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end(),greater<int>());
    for(ll i=0; i<v.size(); i++)
    {
        if(i%2==0) m+=v[i];
        else p+=v[i];
    }
    cout<<m-p<<endl;
}






Measured memory_bytes: 384
package main

import (
        "bufio"
        "fmt"
        "os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int){
        sc.Scan()
        for _, v := range sc.Bytes(){
                n = n*10 + int(v-48)
        }
        return
}

func main(){
        sc.Split(bufio.ScanWords)
        n := ri()
        ans := 0
        for i := 0; i < n; i++{
                for a := ri(); a&1 == 0; a>>= 1{
                        ans++
                }
        }
        fmt.Println(ans)
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;
  
  int ans=0;
  if(S=="RRR") ans=3;
  else if(S[0]==S[1]&&S[0]=='R') ans=2;
  else if(S[1]==S[2]&&S[1]=='R') ans=2;
  else if(S[0]=='R'||S[1]=='R'||S[2]=='R') ans=1;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        long dia=0;
        long rec =0;
        String []sp =new String[3];
        while(scan.hasNext()){
        	sp = scan.nextLine().split(",");
            long a = Integer.parseInt(sp[0]);
            long b = Integer.parseInt(sp[1]);
            long c = Integer.parseInt(sp[2]);
        	if((long)Math.pow(a, 2)+(long)Math.pow(b, 2)==(long)Math.pow(c, 2))rec++;
        	if(a==b)dia++;
        }
        System.out.println(rec);
        System.out.println(dia);

  }
  }

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

int main() {
    int64_t N, A, B, ans = 0;
    cin >> N >> A >> B;
    if (A != 0 || B != 0) {
        ans += (int64_t)(N / (A + B)) * A;
        if (N - (int64_t)(N / (A + B)) * (A + B) > A) {
            ans += A;
        } else {
            ans += N - (int64_t)(N / (A + B)) * (A + B);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];

    vector<int> pass(N);
    iota(all(pass), 0);
    double sum = 0;
    int n = 0;
    do {
        double dist = 0;
        rep(i, 1, N) {
            dist += hypot((double)X[pass[i]] - X[pass[i - 1]], (double)Y[pass[i]] - Y[pass[i - 1]]);
        }
        sum += dist;
        n++;
    } while (next_permutation(all(pass)));

    write(sum / n);
}

Measured memory_bytes: 256
import re
#import time
N = int(input())
S = input()
#start = time.time()
cnt = 0
for i in range(10):
    fir = S.find(str(i))
    if fir == -1:
        continue
    for j in range(10):
        sec = S.find(str(j), fir + 1)
        if sec == -1:
            continue
        for h in range(10):
            thi = S.find(str(h), sec + 1)
            if thi == -1:
                continue
            cnt += 1
print(cnt)
#stop = time.time()
#print(stop - start)

Measured memory_bytes: 71264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A, B;
  cin >> A >> B;
  int x = 0;
  int C = A;
  
  for (int i = 0; i < B - A + 1; i++) {
    
    int y = C / 10000 + C / 1000 % 10 *10 + C / 100 % 10 * 100 + C / 10 % 10 * 1000 + C % 10 * 10000;
   
     if ( C == y ){
      x += 1;
    }
    
    
    C += 1;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();

        if(x >= 400 && x <= 599) {
            System.out.println("8");
        }else if(x >= 600 && x <= 799) {
            System.out.println("7");
        }else if(x >= 800 && x <= 999) {
            System.out.println("6");
        }else if(x >= 1000 && x <= 1199) {
            System.out.println("5");
        }else if(x >= 1200 && x <= 1399) {
            System.out.println("4");
        }else if(x >= 1400 && x <= 1599) {
            System.out.println("3");
        }else if(x >= 1600 && x <= 1799) {
            System.out.println("2");
        }else if(x >= 1800 && x <= 1999) {
            System.out.println("1");
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

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

        int a,b;
        cin>>a>>b;
        int mx=max(a-b,a+b);
        mx=max(mx,a*b);
        cout<<mx<<"\n";

        return 0;
}
/**

**/


Measured memory_bytes: 384
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n

let sum i = i * (i + 1) / 2

let () = Printf.printf "%d\n" @@ 
  sum n 
  - (sum (n / 3) * 3) 
  - (sum (n / 5) * 5)
  + (sum (n / 15) * 15)


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

int N;
ll A[200000], B[200000];

map<pair<ll, ll>, ll> pos, neg, Map;
ll zero;

ll modpow(ll a, ll n, ll mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] == 0 && B[i] == 0) zero++;
        else if (A[i] == 0) neg[MP(1, 0)]++;
        else if (B[i] == 0) pos[MP(1, 0)]++;
        else {
            ll g = gcd(A[i], B[i]);
            ll a = A[i] / g;
            ll b = B[i] / g;
            if (a < 0) {
                a *= -1;
                b *= -1;
            }
            if (b > 0) pos[MP(a, b)]++;
            else neg[MP(-b, a)]++;
        }
    }

    ll ans = 1;

    map<pair<ll, ll>, ll>::iterator p;
    for (p = pos.begin(); p != pos.end(); p++) {
        Map[MP(p->first.first, p->first.second)] += modpow(2, p->second, MOD) - 1;
    }

    for (p = neg.begin(); p != neg.end(); p++) {
        Map[MP(p->first.first, p->first.second)] += modpow(2, p->second, MOD) - 1;
    }

    for (p = Map.begin(); p != Map.end(); p++) {
        ans = ans * (p->second + 1) % MOD;
    }

    if (zero > 0) ans += zero;

    if (ans == 0) ans = MOD;
    ans--;
    PRINT(ans);

    return 0;
}

Measured memory_bytes: 31652
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: ;2020-02-22 21:12:49
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

LL power(LL n, LL m) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = power(n, m/2);
        return p*p % MOD;
    } else {
        return n*power(n, m-1) % MOD;
    }
}

LL modinv(LL n) {
    return power(n, MOD-2);
}

LL combination(LL n, LL r) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= MOD;
        ret *= modinv(i+1);
        ret %= MOD;
    }

    return ret;
}

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

    LL ans = power(2, n) - 1;
    ans -= combination(n, a);
    ans -= combination(n, b);

    for (; ans < 0; ans += MOD) {}

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    long N,K;
    cin >> N >> K;
    long H[N];
    for(long i = 0;i < N;i++){
        cin >> H[i];
    }
    sort(H,H + N);
    long S = 0;
    for(long i = 0;i < N - K;i++){
        S += H[i];
    }
    cout << S << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

typedef __int128 BS;

const int N = 110, LIM = 20, P = 998244353;

int n;
char s[N];
int dp[2 << LIM];

map<BS, int> dp1;

int dfs(BS bs) {
  if (bs < (2 << LIM))
    return dp[bs];
  if (dp1.count(bs))
    return dp1[bs];
  int ret = dfs(bs >> 1) * ((bs & 1) + 1) % P;
  int i = 100;
  while (!((bs >> i) & 1)) --i;
  BS j = bs ^ (BS(1) << i);
  for (int l = 1; l <= i; ++l) {
    BS mask = j & ((BS(1) << l) - 1);
    for (int k = 2; k * l <= i; ++k) {
      mask &= j >> ((k - 1) * l);
      ret = (ret + dfs((BS(1) << l) | mask) * (ll)dfs((BS(1) << (i - k * l)) | (j >> (k * l)))) % P;
    }
  }
  return dp1[bs] = ret;
}

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

  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i)
    s[i] -= '0';
  BS bs(1);
  bs <<= n;
  for (int i = 0; i < n; ++i)
    if (s[i + 1])
      bs |= BS(1) << i;
  dp[1] = 1;
  for (int i = 1; i <= LIM; ++i)
    for (int j = 0; j < 1 << i; ++j) {
      dp[j | (1 << i)] = dp[(j >> 1) | (1 << (i - 1))] * ((j & 1) + 1) % P;
      for (int l = 1; l <= i; ++l) {
        int mask = j & ((1 << l) - 1);
        for (int k = 2; k * l <= i; ++k) {
          mask &= j >> ((k - 1) * l);
          dp[j | (1 << i)] = (dp[j | (1 << i)] + dp[(1 << l) | mask] * (ll)dp[(1 << (i - k * l)) | (j >> (k * l))]) % P;
        }
      }
    }
  cout << dfs(bs) << '\n';

  return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[100005] = {}, z;
    cin >> n;
    fr(n) cin >> a[i];
    //fr(n) cout << a[i] << ' '; cout << '\n';
    ll l = 0, r = (ll)mod * mod;
    while (l + 1 < r) {
        ll m = (l + r) >> 1;
        ll c = m;
        fr(n) {
            if (i && a[i] == a[i - 1]) continue;
            c /= a[i], c *= a[i];
            if (!c) break;
        }
        if (c < 2) l = m;
        else r = m;
    }
    z = r;
    //cout << z << ' ';
    l = 0, r = (ll)mod * mod;
    while (l + 1 < r) {
        ll m = (l + r) >> 1;
        ll c = m;
        fr(n) {
            if (i && a[i] == a[i - 1]) continue;
            c /= a[i], c *= a[i];
            if (!c) break;
        }
        if (c <= 2) l = m;
        else r = m;
    }
    if (z > l) cout << -1;
    else cout << z << ' ' << l;
}


Measured memory_bytes: 1024
a = input()

l = []
for i in range(len(a)):
    l.append(a[i])

if l.index(max(l)) == 0:
    for _ in range(len(l)):
        print(l[0],end='')
else:
    for _ in range(len(l)):
        print(int(l[0])+1,end='')


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
#define MOD 1000000007
int main(){
  long long n,k;cin>>n>>k;
  int a[n];
  long long ans = 0;
  for(int i = 0; n > i;i++)cin>>a[i];
  for(int i = 0; n > i; i++){
    for(int j = 0; n > j; j++){
      if(a[i] > a[j]){
        if(i < j){
          if(k%2==0)ans = (ans + (1+k)*(k/2))%MOD;
          else ans = (ans + ((1+k)/2)*(k))%MOD;
        }else{
          if(k%2==0)ans = (ans + (k/2)*(k-1))%MOD;
          else ans = (ans + (k)*((k-1)/2))%MOD;
        } 
      }
    }
  }
  cout << ans << endl;
}

//(1+k)*(k)/2
//(k)*(k-1)

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int dp[maxn], a[maxn];
int n, k;
int dfs(int x){
    if(dp[x] != -1) return dp[x];
    int flag = 1;
    for(int i = 1; i <= n; i++){
        if(x - a[i] >= 0) flag = min(flag, dfs(x-a[i]));
    }
    return dp[x] = flag^1;
}

int main()
{
    //freopen("a", "r", stdin);
    cin>>n>>k;
    for(int i = 1; i <= n; i++) cin>>a[i];
    for(int i = 0; i <= k; i++) dp[i] = -1;
    dp[0] = 0;
    if(dfs(k)){
        printf("First");
    } else printf("Second");
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DEBUG false

class F {
private:
    multiset<int> lowA, highA;
    LL sumA, sumLowA, sumHighA, sumB;

public:
    F() {
        sumA = sumLowA = sumHighA = sumB = 0;
    }

    void insert(int a, int b) {
        if (lowA.size() > 0 && a <= *lowA.rbegin()) {
            lowA.insert(a);
            sumLowA += a;

            //balancing
            while (lowA.size() - highA.size() > 1) {
                auto ptr = --(lowA.end());
                int val = *ptr;

                lowA.erase(ptr);
                sumLowA -= val;

                highA.insert(val);
                sumHighA += val;
            }
        } else {
            highA.insert(a);
            sumHighA += a;

            //balancing
            while (highA.size() > lowA.size()) {
                auto ptr = highA.begin();
                int val = *ptr;

                highA.erase(ptr);
                sumHighA -= val;

                lowA.insert(val);
                sumLowA += val;
            }
        }

        sumB += b;

        if (DEBUG) {
            cout << "lowA:\n";
            for (auto i: lowA) cout << i << " ";
            cout << endl;

            cout << "highA:\n";
            for (auto i: highA) cout << i << " ";
            cout << endl;

            cout << sumLowA << " " << sumHighA << endl;
        }
    }

    pair<int, LL> query() {
        int szLow = (int) lowA.size();
        int szHigh = (int) highA.size();

        int x = *lowA.rbegin();

        LL result = ((LL) x * szLow - sumLowA) + (sumHighA - (LL) x * szHigh) + sumB;
        return {x, result};
    }
};

int Q;
F f = F();

int main() {
    scanf("%d", &Q);
    for (int q = 1; q <= Q; q++) {
        int t, a, b;
        scanf("%d", &t);

        if (t == 1) {
            scanf("%d%d", &a, &b);
            f.insert(a, b);
        } else {
            auto answer = f.query();
            printf("%d %lld\n", answer.first, answer.second);
        }
    }
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    ll ans = 0;
    ll l_2 = (double)n / 2;
    ll num = 8 * q;
    num = min(num, 4 * h);
    num = min(num, 2 * s);
    num = min(num, d);
    if (l_2 >= 1) {
        ans = l_2 * num;
    }


    int l_1 = n % 2;
    if (l_1 == 1) {
        num = 4 * q;
        num = min(num, 2 * h);
        num = min(num, s);

        ans += num;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::map<int64_t, int64_t> num;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t A;
        std::cin >> A;
        num[A]++;
    }

    int64_t ans = 0;
    for (auto v : num)
    {
        if (v.second % 2 == 1) ans++;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 9740
bottons=[]
for x in input().split():
    bottons.append(int(x))
if bottons[0]>bottons[1]:
    max=bottons[0]+(bottons[0]-1)
elif bottons[1]>bottons[0]:
    max=bottons[1]+(bottons[1]-1)
else:
    max=sum(bottons)

print(max)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    int l;
    cin>>l;
    double ans = (double)l*l*l/27;
    cout<<fixed<<setprecision(12)<<ans;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int[] cnt = new int[4];
            for (int i = 0; i < 3; i++) {
                int from = Integer.parseInt(in.next());
                int to = Integer.parseInt(in.next());
                cnt[from - 1]++;
                cnt[to - 1]++;
            }
            boolean ok = true;
            for (int i = 0; i < 4; i++) {
                if (cnt[i] >= 3) ok = false;
            }

            // 出力
            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 21716