akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int N;
  ins(N);

  int hoge[3] = {0, 0, 0};
  rep(i, N) {
    int in(a);
    if (a % 2 != 0)
      ++hoge[0];
    else if (a % 4 == 0)
      ++hoge[2];
    else
      ++hoge[1];
  }
  if (hoge[0] - 1 > hoge[2]) {
    cout << "No\n";
  } else if (hoge[0] - 1 == hoge[2] && hoge[1] > 0) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }

  return 0;
}


Measured memory_bytes: 3560
package main

import "fmt"

const inf = 1 << 60

func f(x, y int) int {
	return y - x
}

func min(x, y int) int {
	if x < 0 {
		return y
	} else if y < 0 {
		return x
	}

	if x < y {
		return x
	}
	return y
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	cost := inf
	cost = min(cost, f(x, y))
	cost = min(cost, f(-x, y)+1)
	cost = min(cost, f(x, -y)+1)
	cost = min(cost, f(-x, -y)+2)

	fmt.Println(cost)
}


Measured memory_bytes: 512
S = input().upper()
T = input().upper()
alpha2num = lambda c: ord(c) - ord('A') + 1
l = [[]for i in range(26)]
for i in range(len(S)):
    if T[i] not in l[alpha2num(S[i])-1]:
        l[alpha2num(S[i])-1].append(T[i])
l = [len(l[i]) for i in range(len(l))]

if max(l) == 1:
    l = [[] for i in range(26)]
    for i in range(len(T)):
        if S[i] not in l[alpha2num(T[i]) - 1]:
            l[alpha2num(T[i]) - 1].append(S[i])
    l = [len(l[i]) for i in range(len(l))]
    if max(l) == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int cnt = 0, tmp = 0;
  for (int i = 0; i < n; i++) {
    if (v.at(i) == 1) {
      cnt++;
    } else {
      cnt = 0;
    }
    tmp = max(cnt, tmp);
  }
  cout << tmp + 1 << endl;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<string.h>

int main(void){
    int n, i, a;
    char s[101], t[51], c[51];

    scanf("%d %s",&n,s);

    if(n%2 == 1){
        printf("No\n");
        return 0;
    }

    for(i=0; i<n/2; i++){   //文字列tを入力
        t[i] = s[i];
    }
    t[n/2] = '\0';

    for(i=0; i<n/2; i++){
        c[i] = s[n/2+i];
    }
    c[n/2] = '\0';
    
    a = strcmp(t,c);
    if(a == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x=nxtl(),y=nxtl();
    if(abs(x-y)<=1)
        cout<<"Brown\n";
    else
        cout<<"Alice\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A + B + C > 21) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if(X >= 400 && X <= 599) {
        	System.out.println("8");
        }else if(X >= 600 && X <= 799) {
        	System.out.println("7");
        }else if(X >= 800 && X <= 999) {
        	System.out.println("6");
        }else if(X >= 1000 && X <= 1199) {
        	System.out.println("5");
        }else if(X >= 1200 && X <= 1399) {
        	System.out.println("4");
        }else if(X >= 1400 && X <= 1599) {
        	System.out.println("3");
        }else if(X >= 1600 && X <= 1799) {
        	System.out.println("2");
        }else if(X >= 1800 && X <= 1999) {
        	System.out.println("1");
        }
	}
}

Measured memory_bytes: 35484
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
#define S 7368792
int l[S];

int main(){
    int i,j,m,n;
    while(1){
        cin>>m>>n;
        if(!m && !n){break;}
        fill(l,l+S,0);
        for(i=m;i<S;i++){
            if(!n){break;}
            if(!l[i]){
                for(j=i;j<S;j+=i){
                    l[j]=1;
                }
                n--;
            }
        }
        for(i=m;i<S;i++){
            if(!l[i]){cout<<i<<endl;break;}
        }
    } 
    return 0;
}
    



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

//ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; } 

