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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        PriorityQueue<Restaurant> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            StringTokenizer st = new StringTokenizer(in.readLine());
            Restaurant r = new Restaurant(st.nextToken(), Integer.parseInt(st.nextToken()), i+1);
            pq.offer(r);
        }

        for (int i = 1; i <= n; i++) {
            Restaurant r = pq.poll();
            System.out.println(r.id);
        }

    }

    static class Restaurant implements Comparable<Restaurant>{
        String city;
        int score, id;
        public Restaurant(String city, int score, int id) {
            this.city = city;
            this.score = score;
            this.id = id;
        }
        public int compareTo(Restaurant r) {
            if (r.city.equals(this.city)) {
                if (this.score > r.score) {
                    return -1;
                } else {
                    return 1;
                }
            } else {
                ArrayList<String> list = new ArrayList<>();
                list.add(r.city);
                list.add(this.city);
                Collections.sort(list);
                if (list.get(0).equals(this.city)) {
                    return -1;
                } else {
                    return 1;
                }
            }
        }
    }
}
/*

 */

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,j,k) for(int i=j;i<k;i++)
#define vl vector<ll>
#define vll vector<vl> 

int main() {
	// your code goes here
	ll n, w;
	cin>>n>>w;	
	vll v(n, vl(2, 0));
	rep(i,0,n){
		cin>>v[i][0]>>v[i][1];
	}
	vll dp(n+1, vl(w+1, 0));
	
	rep(i,1,n+1){
		rep(j,1,w+1){
			ll wt = v[i-1][0];//i-1 coz v is 0-indexed
			ll val = v[i-1][1];
			if(wt<=j){//if weight<=j
				dp[i][j]=max(dp[i-1][j-wt]+val, //choosing item i
							dp[i-1][j]);//not choosing item i
			}
			else dp[i][j]=dp[i-1][j];
		}
	}
	auto idx = max_element(dp[n].begin(), dp[n].end());
	cout<<*idx<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

int main(void)
{
    int n;
    int a[200000];
    int i;
    int max = 0;
    int max_2 = 0;
    int *p_1;

    scanf("%d", &n); 

    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for(i = 0; n > i; i++){
        if(a[i] > max){
            p_1 = &a[i];
            max = a[i];
        }

        if(a[i] > max_2 && &a[i] != p_1){
            max_2 = a[i];
        }
    }

    for(i = 0; n > i; i++){
        if(p_1 != &a[i]){
            printf("%d\n", max);
        }

        else{
            printf("%d\n", max_2);
        }
    }

    return 0;
}

Measured memory_bytes: 2304
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())
    top = 0
    bottom = 0
    top_and_bottom = 0
    ans = 0
    for _ in range(n):
        sentence = input().rstrip()
        ans += sentence.count("AB")
        if sentence[0] == "B":
            top += 1
            if sentence[-1] == "A":
                top_and_bottom += 1
        if sentence[-1] == "A":
            bottom += 1
    if top == 0 and bottom == 0:
        print(ans)
    elif top == top_and_bottom and top_and_bottom == bottom:
        print(ans+top-1)
    else:
        print(ans+min([top, bottom]))


Measured memory_bytes: 3064
n,k=map(int,input().split())
a=[int(j) for j in input().split()]
f=[int(j) for j in input().split()]
a.sort()
f.sort()
f.reverse()
if k>=sum(a):
    print(0)
    exit()

ans=[]
a.sort()
for i in range(n):
    ans.append([a[i]*f[i],a[i]])
ans.sort()
ans.reverse()

