akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String S = br.readLine();
      String s1 = "hi";
      String s2 = "hihi";
      String s3 = "hihihi";
      String s4 = "hihihihi";
      String s5 = "hihihihihi";
      boolean f = S.equals(s1) || S.equals(s2) || S.equals(s3) || S.equals(s4) || S.equals(s5);
      System.out.println(f ? "Yes" : "No");
    }catch(Exception e){
    }
  }
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	ll n;  cin >>n;
	
	if(n%2==0) cout <<n <<endl;
	else cout <<2*n <<endl;
	
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];

  ll ans = 0;
  ll sum = 0;
  // odd is minus
  REP(i, n){
    sum += a[i];
    if(i % 2 == 1){
      if(sum >= 0){
        ans += sum + 1;
        sum = -1;
      }
    }
    else{
      if(sum <= 0){
        ans += 1 + abs(sum);
        sum = 1;
      }
    }
  }

 
  ll ans2 = 0;
  sum = 0;
  // even is minus
  REP(i, n){
    sum += a[i];
    if(i % 2 == 0){
      if(sum >= 0){
        ans2 += sum + 1;
        sum = -1;
      }
    }
    else{
      if(sum <= 0){
        ans2 += 1 + abs(sum);
        sum = 1;
      }
    }
  } 

  cout << min(ans, ans2) << endl;
  //cout << ans << endl;
  //cout << ans2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int n; cin >> n;
  vector<vector<int>> a(2,vector<int>(n));
  rep(i,2) rep(j,n) cin >> a[i][j];
  rep(i,n-1){
    a[0][i+1] += a[0][i];
    a[1][n-i-2] += a[1][n-i-1];
  }
  int ans=0;
  rep(i,n) chmax(ans, a[0][i]+a[1][i]);
  cout << ans;
  
  return 0;
}


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

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

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {

    int r, g, b;
    int N;
    cin >> r >> g >> b;

    N = 100*r + 10*g + 1*b;

    if(N%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 504
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		int n;
		int maxi = 0;
		bool flag = false;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string> s(n + 1);
		vector<int> count(n + 1, 0);
		FOR(i, 1, n) {
			cin >> s[i];
			if (i != 1) {
				RFOR(j, s[i].size() - 1, 0) {
					if (s[i][j] == '.') {
						count[i] = j + 1;
						break;
					}
				}
			}
			
			if (maxi < count[i]) {
				maxi = count[i];
			}
		}

		FOR(i, 0, maxi-1) {
			FOR(j, 1, n) {
				flag = false;

				FOR(k, j+1, n) {
					//cout << j << "  " << k << endl;
					if (count[j] > count[k]) {
						break;
					}
					if (count[j] == count[k]) {
						s[j][count[j] - 1] = '+';
						s[k][count[k] - 1] = '+';
						FOR(l, j+1, k-1) {
							//cout << l << endl;
							if (count[j] - 1 <= s[l].size()) {
								if (s[l][count[j] - 1] == '.') {
									s[l][count[j] - 1] = '|';
								}
							}
							
							
						}
						flag = true;
						break;
					}
				}

				if (flag == false&&count[j]!=0) {
					//cout << j << " " << count[j] - 1 << endl;
					s[j][count[j] - 1] = '+';
				}
			}
		}
		
		FOR(i, 1, n) {
			FOR(j, 0, count[i]-1) {
				if (s[i][j] == '.') {
					s[i][j] = ' ';
				}
			}
		}
		FOR(i, 1, n) {
			cout << s[i] << endl;
		}


	}
	return 0;
}


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

int a[4][4],cnt[4][4];

void solve(int temp){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++) if(a[i][j]==temp) cnt[i][j]++;
	}	
}

