akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
    double cx, cy, r, x1, x2, y1, y2, slope, cross_x, cross_y, k, div_x, div_y,
        ans1_x, ans1_y, ans2_x, ans2_y;
    int  q;
    bool X_FLG, Y_FLG;

    scanf("%lf %lf %lf", &cx, &cy, &r);
    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

        X_FLG = false, Y_FLG = false;

        if (y1 == y2) {
            X_FLG = true;
        } else if (x1 == x2) {
            Y_FLG = true;
        } else {
            slope = (y2 - y1) / (x2 - x1);
        }

        if (X_FLG) {
            cross_x = cx;
            cross_y = y1;
        } else if (Y_FLG) {
            cross_x = x1;
            cross_y = cy;
        } else {
            cross_x =
                (cy * (x2 - x1) * (y2 - y1) + cx * (x2 - x1) * (x2 - x1) -
                 y1 * (y2 - y1) * (x2 - x1) + x1 * (y2 - y1) * (y2 - y1)) /
                ((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
            cross_y = ((x1 - x2) * cross_x + cy * (y2 - y1) + cx * (x2 - x1)) /
                      (y2 - y1);
        }

        k = sqrt(r * r - ((cx - cross_x) * (cx - cross_x) +
                          (cy - cross_y) * (cy - cross_y)));

        if (X_FLG) {
            printf("%.8lf %.8lf %.8lf %.8lf\n", cross_x - k, y1, cross_x + k,
                   y1);
        } else if (Y_FLG) {
            printf("%.8lf %.8lf %.8lf %.8lf\n", x1, cross_y - k, x1,
                   cross_y + k);
        } else {
            div_x = k * (x2 - x1) /
                    (sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
            div_y = k * (y2 - y1) /
                    (sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));

            ans1_x = cross_x - div_x;
            ans1_y = cross_y - div_y;

            ans2_x = cross_x + div_x;
            ans2_y = cross_y + div_y;

            if (ans1_x < ans2_x) {
                printf("%.8lf %.8lf %.8lf %.8lf\n", ans1_x, ans1_y, ans2_x,
                       ans2_y);
            } else if (fabs(ans1_x - ans2_x) < 0.00000001 && ans1_y <= ans2_y) {
                printf("%.8lf %.8lf %.8lf %.8lf\n", ans1_x, ans1_y, ans2_x,
                       ans2_y);
            } else {
                printf("%.8lf %.8lf %.8lf %.8lf\n", ans2_x, ans2_y, ans1_x,
                       ans1_y);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 2752
N, K = map(int, input().split())
a = list(map(int, input().split()))

dp = [None] * (K + 1)
dp[0] = False  # 手番が回ってきた時に0個の場合は必ず負け
for i in range(1, K + 1):
    # 手番を回して、相手が負けのものが一つでもあれば勝ち
    dp[i] = any(not dp[i - x] for x in a if x <= i)

if dp[K]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 3828
loop do
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0
  c = 0
  n.downto (x + 3) / 3 do |i|
    (i-1).downto (x - i + 1) / 2 do |j|
      k = x - (i + j)
      c += 1 if 1 <= k && k < j
    end
  end
  p c
end

Measured memory_bytes: 8732
N = int(input())
A = list(map(int, input().split())) # 現準備度
B = list(map(int, input().split())) # 必要準備度

if sum(A) < sum(B):
    print(-1)
else:
    minus = 0
    plus_list = []
    ans = 0
    for a, b in zip(A, B):
        if a - b < 0:
            ans += 1
            minus += b - a
        elif a - b > 0:
            plus_list.append(a - b)

    plus_list.sort(reverse=True)
    for p in plus_list:
        if minus <= 0:
            break
        ans += 1
        minus -= p
    if minus > 0:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 81712
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M;
  cin >> N >> M;

  vector<string> s(N);
  REP(i, N) cin >> s[i];

  vector<string> t(M);
  REP(i, M) cin >> t[i];


  bool ans = false;
  REP(i, N-M+1) REP(j, N-M+1){
    bool flag = true;
    REP(x, M) REP(y, M){
      if(s[i+x][j+y] != t[x][y]) flag = false;
    }
    ans |= flag;
  }

  ans? Yes: No;

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main{

	static Scanner sc = new Scanner(System.in);
	static boolean flag[][] = new boolean[16][16];
	static int sum[][] = new int[16][16];
	static int a, b, n, p, q;

	public static void main(String[] args) {
		
		while(init()){
			solve();
		}

	}	

	public static boolean init(){
		
		a = sc.nextInt();
		b = sc.nextInt();
		
		if(a == 0 && b == 0) return false;

		for(int i = 0; i < a; i++){
			Arrays.fill(flag[i], false);
		}

		n = sc.nextInt();

		for(int i = 0; i < n; i++){
			p = sc.nextInt();
			q = sc.nextInt();

			flag[p-1][q-1] = true;
			sum[p-1][q-1] = 0;
		}

		flag[0][0] = true;
		sum[0][0] = 1;
		for(int i = 1; i < a; i++){
			if(flag[i][0] == false){
				flag[i][0] = true;
				sum[i][0] = sum[i-1][0];
			}
		}
		for(int i = 1; i < b; i++){
			if(flag[0][i] == false){
				flag[0][i] = true;
				sum[0][i] = sum[0][i-1];
			}
		}

		return true;
	}

	public static void solve(){

		for(int i = 1; i < a; i++){
			for(int j = 1; j < b; j++){
				if(flag[i][j] == false){
					flag[i][j] = true;
					sum[i][j] = sum[i-1][j] + sum[i][j-1];
				}
			}
		}

		System.out.println(sum[a-1][b-1]);

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e5;
ll a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  if(a==1||b==1){
    cout << 1 << endl;
    return 0;
  }
  cout << (a*b+1)/2 << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<vector<int>> a(3,vector<int>(3));
  rep(i,3) rep(j,3) cin >> a[i][j];
  int n;cin >> n;
  vector<vector<bool>> f(3,vector<bool>(3,false));
  rep(i,n){
    int b;cin >> b;
    rep(j,3) rep(k,3) if(b==a[j][k]) f[j][k]=true;
  }

  bool ff = false;
  rep(i,3){
    if(f[i][0]&&f[i][1]&&f[i][2]) ff = true;
    if(f[0][i]&&f[1][i]&&f[2][i]) ff = true;
  }
  if(f[0][0]&&f[1][1]&&f[2][2]) ff = true;
  if(f[0][2]&&f[1][1]&&f[2][0]) ff = true;

  if(ff) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {


	int a,b; cin >> a >> b;
	cout << b * 2 - a << endl;

	return 0;
}

Measured memory_bytes: 768
str = input()

a = 0
b = 0
c = 0
d = 0
for i in range(4):
	if (str[i] == str[0]):
		a+=1
	if (str[i] == str[1]):
		b+=1
	if (str[i] == str[2]):
		c+=1
	if (str[i] == str[3]):
		d+=1
		
if (a == 2 and b == 2 and c == 2 and d == 2) :
	print('Yes')
else :
	print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K) cout << K << endl;
  else if(A + B >= K) cout << A << endl;
  else if(A + B + C >= K) cout << A - (K - A - B) << endl;
  else cout << A - C << endl;
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N=sc.nextInt(),ans=0;
		int[] p = new int[N];
		for(int i=0;i<N;i++) p[i]=sc.nextInt();
      	int m = p[0];
		for(int i=0;i<N;i++) {
			m = Math.min(m,p[i]);
          	if(m==p[i]) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 65884
N = int(input())
A = list(map(int, input().split()))
# TLE
def test():
    duplication = {}
    ans = 0
    for x in A:
        if x in duplication:
            continue
        count = A.count(x)
        if count > 1:
            duplication[x] = count
            ans += count*(count-1)//2
    for x in A:
        if x not in duplication:
            print(ans)
        else:
            print(ans -(duplication[x]-1))
from collections import defaultdict

sum = 0
count_dic = defaultdict(int)
for x in A:
    count_dic[x] +=1
for v in count_dic.values():
    sum += v*(v-1)//2
for x in A:
    print(sum -(count_dic[x]-1))

Measured memory_bytes: 87756
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int n,get[100000],i,j,t=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&get[i]);
    }
    
    for(i=1;i<=100;i++){
        int count=0;
        for(j=1;j<=n;j++){
            
            if(i<=get[j]){
                
                count++;
                
            }
            
            
            
        }
        if(i<=count){
           t++;
           
        }
        
    }   
    printf("%d\n",t);
    
    
}


Measured memory_bytes: 2056
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] count = new int[4];
        boolean b = true;
        for(int i=0; i<6; i++){
            int N = sc.nextInt();
            count[N-1]++;
        }
        for(int i=0; i<4; i++){
            if(count[i]>2){
                b = false;
            }
        }
        if(b){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35844
#!/usr/bin/env python3

N = int(input())
X = list(map(int, input().split()))
D = {}
for i in range(N):
    D[i] = X[i]

X = sorted(X)
ans = [X[N//2-1], X[N//2]]
A = {}

cnt = 0
for i, v in sorted(D.items(), key=lambda x:x[1]):
    if cnt < N // 2:
        A[i] = ans[1]
    else:
        A[i] = ans[0]
    cnt += 1

for i, v in sorted(A.items(), key=lambda x:x[0]):
    print(v)


Measured memory_bytes: 71480
use std::cmp::min;

fn is_keyence(s1: &str, s2: &str) -> bool {
    "keyence".starts_with(s1) && "keyence".ends_with(s2)
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let s: &str = line.split_whitespace().next().unwrap();
    let len = s.len();
    let res = match (0..(min(len, 7)+1)).find(|&pos| is_keyence(&s[0..pos], &s[(len-7+pos)..len])) {
        Some(_) => "YES",
        None => "NO"
    };
    println!("{}", res)
}


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

int main() {
    ll N,W;
    cin>>N>>W;
    ll wt[N],val[N];
    for(ll i=0;i<N;i++)
        cin>>wt[i]>>val[i];
    ll dp[N+1][W+1];
    for(ll i=0;i<=N;i++) {
        for(ll j=0;j<=W;j++) {
            if(i==0||j==0)
                dp[i][j] = 0;
            else if(j>=wt[i-1]) {
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[N][W];
    return 0;
}


Measured memory_bytes: 79104
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define trace(x) cerr << #x << ": " << x << " " << endl;
//#define int long long

void test_case(){
	string s;
	cin >> s;
	int ans=0;
	int n = s.length();

	for(int i=0;i<n;i++){
		if(s[i]!='R') continue;
		int j = i+1;
		while(j<n && s[j]=='R') j++;
		ans = max(ans, j-i);
		i=j-1;
	}

	cout << ans << endl;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}














//     	 __       _   __  _     _   _______   __
//	    /  \     | | / / | |   | | |__   __| |  |
//	   / /\ \    | |/ /  | |___| |    | |    |  |
//	  / /__\ \   |   <   |  ___  |    | |    |  |
//	 / ______ \  | |\ \  | |   | |  __| |__  |  |_____
//	/_/      \_\ |_| \_\ |_|   |_| |_______| |________|




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n,m;
	cin>>n>>m;
	int l=1,r = n;
	for(int i=0;i<m;i++){
		int ll ,rr;
		cin>>ll>>rr;
		l = max(l,ll);
		r = min(r,rr);
	}	
	cout<<max(0,r-l+1)<<endl;


	return 0;
}


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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;


int solve(LL K) {
    vector<LL> v(50, 49);

    LL num = K / 50;
    FOR(i, 0, v.size()) {
        v[i] += num;
    }

    LL rest = K % 50;
    FOR(i, 0, rest) {
        v[i] += 50;
        FOR(j, 0, 50) {
            if (i != j) {
                v[j] -= 1;
            }
        }
    }

    cout << 50 << endl;
    FOE(x, v) {
        cout << x << endl;
    }
}


int main() {
    LL K;
    cin >> K;
    solve(K);

    return 0;
}

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

using namespace std;

using ll = long long;

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

    string s;
    int k;

    cin >> s >> k;
    set<string> sub;
    const int n = s.size();
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k && j + i <= n; ++j)
            sub.insert(s.substr(i, j));
    }

    int cnt = 0;
    for (auto it : sub) {
        ++cnt;
        if (cnt == k) {
            cout << it << endl;
            break;
        }
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    long n;
    cin >> n;
    
    long m = LLONG_MAX;
    rep(i, 5) {
        long a;
        cin >> a;
        m = a < m? a : m;
    }
    
    long ans = n / m + 4;
    if(n % m != 0) ans += 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);

        int N = 10;
        int M = 3;
        int height[] = new int[N];
        int ans[] = new int[N];
        //String str[] = new String[N];

        // 処理
        for (int i = 0; i < N; i++) {
            // 入力
            //System.out.print("input : ");
            height[i] = scanner.nextInt();
           
            //str[i] = scanner.nextLine();

            //System.out.print("output : ");
            //System.out.println(height[i]);
        }

        Arrays.sort(height);
        
        for (int i = 1; i <= M; i++) {
            System.out.println(height[N - i]);
        }

        scanner.close();
    }
}


Measured memory_bytes: 26368
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;
int main(void){
    int n,m;
    cin >>n>>m;
    string mass;
    //int def;
    int pre;
    int point;
    int onelen=0;
    int lentem=0;
    vector<int> ans;
    //vector<int>iterator way;
    cin>>mass;
    for(int i=0;i<n;i++){
        
        if(mass.at(i)=='1'){
            lentem++;
        }else{
            onelen=max(onelen,lentem);
            lentem=0;
        }
    }
    onelen=max(onelen,lentem);
    point=n;

    if(onelen >=m){
        cout <<-1<<endl;
    }else{
    
        while(point >0){
            pre=max(point-m,0);
          //  cout<<mass.at(pre);
            while(mass.at(pre)!='0'){
                pre++;
             //   cout<<mass.at(pre);
            }
            cout<<endl;
            ans.push_back(point-pre);
            point=pre;
        }
        //way=ans.end();
        //while(way!=ans)
        
        for(int i=ans.size()-1;i>=0;i--){
            cout <<ans.at(i);
            if(i!=0){
                cout <<" ";
            }
        }
         
    }
   

}


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

#define int long long 

int32_t main()
{
    int n,w;
    cin >> n >> w;
    int a,b;
    vector<int> wt,v;
    for(int i=0;i<n;++i)
    {
        cin >> a >> b;
        wt.push_back(a);
        v.push_back(b);
    }

    int dp[n+1][w+1];

    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
                continue;
            }
            int x = dp[i-1][j];
            int y =  (j>=wt[i-1])  ?  v[i-1] + dp[i-1][j - wt[i-1]]  : dp[i-1][j] ;
 
            dp[i][j] = max(x,y);


        }
    }

    cout << dp[n][w];
}


