akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>
#include <set>
 
using namespace std;
 
int sqrtN = 512;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketUpdatedLazy;
    vector <long long> bucketMin;
     
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N + sqrtN, ((long long) 1 << 31) - 1);
        bucketUpdatedLazy.assign(K, -1);
        bucketMin.assign(K, ((long long) 1 << 31) - 1);
    }
 
    void propagateLazy(int k){
        if(bucketUpdatedLazy[k] < 0){
            return;
        }
        for(int i = 0; i < sqrtN; i++){
            data[k * sqrtN + i] = bucketUpdatedLazy[k];
        }
        bucketMin[k] = bucketUpdatedLazy[k];
        bucketUpdatedLazy[k] = -1;
    }

    void updateMin(int k){
        bucketMin[k] = data[k * sqrtN];
        for(int i = 0; i < sqrtN; i++){
            bucketMin[k] = min(data[k * sqrtN + i], bucketMin[k]);
        }
    }

    long long get(int x){
        propagateLazy(x / sqrtN);
        return data[x];
    }

    long long find(int x, int y){
        propagateLazy(x / sqrtN);
        propagateLazy((y - 1) / sqrtN);
        long long ans = data[x];
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans = min(ans, data[i]);
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans = min(ans, bucketMin[i]);
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans = min(ans, data[i]);
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans = min(ans, data[i]);
        }
        return ans;
    }
 
    void update(int x, int y, long long a){
        if(y - x < sqrtN){
            propagateLazy(x / sqrtN);
            propagateLazy((y - 1) / sqrtN);
            for(int i = x; i < y; i++){
                data[i] = a;
            }
            updateMin(x / sqrtN);
            updateMin((y - 1) / sqrtN);
            return;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            bucketUpdatedLazy[i] = a;
            bucketMin[i] = a;
        }

        propagateLazy(x / sqrtN);
        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            data[i] = a;
        }
        updateMin(x / sqrtN);
        propagateLazy((y - 1)/ sqrtN);
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            data[i] = a;
        }
        updateMin((y - 1) / sqrtN);
    }
     
};

 
int main(){
    int n;
    int q;
    cin >> n >> q;
    SqrtDecomposition sq(n);
    for(int i = 0; i < q; i++){
        int com;
        int s;
        int t;
        int x;
        cin >> com;
        if(com == 0){
            cin >> s >> t >> x;
            sq.update(s, t + 1, x);
        } else {
            cin >> s >> t;
            cout << sq.find(s, t + 1) << endl;
        }
    }
    return 0;
}


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

ll cmd(ll a, ll b){
return b==0?a:cmd(b,a%b);}
ll gcd(ll a , ll b){
    ll k = cmd(a,b);
    return (a/k)*b;
}
ll a[10000]={0};
int main(){
    ll n,num=1;
    cin >>n;
    for(ll i=1;i<=n;i++){
        cin >>a[i];
    }
    for(ll i=1;i<=n;i++){
        num=gcd(a[i],num);
    }
    cout<<num<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i < 10) {

			cout << "Yes";
			return 0;
		}
	}
			cout << "No";
}

//int m[500][26] = {};
//void func(string& s, int N, int i, vector<string>a, int J) {
//	int j;
//		for (j = 0; j < J; j++) {
//			if (m[J - 1 - i][(int)a[i][j] - 97] == 1) {
//		s += a[i][j];
//				break;
//			}
//			if (j == J - 1) {
//				s = "-1";
//				i = N - 1;
//				break;
//			}
//		}
//		i++;
//	if (i == N) {
//		
//	}
//	else {
//		func(s, N, i, a, J);
//	}
//}
//
//int main() {
//	ll N;
//	cin >> N;
//	vector<string>a(N);
//	
//	rep(i, N) {
//		cin >> a[i];
//	}
//	if (N == 1) {
//		cout << a[0];
//		return 0;
//	}
//	rep(i, N) {
//		rep(j, N) {
//			m[i][(int)a[i][j] - 97]=1;
//		}
//	}
//	string ans;
//
//	func(ans, N/2,0,a,N);
//
//	if (ans == "-1") {
//		cout <<ans;
//		return 0;
//	}
//		cout << ans;
//		
//		if (N % 2 == 1) {
//			cout << a[N / 2 + 1][0];
//		}
//	rep(i, N / 2) {
//
//	cout << ans[N/2-i-1];
//	
//	}
//}
//
//
//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
//const int 1001001001;
const int NMAX=8;
const ll MOD=1000000007;
const int dbase=80*160;



