akhauriyash/Code-Regression huggingface dataset:
n,k = map(int, input().split())
link = [[] for _ in range(n)]
ln = []
for i in range(n-1):
    a,b = list(map(int,input().split()))
    link[a-1].append(b-1)
    link[b-1].append(a-1)
    ln.append([a-1,b-1])

if k==1:
    print(n-2)
    exit()

from collections import deque
def get_v(node,dist):
    Q = deque()
    Q.append([node,0])
    visited=[-1]*n
    visited[node]=1
    while Q:
        now,cnt = Q.popleft()
        if cnt > dist:
            break
        for nxt in link[now]:
            if visited[nxt]!=-1:
                continue
            visited[nxt]=cnt+1
            Q.append([nxt,cnt+1])
    for i in range(n):
        if visited[i] == -1:
            ret = 0
        elif visited[i] <= dist:
            ret = 1
        else:
            ret = 0
        visited[i] = ret
    return visited
def borsm(l1,l2):
    sm=0
    for b1,b2 in zip(l1,l2):
        sm+=(b1 | b2)
    return sm
ans=float("inf")
if k%2==0:
    for i in range(n):
        ret = n - sum(get_v(i,k//2))
        ans=min(ret,ans)
else:
    for tmp in ln:
        n1,n2=tmp
        c1=get_v(n1,k//2)
        c2=get_v(n2,k//2)
        ret = n- borsm(c1,c2)
        ans=min(ret,ans)
print(ans)

Measured memory_bytes: 59992
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		Map<String, Integer> count = new TreeMap<String, Integer>();
		String base = sc.next();
		count.put(base, 1);
		for (int i = 1; i < N; i++) {
			String temp = sc.next();
			if (!count.containsKey(temp)) {
				count.put(temp, 1);
			} else {
				count.replace(temp, (count.get(temp) + 1));
			}
		}
		int temp = 0;
		for (String k : count.keySet()) {
			temp = Math.max(temp, count.get(k));
		}
		for (String k : count.keySet()) {
			if (temp == count.get(k)) {
				System.out.println(k);
			}
		}
	}
}

Measured memory_bytes: 78100
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238

#define gcd __gcd
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }   
        vector<vector<ll>> dp(n + 1, vector<ll>(2));
        dp[1][0] = v[0];
        dp[1][1] = -INF;
        for(i = 1; i < n; i++){
            dp[i + 1][0] = max(dp[i][0] + v[i], dp[i][1] + v[i]);
            dp[i + 1][1] = max(dp[i][0] - v[i] - 2 * v[i - 1], dp[i][1] - v[i] + 2 * v[i - 1]);
        }
        cout << max(dp[n][0], dp[n][1]);
    }

    return 0;
}


Measured memory_bytes: 9500
#include <stdio.h>

