akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 998244353;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s; cin >> n >> s;
    vector<int> a(n); rep (i, n) cin >> a[i];
    vector<vector<ll> > dp(n + 1, vector<ll> (7000));
    rep (i, n + 1) dp[i][0] = i + 1;
    rep (i, n) {
        rep (j, s + 1) {
            if (j > 0) dp[i + 1][j] = mod(dp[i + 1][j] + dp[i][j]);
            dp[i + 1][j + a[i]] = mod(dp[i + 1][j + a[i]] + dp[i][j]);
        }
    }
    rep (j, s + 1) {
        rep (i, n + 1) {
            eprintf("%4lld", dp[i][j]);
        }
        eprintf("\n");
    }
    ll ans = 0;
    rep (i, n + 1) {
        ans = mod(ans + dp[i][s]);
    }
    eprintf("%lld %lld\n", dp[n][s], ans);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 164608
import java.io.*;
public class Main
{
	public static void main(String args[])
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());
			
		
			String[] str = br.readLine().split(" ");
			int num[] = new int[n];
			int ave = 0;

			for(int i=0;i<n;i++){
				num[i]=Integer.parseInt(str[i]);
				ave+=num[i];
			}
			
			double ave2 = (double)(ave)/n;
			int ave3 = (int)Math.round(ave2);
			int cost=0;

			for(int i=0;i<n;i++){
				double buf = ave2 - num[i];
				if(buf <= 0.5 && -0.5 <= buf){
				}else{
					cost+=Math.pow((num[i]-ave3),2);
				}
			}

			System.out.println(cost);
		} catch (Exception e) {
			// System.out.println(e);
        }
	}
}


Measured memory_bytes: 8020
#include <stdio.h>
#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

void solve() {
    int n; cin >> n;
    char s[n + 1]; cin >> s;

    long nR = 0;
    long nG = 0;
    long nB = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            nR++;
        } else if (s[i] == 'G') {
            nG++;
        } else if (s[i] == 'B') {
            nB++;
        } else {
        }
    }

    long w = nR * nG * nB;

    long z = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            int k = 2 * j - i;
            if (k < n && j < k) {
                if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                    z++;
                }
            }
        }
    }

    cout << w - z << endl;
}

