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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], int n) {
    string result = "{";
    REP(i, 0, n) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

string bin_string(int x) {
    const int d = 64;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

vector<int> getZ(string s) {
    int n = s.size();
    vector<int> z(n);
    int x = 0, y = 0;
    REP(i, 1, n) {
        z[i] = max(0LL, min(z[i-x], y-i+1));
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            x = i;
            y = i+z[i];
            ++z[i];
        }
    }
    return z;
}

int powa(int base, int exp) {
    if (exp<=0) return 1;
    if (base<=0) return 0;
    int val = powa(base, exp>>1);
    val = val*val % MOD;
    if (exp&1) {
        val = val*base % MOD;
    }
    return val;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    int a[n];
    REP(i, 0, n) cin >> a[i];

    int res = 0;
    int tk = 1;
    REP(d, 0, 60) {
        int cnt[2] = {};
        for (int i : a) ++cnt[(i&1LL<<d)!=0];
        res += cnt[0]*cnt[1] % MOD*tk % MOD;
        tk = (tk+tk)%MOD;
        res %= MOD;
    }
    cout << res;
}

Measured memory_bytes: 2560
n,k=map(int,input().split())
s=input()
rl=s.count("RL")
lr=s.count("LR")
cnt=0
for i in range(n):
    if (i>0 and s[i]=="L" and s[i-1]=="L") or (i<n-1 and s[i]=="R" and s[i+1]=="R"):
        cnt+=1
for i in range(k):
    if min(rl,lr)>0:
        cnt+=2
        rl-=1
        lr-=1
    elif rl>0:
        cnt+=1
        rl-=1
    elif lr>0:
        cnt+=1
        lr-=1
    else:
        break
print(cnt)

Measured memory_bytes: 40048
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();   
        if( Character.isUpperCase( str.charAt( 0 ) ) ) {
            System.out.println( "A" );
            }
        else {
            System.out.println( "a" );
            }
        scan.close();
    }
}