def fun(m):
    p=0
    for i,j in zip(a,f):
        if i>m//j:
            p+=i-(m//j)
            if p>k:
                return False
    return True

left=0
right=ans[0][0]
while right-left>1:
    mid=(left+right)//2
    if fun(mid):
        right=mid   #ここがleftならansもleft。
    else:
        left=mid

print(right)






Measured memory_bytes: 123340
<?php
while(1){
  list($m,$f,$r)=explode(' ',trim(fgets(STDIN)));
  if($m!=-1||$f!=-1||$r!=-1){
    if($m==-1||$f==-1){
      echo "F\n";
      continue;
    }
    $x=$m+$f;
    if(80<=$x) echo "A\n";
    elseif(65<=$x) echo "B\n";
    elseif(50<=$x) echo "C\n";
    elseif(30<=$x) echo (50<=$r)? "C\n":"D\n";
    else echo "F\n";
  }
  else break;
}

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

int main(){
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if(S==U){
    A--;
  }else if(T==U){
    B--;
  }
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

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

	cin >> N;
	int ans = 0;
	vector <int>data(N);
	for (auto &x : data)
	{
		cin >> x;
	}
	/*for (auto &i : data)
	{
		cout << i << endl;
	}*/
	map <int, int>box;
	for (auto &x : data)
	{
		box[x]++;
	}
	
	for (auto &x : box)
	{
		if (x.second % 2 != 0)
		{
			ans++;
		}
	}
	
		cout << ans << endl;
	return 0;

}


Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long int ll;

int main(void){
    string s , t ;
    cin >> s >> t ;
    size_t n = s.length() ;
    sort(s.begin() , s.end());
    sort(t.begin() , t.end());
    
    vector<ll>sn(200000 , 0) ;
    vector<ll>tn(200000 , 0) ;
    ll count = 1 ;
    ll now = 0;
    for(ll i = 0 ; i < n-1 ; i++){
        if(s[i] == s[i+1]){
            count ++ ;
        }else{
            sn[now] = count ;
            count = 1 ;
            now++ ;
        }          
    }
    sn[now] = count ;
    count = 1 ;
    for(ll i = 0 ; i < n-1 ; i++){
        if(t[i] == t[i+1]){
            count ++ ;
        }else{
            tn[now] = count ;
            count = 1 ;
            now++ ;
        }          
    }
    tn[now] = count ;
    count = 1 ;
    
    bool flag = true ;

    sort(sn.begin() , sn.end()) ;
    sort(tn.begin() , tn.end()) ;

    for(ll j = 0; j < 200000 ; j++){
        if(sn[j] != tn[j]){
            flag = false ;
        }
    }
    
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b  >>c ;
  if (max(max(a,b),c)*2 == (a+b+c))cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string s;


void solve(){
	rep(i, 0, SIZE(s)-2)
		if(s[i] == s[i+2]){ cout << i+1 << ' ' << i+3 << endl; return; }
		else if(s[i] == s[i+1]){ cout << i+1 << ' ' << i+2 << endl; return; }
	if(s[SIZE(s)-2] == s[SIZE(s)-1]){ cout << SIZE(s)-1 <<  ' ' << SIZE(s) << endl; return; }
	cout << -1 << ' ' << -1 << endl;
}


signed main(){
	cin >> s;

	solve();

	return 0;
}

Measured memory_bytes: 512
a, b, x = [int(i) for i in input().split()]

if x % 1000:
    max_a = x // 1000 + 1
else:
    max_a = x // 1000

if x % 500:
    max_b = x // 500 + 1
else:
    max_b = x // 500

min_cost = max_a*a + max_b*b

for i in range(max_a + 1):
    for j in range(max_b + 1):
        if 1000*i + 500*j >= x:
            if a*i + b*j < min_cost:
                min_cost = a*i + b*j
            break
        
print(min_cost)



Measured memory_bytes: 5604
#include <iostream>
#include <string>

using namespace std;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int tmp;
  tmp = Z;
  Z = Y;
  Y = X;
  X = tmp;

  cout << X << " " << Y << " " << Z << endl;

  return 0;
}


Measured memory_bytes: 888
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int x1,y1,x2,y2,x3,y3;scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3),x1||y1||x2||y2||x3||y3;){
		double a,b,c;
		a=hypot(x2-x3,y2-y3);
		b=hypot(x3-x1,y3-y1);
		c=hypot(x1-x2,y1-y2);
		double A,B,C;
		A=acos((b*b+c*c-a*a)/(2.*b*c))/2;
		B=acos((c*c+a*a-b*b)/(2.*c*a))/2;
		C=acos((a*a+b*b-c*c)/(2.*a*b))/2;

		double cotA,cotB,cotC;
		cotA=cos(A)/sin(A);
		cotB=cos(B)/sin(B);
		cotC=cos(C)/sin(C);

		double s=(a+b+c)/2;
		double area=sqrt(s*(s-a)*(s-b)*(s-c));

		double r1,r2,r3;
		double r1min=0.05,r1max=2*area/(a+b+c);
		rep(i,50){
			r1=(r1min+r1max)/2;
			r2=(-sqrt(r1)+sqrt(r1+cotB*(c-r1*cotA)))/cotB;	r2=r2*r2;
			r3=(-sqrt(r1)+sqrt(r1+cotC*(b-r1*cotA)))/cotC;	r3=r3*r3;
			if(r2*cotB+2*sqrt(r2*r3)+r3*cotC<a)	r1max=r1;
			else								r1min=r1;
		}
		printf("%f %f %f\n",r1,r2,r3);
	}

	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int x,a,b;
  
  scanf(" %d %d %d",&x,&a,&b);
  
  if(b-a > 0){
    if(b-a > x){
      printf("dangerous\n");
    } else {
      printf("safe\n");
    }
  } else {
    printf("delicious\n");
  } 
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e6 + 5;