Measured memory_bytes: 79104
def factorization(n):
    arr=[]
    temp=n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    if (n==1):
        arr=[]
    return arr

n=int(input())
List=factorization(n) 
#print(List)
number=len(List)
ans=0
for i in range(number):
    k=1
    while (k<=List[i][1]):
        ans+=1
        List[i][1]-=k
        #print(List[i][1])
        k+=1
print(ans)

Measured memory_bytes: 9528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int S[1000], top;

void push(int n) {
  S[++top] = n;
}

int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a, b;
  char s[100];
  top = 0;
  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    }
    else if (s[0] == '-') {
      a = pop();
      b = pop();
      push(b-a);
    }
    else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
    }
    else push(atoi(s));
  }
  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 3232
n,k = map(int,input().split())
H= list(map(int,input().split()))
if(k<n):
  H.sort()
  for i in range(k):
    H.pop()
  cont=0
  for i in range(len(H)):
    cont+= H[i]
  print(cont)
else:
  print(0)


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

main() {
    int a,b,c; cin >> a >> b >> c;
    map<int,int>m;
    m[a]++;m[b]++;m[c]++;
    if(m[5]==2 && m[7]==1)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  
  ll a,b,c,d;
  ll f=0;
  cin>>a>>b>>c>>d;
  while(a>0||c>0)
  {
      if(f==0)
      {
        c=c-b;
        f=1;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
      }
      else
      {
          a=a-d;
          f=0;
          if(a<=0){
          cout<<"No";
          break;}
      }
      
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    const int nax=305;
    double p[nax][nax][nax],ev[nax][nax][nax];
    int main()
    {
        std::ios::sync_with_stdio(false);   
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            //cout<<"hello";
            ll n;
            cin>>n;
            ll a[n];
            ll cnt[4]={0};
            for(ll i=0;i<n;i++)
            {
                cin>>a[i];
                cnt[a[i]]++;
            }
            p[cnt[1]][cnt[2]][cnt[3]]=1;
            for(ll c=n;c>=0;c--)
            {
                for(ll b=n;b>=0;b--)
                {
                    for(ll a=n;a>=0;a--)
                    {
                        if(a==0 && b==0 && c==0)
                            continue;
                        if(a+b+c>n)
                            continue;
                        double p_waste=(double)(n-(a+b+c))/n;
                        double ev_waste=p_waste/(1-p_waste)+1;
                        ev[a][b][c]+=ev_waste*p[a][b][c];
                        if(a!=0)
                        {
                            double p_go=(double)a/(a+b+c);
                            p[a-1][b][c]+=p[a][b][c]*p_go;
                            ev[a-1][b][c]+=ev[a][b][c]*p_go;
                        }
                        if(b!=0)
                        {
                            double p_go=(double)b/(a+b+c);
                            p[a+1][b-1][c]+=p[a][b][c]*p_go;
                            ev[a+1][b-1][c]+=ev[a][b][c]*p_go;
                        }
                        if(c!=0)
                        {
                            double p_go=(double)c/(a+b+c);
                            p[a][b+1][c-1]+=p[a][b][c]*p_go;
                            ev[a][b+1][c-1]+=ev[a][b][c]*p_go;
                        }
                    }
                }
            }
            printf("%.10lf",ev[0][0][0]);
        }
        return 0;
    }


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

int main(void){
  char input[3];
  cin >> input[0] >> input[1] >> input[2];
  int number = atoi(input);
  if(number%4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    string s1="AC",s2="WA",s3="TLE",s4="RE";
    lg a1=0,a2=0,a3=0,a4=0;
    lg n;
    cin>>n;
    for(lg i=0;i<n;i++)
    {
        string j;
        cin>>j;
        if(j==s1) a1++;
        else if(j==s2) a2++;
        else if(j==s3) a3++;
        else if(j==s4) a4++;
    }
    cout<<s1<<" x "<<a1<<endl;
    cout<<s2<<" x "<<a2<<endl;
    cout<<s3<<" x "<<a3<<endl;
    cout<<s4<<" x "<<a4<<endl;
}


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

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;
  int head, tail;
  for(int i = 0; i < s.length(); i++)
  {
    if(s[i] == 'A')
    {
      head = i;
      break;
    }
  }
  for(int i = s.length()-1; i >= 0; i--)
  {
    if(s[i] == 'Z')
    {
      tail = i;
      break;
    }
  }
  cout << tail - head + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

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

if N >= M:
    print(0)
    sys.exit()
X.sort()

dist = []
for i in range(len(X)-1):
    dist.append(X[i+1]-X[i])

dist.sort()
print(sum(dist[:len(dist)-(N-1)]))

Measured memory_bytes: 56744
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<P> lr(m);
	rep(i, m) cin >> lr.at(i).first >> lr.at(i).second;
	ll mn = 1, mx = n;
	rep(i, m) {
		mn = max(mn, lr.at(i).first);
		mx = min(mx, lr.at(i).second);
	}
	if (mn > mx) cout << 0;
	else cout << mx - mn + 1;
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007
#define MAX 2000010

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

ll	MPl(ll x, ll y) {
	return (x+y)%MOD;
}

ll	MMi(ll x, ll y) {
	return (x-y+MOD)%MOD;
}

ll	MMul(ll x, ll y) {
	return (x*y)%MOD;
}

// Array
vector<ll> fac(MAX, 0);
vector<ll> finv(MAX, 0);
vector<ll> inv(MAX, 0);

void	DivInit() { // fac, finv, inv
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

ll	MDiv(ll x, ll y) {
	if (1!=inv.at(1))
		DivInit();
	return (x*inv.at(y))%MOD;
}

ll	MComb(ll N, ll K) {
	if (1!=inv.at(1))
		DivInit();
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int	main() {
	ll K;
	string S;
	cin >>K >>S;
	ll N=S.size();
	ll SS=0;
	Rep0(i, K+1) {
		ll SSS=MComb(N+i-1, i);
		SSS=MMul(SSS, myPow(25, i));
		SSS=MMul(SSS, myPow(26, K-i));
		SS=MPl(SS, SSS);
	}
	cout <<SS <<endl;
	return 0;
}



Measured memory_bytes: 52216
#include <stdio.h>
#include <cmath>
using namespace std;

int main()
{
	int person[15][15];
	for(int i = 0; i < 15; i++){
		for(int j = 0; j < 15; j++){
			person[i][j] = -1;
		}
	}
	int N;
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		int A;
		scanf("%d", &A);
		for(int j = 0; j < A; j++){
			int x, y;
			scanf("%d %d", &x, &y);
			person[i][x-1] = y;
		}
		person[i][i] = 1; // 便宜上、自分自身は正直者であると言うことにする
	}
	
	int answer = 0;
	int bitMax = pow(2 , N);
	for(int bit = 0; bit < bitMax; bit++){
		int honest[15];
		int count = 0;
		for(int i = 0; i < N; i++){
			honest[i] = (bit >> i) & 1;
			if(honest[i] == 1){
				count++;
			}
		}
		// 矛盾判定
		bool consistent = true;
		for(int i = 0; i < N; i++){
			if(honest[i] == 1){
				for(int j = 0; j < N; j++){
					if(person[i][j] == 1 && honest[j] == 0){
						consistent = false;
						break;
					}else if(person[i][j] == 0 && honest[j] == 1){
						consistent = false;
						break;
					}
				}
			}
		}
		
		if(consistent && answer < count){
			answer = count;
		}
	}
	
	printf("%d\n", answer);
}

Measured memory_bytes: 128
S = list(input())
N = len(S)
K = int(input())
  
if len(set(S)) == 1:
  print((N*K)//2)
  exit()

ans = 0
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    ans += 1
    i += 1
  i += 1

if S[0] != S[N-1]:
  print(ans*K)
  exit()

a = 1
while S[0] == S[a]:
  a += 1

b = 1
while S[N-1] == S[N-1-b]:
  b += 1
print(ans*K - (K-1)*(a//2 + b//2 - (a+b)//2))

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
	ll n;
	cin >> n;
	prt(n*(n-1)/2);
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int n; cin>>n;
    int ht[n], dp[n];
    memset(dp, 0, sizeof dp);
    for(int i=0; i<n; i++) cin>>ht[i];
    dp[1] = abs(ht[0] - ht[1]);
    for(int i=2; i<n; i++) {
        int d1 = abs(ht[i] - ht[i-1]);
        int d2 = abs(ht[i] - ht[i-2]);
        dp[i] = min(dp[i-1] + d1, dp[i-2] + d2);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5156
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
vector<int> l(8);
int N, A, B, C;
const int INF = 1e9;
int deep(int n, int a, int b, int c)
{
   if(n == N) 
   {
      if(a == 0 || b == 0 || c == 0)
         return INF;

      return abs(A - a) + abs(B - b) + abs(C - c);
   }
   int ans0 = deep(n + 1, a, b, c);
   int ans1 = deep(n + 1, a + l[n], b, c);
   int ans2 = deep(n + 1, a, b + l[n], c);
   int ans3 = deep(n + 1, a, b, c + l[n]);
   if(a != 0)
      ans1 += 10;
   if(b != 0)
      ans2 += 10;
   if(c != 0)
      ans3 += 10;
   return min({ans0, ans1, ans2, ans3});
}
int main()
{
   cin >> N >> A >> B >> C;
   rep(i, N)
   {
      cin >> l[i];
   }
   int ans = deep(0, 0, 0, 0);
   cout << ans << endl;
   return 0;
}


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

typedef long long LL;

const int N = 1e5+7, RT = 150;
int a[N];
LL sum[N][RT];

LL query(int l, int r, int d) {
    assert((r-l)%d==0);
    if (d < RT) {
        if (l<=d)    return sum[r][d];
        return sum[r][d] - sum[l-d][d];
    }

    LL ans = 0;
    for (int i=l; i<=r; i+=d)   ans += a[i];
    return ans;
}

vector<int> divs[N];
int cnt[N];

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

    for (int i=1; i<N; i++)
        for (int j=i; j<N; j+=i)
            divs[j].push_back(i);

    int n;
    cin>>n;
    n--;

    for (int i=0; i<=n; i++)    cin>>a[i];
    for (int i=1; i<RT && i<=n; i++) {
        for (int j=1; j<=n; j++) {
            sum[j][i] = a[j];
            if (j>=i)  sum[j][i] += sum[j-i][i];
        }
    }

    LL ans = 0;
    for (int a=1; a<n; a++) {
        for (int d: divs[n-a]) {
            if (d >= a) break;
            int k = (n-a)/d;
            if (a%d==0 && k*d>=a)   continue;
            LL x = query(a, n, d) ;
            LL y = query(d, k*d, d);
            LL cur =  x + y;
            ans = max(ans, cur);
//            cout<<a<<" "<<a-d<<" = "<<cur<<" "<<x<<" "<<y<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 128256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


Measured memory_bytes: 30116
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b)
		printf("a > b\n");
	else if (a < b)
		printf("a < b\n");
	else
		printf("a == b\n");
	return 0;
}

Measured memory_bytes: 2604
#include<iostream>
using namespace std;
int main(){
    int n,maxv,minv;
    cin>>n;
    int r[2];
    cin>>r[0]>>r[1];
    maxv=r[1]-r[0];
    if(r[0]<r[1]){
        minv=r[0];
    }
    else minv=r[1];
    for(int i=2;i<n;i++){
        int a;
        cin>>a;
        if(maxv<a-minv){
            maxv=a-minv;
        }
        if(a<minv){
            minv=a;
        }
    }
    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 3112
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value

def main():
    S = input()
    if S == S[::-1]:
        print(0)
        exit()
    l = len(S)
    T = S.replace('x', '')
    if T != T[::-1]:
        print(-1)
        exit()
    st, end = 0, l-1
    l = len(T) % 2
    cnt = 0
    while True:
        if S[st] == S[end]:
            if st+1!=end:
                st += 1
                end -= 1
            else:
                st=end
        elif S[st] == 'x':
            st += 1
            cnt += 1
        elif S[end] == 'x':
            end -= 1
            cnt += 1
        if st==end:
            break
    print(cnt)
    '''
    else:
        al = T[len(T)//2]
    pos_list = []
    for i in range(l):
        if S[i] == al:
            pos_list.append(i)
    cnt = 0
    if len(pos_list)%2 == 1:
        mid = pos_list[len(pos_list)//2]
        if mid>0:
            st = mid-1
        else:
            st = 0
        if mid<l-1:
            end = mid+1
        else:
            end = l-1
    else:
        mids = pos_list[len(pos_list)//2-1 : len(pos_list)//2+1]
        if mids[0]>0:
            st = mids[0]-1
        else:
            st = 0
        if mids[1]<l-1:
            end = mids[1]+1
        else:
            end = l-1
    flag = 0
    while True:
        if st==0 and end==l-1:
            flag = 1
        if S[st] == S[end]:
            if st > 0:
                st -= 1
            if end < l-1:
                end += 1
        elif S[st] == 'x':
            if st > 0:
                st -= 1
            cnt += 1
        elif S[end] == 'x':
            if end < l-1:
                end += 1
            cnt += 1
        if flag:
            break
    print(cnt)
    '''

if __name__ == "__main__":
    main()


Measured memory_bytes: 3676
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
#define int long long

#define m_p make_pair
#define mod 1000000007
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



signed main() {
	int n, t = 0, b;
	cin >> n;
	vector<int>vec1(n + 1);
	vecin(vec1);
	for (int i = 0; i < n; i++) {
		cin >> b;
		t += min(b, vec1[i + 1] + vec1[i]);
		vec1[i + 1] = max(0ll, min(vec1[i + 1], vec1[i] + vec1[i + 1] - b));
	}
	cout << t << endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(s.length() - 1);
        if (c == '3') {
            System.out.println("bon");
        } else if (c == '0' || c == '1' || c == '6' || c == '8') {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }
}

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

#define Int long long int

int main(){
    int n;
    Int h;
    cin >> n >> h;
    vector<Int> b(n);
    Int a,maxA=0;
    for(int i=0;i<n;i++){
        cin >> a >> b[i];
        maxA = max(a,maxA);
    }
    Int sum=0,sumB=0;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    for(int i=0;i<n;i++){
        if(maxA<b[i]){
            sum++;
            sumB+=b[i];
        }
        if(h-sumB<=0)break;
    }
    if(h-sumB<=0)cout << sum << endl;
    else if((h-sumB)%maxA>0)cout << sum+(h-sumB)/maxA+1 << endl;
    else cout << sum+(h-sumB)/maxA << endl;
}


Measured memory_bytes: 1024
k = int(input())
if k <= 9:
    print(k)
    exit()
lunlun = [[1,2,3,4,5,6,7,8,9]]
count = 9
digit = 1
while True:
    lunlun.append([])
    for i in lunlun[digit-1]:
        if i % 10 == 0:
            x = i*10
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
            x = i*10+1
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
        elif i % 10 == 9:
            x = i*10+8
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
            x = i*10+9
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
        else:
            y = i % 10
            x = i*10+y-1
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
            x = i*10+y
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
            x = i*10+y+1
            lunlun[digit].append(x)
            count += 1
            if count == k:
                print(x)
                exit()
    digit += 1

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n,m;

vector<int> bulbs;
vector<int> P;

bool on(int idx, int mask) {
  int bulb = bulbs[idx];
  int cnt = 0;
  for (int i=0; i<n; i++) {
    if ((bulb>>i)&1) {
      if ((mask>>i)&1) {
	cnt++;
      }
    }
  }

  return cnt%2 == P[idx];
}

bool allgood(int mask) {
  for (int i=0; i<m; i++) {
    if (!on(i, mask)) return false;
  }
  return true;
}

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

  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int k; cin>>k;
    int mask = 0;
    while (k--) {
      int s; cin>>s; --s;
      mask = mask | (1<<s);
    }
    bulbs.push_back(mask);
  }

  for (int i=0; i<m; i++) {
    int p; cin>>p;
    P.push_back(p);
  }

  int ans = 0;
  for (int mask=0; mask<(1<<n); mask++) {
    if (allgood(mask)) ans++;
  }
  cout<<ans<<endl;    

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

citys = []
for i in range(m):
    p, y = map(int, input().split())
    citys.append([p, y, i])
    
citys.sort(key=lambda x: x[1])
citys.sort()

ans = [[str("{:06}".format(citys[0][0])) + str("{:06}".format(1)), citys[0][2]]]
num = 2
for i in range(1, m):
    if citys[i - 1][0] != citys[i][0]:
        num = 1
    
    ans.append([str("{:06}".format(citys[i][0])) + str("{:06}".format(num)), citys[i][2]])
    
    num += 1

ans.sort(key=lambda x: x[1])
for i in range(m):
    print(ans[i][0])

Measured memory_bytes: 41440
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll n, sum, sum2, a[N];

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

    cin >> n;
    forn(i, 1, n) {
        cin >> a[i];
        sum += a[i];
    }

    if (sum % (n * (n + 1) / 2) != 0) {
        cout << "NO\n";
        return 0;
    }

    a[n + 1] = a[1];

    ll lim = sum / (n * (n + 1) / 2);
    ll cnt = 0;
    forn(i, 2, n + 1) {
        ll x = a[i] - a[i - 1];
        if (x > lim || (lim - x) % n != 0) {
            cout << "NO\n";
            return 0;
        }
        cnt += (lim - x) / n;
    }

    if (cnt != lim) cout << "NO\n";
    else cout << "YES\n";

	return 0;
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    /*

            0 ^ 0 = 0 + 0
            0 ^ 1 = 0 + 1
            1 ^ 0 = 1 + 0

    */

    string s; cin >> s;

    long long tot = 1, mult = 1;

    for(int i = s.size() - 1; i >= 0; --i){

        if(s[i] == '1')
            tot = (tot * 2 + mult) % MOD; // * 2 for unordered pairs, + because they're independent

        mult = mult * 3 % MOD;

    }

    cout << tot;

    return 0;

}


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

int main() {
	int n;
	cin >> n;
	string w[n], ans = "Yes";
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		if (i == 0) continue;
		if (w[i - 1][w[i - 1].size() - 1] != w[i][0]) {
			ans = "No";
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (w[i] == w[j]) ans = "No";
		}
		cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256