akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}








vector<pair<ll,ll>>q;
ll fs(ll n){
    vector<pair<ll,ll>>q;
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        if(cnt!=0)q.emplace_back(i,cnt);
        if(n==1)break;
    }
    if(n!=1)q.emplace_back(n,1);
    ll sum=1;
    for(auto x:q){
       sum*=(x.second+1);
    }
    return sum;
}




int main()
{
 ll n;
 ll a,b;
 cin>>n;
 ll ans=0;
 Rep(i,n)ans+=fs(n-i);
 cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[3007];
ll dp[3007][3007][2];
ll f(ll i,ll j,ll k)
{
	if(i>j)
		return 0;
	if(dp[i][j][k]!=-1)
		return dp[i][j][k];
	if(k==0)
		return dp[i][j][k]=max(arr[i]+f(i+1,j,1),arr[j]+f(i,j-1,1));
	else
		return dp[i][j][k]=min(f(i+1,j,0)-arr[i],f(i,j-1,0)-arr[j]);
}
int main()
{
	ll n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>arr[i];
	memset(dp,-1,sizeof(dp));
	cout<<f(0,n-1,0);
	return 0;
}


Measured memory_bytes: 141696
S = input().rstrip()
front = int(S[0:2])
back = int(S[2:4])

f = True if 1 <= front <= 12 else False
b = True if 1 <= back <= 12 else False

if f and b:
    print('AMBIGUOUS')
elif f:
    print('MMYY')
elif b:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for (int i = 0; i < n/2; ++i) {
    if (s[i] != s[n-1-i]) {
      ++ans;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3644
package main

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

func main() {
	var n, q int
	fmt.Scan(&n, &q)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	eg := make(map[int]map[int]bool)
	for i := 0; i < n-1; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		if _, ok := eg[a]; !ok {
			eg[a] = make(map[int]bool)
		}
		eg[a][b] = true
		if _, ok := eg[b]; !ok {
			eg[b] = make(map[int]bool)
		}
		eg[b][a] = true
	}

	ans := make([]int, n+1)
	for i := 0; i < q; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		ans[p] += x
	}

	qu := make([]int, 1, n)
	qu[0] = 1
	wk := make([]bool, n+1)
	wk[1] = true
	for {
		p := qu[0]
		for v := range eg[p] {
			if wk[v] {
				continue
			}
			wk[v] = true
			qu = append(qu, v)
			ans[v] += ans[p]
		}
		if len(qu) > 1 {
			qu = qu[1:]
			continue
		}
		break
	}

	wr := bufio.NewWriter(os.Stdout)
	for i := 1; i <= n; i++ {
		wr.WriteString(strconv.Itoa(ans[i]))
		if i != n {
			wr.WriteString(" ")
			continue
		}
		wr.WriteString("\n")
	}
	wr.Flush()
}


Measured memory_bytes: 61312
import java.util.*;

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

        int val1 = sc.nextInt();

        boolean can = false;
        for (int i = 1; i <= 9; i++) {
            for (int n = 1; n <= 9; n++) {
                int sum = i * n;
                if (sum == val1) {
                    can = true;
                    break;
                }
            }
            if (can) {
                break;
            }
        }

        if (can) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 25172
s = input().strip()
t = input().strip()
ls = len(s)
lt = len(t)

dp = [[0]*(lt+1) for i in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        v = dp[i][j]+1 if s[i] == t[j] else 0
        dp[i+1][j+1] = max([v, dp[i+1][j], dp[i][j+1]])

ans = ''
i, j = ls, lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1]+ans
        i -= 1
        j -= 1

print(ans)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	int N;
	cin >> N;

	pairs(A);
	pairs(B);
	fx(N) {
		pairsp(A);
	}
	fx(N) {
		pairsp(B);
	}

	sorts(A); sorts(B); reverses(A);
	bool flag[110] = { false, };
	int ans = 0;
	fx(N) {
		int j = 300;
		int x2 = -1;
		fy(N) {
			if (flag[y]) { continue; }
			if (A[x].first<B[y].first&&A[x].second<B[y].second&&j>B[y].second) {
				x2 = y;
				j = B[y].second;
			}
		}
		if (x2>=0) {
			ans++;
			flag[x2] = true;
		}
	}
	ce(ans)

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  bool bl = (sz(A) == N);
  if (bl) puts("YES");
  else puts("NO");  
  return 0;
}