Measured memory_bytes: 35416
#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;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  ll s = 0;
  srep(i,1,K+1) {
    srep(j,1,K+1) {
      srep(k,1,K+1) {
        s += __gcd(i,__gcd(j,k));
      }
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int n,m,q,a[55][4],b[11],c=0,d;

main(){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<q;i++){
        for(int j=0;j<4;j++) scanf("%d",&a[i][j]);
    }

    for(b[0]=1;b[0]<=m;b[0]++){
        for(b[1]=b[0];b[1]<=m;b[1]++){
            for(b[2]=b[1];b[2]<=m;b[2]++){
                for(b[3]=b[2];b[3]<=m;b[3]++){
                    for(b[4]=b[3];b[4]<=m;b[4]++){
                        for(b[5]=b[4];b[5]<=m;b[5]++){
                            for(b[6]=b[5];b[6]<=m;b[6]++){
                                for(b[7]=b[6];b[7]<=m;b[7]++){
                                    for(b[8]=b[7];b[8]<=m;b[8]++){
                                        for(b[9]=b[8];b[9]<=m;b[9]++){
                                            d=0;
                                            for(int i=0;i<q;i++){
                                                if(b[a[i][1]-1] - b[a[i][0]-1] == a[i][2]){
                                                    d += a[i][3];
                                                }
                                            }
                                            c = max(c, d);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 1736
//author Eterna
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#include<unordered_map>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 100;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
int arr[maxn + 5], n;
bool flag;
stack<int> res;
int main()
{
	n = read_int();
	for (int i = 1; i <= n; ++i)arr[i] = read_int();
	for (int i = n; i > 0; --i) {
		for (int j = i; j > 0; --j) {
			if (arr[j] > i) {
				flag = true;
				break;
			}
			if (arr[j] == j) {
				res.push(j);
				for (int k = j; k < n; ++k)arr[k] = arr[k + 1];
				break;
			}
		}
		if (flag)break;
	}
	if (flag)cout << "-1" << endl;
	else {
		for (int i = 1; i <= n; ++i) {
			printf("%d\n", res.top());
			res.pop();
		}
	}
	//system("pause");
	return 0;
}

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

using P = pair<int, int>;

const int INF = (1 << 28);
const int MAX_N = 100010;

int lb[MAX_N], ub[MAX_N];
vector<int> graph[MAX_N];

int vid[MAX_N];

int main() {
    int n, k;
    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    fill(lb, lb + n, -INF);
    fill(ub, ub + n, INF);

    queue<P> que1, que2;
    cin >> k;
    for (int i = 0; i < k; i++) {
        int v, p;
        cin >> v >> p;
        v--;
        lb[v] = p; ub[v] = p;
        que1.push(make_pair(v, p));
        que2.push(make_pair(v, p));
    }

    int start;
    while (!que1.empty()) {
        P elt = que1.front(); que1.pop();
        int v = elt.first,
            p = elt.second;
        if (lb[v] > p) continue;
        for (auto nv : graph[v]) {
            if (lb[nv] < p - 1) {
                lb[nv] = p - 1;
                que1.push(make_pair(nv, p - 1));
            }
        }
        start = v;
    }

    while (!que2.empty()) {
        P elt = que2.front(); que2.pop();
        int v = elt.first,
            p = elt.second;
        if (ub[v] < p) continue;
        for (auto nv : graph[v]) {
            if (ub[nv] > p + 1) {
                ub[nv] = p + 1;
                que1.push(make_pair(nv, p + 1));
            }
        }
    }

    for (int v = 0; v < n; v++) {
        if (lb[v] > ub[v]) {
            cout << "No" << endl;
            return 0;
        }
    }
    fill(vid, vid + n, INF);

    queue<P> que;
    que.push(make_pair(start, lb[start]));
    vid[start] = lb[start];
    while (!que.empty()) {
        P elt = que.front(); que.pop();
        int v = elt.first,
            p = elt.second;
        for (auto nv : graph[v]) {
            for (int diff = -1; diff <= 1; diff += 2) {
                if (vid[nv] != INF) continue;
                int np = p + diff;
                if (np < lb[nv] || np > ub[nv]) continue;
                que.push(make_pair(nv, np));
                vid[nv] = np;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (vid[i] == INF) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        cout << vid[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 9216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        int[] c = new int[100001];
        for(int i=0; i<m; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[a[i]]++;
            c[b[i]]++;
        }

        for(int i=0; i<c.length; i++){
            if(c[i] % 2 != 0){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");

    }
}

Measured memory_bytes: 65040
#include <iostream>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b, r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  } else if (l == r) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}

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

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;
}

static const int INF = 1145141919;
const long long INFL = 1LL<<60;

int main()
{
	int n, k;
	cin >> n >> k;
	long long int h[110000];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	long long int dp[110000];
	for (int i = 0; i < 110000; ++i)
	{
		dp[i] = INFL;
	}
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = i - 1; j >= max(0, i - k); --j)
		{
			chmin(dp[i], dp[j]+abs(h[i]-h[j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1920
#[warn(unused_imports)]
use proconio::{
   fastout, input,
};
use std::cmp::min;

#[fastout]
fn main() {
   input! {
      A:usize, B:usize, N:usize
   }
   let a = A % B;
   let k = A / B;
   let x = min(N, B-1);
   let ans = k*x + (a*x)/B;
   println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
s = input()
res = 10**5
cta = 0
ctb = 0
a = [0] * (n)
b = [0] * (n)
#a:i番目までの白の数、b:i番目までの黒の数
for i in range(n):
  if s[i] == ".":
    cta += 1
  else:
    ctb += 1
  a[i] = cta
  b[i] = ctb
#print(b)
#print(a)
for i in range(n):
  res = min(res,b[i]+a[-1]-a[i]) #i番目までの黒の数+i番目以降の白の数
  #print(res)
res = min(res,a[-1],b[-1])
print(res)

Measured memory_bytes: 12776
import collections as c
from fractions import gcd
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
A,B,C,D = ip()
cd = C*D//gcd(C,D)
# print(cd)
ans = B-A+1 - ( B//C - (A+C-1)//C + B//D - (A+D-1)//D - B//cd + (A+cd-1)//cd + 1)
# print(B//C - (A+C-1)//C + 1)
# print(B//D - (A+D-1)//D + 1)
# print(B//cd - (A+cd-1)//cd + 1)
print(ans)

Measured memory_bytes: 5312
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
//---------------------------------------------------------------------------------------------------
ll solve() {
	if (N == 0) {
		if (A[0] == 1) return 1;
		else return -1;
	}

	if (A[0] != 0) return -1;

	ll tot = 0;
	rep(i, 0, N + 1) tot += A[i];

	ll cur = 1;
	ll ans = 1;
	rep(i, 1, N + 1) {
		cur *= 2;

		if (cur < A[i]) return -1;

		ans += min(cur, tot);
		cur = min(cur, tot) - A[i];
		tot -= A[i];
	}
	return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N + 1) cin >> A[i];
	cout << solve() << endl;
}







Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	ll Tnow, Anow;
	Tnow = Anow = 1;
	rep(i, 1, n)
	{
		ll t, a; cin >> t >> a;
		ll x = max((Tnow + t - 1) / t, (Anow + a - 1) / a);
		Tnow = t * x;
		Anow = a * x;
	}
	cout << Tnow + Anow << endl;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> v(1<<n);
    for(int i=0;i<(1<<n);++i) cin>>v[i];
    sort(v.begin(),v.end());
    multiset<int> m;
    for(int i=0;i<(1<<n)-1;++i)m.insert(v[i]);
    vector<int> ret;
    ret.push_back(v[(1<<n)-1]);
    for(int i=0;i<n;++i){
        vector<int> to = ret;
        for(auto vi : ret){
            auto it = m.lower_bound(vi);
            if(it == m.begin()){
                cout << "No" << endl;
                return 0;
            }
            it--;
            to.push_back(*it);
            m.erase(it);
        }
        sort(to.begin(),to.end());
        reverse(to.begin(),to.end());
        swap(to,ret);
    }
    
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 14224
use proconio::input;

fn main() {
    input! {
        x: usize,
        y: usize,
    };
    if x % y == 0 {
        println!("-1");
        return;
    }
    for n in (x + x..).step_by(x) {
        if n % y != 0 {
            println!("{}", n);
            return;
        }
    }
}


Measured memory_bytes: 2136
#include <stdio.h>
int main(){
	int n;
	int n2=0;
	int i;
	int mrem;
	scanf("%d",&n);
	mrem=n;
	for(i=0;i<=10;i++){
		n2=n2+n%10;
		n=(n-n%10)/10;
		}
	if(mrem%n2==0)
	{
		printf("Yes");
	}
	else{
		printf("No");
		}
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}struct Node{int x,n0,n1;Node(){}Node(int x,int n0,int n1):x(x),n0(n0),n1(n1){}};
inline bool operator<(Node x,Node y){return 1ll*x.n0*y.n1==1ll*x.n1*y.n0?x.n0<y.n0:1ll*x.n0*y.n1<1ll*x.n1*y.n0;}
int n,fa[MAXN],Sum0[MAXN],Sum1[MAXN],f[MAXN],s1,vis[MAXN];ll ans,F[MAXN];
int gf(int x){return f[x]==x?x:f[x]=gf(f[x]);}
inline void Merge(int x,int y){if(gf(x)==gf(y))return;f[gf(y)]=gf(x);}
priority_queue<Node>q;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,2,n)fa[i]=read();
	vis[0]=1;
	Rep(i,1,n){
		int x=read();
		if(x)Sum1[i]=1,q.push(Node(i,0,1));
		else Sum0[i]=1,q.push(Node(i,1,0));
	}Rep(i,1,n)f[i]=i;
	for(int x;!q.empty();){
		Node o=q.top();q.pop();
		if(vis[o.x]||o.n0!=Sum0[o.x]||o.n1!=Sum1[o.x])continue;
		vis[x=o.x]=1;
		if(vis[gf(fa[x])])ans+=F[x]+1ll*s1*Sum0[x],s1+=Sum1[x];
		else{
			int u=gf(fa[x]);
			F[u]+=F[x]+1ll*Sum0[x]*Sum1[u],Sum0[u]+=Sum0[x],Sum1[u]+=Sum1[x];
			q.push(Node(u,Sum0[u],Sum1[u])),Merge(u,x);
		}
	}cout<<ans<<'\n';
	return 0;
}




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

int main()
{
	string s;	cin >> s;
	int flag = 0;
	if(s.length() == 2)
	{
		if(s[0] == s[1])	cout << "1 2" << endl;
		else	cout << "-1 -1" << endl;
	}
	else
	{
		for(int i = 0; i < s.length() - 1; i ++)
		{
			if(s[i] == s[i + 1])
			{
				flag = 1;
				cout << i + 1 << " " << i + 3 << endl;
				break;
			}
			if(i != s.length() - 2 && s[i] == s[i + 2])
			{
				flag = 1;
				cout << i + 1 << " " << i + 3 << endl;
				break;
			}
		}
		if(!flag)
			cout << "-1 -1" << endl;
	}
}

Measured memory_bytes: 512
#ABC 116 B
s = int(input())
count = 1
num_set = {s}
def f(a):
    if a%2 == 0:
        return a/2
    else:
        return 3*a + 1
while (1):
    s = f(s)
    count += 1
    if s in num_set:
        print(count)
        break
    else:
        num_set.add(s)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    sort(A, A+N, greater<ll>());
    ll arr[100010] = {};
    rep(i,0,N/2){
        arr[2 * i + 1] = A[i];
    }
    ll ans = 0;
    if(N == 2){
        print(abs(A[0] - A[1]));
        return 0;
    }
    if(N % 2 == 1){
        ll val = (N-1)/2;
        if(val == 1){
            ans += A[0] - A[2];
            ans += max(abs(A[0]-A[1]), abs(A[1] - A[2]));

        }else{
            rep(i,0,val-2){
                ans += 2 * A[i];
            }
            rep(i,val-2, val){
                ans += A[i];
            }
            rep(i,0,val-1){
                ans -= 2 * A[N-1-i];
            }
            ll amari1 = A[val];
            ll amari2 = A[val + 1];
            ans += abs(A[val-2] - amari2);
            ans += max(abs(amari2 - amari1), abs(A[val-1] - amari1));
        }

    }else{
        ll val = N/2;
        rep(i,0,val-2){
            ans += 2 * A[i];
        }
        rep(i,val-2, val){
            ans += A[i];
        }
        rep(i,0,val-1){
            ans -= 2 * A[N-1-i];
        }
        ll amari = A[val];
        ans += max(abs(A[val-2] - amari), abs(A[val-1] - amari));

    }
    print(ans);
    // ll lv = -1;
    // ll rv = -1;
    // ll ans = 0;

    // rep(i,0,N/2){
    //     if(i == 0){
    //         lv = A[i];
    //         rv = A[i];
    //     }else{
    //         ll val_left = abs(lv - A[i]);
    //         ll val_right = abs(rv - A[i]);
    //         if(val_left >= val_right){
    //             lv = A[i];
    //             ans += val_left;
    //         }else{
    //             rv = A[i];
    //             ans += val_right;
    //         }
    //     }
    //     ll val_left = abs(lv - A[N-1-i]);
    //     ll val_right = abs(rv - A[N-1-i]);
    //     if(val_left >= val_right){
    //         lv = A[N-1-i];
    //         ans += val_left;
    //     }else{
    //         rv = A[N-1-i];
    //         ans += val_right;
    //     }

    // }
    // if(N % 2 == 1){
    //     ll mid = (N-1)/2;
    //     ll left_tmp = abs(lv - A[mid]);
    //     ll right_tmp = abs(rv - A[mid]);
    //     ll max_val = max(left_tmp, right_tmp);
    //     ans += max_val;
    // }
    // print(ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  float N;
  int change_amt;
  float residue;
  cin>>N;
  residue=ceil(N/1000);
  
  change_amt=(1000*residue)-N;
  cout<<change_amt;
  
  return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int K, X;

int main() {
    cin >> K >> X;
    bool first = true;
    for (int i=X-(K-1); i<X+K; i++) {
        if (i < -1000000 || i > 1000000) {
            continue;
        }
        if (first == true) {
            cout << i;
            first = false;
        } else {
            cout << " " << i;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e5+7;

vector<int> vp[30];
char s1[MAXN],s2[MAXN];

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

    cin >> s1+1 >> s2+1;
    int len1 = strlen(s1+1),len2 = strlen(s2+1);
    rep(i,1,len1) {
        int c = s1[i]-'a';
        vp[c].pb(i);
    }
    ll ans = 0,now = 0;
    rep(j,1,len2) {
        int c = s2[j]-'a';
        if (vp[c].size() == 0) {
            ans = -1;
            break;
        }
        int id = upper_bound(vp[c].begin(),vp[c].end(),now)-vp[c].begin();
        if (id == vp[c].size()) {
            ans += len1-now;
            now = 0;
            j --;
        }else {
            ans += vp[c][id]-now;
            now = vp[c][id];
        }   
    }
    cout << ans << endl;
}




Measured memory_bytes: 1148
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
using namespace std;
const int M=3e5+10;
int idx[M],id[M],n;
vector<int> L,R;
bool cheak(int l,int r){
	L.clear();R.clear();
	for(int i=l+1;i<=r;i+=2)if(idx[i]!=i)return 0;
	for(int i=l;i<=r;i+=2){
		if(idx[i]<=i) R.push_back(idx[i]);
		else L.push_back(idx[i]);
	}
	if(L.size()>=2)
	for(int i=0;i<L.size()-1;i++)if(L[i]>L[i+1])return 0;
	if(R.size()>=2)
	for(int i=0;i<R.size()-1;i++)if(R[i]>R[i+1])return 0;
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		idx[i]=read();id[idx[i]]=i;
		if((idx[i]-i)&1){printf("No\n");return 0;}
	}
	int nl=1,nr=1;
	for(int i=1;i<=n;){
		for(;i<=n;i++){
			if(id[i]>nr)nr=id[i];
			if(i==nr)break;
		}
		if(!cheak(nl,nr)){printf("No\n");return 0;}
		i=nl=nr+1;
		++nr;
	}
	printf("Yes\n");
	return 0;
}


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

using namespace std;

//#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)

#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

ll R, G, B, N;

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

  cin >> R >> G >> B >> N;

  ll ans = 0;

  for(int r=0;R*r<=N;++r) {
    for(int g=0;G*g<=N-R*r;++g) {
      if( (N-R*r-G*g) % B == 0) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;


int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int i;
    string o,e;
    cin>>o>>e;
    int leno = o.length();
    int lene = e.length();

    fo(i, lene) {
        cout<<o[i]<<e[i];
    }
    if(leno>lene) 
        cout<<o[leno-1];

return 0;
}

Measured memory_bytes: 3632
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        aa: [usize; n],
        bb: [usize; m],
    }

    let mut max = 0;

    let mut cumsum_a = vec![0];

    let mut sum_a = 0;
    for a in aa {
        sum_a += a;
        if sum_a > k {
            break;
        }
        cumsum_a.push(sum_a);
    }
    let mut cumsum_b = vec![0];

    let mut sum_b = 0;
    for b in bb {
        sum_b += b;
        if sum_b > k {
            break;
        }
        cumsum_b.push(sum_b);
    }

    let mut b_index = 0;

    for (i, &a) in cumsum_a.iter().enumerate().rev() {
        let rem = k - a;
        for j in b_index..cumsum_b.len() {
            if rem < cumsum_b[j] {
                break;
            }
            b_index = j;
        }
        max = std::cmp::max(i+b_index, max);

    }

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

Measured memory_bytes: 9636
//
// Created by kuroneko on 2019-08-10.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int A, B; cin >> A >> B;
    int p = A + B, s = A - B, m = A * B;

    cout << max(p, max(s, m)) << endl;
    return 0;
}


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

int main()
{
    string n;
    cin >> n;
    int l = n.size();

    int sum = 0;
    for(int i = 0; i < l; i++){
        sum += n[i] - 48;
    }
    if(sum%9) cout << "No";
    else cout << "Yes";

    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n, m;
    cin >> n >> m;
    int A[n][m], b[m];
    rep(i, 0, n) {
        rep(j, 0, m) {
            cin >> A[i][j];
        }
    }
    rep(i, 0, m) {
        cin >> b[i];
    }

    int ans[n] = {0};
    rep(i, 0, n) {
        rep(j, 0, m) {
            ans[i] += A[i][j] * b[j];
        }
    }

    rep(i, 0, n) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #pragma optimize("TKACHENKO-GORYACHENKO")
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
// #pragma comment(linker, "/stack:2000000000")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 2e5;

ll n, m, k, t;

int main() {
    ll q, w, e, a, b, c, d;
    string s;
    cin >> s;
    if (s.length() % 2 != 0) {
        cout << "No";
        return 0;
    }
    for (q = 0; q < s.length(); q += 2) {
        string ds = s.substr(q, 2);
        if (ds != "hi") {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>  
#include <string.h> 
using namespace std;
int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int w = x * 100 + y * 10 + z;
    if (w % 4 == 0)
        cout << "YES";
    else
        cout << "NO";

    
    return 0;
}



Measured memory_bytes: 3616
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100010],n;
inline int read(void)
{
	int x=0,f=1;
     char ch=getchar();
     while(ch>'9'||ch<'0'){
       if(ch=='-') f=-1;
       ch=getchar(); }
     while(ch>='0'&&ch<='9'){
       x=x*10+ch-'0';
       ch=getchar();}
     return x*f;
}
int gcd(int a,int b)
{
     return (b==0)?a:gcd(b,a%b);
}
bool pd()
{
	 long long sum=0;
	 int ex=0,tot=0;
	 for(int i=1;i<=n;++i)
	 {
			sum+=a[i]-1;
			if(a[i]&1) tot++;
			if(a[i]==1) ex=1;
	 }
	 if(ex) return sum%2;
	 if((n-tot)%2) return 1;
	 if(tot==1)
	 {
			int g=0;
			for(int i=1;i<=n;++i) if(a[i]&1) a[i]--;
			for(int i=1;i<=n;++i) g=gcd(g,a[i]);
			for(int i=1;i<=n;++i) a[i]/=g;
			return pd()^1;
	 }
	 return 0;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	if(pd()) puts("First");
 	else puts("Second");
	return 0;
}

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

typedef long long ll;
#define type(a) typeid(a).name();
#define pop() pop_back()
#define push(n) push_back(n)
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl

int main(){
  ll a,b;
  cin >> a >> b;
  ll res = a - (2*b);
  if(res<=0){
	  cout << 0;
  }else{
  cout <<  res;
  }
}  

















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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int w = tx - sx, h = ty - sy;
    string ans = "";

    // Path 1
    // cout << string(w, 'R') << string(h, 'U');
    ans += string(w, 'R') + string(h, 'U');

    // Path 2
    // cout << string(w, 'L') << string(h, 'D');
    ans += string(w, 'L') + string(h, 'D');

    // Path 3
    // cout << 'D' << string(w+1, 'R') << string(h+1, 'U') << 'L';
    ans += "D" + string(w+1, 'R') + string(h+1, 'U') + "L";

    // Path 4
    // cout << 'U' << string(w+1, 'L') << string(h+1, 'D') << 'R';
    ans += "U" + string(w+1, 'L') + string(h+1, 'D') + 'R';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())                                                
a_list = list(map(int, input().split()))
a_list.sort()
cost = 0
min_cost=0
 
for i in range(a_list[0], a_list[-1]):
    for j in range(len(a_list)):
        cost = cost + (a_list[j] - i)**2
 
    if i == a_list[0]:
        min_cost=cost
 
    min_cost = min(cost, min_cost)
    cost = 0
 
print(min_cost)

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

int dfs(vector<vector<int>> &v, int now, int par = -1){
	int r = 0;
	for(auto n:v[now]) if(n != par){
		r ^= dfs(v, n, now) + 1;
	}
	return r;
}

int main(){
	int n;
	cin >> n;
	vector<vector<int>> v(n);
	for(int i = 0; i < n - 1; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		v[x].emplace_back(y);
		v[y].emplace_back(x);
	}
	cout << (dfs(v, 0) ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 11904
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    int k;
    cin>>n>>k;
    string s;
    cin>>s;
    int point=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){point++;}
    }
    for(int i=0;i<k;i++){
        if(point<n-2){
            point=point+2;
        }
        else if(point==n-2){
            point=n-1;
        }
        else{
            break;
        }
    }

    cout<<point<<endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC128
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int P = int.Parse(s[1]);
            
            Console.WriteLine((A * 3 + P) / 2);
        }
    }
}

Measured memory_bytes: 11092
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const isPalindromic = num => {
  const stNum = String(num)
  const revStNum = stNum
    .split('')
    .reverse()
    .join('')

  return stNum === revStNum
}

const ans = () => {
  let count = 0
  for (let i = a; i <= b; i++) {
    count += isPalindromic(i) ? 1 : 0
  }

  console.log(count)
}

ans()


Measured memory_bytes: 13480
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll w,h ;
	cin >> w >> h ;
	vll p(w),q(h) ;
	for(auto &i:p) cin >> i ;
	for(auto &i:q) cin >> i ;
	vector<pll> r ;
	for(int i=0;i<w;i++) r.emplace_back(p.at(i),0) ;
	for(int i=0;i<h;i++) r.emplace_back(q.at(i),1) ;
	ll a=0,b=0 ;
	sort(all(r)) ;
	ll ans = 0 ;
	for(int i=0;i<w+h;i++){
		if(r.at(i).second){
			ans += r.at(i).first*(w+1-a) ;
			b++ ;
		}else{
			ans += r.at(i).first*(h+1-b) ;
			a++ ;
		}
	}
	cout << ans << endl ;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

using namespace std;

int N;
vector<int> l, r;

long long int sum;

int main()
{
	cin >> N;
	l = vector<int>(N);
	r = vector<int>(N);
	for (int i = 0; i < N; i++){
		cin >> l[i] >> r[i];
	}
	
	sum = 0;
	for (int i = 0; i < N; i++){
		sum += (r[i] - l[i] + 1);
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n, a, b, c, d, count;
	while(scanf("%d",&n) !=EOF){
		count =0;
		for(a = 0; a < 10 ;a++){
			for(b = 0; b < 10 ;b++){
				for(c = 0; c < 10 ;c++){
					for(d = 0; d < 10 ;d++){
						if(a + b + c + d == n)
							count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int n,t,p,c=0;
  string s;
  cin>>n>>t;
  queue<pair<string,int> >a;
  while(n--){
    cin>>s>>p;
    a.push(make_pair(s,p));
  }
  while(!a.empty()){
    pair<string,int>b=a.front();
    a.pop();
    if(b.second<=t){
      c+=b.second;
      cout<<b.first<<' '<<c<<endl;
    }
    else{
      b.second-=t;
      c+=t;
      a.push(b);
    }
  }
}


Measured memory_bytes: 6340
import sys

def get_pfn(N):
  e = [0] * (N+1)
  for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
      while cur % j == 0:
        e[j] += 1
        cur //= j
  return e


def num(n, e):
  return len(list(filter(lambda x: x >= n-1, e)))

def main():
  input = sys.stdin.readline
  N = int(input())
  e = get_pfn(N)
  print(num(75, e) +\
        num(25, e) * (num(3, e) - 1) +\
        num(15, e) * (num(5, e) - 1) +\
        num(5, e) * (num(5, e) - 1) * (num(3, e) - 2) // 2)

  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,K = inpl()
L = K.bit_length()

koho = [K]
tmp = 0
for b in reversed(range(L)):
	if (K>>b) & 1:
		tmp += (1<<b)
		koho.append(tmp-1)

nums = [0]*len(koho)
for _ in range(N):
	A,B = inpl()
	for i,k in enumerate(koho):
		if k|A == k:
			nums[i] += B

print(max(nums))


Measured memory_bytes: 4336
N,M,X = list(map(int, input().split()))
A = set(map(int, input().split()))
back = 0
for num in range(0, X):
  if num in A:
    back += 1
forward = 0
for num in range(X+1, N+1):
  if num in A:
    forward += 1
print(min([back,forward]))

Measured memory_bytes: 3064
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [d, n] <- readInts
  print $ solve d n

solve :: Int -> Int -> Int
solve d n = if n == 100
  then 101 * (foldl' (flip $ const (* 100)) 1 [1 .. d])
  else n * (foldl' (flip $ const (* 100)) 1 [1 .. d])

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 380
#include <iostream>
#include <cstring>
using namespace std;
string s,t;
int main(){
	cin>>s;
	t="";
	for(int i=s.length()-1;i>=0;i--)t+=s[i];
	for(int i=0;i<t.length();i++){
		switch(t[i]){
			case 'b':t[i]='d';break;
			case 'd':t[i]='b';break;
			case 'p':t[i]='q';break;
			case 'q':t[i]='p';break;
		}
	}
	if(s==t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

bool flag=false,flag1=false;

int main(){
	char c;
	while((c=getchar()) && c!=EOF){
		if(c=='F' && flag){
			printf("Yes");
			return 0;
		}
		if(c=='C') flag=true;
	}
	printf("No");
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

int main(int argc, char **argv)
{
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

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

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

  ll s = 0;
  for(int i=0; i<n-1; i++) {
    if(i%2 == 0) s += a[i];
    else s -= a[i];
  }

  vector<ll> b(n);
  b[0] = (s + a[n-1])/2;
  b[1] = a[0] - b[0];

  for(int i=2; i<n; i++) {
    b[i] = a[i-1] - b[i-1];
  }

  for(ll x : b) cout << 2*x << ' ';



  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double N;
  cin>>N;
  vector<double> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1;i<N;i++){
    v[0]=(v[0]+v[i])/2;
  }
  cout<<v[0]<<endl;
}

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

int a, b, c;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c;
	cout << min({a + b, a + c, b + c});
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc134/tasks/abc134_e
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  multiset<ll> cs;
  int c = 0;
  REP(i,n) {
    ll a;
    cin >> a;
    auto it = cs.upper_bound(a*-1);
    debug(a, *it,it != cs.end(), cs);
    if (it != cs.end() && *it * -1 < a) {
      debug(1);
      cs.erase(it);
      cs.insert(a*-1);
    } else {
      cs.insert(a*-1);
    }
  }
  debug(cs);
  cout << cs.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
/* B - Popular Vote */

#include <stdio.h>

int main(void){
  int N, M, i, A[100], sum = 0, count = 0;
  scanf("%d %d", &N, &M);
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
    sum += A[i];
  }
  for(i = 0; i < N; i++){
    if(sum % (4 * M) == 0){
      if(A[i] >= sum / (4 * M)){
        count++;
      }
    }else{
      if(A[i] >= sum / (4 * M) + 1){
        count++;
      }
    }
  }
  if(count >= M){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 128