int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++) cin>>a[i][j];
	}
	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int temp;
		cin>>temp;
		solve(temp);
	}
	
	for(int i=1;i<=3;i++){
		int ok=0;
		for(int j=1;j<=3;j++) {if(cnt[i][j]) ok++;}
		if(ok==3) {cout<<"Yes\n";return 0;}
	}
	for(int i=1;i<=3;i++){
	  int ok=0;
	  for(int j=1;j<=3;j++) {if(cnt[j][i]) ok++;}
      if(ok==3) {cout<<"Yes\n";return 0;}
	}
	if(cnt[1][1]&&cnt[3][3]&&cnt[2][2]) {cout<<"Yes\n";return 0;}
	else if(cnt[1][3]&&cnt[2][2]&&cnt[3][1]) {cout<<"Yes\n";return 0;}
	cout<<"No\n";
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, input().split())
    a,b,c,d = [],[],[],[]
    for i in range(Q):
        _a,_b,_c,_d = map(int, input().split())
        a.append(_a-1)
        b.append(_b-1)
        c.append(_c)
        d.append(_d)
    ans = 0
    for A in combinations_with_replacement(range(M), N):
        # print(A)
        tmp = 0
        for i in range(Q):
            if A[b[i]] - A[a[i]] == c[i]:
                tmp += d[i]
        ans = max(ans, tmp)
    print(ans)
    return
main()

Measured memory_bytes: 9208
#include <iostream>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    lint sum = 0;
    for (lint i = 1; i <= n; ++i) {
        sum += i * (n - i + 1);
    }

    for (int i = 0; i < n - 1; ++i) {
        lint l, r;
        std::cin >> l >> r;
        if (l > r) std::swap(l, r);
        sum -= l * (n - r + 1);
    }

    std::cout << sum << "\n";
}

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

    solve();

    return 0;
}


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

using namespace std;

using ll = long long;

const int L = 60; 
ll basis[L];

void insert_vec(ll msk) {
    for (int i = L-1; i >= 0; i--) { // large prefered
        if (!(msk&(1ll<<i))) continue;
        if (!basis[i]) {
            basis[i] = msk; return;
        }
        msk ^= basis[i];
    }
}