using namespace std;
using ll = long long;

int main(){
	ll n;
	cin>>n;
	vector<P> a(n+5);
	rep(i,n){
		ll temp;
		cin>>temp;
		a[i]=make_pair(temp,i);
	}
	sort(a.rbegin(),a.rend());
  ll ans=0;
	vector<vector<ll>> d(n+5,vector<ll>(n+5,0));

	for(ll i=0;i<n;i++){
		for (ll j=0;j<n;j++){
		if ((j+i)>=n) {
			ans=max(d[i][j],ans);
			break;
		}

		d[i+1][j]=max(d[i+1][j],d[i][j]+(a[i+j].second-i)*(a[i+j].first));
		d[i][j+1]=max(d[i][j+1],d[i][j]+(n-1-j-a[i+j].second)*(a[i+j].first));
	//	cout<<d[i][j]<<' '<<i<<'i'<<j<<'j'<<endl;

	  }
	}
	cout<<ans;

}


Measured memory_bytes: 34652
const main = (input: string) => {
  const [A, B, K] = input.split(" ").map(str => parseInt(str))
  let divisorList = [];

  for (let i = 1; i <= A; i++) {
    if(A % i === 0 && B % i === 0) {
      divisorList.push(i)
    }
  }

  const answer = divisorList.reverse();
  console.log(answer[K - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
n,k = map(int,input().split())

INF = 1e12

dp = [INF] * n

h = list(map(int,input().split()))

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):#Ele vai começar a contar cada pedra a partir da terceira
    pulo = 0
    for j in range(i-1,-1,-1):#O pulo começar pequeno, tendo tamanho 1 e indo até o máximo k
        pulo += 1
        if pulo > k:
            break
        else:
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))
#No final ele vai armazenar o pulo de menor custo, afinal não importa o tamanho do pulo e sim seu custo, sendo assim,
#Temos que calcular os custos de todos os possiveis pulos até a pedra atual.

print(dp[n-1])


Measured memory_bytes: 55392
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long int ll;
char c[100000000];
int main()
{
    long long int n;
    scanf("%lld",&n);
    
    int num=0;
    while(n--)
    {
        c[num++]=(n)%26ll+'a';
        n/=26ll;
    }
    for(int i=num-1;i>=0;i--)
    {
        printf("%c",c[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3768
S=input()
s=[input() for i in range(0,0)]

a=S.count('RRR')
b=S.count('RR')
c=S.count('R')

if a==1:
    x=3
else:
    if b==1:
        x=2
    elif c!=0:
        x=1
    else:
        x=0

print(x)

Measured memory_bytes: 9116
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[200005];

ll comb(ll a, ll b) {
  ll ue = frac[a];
  ll sh1 ,sh2;
  ll h = mod-2;
  ll two;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh2 *= sh2;
      sh1 %= mod;
      sh2 %= mod;
    }
    h -= two;
    ue *= sh1;
    ue %= mod;
    ue *= sh2;
    ue %= mod;
  }
  return ue;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<200005;++i) frac[i] = frac[i-1]*i%mod;
  ll N, M, K;
  cin>>N>>M>>K;
  ll dist = 0;
  for(ll i=0;i<N;++i) {
    dist += i*(i+1)/2%mod*M%mod*M%mod;
    dist += (N-1-i)*(N-i)/2%mod*M%mod*M%mod;
    dist %= mod;
  }
  for(ll i=0;i<M;++i) {
    dist += i*(i+1)/2%mod*N%mod*N%mod;
    dist += (M-1-i)*(M-i)/2%mod*N%mod*N%mod;
    dist %= mod;
  }
  ll h = mod - 2;
  ll two;
  ll tmp;
  while(h>0) {
    tmp = 2;
    two = 1;
    while(2*two<h) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    h -= two;
    dist *= tmp;
    dist %= mod;
  }
  cout<<dist*comb(N*M-2, K-2)%mod<<endl;
}



Measured memory_bytes: 5216
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>

#define ll long long int
#define MAX 1000000

using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	if (a == b) {
		cout << "Draw" << endl;
		return (0);
	}

	if (a == 1) {
		cout << "Alice" << endl;
		return 0;
	}
	if (b == 1) {
		cout << "Bob" << endl;
		return 0;
	}

	if (a > b) {
		cout << "Alice" << endl;
		return 0;
	}
	else {
		cout << "Bob" << endl;
	}

	return (0);
}