int n, k;
int a[N];

int32_t main()
{
	IOS;
	cin >> k >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = k;
	int sum = 0;
	for(int i = 1; i + 1 <= n; i++)
		sum += a[i + 1] - a[i];
	ans = min(ans, k - (k - a[n] + a[1]));
	for(int i = 1; i + 1 <= n; i++)
		ans = min(ans, k - (a[i + 1] - a[i]));
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
a, b, c = map(int, input().split())

def count(a,b,c):
    r = b // c - a // c
    if a % c == 0:
        r += 1
    return r
if a == 0:
    ans = count(a+1,b,c) + 1
else : ans = count(a,b,c)
print(ans)

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    int l = 0;
    int r = 1;
    long sum = a[0];
    for (l = 0; l < n; l++) {
      if (l == r) {
        sum += a[r];
        r++;
      }
      while (r < n && a[r] <= sum * 2) {
        sum += a[r];
        r++;
      }
      if (r == n) {
        os.println(r - l);
        return;
      }
    }
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a <= n; ++a) {
    ans += (n - 1) / a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
package main

import (
  "fmt"
)

func main() {
  var N int
  
  fmt.Scan(&N)
  
  bty := 380000.0
  
  total := 0.0
  
  for i := 0; i < N; i++ {
    var x float64
    var u string
    fmt.Scan(&x, &u)
    switch u {
    case "BTC":
      total += x * bty
    case "JPY":
      total += x
    }
  }
  fmt.Println(total)
}

Measured memory_bytes: 512
N, M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i] = map(int, input().split())

ran = []
for i in range(10 ** (N - 1), 10 ** N):
    ran.append(i)
if N == 1:
    ran.append(0)

ran.sort()
minimum = 10 ** N
for r in ran:
    st = str(r)
    ok = True
    for j in range(M):
        if st[s[j] - 1] != str(c[j]):
            ok = False
    if ok == True:
        minimum = min(minimum, r)
        break
if minimum == 10 ** N:
    print(-1)
else:
    print(minimum)


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

int main() {
  int N = 1;
  for(int i = 1; i < 10001; i++){
      cin >> N;
      if (N == 0){

          break;
      }
      else cout << "Case " << i << ": " << N << endl;
  }
}


Measured memory_bytes: 3092
def fun(j,t)
	return $dp[j][t] unless $dp[j][t].nil?
	
	cmpr = t - $xArr[j-1] + $a
	if j == 0 && t == $nx then
		tmp = 1
	elsif j >= 1 then
		if cmpr < 0 || cmpr > 2*$nx then
			tmp = $dp[j-1][t].nil? ? fun(j-1,t) : $dp[j-1][t]
		else
			t1 = $dp[j-1][t].nil? ? fun(j-1,t) : $dp[j-1][t]
			t2 = $dp[j-1][cmpr].nil? ? fun(j-1,cmpr) : $dp[j-1][cmpr]
			tmp = t1 + t2
		end
	else
		tmp = 0
	end
	
	$dp[j][t] = tmp
end

$n,$a = gets.split(" ").map(&:to_i)
$xArr = gets.split(" ").map(&:to_i)

xMax = $xArr.max
x = xMax > $a ? xMax : $a
$nx = $n * x

$dp = Hash.new { |h,k| h[k] = {} }
fun($n,$nx)

p $dp[$n][$nx] - 1