Measured memory_bytes: 4000
#include <stdio.h>
 
int main(void) {
    int n, info[4][3][10];
    int i, j, k, b, f, r, v;
     
    for (i=0; i<4; i++) {
        for (j=0; j<3; j++) {
        for (k=0; k<10; k++) info[i][j][k] = 0;
    }
    }
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
    info[b-1][f-1][r-1] += v;
    }
    for (i=0; i<4; i++) {
    for (j=0; j<3; j++) {
        for (k=0; k<10; k++) {
           printf(" %d", info[i][j][k]);
           if (k==9) printf("\n");
        }
    }
        if (i==3) break;
    printf("####################\n");
    }
 
    return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector <int> a(4);
  for(int i = 1;i<4;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a.at(3)*10+a.at(2)+a.at(1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 2019
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;cin >> s;ll n;n=s.size();
    ll dp[n];dp[n-1]=s[n-1]-'0';ll d=10;
    for(ll i=n-2;i>=0;i--)
    {
        dp[i]=((d%mod)*(s[i]-'0')%mod)%mod;
        _(dp[i],dp[i+1]);d*=10;d%=mod;
    }
    ll dd[2019];memset(dd,0,sizeof(dd));ll ans=0;dd[0]=1;
    for(ll i=n-1;i>=0;i--)
    {
        ans+=dd[dp[i]];
        dd[dp[i]]++;
    }
    cout << ans;
    }

Measured memory_bytes: 5260
#include <iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a >= b){
		cout << "No" << endl;
	}else if(b >= c){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int cnt = 0;
		for (int j = 0; j < i; ++j)
			cnt += v[i] >= v[j];
		if (cnt == i)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}

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

int N, X[100009], M, Q[100009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i];
	cin >> M;
	for (int i = 1; i <= M; i++) {
		cin >> Q[i];
		if (X[Q[i]] == 2019 || X[Q[i]] + 1 == X[Q[i] + 1]) continue;
		X[Q[i]]++;
	}
	for (int i = 1; i <= N; i++) cout << X[i] << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}