Measured memory_bytes: 256
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

m = 0
ans = 0
for v in a:
    m = max(m, v)
    ans += m - v
print(ans)


Measured memory_bytes: 92040
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */
int n,g;	
int p[10],c[10],ans=1000000;

void go(int stat,int score,int count){
	if(count>=ans) return;
	for(int i=0;i<n;i++){
		if(stat&(1<<i)) continue;
		if(g<=score+p[i]*(i+1)*100+c[i]){
			int rm=score,rs=count;
			int memo=p[i];
			while(g>score){
				count++;
				memo--;
				score+=(i+1)*100;
				if(memo==0)score+=c[i];
			}
			ans=min(ans,count);
			score=rm;
			count=rs;
		}
		else{
			int rm=count;
			count+=p[i];
			int sss=stat,ss=score;
			stat|=(1<<i);
			score+=p[i]*(i+1)*100+c[i];
			go(stat,score,count);
			stat=sss;
			score=ss;
			count=rm;
		}
	}
	return;
}

int main(){
	cin>>n>>g;
	lp(i,n){
		cin>>p[i]>>c[i];
	}
	go(0,0,0);
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n, m;
    cin >> n >> m;
    VI a(n);
    REP(i,m){
        int x, y;
        scanf("%d %d", &x, &y);
        a[x-1]++;
        a[y-1]++;
    }

    REP(i,n){
        if (a[i] % 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 640
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x):#約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x):#素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  x=[[0 for _ in range(n)] for _ in range(n)]
    n=int(input())
    a = list(map(int,input().split()))
    ans=gcd(a[0],a[1])
    for i in range(n-2):
        ans=gcd(ans,a[i+2])
        if ans==1:
            break
    print(ans)
main()

Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define N 100005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef long long int ll;
typedef long int li;

int n,m; ll num,ans;
priority_queue<ll> pq; 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
   cin>>n>>m;
   for(int i=1;i<=n;i++) { cin>>num; pq.push(num); }
   while(m--) {
        num = pq.top();
        if(num == 0) { cout<<0; return 0; }
        pq.pop(); pq.push(num/2);
   }
   while(!pq.empty()) { ans += pq.top(); pq.pop(); }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N;

		cin >> N;
		
		cout << N * N * N << '\n';

		return 0;
	}



Measured memory_bytes: 764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func insertionSort(xs []int, n int) {
	printArray(xs)
	for i := 1; i < n; i++ {
		v := xs[i]
		j := i - 1
		for ; j >= 0; j-- {
			if xs[j] > v {
				xs[j+1] = xs[j]
			} else {
				break
			}
		}
		xs[j+1] = v
		printArray(xs)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	var xs []int
	for i := 0; i < n; i++ {
		xs = append(xs, nextInt(sc))
	}
	insertionSort(xs, n)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func printArray(xs []int) {
	fmt.Println(strings.Trim(fmt.Sprint(xs), "[]"))
}



Measured memory_bytes: 1268
#include <iostream>
#include <string.h>
#define LL long long
using namespace std;

int main(void) {
  int n;
  LL ans = 1;
  cin >> n;

  int line[n];
  int report;

  for (int i=0; i<n; i++) {
    line[i] = 0;
  }

  for (int i=0; i<n; i++) {
    cin >> report;
    line[report]++;
  }

  /*
  for (int i=0; i<n; i++) {
    cout << i << ":" << line[i] << endl;
  }
  */
  if (line[0] > 1) {
    //cout << "resutl1:" << 0 << endl;
    cout << 0 << endl;
    return 0;
  }

  int s = n%2+1;
  for (int i=1; i<n; i++) {
    if (line[i] != 2 && line[i] != 0) {
      //cout << "resutl2:" << 0 << endl;
      cout << 0 << endl;
      return 0;
    }
    if (s == 2 && i % 2 != 0 && line[i] > 0) {
      cout << 0 << endl;
      return 0;
    }
    if (s == 1 && i % 2 != 1 && line[i] > 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  int waru = 1;
  for (int i=0; i<9; i++) {
    waru *= 10;
  }

  waru += 7;

  for (int i=0; i<n/2; i++) {
    ans *= 2;
    ans %= waru;
  }

  //cout << waru << endl;

  //cout << "resutl3:" << ans % waru << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

const int MAX_N = 3 * 1e5 + 1;
ll N;
ll A[MAX_N];
ll cnt[MAX_N][61];
ll sumCnt[61];

void initCnt() {
    rep(i, N) {
        int j = 0;
        while(A[i] > 0) {
            cnt[i][j] = (A[i] % 2LL);
            A[i] /= 2LL;
            ++j;
        }
    }
}

int main() {
    cin >> N;
    rep(i, N)
        cin >> A[i];
    initCnt();
    rep(i, N) {
        rep(j, 61) {
            sumCnt[j] += cnt[i][j];
        }
    }
    ll ans = 0LL;
    for(ll i = 0;i < N - 1;++i) {
        rep(j, 61) {
            sumCnt[j] -= cnt[i][j];
        }
        rep(j, 61) {
            if(cnt[i][j] == 1) {
                ans = (ans + ((1LL << j)%MOD * (N - i - 1LL - sumCnt[j]))%MOD)%MOD;
            }else {
                ans = (ans + ((1LL << j)%MOD * (sumCnt[j])) % MOD)%MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 145536
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

int main() {
  ll N;

  cin >> N;

  ll ans = 0;
  ll buf = 0;
  for (int i = 1; i <= N; i++) {
    ll tmp;
    cin >> tmp;
    if(tmp == i){
      buf++;
    } else {
      ans += (buf + 1) / 2;
      buf = 0;
    }
  }
  ans += (buf + 1) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("data.txt");

int n, r1, r2;
long long v1, v2, aux;

long long f(long long a, long long x) {
  long long ans = a/x;
  if (a % x) ans++;
  return ans;
}

int main() {
  cin >> n;
  cin >> v1 >> v2;
  n--;

  while (n--) {
    cin >> r1 >> r2;
    aux = max(f(v1, r1), f(v2, r2));
    v1 = r1*aux;
    v2 = r2*aux;
  }
  cout << v1 + v2;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, K = 0;
  cin >> A >> B >> K;
  for (int i=0; i < K; i++) {
    if (i%2 == 0) {
      A /= 2;
      B += A;
    } else {
      B /= 2;
      A += B;
    }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#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() {

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if (a1+a2+a3<22){
    cout << "win" << endl;
  }
  else { 
    cout << "bust" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
using namespace std;
int main(){
	string s;
	int k;
	cin>>s>>k;
	for(int i=0;i<s.size();++i){
		int x='z'-s[i]+1;
		if(s[i]=='a')
			continue;
		if(k>=x){
			s[i]='a';
			k-=x;
		}
	}
	k%=26;
	s[s.size()-1]+=k;
	cout<<s<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
 
using namespace std;
 
int main(){
	char S[100005];
	for(int i=0;i<100000;i++){
		S[i]='A';
	}
	int big=0;
	scanf("%s",&S);
	for(int i=0;i<100000;i++){
		if(S[i]!='A')big++;
	}
	
	int cha=0;
	if(S[0]=='B')cha=1;
	if(S[0]=='W')cha=2;
	int ans=0;
	
	for(int i=1;i<big;i++){
		if(cha==1&&S[i]=='W'){
			ans++;cha=3;
		}
			
		if(cha==2&&S[i]=='B'){
			ans++;cha=1;
		}
		if(cha==3)cha=2;
	}
	printf("%d\n",ans);
	
	
}

Measured memory_bytes: 384
#include <stdio.h>

#define N 100

int main(void) {
    int n, m;
    int a[N] = {-1};
    scanf("%d %d", &n, &m);
    int i, vote = 0, count = 0;

    for (i = 0; i<n; i++) {
        scanf("%d", &a[i]);
        vote += a[i];
    }

    for (i=0; i<n; i++) {
        if (a[i]*4*m >= vote) count += 1;
    }

    if (count >= m) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N=II()
ans=0
List=[[-1 for _ in range(N)] for _ in range(N)]
for j in range(N):
  A=II()
  for i in range(A):
    x,y=MI()
    x-=1
    List[j][x]=y
for i in range(1<<N):
  honests=[0]*N
  for j in range(N):
    if 1&(i>>j):
      honests[j]=1
  ok=True
  for j in range(N):
    if honests[j]:
      for k in range(N):
        if List[j][k]==-1:
          continue
        if List[j][k]!=honests[k]:
          ok=False
  if ok:
    ans=max(ans,honests.count(1))
print(ans)

Measured memory_bytes: 9140
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 200005;
#define ld long double
#define PI 3.14159265358979323846
const int X = 500000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(12);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
int get(int x){
    if(x==0)return 0;
    int n = __builtin_popcount(x);
    return 1+get(x%n);
}
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt1=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1')cnt1++;
    }
    reverse(s.begin(),s.end());
    int mod = (cnt1+1);
    if(cnt1>1)mod*=(cnt1-1);
    int po2[N];
    po2[0]=1;
    for(int i=1;i<n;i++){
        po2[i] = (po2[i-1]*2)%mod;
    }
    int num = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='1')num = (num + po2[i])%mod;
    }
    //reverse(s.begin(),s.end());
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
            if(cnt1==1)cout<<"0\n";
            else{
                int numd = (num - po2[i] + mod)%(cnt1-1);
                cout<<1+get(numd)<<"\n";
            }
        }
        else{
            int numd = (num + po2[i] + mod)%(cnt1+1);
            cout<<1+get(numd)<<"\n";
        }
    }
    return;
}
/*
Thanks to
hitman623
*/

Measured memory_bytes: 5292
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort(key=itemgetter(1))
    t = 0
    for a, b in AB:
        t += a
        if t > b:
            print('No')
            return
        
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 53704
//boom diggy diggy boom boom
/*
freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      */
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define ll long long 
#define ld long double 

int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}int max(int a,int b){int ans=a>b?a:b;return ans;}

using namespace std;

int main()
{
 int n,w;
 cin>>n>>w;
 ll W[n+1],v[n+1];
 for (int i = 1; i <= n; ++i)
    {
      cin>>W[i]>>v[i];
    }   
  ll value[n+1][w+1];
  for (int i = 0; i <= n; ++i)
  {
    for (int j = 0; j <= w; ++j)
    {
      value[i][j]=0;
    }
  }
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= w; ++j)
    {
      if(W[i]<=j)
          {
            value[i][j]=max(value[i-1][j],v[i]+value[i-1][j-W[i]]);
          }
      else 
        value[i][j]=max(value[i-1][j],value[i][j-1]);
    }
  }
 
  cout<<value[n][w];
return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
int main(){
	long long a=0,b=1;
	int n;
	scanf("%d",&n);
	while(n--){
		int q,x;
		scanf("%d%d",&q,&x);
		if(q==1)a*=x,b*=x;
		if(q==2)a-=x;
		if(q==3)a+=x;
	}
	printf("%lld %lld\n",a,b);
}


Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0)break;
		string c;
		cin>>c;
		int mai[10];
		for(int i=0;i<n;i++){
			mai[i]=0;
		}
		int ba=0;
		int turn=0;
		for(int i=0;i<c.size();i++){
			if(c[i]=='M')
				mai[turn]++;
			else if(c[i]=='S'){
				mai[turn]++;
				ba+=mai[turn];
				mai[turn]=0;
			}
			else{
				mai[turn]++;
				mai[turn]+=ba;
				ba=0;
			}
			turn++;
			turn%=n;
		}
		sort(mai,mai+n,less<int>());
		for(int i=0;i<n;i++){
			cout<<mai[i]<<" ";
		}
		cout<<ba<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
def examC():
    H, W = LI()
    A = [SI() for _ in range(H)]
    d = defaultdict(int)
    ans = "Yes"
    for a in A:
        for s in a:
            d[s] +=1
#    print(d)
    h = H//2; w = W//2; k = h*w
    for key,i in d.items():
        if k == 0:
            break
        while(d[key]>=4):
            d[key]-=4
            k -=1
            if k == 0:
                break
    if k>0:
        ans = "No"
#    print(d,k)
    k = 0
    if H%2==1:
        k +=w
    if W%2==1:
        k +=h
    for key,i in d.items():
        if k ==0:
            break
        while(d[key]>=2):
            d[key] -= 2
            k -= 1
            if k == 0:
                break
    if k>0:
        ans = "No"
#    print(d,k)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 39024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main(){
    ll x;
    double n1, n2;
    cin >> x;
    n1= (-1 + sqrt(1 + 8 * x)) / 2.0;
    n2 = (-1 - sqrt(1 + 8 * x)) / 2.0;
    if(n2<0){
        n2 =1000000000;
    }
    if((ll)(n1)<n1){
        n1++;
    }
    if ((ll)(n2) < n2)
    {
        n2++;
    }
    cout << min((ll)(n1), (ll)(n2)) << endl;
    
}

Measured memory_bytes: 256
N,M = map(int,input().split())
# N,M=10,10

S = []
for m in range(M):
    s = list(map(int,input().split()))
#     s = [i for i in range(10)]
    S.append(s[1:])

P = list(map(int,input().split()))
# P = [m for m in range(M)]

import itertools
cnt = 0
for tpl in itertools.product([0,1], repeat=N):
    f = True
    for m in range(M):
        c = 0
        for s in S[m]:
            c += tpl[s-1]
        # print(m, tpl, P[m], c)
        if (c%2+P[m])%2 != 0:
            f = False
            break
    if f:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fr(i,n) for(ll i=0;i<n;i++)
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
using namespace std;
int main()
{
	int r;
	cin>>r;
	double pi = 3.14159;
	double c=2*pi*r;
	cout << fixed << setprecision(2) << c <<endl; 
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  double answer;
  if(N==1){
    answer=1;
  }else{
  answer=(N+1)/2;
    answer/=N;
  }
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 384
// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[3000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
string s;
// string s=bitset<64>(n).to_string();
int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
	ll n;
	cin>>n;
	
	cin>>s;
	fact(3000005);
	ll ans=0;
	ll length=s.size();
	// cout<<ncr(0,0)<<endl;
	for(int i=0;i<=n;i++)
	{
		ans+=((power(25,i)*ncr(length+i-1,length-1))%mod*power(26,n-i))%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27648
#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 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 rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int power(ll a, ll b, ll c) {
	ll res = 1;
	while (b != 0) {
		if (b & 1)
			res = (res * a) % c;
		a = (a * a) % c;
		b /= 2;
	}
	return (int) res;
}
int func(int val) {
	int ans = 1;
	while(val != 0) {
		val = val % __builtin_popcount(val);
		ans++;
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1')
			cnt++;
	}
	int c0 = 0, c1 = 0, c2 = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '1') {
			c0 = (c0 + power(2, n - 1 - i, cnt)) % cnt;
			if (cnt - 1 != 0)
				c1 = (c1 + power(2, n - 1 - i, cnt - 1)) % (cnt - 1);
			c2 = (c2 + power(2, n - 1 - i, cnt + 1)) % (cnt + 1);
		}
	}
	//cout << c0 << " " << c1 << " " << c2 << "\n";
	int ans;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') {
			ans = func((c2 + (power(2, n - i - 1, cnt + 1)) % (cnt + 1)) % (cnt + 1));
		}
		else {
			if (cnt - 1 != 0) {
				int val = (c1 - (power(2, n - i - 1, cnt - 1)) % (cnt - 1));
				val = (val + (cnt - 1)) % (cnt - 1);
				ans = func(val);
			}
			else {
				ans = 0;
			}
		}
		cout << ans << "\n";
	}
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<functional>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 


using namespace __gnu_pbds; 
using namespace std;
typedef long long unsigned llu;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vl;

//use as vector<ii> v;
#define ff(a,b) for(ll i=a; i<b;i++)
#define MAX INT_MAX	
#define trace(x) cerr<<#x<<": "<<x<<" "<<'\n';
#define pb push_back
#define pob pop_back

int main(){
    long long int x,k,d;
    cin>>x>>k>>d;
    long long temp=abs(x);
    x=temp;
    long long int t=x/d;
    if(x>d){

    if(k>=t){
        x-=d*t;
        k-=t;
    }
    else{
        x-=d*k;
        cout<<x;
        return 0;
    }
    }
    if(k%2==0){
        cout<<x;
    }else{
        cout<<abs(x-d);
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
const int N = 15;
string s;
ll mem[N][2][10][2];
ll C(int i, bool bound, int last, bool any) {
    ll& ans = mem[i][bound][last][any];
    if(ans == -1) {    
        if(i == s.size()) {
            ans = 1;
        } else if(any) {
            ans = 0;
            for(int d = 0; d <= (bound ? s[i] : 9); d++) {
                ans += C(i + 1, bound and d == s[i], d, any and d == 0);
            }
        } else {
            ans = 0;
            for(int d = max(0, last - 1); d <= min(bound ? s[i] : 9, last + 1); d++) {
                ans += C(i + 1, bound and d == s[i], d, false);
            }
        }
    }
    return ans;
}
ll nlun(ll n) {
    s = to_string(n);
    for(char& c : s) c -= '0';
    memset(mem, -1, sizeof mem);
    return C(0, true, 0, true) - 1;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    cout << bsearch<ll>(0, 1'000'000'000'000ll, [&](ll n) {
        return nlun(n) >= k;
    }, false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    int l[q],r[q];

    rep(i,0,q){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }
    int sum[n];
    rep(i,0,n) sum[i] = 0;
    int tmp = 0;
    rep(i,1,n){

        if(s[i-1] == 'A' && s[i] == 'C') tmp++;
        sum[i] = tmp;
        
    }
    rep(i,0,q){
        cout << sum[r[i]]-sum[l[i]] <<endl;
    }
    
}

Measured memory_bytes: 2256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e9
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// MODのべき乗
ll powMod(ll n, ll p) 
{
	ll res = 1;
	while (p) {
		if (p & 1) (res *= n) %= MOD;
		(n *= n) %= MOD;
		p >>= 1;
	}
	return res;
}

// MODの逆元
ll invMod(ll n) 
{
	return powMod(n, MOD - 2);
}

/* 素因数分解 */
void primeFactor(ll n, map<ll, ll> &factMap)
{
	if ((n % 2) == 0){
		while((n % 2) == 0) {
			factMap[2]++;
			n = n / 2;
		}
	}

	for(ll i = 3; i <= sqrt(n); i += 2){
		while ((n % i) == 0){
			factMap[i]++;
			n = n / i;
		}
	}

	if (n != 1) {
		factMap[n]++;
	}
}

// メイン
int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	
	map<ll, ll> mpAll;
	REP(i, N) {
		map<ll, ll> mpOne;
		primeFactor(A[i], mpOne);
		for (auto &mpCnt : mpOne) {
			if (mpAll.count(mpCnt.first) == 0) {
				mpAll[mpCnt.first] = mpCnt.second;
			} else {
				mpAll[mpCnt.first] = max(mpCnt.second, mpAll[mpCnt.first]);
			}
		}
	}

	ll lcm = 1;
	for (auto &mpCnt : mpAll) {
		lcm *= powMod(mpCnt.first, mpCnt.second);
		lcm %= MOD;
 	}
	
	ll ans = 0;
	REP(i, N) {
		ans += lcm * invMod(A[i]);
		ans %= MOD;
	}

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



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    if (n == 1)
        OP("Hello World");
    else
    {
        int a, b;
        cin >> a >> b;

        OP(a + b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
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;
  cin >> N;
  vl A(N+1);
  rep(i,N+1) {
    cin >> A[i];
  }
  vl acc(N+2,0);
  drep(i,N+1) {
    acc[i] = acc[i+1]+A[i];
  }
  ll alive=1;
  ll ans = 0;
  rep(k,N+1) {
    ll rem = alive-A[k];
    if(rem<0) {
      cout << -1 << endl;
      return 0;
    }
    if(rem==0&&k!=N) {
      cout << -1 << endl;
      return 0;
    }
    if(k==N&&rem!=0) {
      cout << -1 << endl;
      return 0;
    }
    ans += alive;
    alive = min(rem*2,acc[k+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;


int main() {
    string o,e,ans;
    cin >> o >> e;
    int oLen = o.length();
    int eLen = e.length();
    rep(i,oLen+eLen) {
        if(i % 2 == 0) {
            ans += o[i/2];
        } else {
            ans += e[i/2];
        }
    }
    cout << ans << endl;
     return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
const ll mod = pow(10, 9) + 7;  

ll modpow(ll n, ll k) {
  ll value = 1;
  for(ll i = 0; i < k; i++) {
    value = value * (n % mod) % mod; 
  }
  return value;
}
 
int main() {
  ll N, ans;
  cin >> N;
  ans = (modpow(10, N) - modpow(9, N)) % mod;
  ans = (ans - modpow(9, N)) % mod;
  ans = (ans + modpow(8, N)) % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3600