int main() {

#ifdef DEV
    std::ifstream in("AtCoder/ABC162/RGB Triplets.input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int A,B,C,X;
	cin>>A>>B>>C>>X;
	int ans=0;
	FDS(i,A+1){
		FDS(j,B+1){
			FDS(k,C+1){
				if(i*500+j*100+k*50==X){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define MAX 200002

int h;
int w;
int n;

char buf[MAX];

string s;
string t;

int sx;
int sy;

vector<pair<int, int> > rng;

bool solve() {
	rng.clear();
	int lef = 0;
	int rig = w - 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (t[i] == 'L') {
			rig++;
			rig = min(rig, w - 1);
		}
		if (t[i] == 'R') {
			lef--;
			lef = max(lef, 0);
		}
		if (lef > rig)return false;
		if (s[i] == 'L') {
			lef++;
		}
		if (s[i] == 'R') {
			rig--;
		}
		rng.push_back(make_pair(lef, rig));
		if (lef > rig) {
			return false;
		}
		
	}
	reverse(rng.begin(), rng.end());
	return lef<=sy&&sy<=rig;
}


int main() {
	cin >> h >> w >> n;
	cin >> sx >> sy;
	sx--;
	sy--;
	scanf("%s", buf);
	s = buf;
	scanf("%s", buf);
	t = buf;
	if (solve() == false) {
		puts("NO");
		return 0;
	}
	swap(sx, sy);
	swap(h, w);
	map<char, int> mp;
	mp['U'] = 'L';
	mp['R'] = 'X';
	mp['L'] = 'X';
	mp['D'] = 'R';
	for (auto &el : s) {
		el = mp[el];
	}
	for (auto &el : t) {
		el = mp[el];
	}
	if (solve() == false) {
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int main()
{
    ll n, a, b;

    scanf("%lld %lld %lld", &n, &a, &b);

    if (abs(a - b) % 2 == 0) {
        puts("Alice");
    }
    else {
        puts("Borys");
    }

    return 0;
}


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

int main(){
  int n,k;
  int s[100];
  bool f;

  while( cin>>n>>k &&(n||k) ){
    for( int i=0;i<k;i++ )
      cin >> s[i];

    f=true;
    for( int i=0;i<n;i++ ){
      for( int j=0,l;j<k;j++ ){
	cin >> l;
	s[j] -= l;
	if( s[j]<0 ) f=false;
      }
    }
    if( f ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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 nextInt() { int x; scanf("%d", &x); return x;}


ll get(string s) {
  ll ans = 0;
  int len = 1;
  for (int i = 1; i < (int)s.size(); i++) {
    if (s[i] == s[i-1]) {
      len++;
    } else {
      ans += len / 2;
      len = 1;
    }
  }
  ans += len / 2;
  return ans;
}

int main2() {
  string s; cin >> s;
  ll K; cin >> K;

  string sorg = s;

  if (s == string(s.size(), s[0])) {
    cout << (s.size() * K) / 2 << endl;
    return 0;
  }

  int rot = 0;
  if (K >= 2) {
    while (s[0] == s.back()) {
      rot++;
      rotate(s.begin(), s.begin() + 1, s.end());
    }
  }
  ll ans = 0;
  ans += get(s) * (K-1);
  ans += get(sorg.substr(0, rot));
  ans += get(sorg.substr(rot));
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

string s,t;
vi idx[26];

int main()
{
  cin >> s >> t;

  forn(i,s.size()) {
    idx[s[i]-'a'].push_back(i);
  }

  ll cnt = 0;
  int si = 0;
  forn(i,t.size()) {
    int ti = t[i]-'a';
    if (idx[ti].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    auto it = lower_bound(idx[ti].begin(),idx[ti].end(),si);
    if (it == idx[ti].end()) {
      cnt++;
      it = lower_bound(idx[ti].begin(),idx[ti].end(),0);
    }
    si = *it + 1;
  }

  cout << cnt*s.size()+si << endl;

  return 0;
}


Measured memory_bytes: 1216
fun main(args:Array<String>){
    val n = readLine()!!.trim().toInt()
    val arms = Array(n){readLine()!!.trim().toLong()}.sortedDescending().toLongArray()
    var sum = 1L
    for (i in 0 until n){
        if (i / 4 < arms[i]) sum += arms[i] - i / 4
    }
    println(sum)
}


Measured memory_bytes: 26616
package main

import (
	"fmt"
)

func main() {
	solved := "No"
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 9; i++ {
		if (n%i==0 && n/i <= 9) {
			solved = "Yes"
			break
		}
	}
	fmt.Println(solved)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed <<setprecision(10);
    cout << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << '\n';

    return 0;
}


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

using ll = long long;
const ll INF = 1e18;

int N;
ll s[100010], t[100010];

using range = tuple<ll,ll,ll>; // l,r,acc
set<range> S;
ll acc = 0;

ll sum(ll x){
    auto it = S.upper_bound(make_tuple(x,-INF,-INF));
    --it;
    // cout << x << ' ';
    // cout << "t " << get<0>(*it) << ' ' << get<1>(*it) << ' ' << get<2>(*it) << endl;
    ll res = get<2>(*prev(it)) + min(get<1>(*it), x) - get<0>(*it);
    return res;
}

int main(){
    ll T;
    while(cin >>T){
        acc = 0;
        S.clear();

        cin >> N;
        S.emplace(-INF-1, -INF-1, 0);
        S.emplace(-INF, -INF, 0);
        rep(i,N){
            cin >> s[i] >> t[i];
            acc += t[i] - s[i];
            S.emplace(s[i], t[i], acc);
        }
        S.emplace(INF, INF, acc);
        ll ans = 0;
        rep(i,N){
            ans = max(ans, sum(s[i]+T) - sum(s[i]));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 10900
#include <bits/stdc++.h>
using namespace std;
int x, n, p[238]; map<int, int> mp;
signed main() {
	scanf ("%d %d", &x, &n);
	for (int i = 1; i <= n; ++i) scanf ("%d", p + i), mp[p[i]] = 1;
	int l = x, r = x;
	while (1) {
		if (!mp[l]) return printf ("%d\n", l), 0;
		if (!mp[r]) return printf ("%d\n", r), 0;
		--l, ++r;
	}
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, ac, wa, tle, re;
  ac =0;
  wa=0;
  tle=0;
  re=0;
    string r;
    cin >> N;

    for (int i = 1; i <= N; i++)
    {
        cin >> r;
        if (r == "AC")
            ac++;
        else if (r == "WA")
            wa++;
        else if (r == "TLE")
            tle++;
        else if (r == "RE")
            re++;
    }
    cout << "AC "
         << "x " << ac << endl;
    cout << "WA "
         << "x " << wa << endl;
    cout << "TLE "
         << "x " << tle << endl;
    cout << "RE "
         << "x " << re << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

#define ll long long
#define ld long double
#define REP(i,a,b) for(int i=a;i<b;i++)
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007

const int N = 1e5 + 5;

using namespace std;

ll dp[1005][1005];

int main() {

	HS
	int n, m;
	cin >> n >> m;
	char arr[1005][1005];

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}

	dp[1][1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (arr[i][j] != '#') {
				dp[i][j] += (dp[i][j - 1] % mod + dp[i - 1][j] % mod) % mod;
			}
		}
	}

	cout << dp[n][m]%mod;

	return 0;
}

Measured memory_bytes: 9088
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	
	h := make([]int, n)
	
	for i := range h {
		fmt.Scan(&h[i])
	}
	
	peaks := make([][]int,n)
	
	a,b := 0, 0
	for i := 0; i < m; i++{
		fmt.Scan(&a,&b)
		a--
		b--
		peaks[a] = append(peaks[a], h[b])
		peaks[b] = append(peaks[b], h[a])
	}
	//fmt.Println(peaks)

	cnt := 0
	for i := range peaks {
		if len(peaks[i]) == 0 {
			cnt++
		} else {
			//fmt.Println("before ",peaks[i])
			sort.Sort(sort.Reverse(sort.IntSlice(peaks[i])))
			//fmt.Println("after ",peaks[i])
        	//fmt.Println(peaks[i][0],h[i])
			if peaks[i][0] < h[i] {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 14028
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(n,k,p_lst):
    pp_lst = sorted(p_lst)
    return sum(pp_lst[0:k])

def main():
    n,k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    
    ans = str(solve(n,k,p_lst))
    print(ans)

    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5 4
50 100 80 120 80
"""
_EXPECTED = """\
210
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 9276
#C
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

L=[0 for i in range(N)]
for i in range(N-2,-1,-1):
    L[i]+=A[i+1]+L[i+1]

ans=0
for i in range(N-1):
    ans+=A[i]*L[i]
    ans%=mod
print(ans)

Measured memory_bytes: 102156
from collections import Counter
n=int(input().rstrip())
d=dict()
for _ in range(n):
    s=input().rstrip()
    if s not in d:
      d[s]=1
    else:
      d[s]+=1
ans=Counter(d).most_common()
ans.sort(key=lambda x: (-x[1],x[0]))
m=ans[0][1]
for i in ans:
    if i[1]!=m:
        break
    print(i[0])

Measured memory_bytes: 59664
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, A, B, k, l, i, j;
	scanf("%lld%lld%lld", &N, &A, &B);
	if(A + B > N + 1 || A * B < N){
		printf("-1\n");
	}
	else if(A == 1){
		for(i = N; i > 0; i--){
			printf("%lld ", i);
		}
		printf("\n");
	}
	else{
		k = (N - B) / (A - 1);
		if((N - B) % (A - 1) == 0){
			l = 0;
		}
		else{
			l = k + N - k * A - B + 1;
		}
//		printf("(k, l) = (%lld, %lld)\n", k, l);
		for(i = 1; i <= k; i++){
			for(j = 1; j <= A; j++){
				printf("%lld ", N - i * A + j);
			}
		}
		for(i = 1; i <= l; i++){
			printf("%lld ", N - k * A - l + i);
		}
		for(i = N - k * A - l; i > 0; i--){
			printf("%lld ", i);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<b)
		{
			System.out.printf("a < b\n");
		}
		else if(a>b)
		{
			System.out.printf("a > b\n");
		}
		else
		{
			System.out.printf("a == b\n");
		}
	}
}

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

int main() {
	int n = 0;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int asum = 0, bsum = 0;
		int a[10000], b[10000];
		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
			if (a[i] > b[i]) {
				asum += a[i] + b[i];
			}
			else if (a[i] < b[i]) {
				bsum += a[i] + b[i];
			}
			else {
				asum += a[i], bsum += b[i];
			}
		}
		cout << asum <<" "<< bsum << endl;
	}
}


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

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j] and L[i]!=L[j] and L[j] != L[k] and L[k] != L[i]:
                ans += 1
                # print(L[i], L[j], L[k])
print(ans)

Measured memory_bytes: 9208
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
using namespace std;

#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

int main()
{
    long long a,b;
    for (; scanf("%lld%lld",&a,&b)!=EOF; )
    {
        int g=1;
        while(a*2<=b) a*=2LL,++g;
        printf("%d\n",g);
    }
    return 0;
}



Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
using namespace std;
using ll =long long ;
const ll maxn=1e5+5,inf=1e18+5;
ll n,m,h[maxn],ans,a,b;
vector <ll> adj[maxn];
bool is;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=0;i<m;i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		for(int j:adj[i]){
			if(h[j]>=h[i]){
				is=1;
			}
		}
		if(!is)ans++;
		is=0;
	}
	cout<<ans;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l < r)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))

#define POS(i,j) (((i)%b)*(m+1)+(j))

const int b=54;
short *dp=NULL;
char *ans=NULL;
int top=0;
void calc(char *s,char *t,int n,int m,int *nextN,int *nextM){
  memset(dp,0,(b+1)*(m+1)*sizeof(short));
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if(s[i]==t[j]){
	dp[POS(i+1,j+1)]=dp[POS(i,j)]+1;
      } else {
	dp[POS(i+1,j+1)]=MAX(dp[POS(i+1,j)],dp[POS(i,j+1)]);
      }
    }
  }
  i=n;
  j=m;
  while(i>MAX(0,n-b) && j>0){
    if(s[i-1]==t[j-1]){
      ans[top++]=s[i-1];
      i--;
      j--;
    } else if(dp[POS(i,j)]==dp[POS(i,j-1)]){
      j--;
    } else {
      i--;
    }
  }
  *nextN=i;
  *nextM=j;
}

void run(void){
  char *s=(char *)calloc(3001,sizeof(char));
  char *t=(char *)calloc(3001,sizeof(char));
  scanf("%s",s);
  scanf("%s",t);
  int n=strlen(s);
  int m=strlen(t);
  dp=(short *)calloc((b+1)*(m+1),sizeof(short));
  ans=(char *)calloc(n+1,sizeof(char));
  while(n>0 && m>0){
    calc(s,t,n,m,&n,&m);
  }
  while(top>0){
    putchar(ans[--top]);
  }
  putchar('\n');
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int H, A;
int ans;

void resolve()
{
    cin >> H >> A;

    ans = (H - 1) / A + 1;
    cout << ans << endl;
}

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


Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    c = 0
    for j in range(N):
        if S[j] == i[c]:
            c += 1
        
        if c == 3:
            ans += 1
            break

print(ans)

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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    ll maxi = 0;
    vector<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first;
    rep(i, N) cin >> A[i].second;
    rep(i, 1LL << N) {
        ll X = 0, Y = 0;
        rep(j, N) {
            if(i >> j & 1) X += A[j].first, Y += A[j].second;
        }
        maxi = max(maxi, X - Y);
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
bool check(char x)
{
    if (x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o')
        return true;
    else
        return false;
}
int main()
{
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        vector<string> str;
        string s[100];
        char ch[100];
        rep(i, n)
        {
            cin >> s[i];
            int pos = 0;
            rep(j, s[i].size())
            {
                if (j == 0)
                {
                    ch[pos] = s[i][j];
                    pos++;
                }
                if (check(s[i][j]))
                {
                    ch[pos] = s[i][j + 1];
                    pos++;
                }
            }
            string tmp(ch, pos);
            str.push_back(tmp);
        }
        //rep(i, str.size()) cout << str[i] << endl;
        int k = 51;
        int ans = -1;
        while (k--)
        {
            vector<string> code;
            rep(i, str.size())
            {
                if (str[i].size() < k)
                    code.push_back(str[i]);
                else
                    code.push_back(str[i].substr(0, k));
            }
            //rep(i, code.size()) cout << code[i] << endl;
            bool flag = false;
            rep(i, code.size())
            {
                for (int j = i + 1; j < code.size(); j++)
                {
                    if (code[i] == code[j])
                        flag = true;
                }
            }
            if (flag == false)
                ans = k;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int A, B, C;
vi arr;

int main() {
  io();
  
  cin >> A >> B >> C;
  arr.pb(A); arr.pb(B); arr.pb(C);
  qsort(arr);
  if(arr[0] + arr[1] == arr[2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  return 0;
}

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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
#define MOD 1000000007
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n,m;
	cin>>n>>m;
	ll ans=min(n,m/2);
	ll t=m-(ans*2);
	// cout<<t;
	cout<<ans+t/4;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

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

  int N, M;
  cin >> N >> M;
  vector<long long> a(N), b(N), c(M), d(M), checkpoint(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int i = 0; i < M; ++i) {
    cin >> c.at(i) >> d.at(i);
  }

  for (int i = 0; i < N; ++i) {
    long long min_place = 1000000000;
    for (int j = 0; j < M; ++j) {
      long long place = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
      if (min_place > place) {
        checkpoint.at(i) = j + 1;
        min_place = place;
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    cout << checkpoint.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){
double a,b,c,d,e,f;
double x,y;


while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){





x=(c*e-b*f)/(a*e-b*d);
y=(a*f-c*d)/(a*e-b*d);

if(x==0){x=0;}
if(y==0){y=0;}
printf("%.3lf %.3lf\n",x,y);
}
return 0;
}

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

typedef long long ll;
const int N = 1e5;

string s;
int n;
map<string,int> ada;
queue<string> qs;

bool cek(int x){
	ada.clear();
	while(!qs.empty()) qs.pop();
	for(int i=x;i<=n-x;i++){
		string tmp = "";
		for(int j=0;j<x;j++){
			tmp.push_back(s[i+j]);
		}
		ada[tmp]++;
		qs.push(tmp);
	}
	for(int i=0;i<=n-x-x;i++){
		string tmp = "";
		for(int j=0;j<x;j++){
			tmp.push_back(s[i+j]);
		}
		if(ada.find(tmp) != ada.end()) return 1;
		tmp = qs.front(); qs.pop();
		ada[tmp]--;
		if(ada[tmp] == 0) ada.erase(tmp);
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> s;
	int l = 1;
	int r = n/2;
	int ans = 0;
	while(l<=r){
		int mid = (l+r)/2;
		if(cek(mid)){
			ans = mid;
			l = mid+1;
		} else {
			r = mid-1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6612
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool contain(int mask, int position){
  if((mask&(1<<position))) return true;
  else return false;
}


signed main(){
	string s; cin>>s;
  int n = s.size()-1;

  ll sum = 0;
  for(int mask=0; mask<(1<<n); mask++){
    int l = 0, r;
    ll tmp = 0;
    for(r=0; r<n; r++){
      if(contain(mask,r)){
        string t = s.substr(l,r-l+1);
        ll num = stoll(t);
        tmp += num;
        l = r+1;
      }
    }
    string t = s.substr(l,r-l+1);
    ll num = stoll(t);
    tmp += num;
    sum += tmp;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i > 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)

Measured memory_bytes: 61924
#                               #
    # author : samars_diary #
    # 19-09-2020 │ 17:37:43 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=i()
    if a[-1]=='s':
        print(a+'es')
    else: 
        print(a+'s')

for _ in range(1):
    solve()

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int X; cin >> X;
	print( (X >= 30) ? "Yes" : "No");
}

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

int main() {
  int l, r, a, b, c, d;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (l > r) cout << "Left" << endl;
  else if (l == r) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  ll n;
  cin >> n;

  string s = "";
  while(n!=0){
    int mod = n%26;
    if(mod==0){
      n--;
      mod = 26;
    }
      s.push_back('a'-1+mod);
    n/=26;
  }
  reverse(ALL(s));
  cout << s << endl;
}


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

using namespace std;
int dp[100008];vector<int> v[100008];
int dfs(int i)
{
	if(dp[i]!=-1)
	return(dp[i]);
	int p = 0 ; 
	for(int j = 0 ; j<v[i].size(); j++)
	{
		p = max(p,dfs(v[i][j]));
	}
	return(dp[i]=(p+1));
}

int main()
{
	int x , y, n , m ; 
	cin>>n>>m;
	 int vis[n+1]= {0};
	for(int i = 1; i<=m ; i++)
	{
		cin>>x>>y ; 
		v[x].push_back(y);
		vis[y]= 1; 
	}
	int a[n+1];
int mx = 0 ; 
memset(dp,-1,sizeof(dp));
  for(int p = 1; p<=n ; p++)
  {  if(vis[p])
  continue; 
  mx = max(mx,dfs(p));
  
	}
	cout<<mx-1;  return(0);
}


Measured memory_bytes: 11136
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let p = 1000000007;
    let v = prime_factorize(m);

    let max = 510000;

    let mut fac = vec![0; max];
    let mut finv = vec![0; max];
    let mut inv = vec![0; max];

    com_init(&mut fac, &mut finv, &mut inv, max, p);

    let mut ans = 1;
    for &nv in &v {
        let tmp = com(n - 1 + nv.1, nv.1, &fac, &finv, p);
        ans = ans * tmp % p;
    }

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

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a += 1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}

fn com_init(
    fac: &mut Vec<isize>,
    finv: &mut Vec<isize>,
    inv: &mut Vec<isize>,
    max: usize,
    m: isize,
) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;

    let mut i = 2;
    while i < max {
        fac[i] = fac[i - 1] * i as isize % m;
        inv[i] = m as isize - inv[m as usize % i] * (m / i as isize) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
        i += 1;
    }
}

fn com(n: usize, k: usize, fac: &Vec<isize>, finv: &Vec<isize>, m: isize) -> isize {
    if n < k {
        return 0;
    }
    fac[n] * (finv[k] * finv[n - k] % m) % m
}


Measured memory_bytes: 13920
#include <stdio.h>

int main(void)
{
	int i, j, N, M, array[1001], num[1001] = {0}, cri, max;
	
	scanf("%d %d", &N, &M);
	
	for (i = 1; i <= N; i++){
		scanf("%d", &array[i]);
	}
	
	for (i = 1; i <= M; i++){
		scanf("%d", &cri);
		
		j = 1;
		while (1){
			if (array[j] <= cri){
				num[j]++;
				break;
			}
			j++;
		}
	}
	
	max = 1;
	for (i = 2; i <= N; i++){
		if (num[i] > num[max]){
			max = i;
		}
	}
	
	printf("%d\n", max);
	
	return (0);
}

Measured memory_bytes: 604
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
	char S[110];
	long long K;
	cin>>S;
	cin>>K;
	int i=0;
	for(i=0;i<110;i++){
		if(S[i]!='1'){
			break;
		}
		if(i==109)i=1000;
	}
	if(i==1000)cout<<S[0];
	else if(i>=K)cout<<1;
	else cout<<S[i];
	return 0;
}
		
	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;


int main() 
{	
	int n, a, b, p, c1 = 0, c2 = 0, c3 = 0;
	cin >> n;
	cin >> a >> b;
	for (int i = 0; i < n; ++i)
	{
		cin >> p;
		if(p <= a)
		{
			c1++;
		}
		else if(p <= b)
		{
			c2++;
		}
		else
		{
			c3++;
		}
	}
	cout << min({c1, c2, c3});
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a;
set<int> st;

int main(){
	cin >> n;
	REP(i,0,n) cin >> a,st.insert(a);
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, v, p; cin >> n >> m >> v >> p;
    vector<int> a(n); rep (i, n) cin >> a[i];
    sort(all(a), greater<int>());
    ll ans = 0, piv = a[p - 1];
    if (v <= p) {
        while (ans < n && a[ans] + m >= piv) ans++;
    } else {
        int ok = -1, ng = n;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            if (a[med] + m < piv) {ng = med; continue;}
            ll rest = 0, vv = v - (n - med);
            rep (j, med) rest += max((j < p - 1 ? m : 0LL), (a[med] + m) - a[j]);
            eprintf("%d, %lld %lld\n", med, rest, m * vv);
            if (rest >= m * vv) ok = med;
            else ng = med;
        }
        ans = ok + 1;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N;
string s1, s2;
vector<int> D;
ulli p;

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> N;
	cin >> s1 >> s2;
	for(int i = 0; i < N; i++){
		if(s1[i] == s2[i]) D.push_back(1);
		else if(s1[i] == s1[i+1]){
			D.push_back(2);
			i++;
		}
	}
	if(D[0] == 1) p = 3;
	if(D[0] == 2) p = 6;
	for(int i = 1; i < (int)D.size(); i++){
		if(D[i] == 1 && D[i-1] == 2) continue;
		else if(D[i] == 2 && D[i-1] == 2) p = p*3%1000000007;
		else p = p*2%1000000007;
	}
	cout << p%1000000007;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

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

    int n; cin >> n;
    ll a[n];
    F0R(i, n) {
        cin >> a[i];
        if(a[i]==0) {
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans = 1;
    ll m=1e18;
    F0R(i, n) {
        if(a[i]<=m/ans) {
            ans *= a[i];
        } else {
            cout << -1 << nl;
            return 0;
        }

    }



    cout << ans << nl;

	return 0;
}




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

while True:
    a, op, b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    else:
        print(int(a) // int(b))


Measured memory_bytes: 5600