void solve()
{
    ll n;
    cin>>n;
    ll a[n+1];
    rep(i,1,n+1) cin >> a[i];
    ll ps[n+1],dp[n+1];
    dp[0] = 0;dp[1] = 0;
    ps[1] = a[1];
    for(ll i=3;i<=n;i+=2) ps[i] = ps[i-2] + a[i];
    rep(i,2,n+1){
        if (i&1){
            dp[i] = max(dp[i-1],a[i]+dp[i-2]);
        }
        else{
            dp[i] = max(dp[i-2] + a[i],ps[i-1]);
        }
    }
    cout << dp[n] << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8336
num = gets.to_i
omo = [1,2,6,24,120,720,5040]
seed = []
num.times do |i|
	seed << i+1
end

arr = gets.split.map(&:to_i)
fir = 1
seed1 = seed.dup

num.times do |i|
	s = seed1.index(arr[i])
	fir = omo[num-2-i]*s + fir
	seed1.delete(arr[i])
end

arr = gets.split.map(&:to_i)
sec = 1
seed2 = seed.dup

num.times do |i|
	s = seed2.index(arr[i])
	sec = omo[num-2-i]*s + sec
	seed2.delete(arr[i])
end
ans = fir - sec
p ans.abs

Measured memory_bytes: 1788
n = int(input())
# root n に近い約数だと移動が45°に近く，移動回数も少なそう。
ca = int(n ** (1 / 2))
while True:
    if n % ca == 0:
        ca_b = n // ca
        break
    ca -= 1

print(ca - 1 + ca_b - 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int N;
    cin >> N;
    cout << N/3 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N, K;
    std::cin >> N >> K;

    if (K % 2 == 1)
    {
        long long temp = N / K;
        std::cout << temp * temp * temp << '\n';
    }
    else
    {
        long long temp = N / K;
        long long temp2 = N / (K / 2) - temp;
        std::cout << temp * temp * temp + temp2 * temp2 * temp2 << '\n';
    }
    return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long
#define INF (int)1e7

using namespace std;

signed main(){
	int N, W; cin >> N >> W;
	vector<int> m(N);
	vector<vector<int> > v(N, vector<int>(1)), w(N, vector<int>(1));
	for(int i = 0; i < N; i++){
		cin >> v[i][0] >> w[i][0] >> m[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 1; (1 << j) <= m[i]; j++){
			if((1 << j)*w[i][0] > W)break;
			v[i].push_back(v[i].back()*2);
			w[i].push_back(w[i].back()*2);
		}
	}

	vector<int> now(W+1, 0), prev(W+1, 0);
	for(int i = 0; i < N; i++){
		vector<int> nsize(W+1,0), psize(W+1, 0);
		for(int j = v[i].size()-1; j >= 0; j--){
			for(int k = 0; k < W+1; k++){
				if(k-w[i][j] >= 0 && psize[k-w[i][j]] + (1 << j) <= m[i]){
					if(prev[k] < prev[k-w[i][j]] + v[i][j]){
						now[k] = prev[k-w[i][j]] + v[i][j];
						nsize[k] = psize[k-w[i][j]] + (1 << j);
					}
					else{
						now[k] = prev[k];
						nsize[k] = psize[k];
					}
				}
				else{
					now[k] = prev[k];
					nsize[k] = psize[k];
				}
			}
			/*
			for(auto e : now)cerr <<  setfill(' ') << setw(3) << e;
			cerr << endl;
			for(auto e : nsize) cerr << setfill('_') << setw(3) << e;
			cerr << endl;
			cerr << endl;
			*/
			swap(now, prev);
			swap(nsize, psize);
		}
		//cerr << endl;
	}
	cout << prev[W] << endl;



	return 0;
}




Measured memory_bytes: 3284
N=int(input())
#S=  [ [-1] * N for i in range(N)]
S=[ [] * N for i in range(N)]
#print(S)
for i in range(N):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    #S[i][x-1]=y
    S[i].append([x-1,y])
#print(S)
ans=0
P=[0]*N
#print(P)
for i in range(2**N):
  tmp=0
  for j in range(N):
    if P[j]==0:
      P[j]=1
      break
    else:
      P[j]=0
  #print(P,sum(P))
  if sum(P)<=ans:
    continue
  flag=0
  for p in range(len(P)):
    if P[p]==1:
      for s in S[p]:
        if s[1]!=P[s[0]]:
          flag=1
  if flag==1:
    continue
  else:
    ans=sum(P)
print(ans)


Measured memory_bytes: 48604
#include <stdio.h>
int main()
{
    unsigned long long int a,b,k,var=0,aft=0,count=0;
    scanf("%llu%llu%llu",&a,&b,&k);
    while(k--)
    {
        count++;
        if(count%2==0)
        {
            var=b;
            aft=a;
        }
        else
        {
        var=a;
        aft=b;
        }
        if(var%2==0 && var!=0)
        {
            var=var/2;
            aft=aft+var;
        }
        else if(var%2!=0)
        {
            var=var-1;
            var=var/2;
            aft=aft+var;
        }
        if(count%2==0)
        {
            b=var;
            a=aft;
        }
        else
        {
        a=var;
        b=aft;
        }
        
    }
    printf("%llu %llu",a,b);
    return 0;
}


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

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

typedef long long ll;

const ll INF = 1LL << 60;
long long dp[100010];
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define MAX 10000
#define NIL -1
struct Node { int p, l, r; };
struct Node T[MAX];

int main() {
    int n;
    ll h[100010];
    cin >> n;
    rep(i,n){
        cin >> h[i];
    }

    rep(i, 100010) dp[i] = INF;

    dp[0] = 0;

    for (int i = 1; i < n; i++)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int a[3] ={0,0,0};
    for(int i = 0; i < 3; i++){
        char tmp;
        cin >> tmp;
        a[tmp -97]++;
    }
    if(a[0] == 1 && a[1] == 1 && a[2] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
as=3.times.map{gets.split.map(&:to_i)}.flatten
n=gets.to_i
bs=n.times.map{gets.to_i}
bs.each do |bn|
  9.times do |i|
    as[i]="C" if bn==as[i]
  end
end
check=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
check.each do |marks|
  if marks.all?{|i| as[i]=="C"}
    puts "Yes"
    exit
  end
end
puts "No"


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

int main(void){
	int N;
	cin >> N;
	ll A[N];
	rep(i,N) cin >> A[i];
	sort(A,A+N, greater<>());
	ll ans = 0;
	for (int i = 1; i < N; i++) {
		ans += A[int(floor(i/2.))];
	}
	cout << ans << endl;
	 
return 0;
}


Measured memory_bytes: 5208
import math

N,P = map(int,input().split())
A = list(map(int,input().split()))

remainders = [a%2 for a in A]

odd = remainders.count(1)
even = remainders.count(0)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
for n in range(N+1):
  for p in range(P,n+1,2):
    if odd >= p and even >= n-p:
      ans += combinations_count(odd,p) * combinations_count(even,n-p)

print(ans)

Measured memory_bytes: 9132
package main

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

const (
	maxBufsize = 1000000
)

func inputs(lines int) []string {
	var strSlice []string

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func main() {
	lines := inputs(2)

	K, _ := strconv.Atoi(lines[0])

	tmp := strings.Split(lines[1], " ")

	A, _ := strconv.Atoi(tmp[0])
	B, _ := strconv.Atoi(tmp[1])

	b := B / K
	bAmari := B % K

	a := A / K
	aAmari := A % K

	if b == 0 {
		fmt.Println("NG")
		return
	}

	if (b - a) > 0 {
		fmt.Println("OK")
		return
	} else {
		if bAmari == 0 || aAmari == 0 {
			fmt.Println("OK")
			return
		} else {
			fmt.Println("NG")
			return
		}
	}

}


Measured memory_bytes: 1868
/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/



#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define ff           first
#define ss           second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num, int pos);
ll setbitt(ll num, ll pos);
ll resetbitt(ll num, int pos);
void abcd() {
#ifndef ONLINE_JUDGE
	input;
	output;
#endif
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#endif
}

void read(int *aa, int sz) {fri(sz) scanf("%d", (aa + i));}
void read(ll *aa, int sz) {fri(sz) scanf("%lld", (aa + i));}
void read(ll *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%lld", (aa + i));}
void read(int *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%d", (aa + i));}
const ll mod =       1e9 + 7;
const ll N =     1e6 + 10;

//.................___Start from here___.................//
//.................._____________________................//
int n, k;
ll dp[N];
ll w[N];
ll v[N];



int solve() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}


	for (int i = 1; i <= n; i++) {
		for (int j = k; j >= 1; j--) {
			if (j >= w[i]) {
				dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
			}
		}
	}

	cout << dp[k] << endl;


	return 0;
}
int main() {
	// abcd();
	int cs = 1;
	int cn = 1;
	//cin>>cs;
	while (cs--) {
		solve();

	}
}


bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}




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

using namespace std;

int main()
{
   int a, b;
   int pstrip = 0;
   int socket = 1;
   cin >> a >> b;
   if(b == 1) {
       cout << 0 << endl;
       return 0;
   }
   while (socket < b) {
       socket = socket + a - 1;
       pstrip++;
   }
   cout << pstrip << endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace ABC119B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var total = 0.0;
            var numGifts = int.Parse(Console.ReadLine());

            for (int i = 0; i < numGifts; i++)
            {
                var temp = Console.ReadLine().Split(' ').ToArray();
                var amount = double.Parse(temp[0]);
                var unit = temp[1];
                Console.Error.WriteLine(amount + " : " + unit);

                if (unit == "JPY")
                {
                    total += amount;
                }
                else
                {
                    total += amount * 380000.0;
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll h[100001] = {};
int main() {
	ll n; cin >> n;
	rep(i, 0, n)cin >> h[i];

	rep(i, 0, n-1) {
		if (h[i] == h[i + 1]) {
			continue;
		}
		else if (h[i] < h[i + 1]) {
			h[i + 1]--;
		}

		if (h[i] > h[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1024
l, r = map(int, input().split())
answer = 2018

if r-l >= 2018:
  answer = 0
else:
  l = [i%2019 for i in range(l, r+1)]
  l.sort()
  for i in range(len(l)):
    for j in range(i+1, len(l)):
      answer = min(answer, l[i]*l[j]%2019)

print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    double ans;
    if(n%2 == 0) {
        ans = 0.5;
    }
    else {
        ans = (double)(n/2+1.0)/(double)n;
    }
    
    exout(ans);
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int n;

void koch(int d, double x1, double y1, double x2,double y2){
 double sin60 = sqrt(3.0)/2.0;
 double cos60 = 0.5;

 double sx = (2 * x1 + x2)/3;
 double sy = (2 * y1 + y2)/3;
 double tx = (2 * x2 + x1)/3;
 double ty = (2 * y2 + y1)/3;

 double vx = tx - sx;
 double vy = ty - sy;

 double ux = sx + cos60 * vx - sin60 * vy;
 double uy = sy + sin60 * vx + cos60 * vy;


 if(d >= n)
  return;

 koch(d + 1,x1,y1,sx,sy);
 printf("%.8f %.8f\n",sx,sy);
 koch(d + 1,sx,sy,ux,uy);
 printf("%.8f %.8f\n",ux,uy);
 koch(d + 1,ux,uy,tx,ty);
 printf("%.8f %.8f\n",tx,ty);
 koch(d + 1,tx,ty,x2,y2);
 }

int main(){

  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  koch(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

Measured memory_bytes: 640
#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
using namespace std;
int main(){
    int N;
    double s=0.0;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a.at(i);
        s+=1.00000000/a.at(i);
    }
    cout << 1.000000000/s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x, y;
    while (1) {
        scanf("%d %d\n", &x, &y);
	if (x == 0 && y == 0) {
   	    break;
	} else if (x >= y) {
	    printf("%d %d\n", y, x);
	} else {
    	    printf("%d %d\n", x, y);
        }
    }
    return 0;
}

Measured memory_bytes: 604
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    auto a = aryread();
    long c;

    while (a.any!(x => x != 0))
    {
        loop: foreach (i, v; a)
        {
            if (v != 0)
            {
                c++;
                size_t j = i;
                while (a[j] != 0 && j < a.length)
                {
                    a[j]--;
                    j++;
                }
                break loop;
            }
        }
    }
    writeln(c);
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = abs(x1-x2);
  int dy = abs(y1 - y2);
  cout << string(dy,'U') << string(dx,'R');
  cout << string(dy,'D') << string(dx,'L');
  cout << 'L' << string(dy + 1,'U') << string(dx + 1,'R') << 'D';
  cout << 'R' << string(dy + 1,'D') << string(dx + 1,'L') << 'U';

return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	int alice=0,bob=0;
	for(int i=0;i<n;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		i%2==0? alice+=a.at(i) : bob+=a.at(i);
	}
	cout<<abs(alice-bob)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N, M;
  cin >> N >> M;
  int s = 0;
  rep(i, M) {
    int a;
    cin >> a;
    s += a;
  }
  N -= s;
  cout << (N < 0 ? -1 : N) << endl;
  return 0;
}

Measured memory_bytes: 3188
while l = gets
    n = l.chomp.to_i
    break if n == 0
    
    s = gets.split.map(&:to_f)
    m = s.inject(:+) / n
    
    sum = s.inject(0){|sum, i| sum + (i - m) ** 2 }
    puts Math.sqrt(sum / n)
end



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

int main(){
    int cnt=0;
    std::string S,T;std::cin>>S>>T;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i]!=T[i])cnt++;
    }
    std::cout<<cnt<<std::endl;
}

Measured memory_bytes: 3868
#include<iostream>
using namespace std;
int main(){
  int a[5], min=9, index;
  for(int i=0; i<5; i++){
    cin >> a[i];
    if(a[i]%10 < min && a[i]%10!=0){
      min = a[i]%10;
      index = i;
    }
  }
  int ans=0;
  for(int i=0; i<5; i++){
    if(i == index){
      ans += a[i];
    }else{
      ans += ((a[i]-1)/10+1)*10;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
import std.typecons;

void main() {
  int N; readlnTo(N);
  auto data = new Tuple!(int, int, int)[N];
  
  int tx, ty, th;
  foreach(i; 0..N) {
    readlnTo(data[i][0], data[i][1], data[i][2]);
    if(data[i][2] >= 1) {
      tx = data[i][0];
      ty = data[i][1];
      th = data[i][2];
    }
  }

  foreach(px; 0..101) {
    foreach(py; 0..101) {
      int ph = th + abs(px - tx) + abs(py - ty);
      bool ok = true;
      
      foreach(e; data) {
        int h = max(ph - abs(e[0] - px) - abs(e[1] - py), 0);
        if(h != e[2])
          ok = false;
      }

      if(ok) {
        "%d %d %d".writefln(px, py, ph);
        return;
      }
    }
  }
}

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
const long long mod = 1e9+7;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
    ll a,b,h;
    cin>>a>>b>>h;
    cout << (a+b) * h / 2 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;++i) cin >> a[i];

    ll x = 0;
    for(int i=2;i<n;++i) x ^= a[i];

    if(x == 0) {
        if(a[0] < a[1] || (a[0] + a[1]) % 2 || (n > 2 && (a[0] - a[1]) / 2 == 0)) {
            cout << -1 << endl;
        } else {
            cout << (a[0] - a[1]) / 2 << endl;
        }
    } else {
        if((a[0] + a[1] - x) % 2) {
            cout << -1 << endl;
            return 0;
        }
        ll c = (a[0] + a[1] - x) >> 1; // a[0] & a[1];
        ll a0 = c, a1 = c;
        for(int i=60;i>=0;--i) {
            if(c & (1LL << i)) {
                continue;
            }
            if(x & (1LL << i)) {
                if(a0 + (1LL << i) <= a[0]) {
                    a0 += (1LL << i);
                } else {
                    a1 += (1LL << i);
                }
            }
        }
        if(!a0 || a0 > a[0] || a1 < a[1]) {
            cout << -1 << endl;
            return 0;
        }
        if((a0 ^ a1) == x) {
            cout << a[0]-a0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    double a,b,x;
    std::cin >> a >> b >> x;

    double ans;
    if(((a*a*a)/(2.0*(a*a*b-x)))>=a/b) ans = atan((a*a*a)/(2.0*(a*a*b-x)));
    else ans = atan(2.0*x/(a*b*b));
    std::cout << std::fixed << std::setprecision(10) << 90-rad2deg(ans) << "\n";
    return 0;
}


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

typedef long long ll;

const int N = 4000;

int a[2*N + 5], n, x;

int le[2*N + 5], ri[N + 5];

ll s[2*N + 5];

int main() {
	scanf("%d%d", &n, &x);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]), a[n + i] = a[i];
	a[0] = a[2*n + 1] = 0;
	for(int i=1;i<=2*n;i++) {
		le[i] = i - 1;
		while( a[le[i]] >= a[i] ) le[i] = le[le[i]];
	}
	for(int i=2*n;i>=1;i--) {
		ri[i] = i + 1;
		while( a[ri[i]] > a[i] ) ri[i] = ri[ri[i]];
	}
	for(int i=1;i<=n;i++) {
		int p = (n + i) - le[n + i], q = ri[i] - i;
		s[0] += a[i], s[min(p, q)] -= a[i];
		s[max(p, q)] -= a[i], s[min(p, q) + max(p, q)] += a[i];
		
	}
	
	for(int i=1;i<=n;i++) s[i] += s[i - 1];
	for(int i=1;i<=n;i++) s[i] += s[i - 1];
	
	ll ans = (1ll << 60);
	for(int i=0;i<=n;i++) ans = min(ans, s[i] + 1ll*i*x);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int cnt=0;
void selectionSort(int A[],int N)
{
    for(auto i=0;i<N;i++)
    {
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj])
                minj=j;
        }
        if(i!=minj){
            int t=A[i];
            A[i]=A[minj];
            A[minj]=t;
            cnt++;
        }
    }
}

int main()
{
    int n;
    cin>>n;
    int a[100];
    for(int i=0;i<n;i++)
        cin>>a[i];
    selectionSort(a,n);
    for(int i=0;i<n;i++)
    {
        if(i>0)
            cout<<" ";
        cout<<a[i];
    }
    cout<<endl<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
ll N, K;
vll A;

bool ch(ll t) {
	ll c = 0;
	repn(i, N) {
		c += (A[i] + t - 1) / t - 1;
	}

	if (c <= K) { return true; }
	return false;
}

int main(){
	cin >> N >> K;
	A.resize(N + 1);
	repn(i, N)cin >> A[i];
	ll l = 0;
	ll r = 1e12;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (ch(m)) { r = m; }
		else { l = m; }
	}
	cout << r << endl;


}



Measured memory_bytes: 4812
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        v.emplace_back(a, 0);
    }
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        v.emplace_back(a, 1);
    }
    std::sort(v.begin(), v.end());

    int t[] { 0, 0 };
    i64 ret = 1;
    for (int i = 0; i < 2 * n; i++) {
        auto &c = t[!v[i].second];
        if (c) {
            ret = ret * c % mod;
            c--;
        } else {
            t[v[i].second]++;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++)
#define vecshow(vec) for(auto itr = (vec).begin(); itr != (vec).end(); itr++)cout << *itr << " ";

using namespace std;
using p = pair<int, int>;
using ll = long long;

int gcd(int a, int b) {
	int l = max(a, b);
	int s = min(a, b);
	while (l * s != 0) {
		int tmp = s;
		s = l % s;
		l = tmp;
	}

	return l;
}

vector<vector<int>> path;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
	return 0;

}

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

int main(void){
	int m,n,ans;
	while(cin>>m,m){
		cin>>n;
		ans = 0;
		for(int i = 1; i <= n ; i *= 5)
		for(int j = i; j <= n ; j *= 3)
		for(int k = j; k <= n ; k *= 2){
			if(k>=m)
				ans ++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import numpy as np
N = int(input())
List = [[]]*N
for T in range(0,N):
    Str,Num = input().split()
    List[T] = [Str,int(Num),T+1]
SorL = sorted(List, key=lambda x:(x[0],-x[1]))
SorI = list(str(x[2]) for x in SorL)
print('\n'.join(SorI))

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

int main(){
    int n,count =0, max=0;
    cin >> n;
    vector<int> h(n);
    for(int i =0; i<n; ++i){
        cin >> h[i];
    }
    for(int i=0; i<n-1; ++i){
        while(h[i]>=h[i+1] && i+1<n){
            ++count;
            ++i;
        }
        if(count > max){max = count;}
        count = 0;
    }
    cout << max << endl;
}

Measured memory_bytes: 640
N = gets.chomp.to_i
cnt = Hash.new(0)
require "set"
mula = Set.new
A = []
gets.chomp.split(" ").each do |aa|
  a = aa.to_i
  A << a
  cnt[a] += 1
  mula << a if cnt[a] > 1
end

combi = {}
t = 0
cnt.each do |a, c|
  combi[c] ||= c * (c-1) / 2
  t += combi[c]
end

ans = Hash.new(0)

A.each do |a|
  c = cnt[a]
  c0 = combi[c]
  c1 = (combi[c-1] ||= (c-1) * (c-2) / 2)
  puts t - (c0 - c1)
end


Measured memory_bytes: 32548
s = input().rstrip()

iG = 0
iP = 0
iR = 0
for i in range(len(s)):
    if s[i] == "g":
        if iP < iG:
            iR += 1
            iP += 1
        else:
            iG += 1
    elif s[i] == "p":
        if iP < iG:
            iP += 1
        else:
            iR -= 1
            iG += 1

print(iR)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}



int main() {
  int N,K;
  cin >> N >> K;
  string s;
  cin >> s;
  char now = s[0];
  int cnt = 0;
  vi nums;
  rep(i,N) {
    if(s[i] == now) {
      cnt++;
    } else {
      nums.push_back(cnt);
      if(now == 'R') {
        now = 'L';
      } else {
        now = 'R';
      }
      cnt = 1;
    }
  }
  if(cnt != 0) nums.push_back(cnt);
  int ans = 0;
  rep(i,sz(nums)) {
    if(nums[i] > 1) {
      ans += nums[i] - 1;
    }
  }
  int between = sz(nums) -1;
  ans += min(between,K*2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long
#define max_sum 100000

using namespace std;

vector <ll> V;
ll dp[101][max_sum + 1];

int main() {
    for(int j = 1; j <= max_sum; j++)
        dp[0][j] = INT_MAX;

    ll n, W;
    cin >> n >> W;
    for(int i = 1; i <= n; i++) {
        ll weights, value;
        cin >> weights >> value;
        for(int j = 1; j <= max_sum; j++) {
            dp[i][j] = dp[i - 1][j];
            if(j - value >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - value] + weights);
        }
    }

    for(int i = max_sum; i >= 0; i--) {
        if(dp[n][i] <= W) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 82532
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string S;
  cin >> S;

  int flag = 1;
  if(S.at(0) != 'A'){
    flag = 0;
  }
  if(S.at(1) < 'a' || S.at(1) > 'z'){
    flag = 0;
  }
  int flag2 = 0;
  FOR(i,2,S.size()-1){
    if(S.at(i) == 'C' && flag2 == 0){
      flag2 = 1;
    }else if(S.at(i) == 'C' && flag2 == 1){
      flag = 0;
    }else if(S.at(i) < 'a' || S.at(i) > 'z'){
      flag = 0;
    }
  }
  if(flag2 == 0){
    flag = 0;
  }
  if(S.at(S.size()-1) < 'a' || S.at(S.size()-1) > 'z'){
    flag = 0;
  }

  if(flag == 1){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
sp = [input().split() for _ in range(n)]
for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i].append(i+1)
sp.sort(key=lambda x:(x[0], 100-x[1]))
for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 3060