Measured memory_bytes: 3068
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;
/*
* * * * * * * * * * * * * * * * * * * * * *
*       ☆꧁𝓑𝓐𝓒𝓚_𝓛𝓞𝓖꧂☆              **
*                                        ***
* * * * * * * * * * * * * * * * * * * * *****
*/ 

int32_t main()
{
  
int d,t,s;
cin>>d>>t>>s;
if((d<=(t*s)))
{
	cout<<"Yes"<<endl;
}
else
{
	cout<<"No"<<endl;
}
return 0;

}




Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

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

	ANS((n - 2) * 180);
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    ll n;cin>>n;
    set<ll> g1={2,4,5,7,9};
    set<ll> g2={0,1,6,8};
    set<ll> g3={3};
    if(g1.count(n%10)){
        cout<<"hon"<<endl;
    }else if(g2.count(n%10)){
        cout<<"pon"<<endl;
    }else cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3636
a,b=map(int,input().split())

ans=0

for i in range(a,b+1):
    buf=str(i)
    #print(buf[0:int(len(buf)/2)],buf[int(len(buf)/2+1):])
    str1=buf[0:int(len(buf)/2)]
    str2=buf[int(len(buf)/2+1):]
    if str1[0]==str2[1] and str1[1]==str2[0]:
        ans+=1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  unsigned long int h,w, tmp_w1, tmp_w2, tmp_h1, tmp_h2;
  unsigned long int counter_l, counter_m;
  scanf("%lu %lu", &h, &w);
  if (w == 1 || h == 1) {
    printf("1");
    return 0;
  }
  if (w % 2 != 0) {
    tmp_w1 = w / 2 + 1;
    tmp_w2 = w - tmp_w1;
  } else {
    tmp_w1 = w / 2;
    tmp_w2 = w - tmp_w1;
  }
  if (h % 2 != 0) {
    tmp_h1 = h / 2 + 1;
    tmp_h2 = h - tmp_h1;
  } else {
    tmp_h1 = h / 2;
    tmp_h2 = h - tmp_h1;
  }
  counter_l = tmp_w1 * tmp_h1;
  counter_m = tmp_w2 * tmp_h2;
  printf("%lu", counter_l + counter_m);
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  bool f = false;
  rep(i, 0, 100) rep(j, 0, 100) {
    if (4 * i + 7 * j == N)
      f = true;
  }
  Yes(f);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, m, s, g;
	E[] G;
	int MAX = 30;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n|m) == 0) break;

			s = sc.nextInt() - 1;
			g = sc.nextInt() - 1;
			if ((n|m|s|g) == 0) break;

			G = new E[n];
			for (int i = 0; i < n; i++) G[i] = new E();

			for (int i = 0; i < m; i++) {
				int x = sc.nextInt() - 1, y = sc.nextInt() - 1, d = sc.nextInt(), c = sc.nextInt();
				G[x].add(new V(y, d, c));
				G[y].add(new V(x, d, c));
			}

			System.out.println(dijkstra());
		}
	}

	String dijkstra() {
		double[][][] d = new double[MAX + 1][n][n];
		for(double[][] a : d) for (double[] b : a) fill(b, INF);
		d[0][s][s] = 0;
		PriorityQueue<S> q = new PriorityQueue<S>();
		q.add(new S(0, s, s, 0));

		for (;!q.isEmpty();) {
			S cur = q.remove();
//			debug(cur);
			if (d[cur.v][cur.p][cur.f] != cur.c) continue;
			if (cur.p == g && cur.v == 1) return "" + cur.c;

			for (V v : G[cur.p]) if (v.t != cur.f) {
				for (int i = -1; i <= 1; i++) {
					int nv = cur.v + i;
					if (nv <= 0 || nv > v.c) continue;
					double nc = cur.c + 1.0 * v.d / nv;
					if (d[nv][v.t][cur.p] > nc) {
						d[nv][v.t][cur.p] = nc;
						q.add(new S(nv, v.t, cur.p, nc));
					}
				}
			}
		}


		return "unreachable";
	}

	class S implements Comparable<S>{
		int v, p, f;
		double c;
		S(int v, int p, int f, double c) {
			this.v = v;
			this.p = p;
			this.f = f;
			this.c = c;
		}
		@Override
		public int compareTo(S o) {
			// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
			return c - o.c > 0 ? 1 : -1;
		}

		public String toString() {
			return "[" + v + ", " + p + ", " + f + ", " + c + "]";
		}
	}


	class E extends ArrayList<V>{};
	class V {
		int t, d, c;
		V(int t, int d, int c) {
			this.t = t;
			this.d = d;
			this.c = c;
		}
	}

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

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(int argc, char const *argv[])
{
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if ((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2]))
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    priority_queue<ll, vector<ll>, greater<ll>> q;
    q.push(1);
    while (--k) {
        ll v = q.top();
        q.pop();

        if (v < 9) q.push(v + 1);

        ll rem = v % 10;
        if (rem > 0) q.push(v * 10 + rem - 1);
        q.push(v * 10 + rem);
        if (rem < 9) q.push(v * 10 + rem + 1);
    }

    cout << q.top() << endl;
    return 0;
}