void solve() {
    int n; cin >> n;
    vector<long long> a(n);
    ll sum = 0;
    for (auto& x: a) {
        cin >> x;
        sum ^= x;
    }
    for (auto& x: a) {
        x -= (x&sum);
        insert_vec(x);
    }
    ll y = 0;
    for (int i = L-1; i >= 0; i--) { // large prefered
        if (!basis[i]) continue;
        if (y & (1ll<<i)) continue;
        y ^= basis[i];
    }
    ll res = (y<<1) + sum;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main(){
  ll n;
  cin>>n;
  
  vector<ll>v(n);
  vector<ll>odd(100000);
  vector<ll>eve(100000);
  ll sum=0;
  for(ll i=0;i<n;i++){
    cin>>v[i];
 if((i+1)%2==0){
eve[v[i]-1]++;
}
    
    else{
      odd[v[i]-1]++;
    }
    if(v[i]==v[0]){
sum++;
    }
    
  }
  if(sum==n){
    cout<<n/2<<endl;
  }
  else{
  
  ll odd2=0;
  ll odd3=0;
  ll eve2=0;
  ll eve3=0;
  for(ll i=0;i<100000;i++){
    if(odd3<odd[i]){
      odd3=odd[i];
      odd2=i;
    }
    
    if(eve3<eve[i]){
      eve3=eve[i];
      eve2=i;
    }
  }
    ll odd4=0;
    ll odd5=0;
    ll eve4=0;
    ll eve5=0;
     for(ll i=0;i<100000;i++){
    if(odd5<odd[i]&&i!=odd2){
      odd5=odd[i];
      odd4=i;
    }
    
    if(eve5<eve[i]&&i!=eve2){
      eve5=eve[i];
      eve4=i;
    }
  }
    
    ll EVE=eve2;
    ll ODD=odd2;
    
    if(eve2==odd2){
      if(eve5>=odd5){
        EVE=eve4;
       
      }
      else{
        ODD=odd4;
     
      }
    }

        
      
  ll ans=0;
  for(ll i=0;i<n;i++){
    if((i+1)%2==0){
      if(EVE+1!=v[i]){
        ans++;
      }
    }
    else{
      if(ODD+1!=v[i]){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  }
}


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

const int INF = 1e9;

int main() {
  long long int X, A = 100;
  cin >> X;
  int cnt = 0;
  while(X > A) {
    A += A / 100; 
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=505;

int n,Mo,f[N][N];

struct P{int l,r,id;}a[N];

bool cmp(P a,P b) {
	int ax,ay,bx,by;
	if (a.id<n) ax=a.l,ay=a.r;else ax=a.r,ay=0;
	if (b.id<n) bx=b.l,by=b.r;else bx=b.r,by=0;
	if (ax!=bx) return ax<bx;
	return ay<by;
}

int main() {
	scanf("%d%d",&n,&Mo);
	fo(i,0,(n<<1)-1) {
		a[i].l=i<n?ceil(sqrt(n*n-i*i))-1:0;
		a[i].r=min((int)sqrt(4*n*n-i*i),(n<<1)-1);
		a[i].id=i;
	}
	sort(a,a+(n<<1),cmp);
	int ans=0;
	fo(k,0,n) {
		fo(i,1,(n<<1)) fo(j,0,min(i,k)) f[i][j]=0;
		f[0][0]=1;int t1=0,t2=0;
		fo(i,1,n<<1) 
			if (a[i-1].id>=n) {
				fo(j,0,min(i,k)) f[i][j]=(ll)f[i-1][j]*(a[i-1].r+1-(t2+j))%Mo;
				t2++;
			} else {
				fo(j,1,min(i,k)) f[i][j]=(ll)f[i-1][j-1]*(a[i-1].l+1-(t2+j-1))%Mo;
				fo(j,0,min(i,k)) (f[i][j]+=(ll)f[i-1][j]*(a[i-1].r+1-(n+t1+(k-j)))%Mo)%=Mo;
				t1++;
			}
		(ans+=(k&1?-1:1)*f[(n<<1)][k])%=Mo;
	}
	printf("%d\n",(ans+Mo)%Mo);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int n[10002],a,k,kk,nn,min1=111111111 ,min2=111111111 ,min3=111111111 ;
  cin>>a;
  for(int j=0;j<a;j++)cin>>n[j];
  kk=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      if(i==j)continue;
      k=1;
      nn=n[i];
      while(nn>=10){
	k++;
	nn=nn/10;
      }
      kk=n[j]*(int)pow(10,k)+n[i];
      //      cout<<kk<<endl;/////////
      if(min1>kk){
	min3=min2;
	min2=min1;
	min1=kk;
      }else if(min2>kk){
	min3=min2;
	min2=kk;
      }else if(min3>kk)min3=kk;
    }
    //cout<<"llllllll"<<endl;///
  }
  cout<<min3<<endl;
  return 0;
}

Measured memory_bytes: 3228
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
MOD = 10**9+7

def dfs(v, c):
    res = -1
    i = 0
    used[v] = 0
    for u in e[v]:
        if used[u] == 1:
            i += 1
            if i == c:
                i += 1
            ans[ord[(u, v)]] = i
            res = max(res, dfs(u, i))
    res = c if res == -1 else res
    res = max(i, res)
    return res

N = int(input())
e = [[] for i in range(N)]
es = defaultdict(int)
ord = defaultdict(int)
ans = [None] * (N-1)
for i in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    e[a].append(b)
    e[b].append(a)
    es[(a, b)] = es[(b, a)] = -1
    ord[(a, b)] = ord[(b, a)] = i
used = [1] * N
print(dfs(0, 0))
print(*ans, sep = '\n')


Measured memory_bytes: 95424
#include<iostream>
int A,B;int main(void){using namespace std;int n,C,D;while(1){cin>>n;if(!n)break;A=0;B=0;for(;n>0;n--){cin>>C;cin>>D;if(C>D){A+=(C+D);}else if(C<D){B+=(C+D);}else{A+=C;B+=D;}}cout<<A<<" "<<B<<endl;}return 0;}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
using namespace std;
int main(){
	int n,s[100000],q,t[50000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	cin>>q;
	for(int i=0;i<q;i++)cin>>t[i];
	int ke;
	for(int i=0;i<q;i++){
		int xl=0,xr=n;
		while(abs(xr-xl)>1){
			int xc=(xr+xl)/2;
			DEB(xc)DEB(s[xc])DEB(xl)DEB(xr)END
			if(s[xc]<=t[i])xl=xc;
			else xr=xc;
			ke=s[xl];
		}
		DEB(xl)DEB(xr)END
		if(ke==t[i]){
			ans++;
			DEB(ke)END
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

//最大公約数
long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}
//最小公倍数
long long lcm(long long a, long long b)
{
    return a / gcd(a, b) * b;
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = b - a + 1;
    ll ca = b / c - (a - 1) / c;
    ll da = b / d - (a - 1) / d;
    ll cd = b / lcm(c, d) - (a - 1) / lcm(c, d);
    cout << (ans - da - ca + cd) << endl;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

a = [[-1] * W for _ in range(H)]

sbs = []
n = 1
for i in range(H):
    si = s[i]
    for j in range(W):
        if si[j] == '#':
            a[i][j] = n
            n += 1
            sbs.append((i, j))

for sb in sbs:
    i, j = sb
    n = a[i][j]
    t, l = i - 1, j - 1
    r = j + 1
    while t > -1:
        if a[t][j] != -1:
            break
        t -= 1
    t += 1
    while l > -1:
        if a[i][l] != -1:
            break
        l -= 1
    l += 1
    while r < W:
        if a[i][r] != -1:
            break
        r += 1
    r -= 1
    for y in range(t, i + 1):
        ay = a[y]
        for x in range(l, r + 1):
            ay[x] = n

for h in range(H - 1, -1, -1):
    if a[h][0] != -1:
        break
h += 1

if h != H:
    for i in range(h, H):
        ai1 = a[i - 1]
        ai = a[i]
        for j in range(W):
            ai[j] = ai1[j]

for i in range(H):
    print(*a[i])


Measured memory_bytes: 14332
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll L, R;

  cin >> L >> R;

#ifdef DEBUG
  cout << "L=" << L << ", R=" << R << endl;
#endif

  ll ans = 0;
  if( R - L >= 2018 ) {
    //cout << "test" << endl;
    ans = 0;
  } else if ( (L%2019) >= (R%2019)) {
    //cout << L%2019 << "..." << R%2019  << endl;
    ans = 0;
  } else {
    L = L%2019;
    R = R%2019;
    ll tmp_min = 2019;
    for(ll i = L; i < R; i++){
      for(ll j = i+1; j <= R; j++){
	if ((i*j) % 2019 < tmp_min ){
	  //cout << tmp_min << ": i=" << i << "j="<< j << ".."<< (i*j) % 2019 << endl;
	  tmp_min = (i*j) % 2019;
	}
      }
    }
    ans = tmp_min;
  }

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


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

int main(int argc, char const* argv[])
{
  int n;
  int m;
  cin >> n;
  cin >> m;
    if (n == m) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  return 0;
}


Measured memory_bytes: 256
def get_prime_factorizations(n):
    """
    [summary]

    Parameters
    ----------
    n : int
        the number factorized by prime numbers.

    Returns
    -------
    dict[int: int]
        prime and exponent pair
        ex.) if n == 40, the function return  {2:3, 5:1} 
    """    
    root_n = int( n**(1/2) )
    primes = {2:0}
    primes.update({i:0 for i in range(3, root_n+1, 2)})
    for i in primes.keys():
        if n == 1:
            primes = {i: v for i, v in primes.items() if v > 0}
            return primes
        # count exponent
        exponent = 0
        while n % i == 0:
            n //= i
            exponent += 1
        # store the prime and exponent
        primes[i] = exponent

    primes = {i: v for i, v in primes.items() if v > 0}

    if n!=1:
        primes[n] = 1

    if len(primes) == 0:
        return {n: 1}
    return primes

n = int(input())
if n == 1:
    print(0)
else:
    primes =  get_prime_factorizations(n)
    result = 0
    for exponent  in primes.values():
        count = 0
        while exponent - count > 0:
            count += 1
            exponent -= count
        result += count
    print(result)


Measured memory_bytes: 65968
import sys
from bisect import bisect_right, bisect_left


def checkScore(p):
    global D, last, S
    rst = 0
    _last = last[p]
    for d in range(1, D + 1):
        down = C[p] * (d - _last[d])
        up = S[d][p] if _last[d] == d else 0
        rst += up - down
    return rst


Z = 26
D = int(input())
C = list(map(int, input().split()))
S = [tuple([0] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]
T = [None] + [int(input()) - 1 for _ in range(D)]

M = int(input())
Q = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]


last = [[0] * (D + 1) for _ in range(Z)]
V = [0] * Z
for d in range(1, D + 1):
    t = T[d]
    for p in range(Z):
        last[p][d] = last[p][d - 1]
    last[t][d] = d
for p in range(Z):
    V[p] = checkScore(p)

score = sum(V)

for d, q in Q:
    d += 1

    p = T[d]
    s = bisect_left(last[p], d)
    e = bisect_right(last[p], d)
    for j in range(s, e):
        last[p][j] = last[p][j - 1]

    old = last[q][d]
    e = bisect_right(last[q], old)
    for j in range(d, e):
        last[q][j] = d

    score -= V[p] + V[q]
    V[p] = checkScore(p)
    V[q] = checkScore(q)
    score += V[p] + V[q]
    print(score)

    T[d] = q


Measured memory_bytes: 96860
#include <bits/stdc++.h>
using namespace std;
int n, l, q;
int x[100020];
int f[100020][17];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	scanf("%d%d", &l, &q);
	for (int i = 0; i < n; i++) {
		f[i][0] = upper_bound(x, x + n, x[i] + l) - x - 1;
	}
	f[0][n] = n;
	for (int j = 1; j < 17; j++) {
		for (int i = 0; i <= n; i++) {
			f[i][j] = f[f[i][j - 1]][j - 1];
		}
	}
	for (int i = 0; i < q; i++) {
		int x, y, z = 0;
		scanf("%d%d", &x, &y);
		if (x > y) {
			swap(x, y);
		}
		x--;
		y--;
		for (int i = 16; i >= 0; i--) {
			if (f[x][i] < y) {
				z += 1 << i;
				x = f[x][i];
			}
		}
		printf("%d\n", z + 1);
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

string replace_with_str(string s, string from, string to){
    string::size_type pos = 0;
    while(pos = s.find(from, pos), pos != string::npos){
        s.replace(pos, from.length(), to);
        pos += to.length();
    }
    return s;
}

int main(int argc, char const *argv[]){
    string s;
    cin >> s;
    s = replace_with_str(s, ",", " ");
    printf("%s\n",s.c_str());
    return 0;
}

Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
mod = 10**9+7

DP = Array.new(n).map{Array.new(k,1)}

n.times { |s| DP[s][0] = s+1 }

n.times do |s|
  k.times do |t|
    if s>0 && t>0 && s>t
      DP[s][t] = (DP[s-1][t] + DP[s-1][t-1]) % mod
    end
  end
end

def com(n,k)
  return 0 if n<k
  return 1 if n==0 && k==0
  return 1 if k < 1
  return DP[n-1][k-1]
end

(1..k).each do |i|
  ans = com(k-1, i-1)*com(n-k+1, i)
  puts ans % mod
end


Measured memory_bytes: 33148
//
// じょえチャンネル
// https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
//
// Created by yamunaku on 2020/02/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

vector<ll> fact, invfact;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}

void buildFact(int n){
    fact = vector<ll>(n + 1, 1);
    invfact = vector<ll>(n + 1, 1);
    for(int i = 1; i <= n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[n] = inv(fact[n]);
    for(int i = n - 1; i >= 1; i--){
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
}

ll bcomb(int n, int k){
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

int main(){
    //CFS;
    ll n, k;
    cin >> n >> k;
    buildFact(200000);
    ll ans = 0;
    rep(i, min(n, k + 1)){
        ans += bcomb(n, i) * bcomb(n - 1, i) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(int argc, char const *argv[])
{
	
	int N,K,D;
	scanf("%d %d",&N,&K );

	if (N<10)
	{
	/* code */
		printf("%d\n",100*(10-N)+K );
		return 0;
	}

	printf("%d",K);
	return 0;
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<pii> v(n);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(b, a);
    }

    sort(all(v));

    bool isok = true;
    ll t = 0;
    REP(i, n) {
        t += v[i].second;
        if(t > v[i].first) {
            isok = false;
            break;
        }
    }

    if(isok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	//var n, m int
	//fmt.Scan(&n, &m)
	n := scanInt()
	m := scanInt()

	//n部屋と通じる通路をグラフで表現
	rooms := make([][]int, n)

	for i := 0; i < m; i++ {
		//var a, b int
		//fmt.Scan(&a, &b)
		a := scanInt()
		b := scanInt()
		a--
		b--
		rooms[a] = append(rooms[a], b)
		rooms[b] = append(rooms[b], a)
	}

	drl := make([]int, n)
	for i := 1; i < n; i++ {
		drl[i] = -1
	}
	//スタックを用意
	stk := make([]int, 0)
	stk = append(stk, 0)

	for len(stk) > 0 {
		v := stk[0]
		stk = stk[1:]

		for _, i := range rooms[v] {
			if drl[i] != -1 {
				continue
			}
			drl[i] = v + 1
			stk = append(stk, i)
		}
	}

	ok := true
	for i := 1; i < n; i++ {
		if drl[i] < 0 {
			ok = false
		}
	}
	if ok {
		fmt.Println("Yes")
		for i := 1; i < n; i++ {
			fmt.Println(drl[i])
		}
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 17556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,b,a) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
int a[105];
bool dp[N];
void solve()
{
  int n,k;
  cin>>n>>k;
  freab(i,1,n)
    cin>>a[i];
  mset(dp,0);
  freab(i,1,k)
  {
    freab(j,1,n)
    {
      if(a[j]>i)
        break;
      if(dp[i-a[j]]==false)
      {
        dp[i]=true;
        break;
      }
    }
  }
  if(dp[k])
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
}

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


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

typedef long long ll;
const int len = 5e3+5;
int del[len][205], mx[15][len][205], po[len], n, m;
ll pref[len], ans = 0;

int findmax(int j, int l, int r){
    int d = po[r-l+1];
    return max(mx[d][l][j], mx[d][r+1-(1<<d)][j]);
}

void solve(int l, int r, int o1, int o2){
    if (l > r) return;

    int mid = (l+r)/2, pos;
    ll hap = 0; // not sure here!!!!!!!!!!!!!!!!!!
    for (int i = o1; i <= min(o2, mid); i++){
        ll sum = -(pref[mid]-pref[i]);
        for (int j = 1; j <= m; j++)
            sum += findmax(j, i, mid);

        if (sum > hap){
            hap = sum;
            pos = i;
        }
    }

    ans = max(ans, hap);
    solve(l, mid-1, o1, pos);
    solve(mid+1, r, pos, o2);
}

int main(){
    scanf("%d %d", &n, &m);

    for (int i = 2; i <= n; i++)
        scanf("%d", &pref[i]);
    for (int i = 2; i <= n; i++)
        pref[i] += pref[i-1];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &del[i][j]);

    for (int i = 1; i <= n; i++){
        po[i] = po[i-1];
        if ((1<<(po[i]+1)) <= i) po[i]++;
    }

    //for (int j = 1; j <= m; j++)
      //  printf("j = %d, best = %d\n", j, findmax(j, 1, n));

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            mx[0][i][j] = del[i][j];
    for (int k = 1; (1<<k) <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++){
                mx[k][i][j] = mx[k-1][i][j];
                if (i+(1<<(k-1)) <= n)
                    mx[k][i][j] = max(mx[k][i][j], mx[k-1][i+(1<<(k-1))][j]);
                //printf("%d, %d, %d = %d\n", k, i, j, mx[k][i][j]);
            }

    solve(1, n, 1, n);

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 58240
def main():
    R, G, B, N = (int(i) for i in input().split())
    ans = 0
    for r in range(N+1):
        for g in range(N+1):
            need = N - r*R - g*G  # 必要ボール数
            if need < 0:
                continue
            b = 0--need//B
            if r*R + g*G + b*B == N:
                ans += 1
                # print(r, g, b)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41068
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100000+2
int S[MAXN],Q[MAXN];
int n,m;
int gg=0;
void input(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>S[i];
	}
	cin>>m;
	for(int i=0;i<m;++i){
		cin>>Q[i];
	}
}
bool pd(int x){
	int l=0,r=n-1;
	while(r>l){
		int mid=(r+l)/2;
		if(S[mid]==x) return true;
		if(S[mid]>x) r=mid;
		else l=mid+1;
	}
	if(S[r]!=x&&S[l]!=x) return false;
	else return true;
}
void output(){
	cout<<gg<<endl;
}
int main(){
	input();
	for(int i=0;i<m;++i){
		if(pd(Q[i])) gg++;
	}
	output();
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
	for (;;)
	{
		int h, w;
		cin >> h >> w;

		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3076
# -*- coding: utf-8 -*-
#コンビネーション
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 2 * 10 ** 5 + 1000  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

ans = 0
h, w, a, b = map(int,input().split())
for i in range(h - a):
    #print(b - 1 + i, i, w - b - 1 + h - i - 1, w - b - 1)
    ans += (cmb(b - 1 + i, i) * cmb(w - b -  1 + h - i - 1, w - b - 1)) % (10 ** 9 + 7)
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 27220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		boolean[] attendance = new boolean[30];
		for (int i = 0; i < 30; i++) {
			attendance[i] = false;
		}
		
		for (int i = 0; i < 28; i++) {
			attendance[scan.nextInt()-1] = true;
		}
		
		for (int i = 0; i < 30; i++) {
			if (!attendance[i]) {
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 17180
S_str=input()
S=int(S_str,2)

test_str=""
for i in range(len(S_str)):
  if i%2==0:
    test_str=test_str+"1"
  elif i%2==1:
    test_str=test_str+"0"

test_bin=int(test_str,2)
result_bin=bin(S ^ test_bin)

print(min(result_bin.count("1"),len(S_str)-result_bin.count("1")))

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

int main() {
  int n, len;
  char s[10005];
  scanf("%d %s", &n, s);
  len = strlen(s);
  for (int i = 0; i < len; i++)
    putchar('A' + ((s[i] - 'A' + n) % 26));
  puts("");
  return 0;
}

Measured memory_bytes: 256
z=[]
a=[]
b=[]
x, y= map(int,input().split())
for i in range(x):
    a.append(i)


for i in a:
    b.append(i+1)
    
b.append(0)


for i in b:
    if (4*x)-(2*i)==y:
        z.append('1')

    
        
if len(z)>0:
    print('Yes')

if len(z)<=0:
    print('No')

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

int main(){

	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt	
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif	

    FAST
//	PRECISE

ll n,k;
cin>>n>>k;
ve <ll> v(n,0);
FOR(i,0,n)
cin>>v[i];
ll ans=0;
srt(v);
FOR(i,0,k)
ans+=v[i];
cout<<ans;


return 0;
 }

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

int main(void){
    int n, m;
    cin >> n >> m;

    int x[m];
    rep(i, m){
        cin >> x[i];
    }

    sort(x, x + m);

    int diff[m-1];
    rep(i, m - 1){
        diff[i] = x[i + 1] - x[i];
    }

    sort(diff, diff + m - 1);

    int ans = 0;
    rep(i, (m - 1) - (n - 1)){
        ans += diff[i];
    }

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


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int[] ary = new int[5];
    	ary[0]=sc.nextInt();
    	ary[1]=sc.nextInt();
    	ary[2]=sc.nextInt();
    	ary[3]=sc.nextInt();
    	ary[4]=sc.nextInt();
    	if((ary[2]+ary[4])<=ary[0]&&(ary[3]+ary[4])<=ary[1]&&ary[2]>=ary[4]&&ary[3]>=ary[4]){
    	    System.out.println("Yes");
    	}else{
    		System.out.println("No");
    	}
    }
}



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

using namespace std;

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

  while(true){
    int n,m;cin >>n>>m;
    if(n==0) break;
    int h[1024*1500]={0},w[1024*1500]={0};
    int tmp_h[n+1],tmp_w[m+1];
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++){
      cin>>tmp_h[i];
      sum1+=tmp_h[i];
        //cout<<tmp_h[i]<<endl;
    }
    for(int i=0;i<m;i++){
      cin >> tmp_w[i];
      sum2+=tmp_w[i];
       // cout<<tmp_w[i]<<endl;
    }
    for(int i=0;i<n;i++){
      int tmp=0;
      for(int j=i;j<n;j++){
        tmp+=tmp_h[j];
        h[tmp]++;
      }
    }
    for(int i=0;i<m;i++){
      int tmp=0;
      for(int j=i;j<m;j++){
        tmp+=tmp_w[j];
        w[tmp]++;
      }
    }
    long long  res=0;
    for(int i=1;i<=min(sum1,sum2);i++){
        res+=h[i]*w[i];
    }
    cout << res<<endl;
  }
}

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

def main():
    m='abcdefghijklmnopqrstuvwxyz'
    m=list(m)
    n=int(input())
    ans=[[] for _ in range(n)]
    ans[0].append(['0','0'])
    for i in range(1,n):
        for j,mj in ans[i-1]:
            for k in range(i+1):
                if k<=int(mj)+1:
                    ans[i].append([j+str(k),str(max(int(mj),k))])
    p=[]
    for i,mi in ans[n-1]:
        s=''
        for j in range(len(i)):
            s+=m[int(i[j])]
        p.append(s)
    p.sort()
    for i in p:
        print(i)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 44236
#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 << "Left" << endl;
  }
  else if(a+b < c+d){
  cout << "Right" << endl;
  }
  else{
  cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
    s = input()
    Yes(s[2]==s[3]and s[4]==s[5])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// Binary Indexed Tree (BIT)
// Verified: AOJ DSL_2_B: Range Sum Query (int??????)

template <typename T>
struct zeroIndexedBIT{
private:
    vector<T> array;
    int n;

public:
    // ????????? (??????)
    zeroIndexedBIT() : array(10, 0), n(10) {}
    zeroIndexedBIT(int _n) : array(_n, 0), n(_n) {}

    // ?????????????????§ BIT ?????????????????¨????????????????????§?????£???
    void resize(int _n) {
        array.resize(_n);
        n = _n;
    }

    // 0???????????? i???????????§????´???????????±???????
    T sum(int i) {
        T s = 0;
        for(int k=i; k>=0; k = (k&(k+1)) - 1) s += array[k];
        return s;
    }

    // [i, j] ???????´??????????
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i ????????? ????´? x ?????????
    void add(int i, T x) {
        for(int k=i; k<n; k |= k+1) array[k] += x;
    }
};

signed main() {
    int n, q; cin >> n >> q;
    zeroIndexedBIT<int> b(n);
    int c, x, y;
    rep(i,0,q) {
        cin >> c;
        if(c == 0) {
            cin >> x >> y; x--;
            b.add(x, y);
        }
        else {
            cin >> x >> y; x--; y--;
            cout << b.sum(x, y) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3528
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n,i;cin>>n;
int a[n+1]={0};a[1]=0;
for(i=2;i<=n;i++)
{
	int b;cin>>b;
	a[b]++;
}
for(i=1;i<=n;i++) cout<<a[i]<<endl;


return 0;
}

Measured memory_bytes: 4392
N = int(input())
*D, = map(int, input().split())
MOD = 998244353

import collections
dic = collections.Counter(D)

flag = 1 if dic[0] != 1 or D[0] != 0 else 0
ans = 1
for d in range(1, max(D)+1):
    ans *= pow(dic[d-1], dic[d], MOD)
    ans %= MOD

if flag: 
    print(0)
else:
    print(ans)

Measured memory_bytes: 23728
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll l;
	cin>>l;
	ll a=l*l*l*(ll)1e9/27;
	string s="";
	while(a>0){
		s+=(a%10+'0');
		a/=10;
	}
	reverse(all(s));
	if(s.size()<9)cout<<0;
	else fo(i,0,s.size()-9)cout<<s[i];
	cout<<'.';
	if(s.size()<9)cout<<0;
	if(s.size()<8)cout<<0;
	if(s.size()<7)cout<<0;
	fo(i,max(0,(int)s.size()-9),s.size())cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    at_least_once = True
    while at_least_once:
        at_least_once = False
        for i in range(N - 1):
            if A[i] > A[i + 1]:
                A[i], A[i + 1] = A[i + 1], A[i]
                at_least_once = True
                ans += 1

    print(" ".join(map(str, A)))
    print(ans)


if __name__ == "__main__":
    main()



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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod;j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++) cin >> v[i];
    sort(allof(v));
    int sum = 0;
    for(int i=0; i<N-1; i++) {
        sum += v[i];
    }

    if(v[N-1] >= sum) cout << "No" << '\n';
    else cout << "Yes" << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin>>s;
    rep(i,4){
        cout<<s[i];
    }
    cout<<" ";
    rep2(i,4,s.size()){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256