int main(void)
{
	int n;
	int s;
	int i, j, k;
	int dp[16][64];	
	
	for (i = 0; i < 16; i++){
		for (j = 0; j < 64; j++){
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	for (i = 0; i <= 9; i++){
		for (j = 8; j >= 0; j--){
			for (k = 0; k < 64; k++){
				if (dp[j][k] != 0){
					dp[j + 1][k + i] += dp[j][k];
				}
			}
		}
	}
	
	while (scanf("%d %d", &n, &s), n != 0 || s != 0){
		if (s < 64){
			printf("%d\n", dp[n][s]);
		}
		else {
			printf("0\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 1044
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[n, m] <- readIntToList <$> BS.getLine
	print $ n * (n - 1) `div` 2 + m * (m - 1) `div` 2


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

int ans[200005]={},memo[200005]={};
vector<int> ab[200005];

void my(int now, int carry)
{
	ans[now]+=carry;
	for (auto i = ab[now].begin(); i != ab[now].end(); ++i)
	{
		if (memo[*i]==0)
		{
			memo[*i]=1;
			my(*i,ans[now]);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n,q;
	cin>>n>>q;
	int a,b;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a>>b;
		--a,--b;
		ab[a].emplace_back(b);
		ab[b].emplace_back(a);
	}
	int p,x;
	for (int i = 0; i < q; ++i)
	{
		cin>>p>>x;
		--p;
		ans[p]+=x;
	}
	memo[0]=1;
	my(0,0);
	cout<<ans[0];
	for (int i = 1; i < n; ++i)
	{
		cout<<" "<<ans[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 21120
N = int(input())
S = list(input().split())

def bubble(S):
    sorted_l = []
    un_sorted_l = S[:]
    counter = 0
    while un_sorted_l:
        n = len(un_sorted_l)
        for i in reversed(range(1, n)):
            if un_sorted_l[i-1][1:] <= un_sorted_l[i][1:]:
                continue
            else:
                counter += 1
                un_sorted_l[i-1], un_sorted_l[i] = un_sorted_l[i], un_sorted_l[i-1]
        sorted_l.append(un_sorted_l[0])
        un_sorted_l = un_sorted_l[1:]

    return sorted_l
    
def select(S):
    selection_sort = S[:]
    counter = 0
    for i in range(len(selection_sort)):
        v = selection_sort[i]
        min_v = v
        min_i = i
        for j in range(i, len(selection_sort)):
            if min_v[1:] > selection_sort[j][1:]:
                min_v = selection_sort[j]
                min_i = j
        if v != min_v:
            counter += 1
            selection_sort[i], selection_sort[min_i] = selection_sort[min_i], selection_sort[i]
            
    return selection_sort

def check(X, S):
    d = {}
    for i, s in enumerate(S):
        d[s] = i
        
    for x, y in zip(X[:-1],X[1:]):
        if x[1:] == y[1:] and d[x] > d[y]:
            return 'Not stable'
    
    return 'Stable'
        
        

b = bubble(S)
print(' '.join(b))
print(check(b, S))

s = select(S)
print(' '.join(s))
print(check(s, S))


    


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

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

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

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


signed main() {
  string s;
  cin >> s;

  int N = s.size();
  s.push_back('R');

  vector<int> ans(N, 0);

  int now = 0;
  int i = 0;
  while(i < N){
    bool f = true;
    pair<int, int> cnt = {0, 0};
    int past = i;
    while(s[i++] == 'R'){
      if(f) cnt.first++;
      else cnt.second++;
      f = !f;
    }
    now = i-1;

    if((now-past)%2){
      ans[now-1] += cnt.first;
      ans[now] += cnt.second;
    }else{
      ans[now-1] += cnt.second;
      ans[now] += cnt.first;
    }

    f = true;
    cnt = {0, 0};
    i--;
    while(s[i++] == 'L'){
      if(f) cnt.first++;
      else cnt.second++;
      f = !f;
    }
    if((i-now)%2){
      ans[now-1] += cnt.first;
      ans[now] += cnt.second;
    }else{
      ans[now-1] += cnt.second;
      ans[now] += cnt.first;
    }
    i--;
  }

  REP(i, N){
    cout << ans[i]; SPBR(i, N);
  }
}

Measured memory_bytes: 1488
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int sx, sy, tx, ty;
char c[] = "UDLR";

int main(void) {
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    REP(i, tx - sx) ans += c[3];
    REP(i, ty - sy) ans += c[0];
    REP(i, tx - sx) ans += c[2];
    REP(i, ty - sy) ans += c[1];
    ans += "D";
    REP(i, tx - sx + 1) ans += c[3];
    REP(i, ty - sy + 1) ans += c[0];
    ans += "L";
    ans += "U";
    REP(i, tx - sx + 1) ans += c[2];
    REP(i, ty - sy + 1) ans += c[1];
    ans += "R";
    puts(ans.c_str());
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
int main()
{
    string s,t;
    cin >> s >> t;
    int a = s.size(), b = t.size();
    for(int i=1;i<=a;i++) {
        for(int j=1;j<=b;j++) {
            if(s[i-1]==t[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }
    /*for(int i=1;i<=a;i++) {
        for(int j=1;j<=b;j++)
            cout << dp[i][j] << " ";
        cout << endl;
    }*/
    string ans = "";
    int x = a, y = b,now = dp[x][y];
    while(now>0) {
        while(dp[x][y-1]==now) y--;
        while(dp[x-1][y]==now) x--;
        //cout << x << " " << y << endl;
        ans += s[x-1];
        x--; y--;
        now--;
    }
    reverse(ans.begin(),ans.end());
    cout <<  ans;
}


Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible\n";
	else cout << "Impossible\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
int n;
int main()
{
	cin>>n>>s;
	if(n%2!=0)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<n/2;i++)
	if(s[i]!=s[i+n/2])
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))

ans = 0
for i in a:
    if i == 1:
        ans += 300000
    elif i == 2:
        ans += 200000
    elif i == 3:
        ans += 100000
    
if a[0] == a[1] == 1:
    ans += 400000

print(ans)

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

int main() {
	int n, fig[200][3], score[200], flag;
	cin >> n;
	
	for (int j = 0; j < n; j++)
		score[j] = 0;
	
	for (int j = 0; j < n; j++)
		for (int k = 0; k < 3; k++)
				cin >> fig[j][k];
	
	for (int j = 0; j < n; j++) {
		for (int k = 0; k < 3; k++) {
			flag = 0;
			for (int m = 0; m < n; m++) {
				if (fig[j][k] == fig[m][k] &&j != m) {
					flag = 1;
					break;
				}
			}
			if (!flag)
				score[j] += fig[j][k];
		}
	}
		
	for (int j = 0; j < n; j++)
		cout << score[j] << endl;
		
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int top, S[1000];
void push(int x)
{
	top = top + 1;
	S[top] = x;
}
int pop()
{
	top = top - 1;
	return S[top + 1];
}
int main()
{
	int a, b;
	char bolan[10];
	while (scanf("%s", bolan) != EOF)
	{
		if (bolan[0] == '+')
		{
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (bolan[0] == '-')
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (bolan[0] == '*')
		{
			b = pop();
			a = pop();
			push(a*b);
		}
		else
		{
			push(atoi(bolan));
		}
	}
	a = pop();
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 3180
box=[0]*1001
for i in range(2,int(1000**0.5)+1):
    count=i
    point=2
    while 1000>count:
        try:
            count=i
            count=count**point
            box[count]=1
            point +=1
        except:break
box[1]=1
target=[]
for i in range(len(box)):
    if box[i]==1:target.append(i)

x=int(input())
if x==1000:print(x);exit()
ans=0
for i in target:
    if x>=i:ans=i
    else:print(ans);break

Measured memory_bytes: 38256
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=1,C[45];
ll A[45],B[45];
ll T,a,b;
ll ans=0;
bool h,o;
//bool D[100005];
char str1[55][55],str2[55][55];
map<string,int> m;
vector<int> v[10];
ll dp[45][405][405];
int main(){
	cin>>N>>Ma>>Mb;
	for(int i=0;i<=N;++i){
		for(int j=0;j<405;++j){
			for(int k=0;k<405;++k)dp[i][j][k]=INF;
		}
	}
	for(int i=0;i<N;++i){
		cin>>A[i]>>B[i]>>C[i];
	}
	dp[0][0][0]=0;
	for(int i=0;i<N;++i){
		for(int j=0;j<401;++j){
			for(int k=0;k<401;++k){
				if(dp[i][j][k]==INF)continue;
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				dp[i+1][j+A[i]][k+B[i]]=min(dp[i+1][j+A[i]][k+B[i]],dp[i][j][k]+C[i]);
			}
		}
	}
	ans=INF;
	for(int j=1;j<401;++j){
		for(int k=1;k<401;++k){
			if(j*Mb==k*Ma){
				ans=min(ans,dp[N][j][k]);
			}
		}
	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

map<string, int> table;
string mole;
int idx;

int getNum()
{
  string ret = "";
  while(idx < mole.size() && isdigit(mole[idx])) ret += mole[idx++];
  return stoi(ret);
}

int getAtom()
{
  string atom = "";
  atom += mole[idx++];
  while(idx < mole.size() && islower(mole[idx])) atom += mole[idx++];
  if(table.count(atom)) return table[atom];
  return -1;
}

int solve()
{
  int ret = 0;
  if(idx == mole.size()) return 0;
  if(mole[idx] == ')') return 0;
  if(mole[idx] == '(') {
    idx++; // skip '('
    ret = solve();
    if(ret == -1) return -1;
    idx++; // skip ')'
    if(isdigit(mole[idx])) ret *= getNum();
  } else {
    ret = getAtom();
    if(ret == -1) return -1;
    if(isdigit(mole[idx])) ret *= getNum();
  }
  int tmp = solve();
  if(tmp == -1) return -1;
  return ret + tmp;
}

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

  string atom;
  int weight;
  while(cin >> atom, atom != "END_OF_FIRST_PART") {
    cin >> weight;
    table[atom] = weight;
  }

  while(cin >> mole, mole != "0") {
    idx = 0;
    int ans = solve();
    if(ans == -1) cout << "UNKNOWN" << endl;
    else cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> seikai(n, 0);
    int ac = 0, wa = 0;
    for(int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(seikai[p] >= 0 && s == "AC") {
            ac++;
            wa += seikai[p];
            seikai[p] = -1;
            continue;
        }
        if(seikai[p] >= 0 && s == "WA") {
            seikai[p]++;
            continue;
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long llong;
// k cars with max load of P can carry how many items?
int n;
int check(llong* weights,llong P,int k){
  int num = 0;
  for(int j=0;j<k;j++){
    llong load = 0;
    while(load+weights[num]<=P){
      load+=weights[num];
      num++;
      if(num==n) return n;
    }
  }
  return num;
}

int binarySearch(llong* weights,int k){
  llong lo = 0, hi = 10000*100000, mid;
  while(lo+1<hi){
    mid = (lo+hi)/2;
    int num = check(weights,mid,k);
    if(num>=n) hi = mid;
    else lo = mid;
  }
  return hi;
}
int main(){
  // n is item, k is cars
  int k;
  cin>>n>>k;
  llong* weights = new llong[n];
  for(int i=0;i<n;i++)
    cin>>weights[i];
  cout<<binarySearch(weights,k)<<endl;
}



Measured memory_bytes: 3892
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    TSTART();
    long ans = 0l;
    REP(i,100000){
      if(i * i > n){
	cout << (i - 1) * (i - 1) << endl;
	break;
      }
    }
    
    TSTOP();
  }
  return 0;
}


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

const int MAXN = 100005;

int N, Q;
int T[MAXN], L[MAXN], P[MAXN][20];  // direct parent, depth, ancestor
vector<int> adjList[MAXN];

void dfs(int node = 0, int depth = 0) {
    L[node] = depth;
    for (int i = 0; i < adjList[node].size(); i++) {
        int child = adjList[node][i];
        dfs(child,depth+1);
    }
}

int query(int u, int v) {
    int tmp;
    if (L[u] < L[v])
        tmp = u, u = v, v = tmp;

    int LOG2;
    for (LOG2 = 1; 1 << LOG2 <= L[u]; LOG2++); LOG2--;

    for (int i = LOG2; i >= 0; i--)
        if (L[u] - (1 << i) >= L[v])
            u = P[u][i];

    if (u == v)
        return u;

    for (int i = LOG2; i >= 0; i--)
        if (P[u][i] != -1 && P[u][i] != P[v][i])
            u = P[u][i], v = P[v][i];

    return T[u];
}

int main() {


    scanf("%d",&N);
    for (int u = 0, M; u < N; u++) {
        scanf("%d",&M);
        for (int i = 0, v; i < M; i++) {
            scanf("%d",&v);

            T[v] = u;
            adjList[u].push_back(v);
        }
    }

    // rooted at 0
    dfs();

    for (int i = 1; i <= N; i++)
        P[i][0] = T[i];
    for (int j = 1; 1 << j < N; j++)
        for (int i = 1; i <= N; i++)
            if (P[i][j-1] != -1)
                P[i][j] = P[P[i][j-1]][j-1];

    scanf("%d",&Q);
    for (int i = 0, u, v; i < Q; i++) {
        scanf("%d%d",&u,&v);
        printf("%d\n", query(u,v));
    }

    return 0;
}

Measured memory_bytes: 18368
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array([lr() for i in range(N)])
INF = 10 ** 10
np.fill_diagonal(A, INF)
answer = 0
for i in range(N):
    for j in range(i+1, N):
        detour = np.min(A[i] + A[j])
        if A[i, j] < detour:
            # 最短距離としてこの道路は必要
            answer += A[i, j]
        elif A[i, j] > detour:
            print(-1)
            exit()

print(answer)
# 05 hint

Measured memory_bytes: 16404
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
using ll = long long;
using namespace std;

#define MOD 1000000007
unsigned int mod;
std::vector<unsigned int> fact_mod;
std::vector<unsigned int> rev_fact_mod;

using namespace std;

template<typename Tint>
Tint gcd(Tint a, Tint b) {
	// O(log max(a,b))
	return b != 0 ? gcd(b, a % b) : a;
}

template<typename Tint>
Tint lcm(Tint a, Tint b) {
	return a / gcd(a, b) * b;
}

// a x + b y = gcd(a, b)
template<typename Tint>
Tint extgcd(Tint a, Tint b, Tint &x, Tint &y) {
	// O(log max(a,b))
	Tint g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}

void set_mod(const int m) {
	mod = m;
}

template<typename Tint>
Tint inv_mod(Tint a) {
	Tint x, y;
	if (extgcd(a, mod, x, y) == 1)
		return (x + mod) % mod;
	else // unsolvable
		return 0;
}


unsigned int pow_mod(const unsigned long long x, const unsigned int k) { //x^k (mod mod) 
	if (k == 0)     return 1;
	if (k % 2 == 0) return pow_mod(x*x % mod, k / 2);
	else            return x * pow_mod(x, k - 1) % mod;
}

std::vector<unsigned int> set_fact_mod(unsigned int n) {
	fact_mod = vector<unsigned int>(n + 1);
	fact_mod[0] = 1;
	for (unsigned int i = 1; i <= n; i++)
	{
		fact_mod[i] = (long long)fact_mod[i - 1] * i % mod;
	}
	return fact_mod;
}

std::vector<unsigned int> set_rev_fact_mod(unsigned int n) {
	rev_fact_mod = vector<unsigned int>(n + 1);
	rev_fact_mod[n] = pow_mod(fact_mod[n], mod - 2);
	for (int i = n - 1; i >= 0; i--)
	{
		rev_fact_mod[i] = (long long)rev_fact_mod[i + 1] * (i + 1) % mod;
	}
	return rev_fact_mod;
}
int main() {
	unsigned int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	set_mod(MOD);
	set_fact_mod(n);
	set_rev_fact_mod(n);

	vector<unsigned int>dp(n + 1, 0);
	dp[0] = 1;
	for (unsigned int tmpb = a; tmpb <= b; tmpb++)
	{
		for (unsigned int tmpn = n; tmpn >= 1; tmpn--)
		{
			unsigned int sum_tmpb_tmpn = 0;
			for (unsigned int tmpk = c; tmpk <= min(tmpn / tmpb, d); tmpk++)
			{
				unsigned int tmprest = tmpn - tmpb * tmpk;
				ll cal;
				ll comb_tmpb = fact_mod[tmpn];
				comb_tmpb *= pow_mod(rev_fact_mod[tmpb], tmpk);
				comb_tmpb %= MOD;
				comb_tmpb *= rev_fact_mod[tmprest];
				comb_tmpb %= MOD;
				comb_tmpb *= rev_fact_mod[tmpk];
				comb_tmpb %= MOD;
				cal = dp[tmprest] * comb_tmpb;
				cal %= MOD;
				cal += sum_tmpb_tmpn;
				cal %= MOD;
				sum_tmpb_tmpn = cal;
			}
			dp[tmpn] = (dp[tmpn] + sum_tmpb_tmpn) % MOD;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

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

int main() {
  int n, a, b;
  cin >> n;
  cin >> a >> b;
  int p[n];
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }

  int c_a = 0;
  int c_b = 0;
  int c_c = 0;
  for(int i = 0; i < n; i++) {
    if(p[i] <= a) {
      c_a++;
    } else if(p[i] >= a + 1 && p[i] <= b) {
      c_b++;
    } else {
      c_c++;
    }
  }
  cout << min(c_a, min(c_b, c_c)) << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> b(N, -1);
    for (int i = 0; i < N; i++) {
        b[i] = a[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (b[b[i]] == i) cnt++;
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;

ll a,b,c,d;

ll gcd(ll x,ll y){
    if(!y) return x;
    return gcd(y,x%y);
}

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if(a<b||d<b){printf("No\n"); continue;}
        if(c>=b){printf("Yes\n"); continue;}
        ll l=a-b,r=a-c-1;
        ll x=gcd(b,d);
        if(r/x-l/x>0) printf("No\n");
        else printf("Yes\n");
    }
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC120A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;
 
            int x;
            var word = Console.ReadLine().Split(' ');
 
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);
 
            if (B / A >= C)
                Console.WriteLine(C);
            if (B / A < C)
                Console.WriteLine(B / A);
 
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
using System;

namespace teeeeeeeeeeeeeeest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n,m;
            int N,a=0;
            n = Console.ReadLine();
            N = int.Parse(n);
            for (int i = 0; i < N; i++)
            {
                if(Console.ReadLine()== "E869120")
                {
                    a++;
                }
            }
            Console.WriteLine(a);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 17948
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(30) ;
	int n , k ; cin >> n >> k ;
	int pos ;
	vi a(n); for(int i = 0 ; i < n ; i++) {cin >> a[i] ;if(a[i] == 1) pos = i ;} 
	int nb = 0 ;
	if(pos <= k - 1){
		nb = 1 ;
		pos = k - 1 ;
		while(pos < n - 1){pos += (k - 1) ; nb++;}
		cout << nb << endl ;
		return 0 ;
	}
	if(n - 1 - pos + 1 <= k){
		nb++ ;
		pos = n - k ;
		while(pos > 0){pos -= (k - 1) ; nb++ ;}
		cout << nb << endl; 
		return 0 ;
	}
	/*int pos1 = pos , pos2 = pos ; 
	while(pos1 > 0) {pos1 -= (k - 1);nb++;}
	while(pos2 < n - 1){pos2 += (k - 1) ; nb++ ;}
	if(n % (k - 1) == 0) nb-- ;*/
	int pos1 = 0 ;
	while(pos1 < n  - 1){pos1 += (k - 1) ; nb++;}
	cout << nb << endl ;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int p[n];
  FOR(i,0,n) {
    cin >> p[i];
  }
  int ans = 0;
  FOR(i,0,n-2) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2]) {
      ans++;
    } else if (p[i] > p[i+1] && p[i+1] > p[i+2]) {
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
while True:
    [x,op,y]=input().split(" ")
    if op == "?":
        break
    
    a=int(x)
    b=int(y)

    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)



Measured memory_bytes: 5596
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
int box[N][2];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        box[i][1] = 1;
    }
    box[1][0] = 1;
    // 0 red
    // 1 white
    int ans = 0;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(box[x][0] == 1){
            box[y][0] = 1;
        }
        box[x][1] -= 1;
        box[y][1] += 1;
        if(box[x][1] == 0){
            box[x][0] = 0;
        }
    }
    for(int i = 1; i <= n; i++){
        ans += (box[i][0] == 1);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    for(int i=0;i<n;i++)
    {
        if((b-a)>=(c*(n-1-i)-d*i) &&(b-a)<=(d*(n-1-i)-c*i) )
        {
            cout<<"YES"<<endl;
            return 0;
        }

    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N,X;
  cin>>N>>X;
  int mi=1000;
  REP(i,N){
    int m;
    cin>>m;
    X-=m;
    mi=min(m,mi);
  }
  cout<<N+X/mi<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    vi a(3);cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    cout<<a[0]+a[1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=998244353;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL num[100005];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		num[a]++;
		if(i==0 && a!=0){
			cout<<0<<endl;
			return 0;
		}
	}
	if(num[0]!=1){
		cout<<0<<endl;
		return 0;
	}
	a=0,b=1;
	for(i=0;i<n;i++){
		if(num[i]==0)break;
		a+=num[i];
		if(i!=0){
			c=1;
			for(j=0;j<num[i];j++){
				c*=num[i-1];
				if(c>=MAX)c%=MAX;
			}
			b*=c;
		}
		if(b>=MAX)b%=MAX;
	}
	if(a!=n)b=0;
	cout<<b<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static int testN=3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
	static void Main(string[] args) {
		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res = -1 ;

		
		int[] vals = parseAry(Console.ReadLine().Split(cs));

		int a = vals[0];
		int b = vals[1];


		int byen = b * 10;
		for ( int i = 0; i <10; i++ ) {
			if ( Math.Floor(( byen + i ) * 0.08) == a ) {
				res = byen + i; break;
			}
		}

		Console.WriteLine(res);

		return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll ans = 0;
  rep2(a, 1, 1000000) {
    rep2(b, 1, N / a + 1) {
      if (a * b == N) continue;
      ans++;
    }
  }
  ANS;
  return 0;
}

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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    cout<<max(max(a+b,a*b),a-b)<<endl;
}


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

void solve(long long A, long long B, long long C, long long K) {
    long long ans = 0;
    if (K > A) {
        K -= A;
        ans += A;
    } else {
        ans += K;
        cout << ans << endl;
        return;
    }
    if (K > B) {
        K -= B;
    } else {
        cout << ans << endl;
        return;
    }
    if (K > C) {
        K -= C;
        ans -= C;
        cout << ans << endl;
        return;
    } else {
        ans -= K;
        cout << ans << endl;
        return;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d%d", &a, &b);
	
	if ((a + b) % 2 == 0){
		printf("%d\n", (a + b) / 2);
	}
	else {
		printf("IMPOSSIBLE\n");
	}
	return (0);
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int tol,p[10000],i,j,n,k,temp;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	temp=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(p[i]>p[j]){
				temp=p[i];
				p[i]=p[j];
				p[j]=temp;
			}
		}
	}
	tol=0;
	for(i=0;i<k;i++){
		tol=tol+p[i];
	}
	printf("%d\n",tol);
	return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 2e9
#define mod 998244353
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=100100;
ll n,k,len,d[N],a[N],b[N],x,w[N],ch;
int main()
{
	cin>>n>>k;
	for(ll i=1;i<=k;i++)
		read(x),w[x]=1;
	while(n)
	{
		len++;
		a[len]=n%10;
		n/=10;
	}
	for(ll i=len;i>=1;i--)
		for(ll j=a[i];j<10;j++)
			if(!w[j]&&j!=a[i])
			{
				b[i]=j;
				ch=1;
				for(i=i-1;i>=1;i--)
					for(j=0;j<=9;j++)
						if(!w[j])
							b[i]=j,j=9;
				break;
			}
			else if(!w[j])
			{
				b[i]=j;
				if(i==1)
					ch=1;
				break;
			}
	if(ch)
	{
		for(ll i=len;i>=1;i--)
			cout<<b[i];
		return 0;
	}
	for(ll i=1;i<=len+1;i++)
		for(ll j=(i==1);j<=9;j++)
			if(!w[j])
				cout<<j,j=9;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a>>s>>b;
  for(int n=0;n<a;n++){
    if(s[b-1]!=s[n]) s[n]='*';
  }
  cout <<s<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
int main(){
    int X;
    cin >> X;
    int d = X / 100;
    int r = X % 100;
    if(d*5>=r) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(50)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll k,x;
  cin>>k>>x;
  if((k*500)>=x)
  	cout<<"Yes";
  else
  	cout<<"No";
  return 0;
}

Measured memory_bytes: 3620