Measured memory_bytes: 5296
while True:
    try:
        a,b,c,d,e,f=map(int,input().split())
        y=(c*d-a*f)/(b*d-a*e)
        x=(e*c-b*f)/(a*e-b*d)
        
        if x==0:
            x=0
        if y==0:
            y=0
        print(f'{x:.3f} {y:.3f}')    
    except:
        break
    




Measured memory_bytes: 5628
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String s = sc.next();
        String c = sc.next();
        
        System.out.println("A" + s.charAt(0) + "C");
    }
}


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

int main()
{

    int N;
    cin >> N;

    vector<vector<int>> A(2, vector<int>(N));

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A.at(i).at(j);
        }
    }

    int lower = 0;
    for (int i = 0; i < N; i++)
    {
        lower += A.at(1).at(i);
    }

    int sum = A.at(0).at(0) + lower;

    int max = sum;
    for (int i = 0; i < N - 1; i++)
    {
        sum += A.at(0).at(i + 1) - A.at(1).at(i);

        if (sum > max)
        {
            max = sum;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

long long get_sum(long long n){
	return n*(n+1)/2;
}

long long get_sum(long long l,long long r){
	return get_sum(r)-get_sum(l-1);
}

int main(){
	
	int N;
	cin>>N;
	
	long long ans = 0;
	
	for(long long i=1;i<=N;){
		long long j = N/(N/i) + 1;
		
		long long t = get_sum(i,j-1);
		long long t2 = get_sum(N/i);
		ans += t*t2;
		
		i = j;
	}
	
	cout<<ans<<endl;
			
	
	return 0;
}

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

int main(){
  long long Q, H, S, D;
  cin >> Q >> H >> S >> D;

  long long N;
  cin >> N;
  
  long long per_litre = min(4 * Q, min(2 * H, S)), per_2_litre = D;
  long long ans = min(per_litre * N, N / 2 * per_2_litre + (N % 2) * per_litre);

  cout << ans << endl;
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
using namespace std;
int main() {

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

	double n = 0, ans = 0;

  cin >> n;

  for(double k = 1; k <= n; k++)
    ans += k / 2 * floor(n / k) * floor(1 + n / k);

  cout << (ll)ans;

  return 0;
}


Measured memory_bytes: 3732
#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      sato
#
# Created:     19/10/2013
# Copyright:   (c) sato 2013
# Licence:     <your licence>
#-------------------------------------------------------------------------------

def kuku():
    for x in range(1,10):
        for y in range(1,10):
            print (str(x) + 'x' +  str(y) + '=' + str(x*y))

if __name__ == '__main__':
    kuku()

Measured memory_bytes: 4188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0;
    else cout<<10;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int a[n];
    long long int sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a + n);
    cout << a[0] << " " << a[n - 1] << " " << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;
cin>>n;
ll a[n];
ll ans=0;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=1;i<n;i++)
{
	if(a[i]>=a[i-1]) continue;
	else {
		
		ans+=abs(a[i-1]-a[i]);
	    a[i]=a[i-1];
	}
}
cout<<ans<<endl;
}

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

long long x;
vector<long long> v;

long long solve(vector<long long> &a);

int main() {
  cin >> x;
  v.resize(x);
  for(int i = 0; i < x; ++i) cin >> v[i];
  cout << solve(v) << endl;
  return 0;
}