int main(){
    string s ;
    cin >> s ;
    int count = 0 ;
    rep(i,s.size()-1){
        if(s[i] == s[i+1] ) continue ;
        else count++ ;
    }
    cout << count << endl;
}

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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    set<string> ans;
    string ss,t;
    cin >> ss >> t;
    for(int i=0;i<ss.size()-t.size()+1;i++){
        bool f=true;
        for(int j=0;j<t.size();j++){
            if(ss[i+j]!=t[j] && ss[i+j]!='?'){
                f=false;
                break;
            }
        }
        if(f){
            string s=ss;
            for(int j=0;j<s.size();j++){
                if(s[j]=='?') s[j]='a';
            }
            for(int j=0;j<t.size();j++){
                s[i+j]=t[j];
            }
            ans.insert(s);
        }
    }

    if(ans.empty()) cout << "UNRESTORABLE" << endl;
    else cout << (*ans.begin()) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include "bits/stdc++.h"
using namespace std;

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   int ans;
   if (B <= C || D <= A) {
       ans = 0;
   } else {
       ans = min(D, B) - max(A, C);
   }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string n;
	while(cin>>n){
		for(int i=0;i<n.size();i++){
		if(n[i]!='@')cout<<n[i];
		else {
			for(int j=0;j<n[i+1]-'0';j++)cout<<n[i+2];
			i+=2;
			}
		}
	cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("ABC")) {
            System.out.println("ARC");
        }
        else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
	int n,m,i,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(i=n;i>=n-m+1;i--){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N, M=map(int, input().split())
s=input()
t=input()
from math import gcd

g=gcd(N,M)

if g==1:
  ans=(N*M)//g
else:
  n=N//g
  m=M//g
  import numpy as np
  pn=np.arange(m, M, m)
  qm=np.arange(n, N, n)
  ans=(N*M)//g
  for i in range(len(pn)):
    if s[qm[i]]!=t[pn[i]]:
      ans=-1
      break
if s[0]!=t[0]:
  ans=-1
print(ans)
  
  
  


Measured memory_bytes: 27292
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;

int judge(char a, char b){
    if(a==b)
        return 1;
    else
        return 0;
}


int main()
{
    string sa, sb;
    cin >> sa >> sb;
    
    int na=sa.length();
    int nb=sb.length();    
    
    int dp[na+1][nb+1];
    for(int i=0; i<na+1; i++)
        dp[i][0]=0;
    for(int i=0; i<nb+1; i++)
        dp[0][i]=0;    
    
    for(int i=1; i<na+1; i++){
        for(int j=1; j<nb+1; j++){
            dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
            dp[i][j]=max(dp[i][j], dp[i-1][j-1]+judge(sa[i-1], sb[j-1]));
        }    
    }   
    int ans = dp[na][nb];    

    int cnt=0;
    string ans_str;
    na --;
    nb --;
    while(cnt<ans){
        if(sa[na]==sb[nb]){
            cnt ++;
            ans_str.push_back(sb[nb]);
            na --;
            nb --;
        }
        else if(dp[na][nb+1]<dp[na+1][nb]){
            nb --;
        }
        else
            na--;
    }
    
    reverse(ans_str.begin(), ans_str.end());


    std::cout << ans_str << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 35456
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	int n;
	cin>>n;
	int ans=0;
	vector<int>dp(n+1,0);
	dp[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=3;j<=n;j++){
			if(i-j>=0){
				dp[i]+=dp[i-j];
				dp[i]%=mod;
			}
		}
	}
	cout<<dp[n];
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = 1;

		for (int i = 0; i < n; i++) {
			if (x <= k)
				x *= 2;
			else
				x += k;
		}
		System.out.println(x);
		sc.close();
	}

}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   Int dist[312][312];
   Int dist2[312][312];
   void solve() {
      Int n; scan(n);
      for(Int i = 0; i < n; ++i) {
         for(Int k = 0; k < n; ++k) {
            Int t; scan(t);
            dist[i][k] = dist2[i][k] = t;
         }
      }
      for(Int k = 0; k < n; ++k) {
         for(Int i = 0; i < n; ++i) {
            for(Int j = 0; j < n; ++j) {
               dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
         }
      }
      bool res = true;
      Int total = 0;
      for(Int i = 0; i < n; ++i) {
         for(Int k = 0; k < n; ++k) {
            if( dist[i][k] != dist2[i][k] ) res = false;
            if( dist[i][k] != dist[k][i] ) res = false;
            total += dist[i][k];
         }
      }
      if( not res ) {
         puts("-1");
         return;
      }
      dumpl(total);
      dumpl(total / n - 1);
      Int w = 0;
      for(Int i = 0; i < n; ++i) {
         for(Int j = 0; j < i; ++j) {
            bool b = true;
            for(Int k = 0; k < n; ++k) {
               if( i == k or j == k ) continue;
               if( dist[i][j] == dist[i][k] + dist[k][j] ) b = false;
            }
            if( b ) w += dist[i][j];
         }
      }
      printf("%ld\n", w);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 1792
import java.util.*;

public class Main {
    /**
     * AtCoder Beginner Contest 165
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int i = 0;
        while ( i * K <= B) {
            int result = i * K;
            if ( A <= result && result <= B) {
                System.out.println("OK");
                return;
            }
            i++;
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35800
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


nCr = {}


def C(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = C(n-1, r) + C(n-1, r-1)
    return nCr[(n, r)]


MOD = 10**9+7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD//i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % MOD


@mt
def slv(H, W, A, B):
    MOD = 10**9+7
    ans = 0
    for i in range(W-B):
        # print(ans)
        w1 = cmb(i+(A-1), i)
        w2 = cmb((W-i-1)+(H-A-1), (H-A-1))
        ans += w1*w2
        ans %= MOD

    return ans % MOD


def main():
    H, W, A, B = read_int_n()

    print(slv(H, W, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 141180
def prime_factorize(x, n):
    while n % 2 == 0:
        x.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            x.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        x.append(n)

A, B = map(int, input().split())
a = []
b = []
prime_factorize(a, A)
prime_factorize(b, B)
k = set(a) & set(b)
print(len(k) + 1)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    int A,B;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
    
    A = a + b + c + d;
    B = e + f + g + h;
    
    if(A > B){
        cout << A << endl;
    }
    else{
        cout << B << endl;
    }
}



Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(ll i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

// [a, b)の整数に対して篩を行う
ll segment_eratosthenes(ll a, ll b) {
	for(int i = 0; (ll)i * i < b; i++) is_prime_small[i] = true;
	for(int i = 0; i < b - a; i++) is_prime_array[i] = true;

	for(int i = 2; (ll)i * i < b; i++) {
		if(is_prime_small[i]) {
			for(int j = 2 * i; (ll)j * j < b; j += i) is_prime_small[j] = false; // [2, sqrt(b))の篩
			for(ll j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) is_prime_array[j - a] = false; // [a, b)の篩
		}
	}
	ll rsl = 0;
	rep(i, 0, sqrt(b)) {
		if(is_prime_array[i]) rsl++;
	}
	return rsl;
}

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

	ll N, P;
	cin >> N >> P;

	if(N == 1) {
		cout << P << endl;
		return 0;
	}
	map<ll, ll> m = prime_factor(P);
	

	ll rsl = 1;
	for(map<ll, ll>::iterator itr = m.begin(); itr != m.end(); itr++ ){
		if(itr->second >= N) rsl *= (pow(itr->first, itr->second / N));
	}
	cout << rsl << endl;

}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


using Graph = vector<vector<int>>;
vector<bool> seen;
map<pair<int, int>, int> res;
void dfs(const Graph &G, int v, int used_color) {
    seen[v] = true;

    int color = 1;
    for (auto next_v: G[v]) {
        if (seen[next_v]) continue;
        if (color == used_color) color++;
        res[make_pair(v,next_v)] = res[make_pair(v,next_v)] = color;
        dfs(G, next_v, color);
        color++;
    }
}

int main() {
    int N;
    cin >> N;
    Graph G(N);
    vector<pair<int, int>> edge;
    rep(i,N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        edge.emplace_back(a,b);
    }

    seen.assign(N,false);
    dfs(G, 0, 0);

    int cnt = 0;
    rep(i,N) if (cnt < G[i].size()) cnt = G[i].size();
    cout << cnt << endl;
    for (auto e: edge) cout << res[e] << endl;
    return 0;
}

Measured memory_bytes: 16760
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int m ;
int R , P , S ; 
string s ;
vector<int> cost(4) ;
vector<vector<int> > dp ;
int n , k ;
int dfs(int x, int cur){
    if ( x == m ) {
        return 0 ;
    }
    if ( dp[x][cur] != -1 ) return dp[x][cur];
    int ans = 0 ; 
    for(int c : {1, 2, 3}){
        if ( c != cur ) {
            if ( s[x] == 'r' ){
                if ( c == 3 ) ans = max(ans, cost[c] + dfs(x + 1, c)) ;
                else ans = max(ans, dfs(x + 1, c));
            }
            else if ( s[x] == 's' ){
                if ( c == 1 ) ans = max(ans, cost[c] + dfs(x + 1, c)) ;
                else ans = max(ans, dfs(x + 1, c));
            }
            else if ( s[x] == 'p' ) {
                if ( c == 2 ) ans = max(ans, cost[c] + dfs(x + 1, c)) ;
                else ans = max(ans, dfs(x + 1, c));
            }
        }
    }
    return dp[x][cur] = ans ;
}
int solve(){
    m = (int) s.size() ;
    dp = vector<vector<int> >(m, vector<int>(4, -1));
    return dfs(0, 0) ;
}
signed main(){
    fastio
    cin >> n >> k ;
    cin >> R >> S >> P ;
    cost[1] = R , cost[2] = S , cost[3] = P  ;
    string t;
    cin >> t ;
    int ans = 0;
    for(int i = 0; i < k; i++){
        s = "" ;
        for(int j = i; j < n; j += k){
            s.push_back(t[j]) ;
        }
        ans += solve() ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 14896
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	Fastio();
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2];
}

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

struct point {
    int x, y, id;
} p[100001];

struct edge_list {
    int w, u, v;
    bool operator < (const edge_list &o) const {
        return w < o.w;
    }
};

int n, ans = 0, up[100001];
vector <edge_list> edge;

int union_find(int u) {
    if(u == up[u]) {
        return u;
    }
    return up[u] = union_find(up[u]);
}

void union_merge(int u, int v) {
    if(union_find(u) != union_find(v)) {
        up[union_find(u)] = union_find(v);
    }
}

signed main() {
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++) {
        up[i] = i;
    }
    for(int i = 1; i <= n; i++) {
        scanf("%lld %lld", &p[i].x, &p[i].y);
        p[i].id = i;
    }
    sort(p + 1, p + n + 1, [](point a, point b) {
        return a.x < b.x;
    });
    for(int i = 1; i < n; i++) {
        edge.push_back({p[i + 1].x - p[i].x, p[i].id, p[i + 1].id});
    }
    sort(p + 1, p + n + 1, [](point a, point b) {
        return a.y < b.y;
    });
    for(int i = 1; i < n; i++) {
        edge.push_back({p[i + 1].y - p[i].y, p[i].id, p[i + 1].id});
    }
    sort(edge.begin(), edge.end());
    for(auto x : edge) {
        int u = x.u, v = x.v, w = x.w;
        if(union_find(u) != union_find(v)) {
            union_merge(u, v);
            ans += w;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 11632
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
   ll t,n,i,j,k,l,mn=0, mx=0;
   cin>>n>>s;

   int f=0, w=0, r=0;
   for(int i=s.size()-1; i>=0; i--)
   {
       if(s[i]=='R')
       {
           r++;
           f=1;
          // break;
       }
       else
       {
           if(f==1)
            w++;
       }
   }
   int rr=r;
   for(int i=0; i<r; i++)
   {
       if(s[i]=='R') rr--;
   }

   cout<<min(rr,w);
}




Measured memory_bytes: 3740
//package src;

import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
import java.math.BigInteger;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static int mod = 1000000007;

	public static void main(String args[]) {
		int n=scn.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=scn.nextInt();
		}
		long memo[]=new long[n+1];
		Arrays.fill(memo, -1);
		System.out.println(mincost(arr, 0,memo));
	}
		public static long mincost(int arr[],int i,long memo[])
		{	int n=arr.length;
			if(i==n-1)
				return 0;
			if(i>=n)
				return Integer.MAX_VALUE;
			if(memo[i]!=-1)
				return memo[i];
			long a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
			a=mincost(arr, i+1,memo)+Math.abs(arr[Math.min(i,n-1 )]-arr[Math.min(i+1, n-1)]);
			b=mincost(arr, i+2,memo)+Math.abs(arr[Math.min(i,n-1 )]-arr[Math.min(i+2, n-1)]);
			memo[i]=Math.min(a, b);
			return Math.min(a, b);
		}
	public static int decode(String str, int i, int[] memo) {
		if (i == 0) {
			return 1;
		}
		int ind = str.length() - i;
		if (str.charAt(ind) == '0')
			return 0;
		if (memo[i] != -1)
			return memo[i];
		int res = decode(str, i - 1, memo);
		if (i >= 2 && Integer.parseInt(str.substring(ind, ind + 2)) <= 26) {
			res += decode(str, i - 2, memo);
		}
		memo[i] = res;
		return res;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static String factorial(int n) {
		BigInteger fac = new BigInteger("1");
		for (int i = 1; i <= n; i++) {
			fac = fac.multiply(BigInteger.valueOf(i));
		}
		return fac.toString();
	}

}

class pair {
	int a;
	int b;

	pair(int x, int y) {
		this.a = x;
		this.b = y;
	}
}

class sorting implements Comparator<pair> {

	@Override
	public int compare(pair o1, pair o2) {
		// TODO Auto-generated method stub
		int a = o1.a - o2.a;
		if (a < 0)
			return -1;
		else
			return 1;
	}

}


Measured memory_bytes: 76916
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;

//main
ll GCD(ll a, ll b);
ll LCM(ll a, ll b);

int main(){
    ll A,B,C,D; cin >> A >> B >> C >> D;
    ll lcm = LCM(C,D);
    ll ansmin = (A-1)-(A-1)/C-(A-1)/D+(A-1)/lcm;
    ll ansmax = B-B/C-B/D+B/lcm;
    cout << ansmax-ansmin << endl;
}

ll GCD(ll a, ll b){
    ll r = b%a;
    while(r != 0){
        b = a;
        a = r;
        r = b%a;
    }
    return a;
}

ll LCM(ll a, ll b){
    return a*b/GCD(a,b);
}



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

int main()
{
	int d, a, b, s;

	d = 1;
	
	
	while(cin >> a >> b){
		
		s = 0;
		

		a += b;

		while(a>0){
			a /= 10;
			s++;
		}

		cout << s << endl;
		d++;

	}


	

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<double,double> PAIR;
const int N = 5e5+5;
const int INF = 0x3f3f3f3f;

int a[N];

int main(){
	int k,n;
	scanf("%d %d",&k,&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	int ma = 0;
	for(int i = 2;i <= n;i++){
		if(a[i] - a[i-1] > ma) ma = a[i] - a[i-1];
	}
	ma = max(ma,k-a[n]+a[1]);
	cout << k - ma << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
S = deque(input())
Q = int(input())
flag = True
for i in range(Q):
    A = list(map(str, input().split()))
    if len(A)==1:
        flag = not flag
    else:
        if flag:
            if A[1]=="1":
                S.appendleft(A[2])
            else:
                S.append(A[2])
        else:
            if A[1]=="1":
                S.append(A[2])
            else:
                S.appendleft(A[2])
S = "".join(S)
if flag:
    print(S)
else:
    print(S[::-1])

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

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

 for( int i=3; i<=n; i++ ){
   if( i<100 ){
     if( i%3==0 || i/10==3 || i%10==3 ){
       cout << " " << i;
     }
   }else if( i>=100 && i<1000 ){
     if( i%3==0 || i/100==3 || i%100/10==3 || i%100%10==3 ){
       cout << " " << i;
     }
   }else if( i>=1000 && i<10000 ){
     if( i%3==0 || i/1000==3 || i%1000/100==3 || i%1000%100/10==3 || i%1000%100%10==3 ){
       cout << " " << i;
     }
   }
 }

 cout << endl;

 return 0;
}


Measured memory_bytes: 3104
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        // int n=sc.nextInt();
        char c[]=sc.nextString().toCharArray();
        int l=c.length;

        if(c[0]=='0' || c[l-1]=='1'){out.println(-1);out.flush();return;}
        else {
            for (int i=0; i<l/2; i++) {
                if(c[i]!=c[l-i-2]){out.println(-1);out.flush(); return;}
            }
        }

        out.println(1+" "+2);

        for (int i=3,s=2; i<=l; i++) {
            out.println(s+" "+i);
            if(c[i-2]=='1'){
                s=i;
            }
        }


      
        // out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 38440
function gcd2(a, b) {
  let m, n
  if (a >= b) {
    m = a
    n = b
  } else {
    m = b
    n = a
  }
  let bn = n
  n = m % n
  m = bn
  while(n !== 0) {
    bn = n
    n = m % n
    m = bn
  }
  return m
}
function gcd(a, b, c) {
  return gcd2(gcd2(a, b), c)
}

function main(input) {
  const K = Number(input)
  let sum = 0
  for(let i = 1; i <= K; i++) {
    for(let j = 1; j <= K; j++) {
      for(let k = 1; k <= K; k++) {
        // console.log(i, j, k, gcd(i, j, k))
        sum += gcd(i, j, k)
      }
    }
  }
  console.log(sum)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32404
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll cost;
	Edge(){}
	Edge(int to,ll cost): to(to),cost(cost){}
};

vector<Edge> G[100010];
ll depth[100010];

void dfs(int v,int pa, ll de){
	depth[v]=de;
	for(auto &e :G[v]){
		if(e.to==pa)continue;
		dfs(e.to,v,de+e.cost);
	}
}

int main(){
	int n; cin >> n;
	for(int i=0;i<n-1;i++){
		int a,b,c; cin >> a >> b >> c;
		a--; b--;
		G[a].push_back(Edge(b,c));
		G[b].push_back(Edge(a,c));
	}
	int q,k; cin >> q >> k;
	k--;
	dfs(k,-1,0);
	for(int i=0;i<q;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		cout << depth[x]+depth[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#pragma GCC optimize("O3")
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> s(1<<n);
    multiset<int> st;
    for(int i=0; i<(1<<n); i++){
        cin>>s[i];
        st.insert(s[i]);
    }

    sort(s.begin(), s.end(), greater<int>());

    st.erase(s[0]);

    vector<int> v;
    v.emplace_back(s[0]);

    for(int i=0; i<n; i++){
        int sz = v.size();
        for(int j=0; j<sz; j++){
            auto itr = st.lower_bound(v[j]);
            if(itr == st.begin()) continue;

            itr--;
            v.emplace_back(*itr);
            st.erase(itr);
        }

        sort(v.begin(), v.end());
    }

    if(v.size() == (1 << n)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 14712
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    int max_val = -1000000;
    int min_val = 1000000;
    long long sum_val = 0;
    int d;
    for (int i = 0; i < n; i++) {
        std::cin >> d;
        max_val = (d > max_val) ? d : max_val;
        min_val = (d < min_val) ? d : min_val;
        sum_val += d;
    }
    std::cout << min_val << ' ' << max_val << ' ' << sum_val << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main (int argc, char *argv[]) {
    int e;
    while (cin>>e, e) {
        int m = e;
        for (int z = 0; z * z * z <= e; ++z) {
            for (int y = 0; y * y <= e - z * z * z; ++y) {
                int x = e - y * y - z * z * z;
                m = min(m, x + y + z);
            }
        }
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 2996
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

map = 0.upto(N-1).map { [] } # map
0.upto(N-2).each do |i|
  parent = A[i] - 1
  child = i + 1
  map[parent] ||= []
  map[parent] << child
end

0.upto(N-1).each do |i|
  p map[i].size
end


Measured memory_bytes: 64012
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    int g = 0, p = 0;
    int ans = 0;
    rep(i, s.size()){
        if(s[i] == 'g'){
            if(p < g){p++;ans++;}
            else{g++;}
        }
        else{
            if(p < g){p++;}
            else{g++;ans--;}
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
(N, H) = STDIN.gets.split(' ').map(&:to_i)
as = []
bs = []
N.times do 
    (a, b) = STDIN.gets.split(' ').map(&:to_i)
    as << a
    bs << b
end

best_a = as.max

currentH = H
counter = 0
bs.sort{|a,b| b <=> a}.each do |b|
    if b < best_a then
        break
    end
    currentH -= b
    counter += 1
    if currentH <= 0 then
        break
    end
end

if currentH > 0 then
    counter += currentH / best_a
    counter += currentH % best_a > 0 ? 1 : 0
end

puts counter


Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  rep(i,m) cin>>a[i];
  sort(begin(a),end(a),greater<ll>());
  map<int,int> cnt;
  cnt[1]=2,cnt[2]=5,cnt[3]=5,cnt[4]=4;
  cnt[5]=5,cnt[6]=6,cnt[7]=3,cnt[8]=7,cnt[9]=6;
  vector<int> dp(n+1,-1e9);
  dp[0]=0;
  FOR(i,1,n+1){
    rep(j,m){
      if(i-cnt[a[j]]>=0) dp[i]=max(dp[i],dp[i-cnt[a[j]]]+1);
    }
  }
  string ans;
  int num=n;
  while(num){
    rep(i,m){
      if(num-cnt[a[i]]>=0 && dp[num-cnt[a[i]]]==dp[num]-1){
        ans.push_back((char)a[i]+'0');
        num-=cnt[a[i]];
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int dp[205][10005]={0};
int n,w;
int wi[10005]={0};
 
int main(){
  int i,j,k=0;
  cin >> n >>w;
  for(i=0;i<n;i++)cin >> wi[i];
  sort(wi,wi+n);
  for(i=0;i<=w;i++)dp[0][i]=1;
  for(i=0;i<=n;i++)dp[i][0]=1;
  for(i=0;i<n;i++){
    for(j=1;j<=w;j++){
      if(wi[i]>j)dp[i+1][j]=dp[i][j]%1000000007;
      else if(wi[i]+k<=j)dp[i+1][j]=1%1000000007;
      else dp[i+1][j]=dp[i][j-wi[i]]+dp[i][j]%1000000007;
      //cout << dp[i+1][j]<<" ";
    }
    k+=wi[i];
    //cout << endl;
  }
  cout << dp[n][w]%1000000007<<endl;
   
  return 0;
}



Measured memory_bytes: 10868
#include<stdio.h>
#include<algorithm>
using std::min;
typedef long long ll;

int n,a[200005],L,R;
ll ans;

inline ll judge(int k)
{
	ll rt=0;
	for (int i=1;i<=n;i++) rt+=abs(k+i-a[i]);
	return rt;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	L=-233333;R=1e9;
	for (int tmp=(R-L)/3,l=L+tmp,r=R-tmp;R-L>2;tmp=(R-L)/3,l=L+tmp,r=R-tmp) if (judge(l)>=judge(r)) L=l;
	else R=r;
	ans=1e18;
	for (int i=L;i<=R;i++) ans=min(ans,judge(i));
	printf("%lld\n",ans);
} 

Measured memory_bytes: 896
def main():
    n = int(input())
    print((n + 1) // 2)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		float ansA = (float)(a / 0.08f);
		float ansB = (float)(b / 0.1f);

		int aa = ansA % 1 == 0 ? (int)ansA : (int)ansA +1;
		int bb = ansB % 1 == 0 ? (int)ansB : (int)ansB +1;

		int c = Math.max(aa, bb);

		Boolean isOK = true;
		if((int)(c * 0.08f) != a){
			isOK = false;
		}
		if((int)(c * 0.1f) != b){
			isOK = false;
		}

		int ans = isOK ? c : -1;
		System.out.println(ans);

	}

}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>

using namespace std;

struct Card {
	int  n;
	char c;
};

int judge( Card a, Card b, Card c )
{
	if(a.n == b.n && b.n == c.n) return true;
	int sum = a.n + b.n + c.n;
	int Min = min(a.n , min(b.n, c.n));
	if(sum == (3*Min+3)) return true;
	return false;
}

const int SIZE = 9;
Card cards[SIZE];
bool locked[SIZE], answer;
void search( int count )
{
	if(count >= 4) return;
	for(int i=0; i < SIZE && !answer; ++i) {
		if(locked[i]) continue;
		locked[i] = true;
		for(int j=0; j < SIZE && !answer; ++j) {
			if(locked[j] || cards[i].c != cards[j].c) continue;
			locked[j] = true;
			for(int k=0; k < SIZE && !answer; ++k) {
				if(locked[k] || cards[j].c != cards[k].c) continue;
				locked[k] = true;
				if(judge(cards[i], cards[j], cards[k])) {
					if(count == 3) { answer = true; return; }
					else { search(count + 1); }
				}
				locked[k] = false;
			}
			locked[j] = false;;
		}
		locked[i] = false;
	}
}

int main( void )
{
	int t;
	cin >> t;
	while(t--) {
		for(int i=0; i < SIZE; ++i) cin >> cards[i].n;
		for(int i=0; i < SIZE; ++i) { cin >> cards[i].c; locked[i] = false; }
		answer = false;
		search(1);
		if(answer)
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(void){
  long long int a[7];
  int i;
  long long int res,tmp,res2;
  res=0;
  for(i=0;i<7;i++){
    scanf("%d",&a[i]);
  }
  res2=res=a[1];

  res+=(a[0]-(a[0]%2)) + (a[3]-(a[3]%2)) + (a[4]-(a[4]%2));
  if(a[0]>0&&a[3]>0&&a[4]>0){
    a[0]--;a[3]--;a[4]--;
    res2+=(a[0]-(a[0]%2)) + (a[3]-(a[3]%2)) + (a[4]-(a[4]%2))+3;
  }
  printf("%lld\n",max(res,res2));
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
	
	Scanner sc = new Scanner(System.in);
	
	void run(){
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
//		Alice、ボリスが勝つ場合は Borys、どちらも勝つことができないなら 'Draw'
		
		if(Math.abs(a-b )%2 ==0 ){
			System.out.println("Alice");
		}else{
			System.out.println("Borys");
		}
		
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			ans++;
		}
	} 
	cout<<ans;
	return 0;
}

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

int main(){

	int a,b,c,d,e,f;

	cin >> a >> b >> c >> d >> e >> f;

	int  m,z;

	if( e<f ){
		z = f;
	}
	else{
		z = e;
	}

	m = a;

	if( a > b ){
		m = b;
	}
	if( m > c ){
		m = c;
	}
	if( m > d ){
		m = d;
	}

	cout << z+a+b+c+d-m << endl;

	return 0;
}


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

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s[] = (new String(in.readLine())).split(" ");
    int N = Integer.parseInt(s[0]);
    int K = Integer.parseInt(s[1]);
    int c;
    
    c = (int)Math.ceil((N - 1.0) / (K - 1.0));
      
    System.out.println(c);
  }
}


Measured memory_bytes: 22484