long long solve(vector<long long> &a) {
  int n = a.size();
  if(n <= 1) return 0;
  long long res = 0;
  vector<long long> b(a.begin(), a.begin() + n / 2),
      c(a.begin() + n / 2, a.end());
  res += solve(b) + solve(c);
  int aid = 0, bid = 0, cid = 0, bsize = b.size(),
      csize = c.size();
  while(aid < n) {
    if(bid < bsize && (cid == csize || b[bid] <= c[cid]))
      a[aid++] = b[bid++];
    else {
      res += n / 2 - bid;
      a[aid++] = c[cid++];
    }
  }
  return res;
}


Measured memory_bytes: 7660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compareStrUp1(const void *a, const void *b) {
  return strcmp((const char *)a, (const char *)b);
}

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

  char arr[n][101];
  for (i=0; i<n; i++) {
    scanf("%s", arr[i]);
  }

  qsort(arr, n, 101, compareStrUp1);
  
  for (i=0; i<n; i++) {
    printf("%s", arr[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 252
# include<bits/stdc++.h>
# include<iostream>
using namespace std;
const long long MAX=1e5+10;
long long a[MAX*2];
long long b[2*MAX];
long long n;
int main ()
{
    cin>>n;
    for(long long i=1; i<=n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b+1,b+1+n);
    int t=b[n/2]+b[n/2+1];
    for(int i=1;i<=n;i++)
    {
        if(a[i]*2<=t)
        {
            cout<<b[n/2+1]<<endl;
        }
        else
            cout<<b[n/2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1){
                break;
            }
            
            if(m == -1 || f == -1){
                System.out.println("F");
            } else if (m + f >= 80){
                System.out.println("A");
            } else if (m + f >= 65 && m + f < 80){
                System.out.println("B");
            } else if (m + f >= 50 && m + f < 65){
                System.out.println("C");
            } else if (m + f >= 30 && m + f < 50){
                if(r >= 50){
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
        }
    }
}


Measured memory_bytes: 26536
while True:
    m = int(input())
    if not m:
        break
    target = {tuple(map(int, input().split())) for _ in range(m)}
    base = min(target)
    target.remove(base)
    bx, by = base
    target = {(x - bx, y - by) for x, y in target}

    n = int(input())
    sky = {tuple(map(int, input().split())) for _ in range(n)}

    for x, y in sorted(sky):
        for tx, ty in target:
            if (x + tx, y + ty) not in sky:
                break
        else:
            print(x - bx, y - by)
            break

Measured memory_bytes: 8144
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 78294349;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int l;
    cin>>l;
    vector<ll> a(l);
    get(a);
    int smallest = 0;
    while (smallest<l&&a[smallest] == 0) smallest++;
    int largest = l-1;
    while (largest>=0&&a[largest] == 0) largest--;
    if (smallest == l) {cout<<0; return 0;}
    vector<ll> b;
    for (int i = smallest; i<=largest; i++) b.push_back(a[i]);
    a = b;
    l = a.size();
    ll answer = 0;
    
    vector<ll> pref_sum(l+1);
    pref_sum[0] = 0;
    for (int i = 1; i<=l; i++) pref_sum[i] = pref_sum[i-1] + a[i-1];
    
    vector<ll> dp_left(l+1);
    dp_left[0] = 0;
    for (int i = 1; i<=l; i++)
    {
        if (a[i-1]!=0) dp_left[i] = a[i-1]%2 + dp_left[i-1];
        else dp_left[i] = min(pref_sum[i], 2 + dp_left[i-1]);
    }
    
    vector<ll> dp_right(l+1);
    dp_right[l] = 0;
    for (int i = l-1; i>=0; i--)
    {
        if (a[i]!=0) dp_right[i] = a[i]%2 + dp_right[i+1];
        else dp_right[i] = min(pref_sum[l] - pref_sum[i], 2 + dp_right[i+1]);
    }
    
    vector<ll> dp_odd(l+1);
    dp_odd[0] = 0;
    for (int i = 1; i<=l; i++)
    {
        dp_odd[i] = min(dp_left[i], (a[i-1]+1)%2 + dp_odd[i-1]);
    }
    
    ll ans = 1e9;
    for (int i = 0; i<=l; i++) ans = min(ans, dp_odd[i]+dp_right[i]);
    cout<<ans<<endl;
    /*print(a);
    print(dp_left);
    print(dp_right);
    print(dp_odd);*/
    
    
    
    
}

Measured memory_bytes: 10224
a,b,k = map(int,input().split())

for i in range(k):
    if(i%2==0):
        if(a%2==0):
            b = b+(a/2)
            a = a-(a/2)
        else:
            a = a-1
            b = b+(a/2)
            a = a-(a/2)
    else:
        if(b%2==0):
            a = a+(b/2)
            b = b-(b/2)
        else:
            b = b-1
            a = a+b/2
            b = b-(b/2)
        
print(int(a),int(b))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n; scanf("%d", &n);
  vector<int> a(n);
  map<int,int> mp;
  rep(i,n) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }

  ll res = 0, d = 0;

  for (auto itr : mp) {
    if (itr.second >= 3) {
      if (itr.second % 2 == 1) {
        res += itr.second - 1;
      } else {
        res += itr.second - 2;
        d += 1;
      }
    } else if (itr.second == 2) {
      d += 1;
    }
  }

  if (d) {
    if (d % 2 == 0) {
      res += d;
    } else {
      int s = d - 1;
      res += s;
      res += 2;
    }
  }
  printf("%lld\n", n - res);
}


Measured memory_bytes: 5376
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

cnt_p = 0
cnt_q = 0

for i, v in enumerate(permutations(range(1, N + 1), N)):
    if v == P:
        cnt_p = i
    if v == Q:
        cnt_q = i
        
print(abs(cnt_p - cnt_q))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int cnt[201010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>x;
		cnt[x]++;
	}
	vector<int> V;
	FOR(i,N+1) if(cnt[i]) V.push_back(cnt[i]);
	sort(ALL(V));
	reverse(ALL(V));
	int tot=0;
	while(V.size()>K) {
		tot+=V.back();
		V.pop_back();
	}
	cout<<tot<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2168
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define int long long
#define mid ((l+r)>>1)
#define MAXN (int)(2e5+2333)
int a[MAXN],asbsummadebysbzzx;
inline int f(int x,int y) { if (x%y) return (int)(x/y)+1; return x/y; }
signed main()
{
	int n,k;
	scanf("%lld%lld",&n,&k);
	for (int i=1;i<=n;i++) 
    {
        scanf("%lld",&a[i]);
        asbsummadebysbzzx+=a[i];
    }
    if(!asbsummadebysbzzx)
    {
        cout<<0;
        return 0;
    }
	int l=1,r=1e9,ans=1e9;
	long long sum;
	while (l<r)
	{
		sum=0;
//		printf(";%d %d %d\n",l,mid,r);
		for (int i=1;i<=n;i++) sum+=(f(a[i],mid)-1);
//		printf("--- %d\n",sum);
		if (sum>k) l=mid+1;
		else { ans=min(ans,mid); r=mid; }
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int dp[300][300][4];
int main(){
	int n;
	int dx[]={0,-1,-1,-1};
	int dy[]={-1,-1,0,1};
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		rep(i,n)rep(j,n+1)rep(k,4)dp[i][j][k]=0;
		rep(i,n)rep(j,n)rep(k,4)if(in[i][j]=='1'){
			if(i==0&&j==0)dp[i][j][k]=1;
			else if(i==0&&k||j==0&&k<2)dp[i][j][k]=1;
			else dp[i][j][k]=dp[i+dx[k]][j+dy[k]][k]+1;
		}else dp[i][j][k]=0;
		int out=0;
//		rep(i,n){rep(j,n)cout<<" "<<dp[i][j][0];cout<<endl;}
		rep(i,n)rep(j,n)rep(k,4)out=max(out,dp[i][j][k]);
		cout<<out<<endl;
	}
}

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

int main(void)
{
    char n[200000] = {0};
    char c;
    long long sum;
    int i, x;
    cin >> n;
    sum = 0;
    for (i = 0; i < 200000; i++)
    {
        if (n[i] != 0)
            sum += (long long)(n[i] - '0');
    }
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
//解答写し
int main(){
	int n;cin>>n;
	string s;cin>>s;
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++)if(s[j]==c)left=true;
			for(int j=i;j<n;j++)if(s[j]==c)right=true;
			if(left&&right)cnt++;
		}
		if(ans<cnt)ans=cnt;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a;
	int b;
	scanf("%d %d", &a,&b);
	if(a == b){
		printf("a == b\n");
	}else if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("InputErr\n");
	}
	return 0;	
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
double arr[3000];double dp[3000][3000];int num;
double prob(int n,int ch)
{ if(n==0)
{
	if(ch>(num/2))
	return(1);
	else
	return(0);
}
if(dp[n][ch]!=-1)
return dp[n][ch];

double x=arr[n]*prob(n-1,ch+1);

double y=(1-arr[n])*prob(n-1,ch); 
return dp[n][ch]=x+y;
 	
}


int main()
{ 
cin>>num;
for(int i=1;i<=num;++i)
cin>>arr[i];
for(int i=0;i<=num;++i)
{
	for(int j= 0 ; j<=num ; ++j )
	dp[i][j]=-1;
}
double t=prob(num,0);
cout<<fixed;
cout<<setprecision(10);
cout<<t;
	
	
	
return(0);	
}

Measured memory_bytes: 70912
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    string S;
    cin >> N >> S;

    vector<int> a(26,0);
    vector<int> b(26,0);

    int tmp,ans = 0;

    for(int i=0;i<N;i++){
        for(int k=0;k<26;k++){
            a[k] = 0;
            b[k] = 0;
        }
        for(int l=0;l<=i;l++){
            tmp = S[l] - 'a';
            a[tmp]++;
        }
        for(int j=N-1;j>i;j--){
            tmp = S[j] - 'a';
            b[tmp]++;
        }
        int cnt = 0;
        for(int k=0;k<26;k++){
            if(a[k]>0&&b[k]>0){
                cnt++;
            }
        }
        if(ans<cnt) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int h,w,n;
    cin >> h >> w >> n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int x=0,y=0;
    int z[h][w];
    int i=1,c=0;
    for(x=0;x<h;x++)
    {
        if (x%2==0)
        {
        for(y=0;y<w;y++)
        {
            z[x][y]=i;
            c++;
            if(a[i-1]==c)
            {
                i++;
                c=0;
            }
        }
        }
        if(x%2==1)
        {
            for(y=w-1;y>=0;y--)
            {
                z[x][y]=i;
                c++;
                if(a[i-1]==c)
                {
                    i++;
                    c=0;
                }
            }
        }
    }
    for(x=0;x<h;x++)
    {
        for(y=0;y<w;y++)
        {
            cout << z[x][y];
            if(y<w-1)
                cout<<" ";
        }
        if (x<h-1)
            cout<<endl;
    }
    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	
	ll n;
	cin >> n;
	cout << n * n * 3 << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>

char str[3];

int main()
{
	scanf("%s", str);
	if (str[0] == '1') str[0] = '9';
	else str[0] = '1';
	if (str[1] == '1') str[1] = '9';
	else str[1] = '1';
	if (str[2] == '1') str[2] = '9';
	else str[2] = '1';
	printf("%s", str);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
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.at(i);
  }
  for(int i = 0; i < (N - 1); i++) {
    if(H.at(i) >= H.at(i + 1)) {
      count++;
      if(max < count)
        max = count;
    } else
      count = 0;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

void sort(int a[],int b[],int c);

int main(){
  int a,b[2000000],d[10001]={0},M=0,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){scanf("%d",&b[i]);
    if(M<b[i])M=b[i];
    d[b[i]]++;
  }
  for(i=0;i<=M;i++)d[i+1]+=d[i];
  //for(i=0;i<=M;i++)printf("%d\n",d[i]);
  
  sort(b,d,a);
  /*for(i=a-1;i>=0;i--){
    c[d[b[i]]]=b[i];
    d[b[i]]--;
  }*/
  //for(i=0;i<=M;i++)printf("%d\n",d[i]);
  for(i=0;i<a;i++){
    printf("%d",b[i]);
    if(i==a-1)printf("\n");
    else printf(" ");
  }
}
void sort(int a[],int b[],int c){
  int i,d[c];
  for(i=c-1;i>=0;i--){
    d[b[a[i]]]=a[i];
    b[a[i]]--;
  }
  for(i=0;i<=c;i++)a[i]=d[i+1];
}



Measured memory_bytes: 17460
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << "a > b";
    }
    else if (a < b) {
        cout << "a < b";
    }
    else {
        cout << "a == b";
    }
    cout << endl;
}


Measured memory_bytes: 3088