TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
impot math
N = int(input())

array = []
for i in range(1,math.floor((N)**0.5)+1)
    if N // i == 0:
        num = N // i
        array.append(num)
l = len(array)
print(int(array[l]) + (N / int(array[l])))

N = int(input())
array = []
for i in range(1,N+1):
    if N // i == 0 and i <= (N // i):
        num = N // i
        array.append(num)
l = len(array)
print(int(array[l]) + (N / int(array[l])))

import math
n = int(input())

ans = float("inf")
for i in range(1,int(math.sqrt(n)+1)):
    if n%i == 0:
        if (i-1)+(n//i-1) < ans:
            ans = (i-1)+(n//i-1)

print(ans)   

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())

for i in range(1, n**.5+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

n = int(input())

for i in range(1, int(n**.5)+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())
n = int((N**(1/2))//1)
s =[0]*n
for i in range(1,n+1):
  if N//i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)


N = int(input())
n = int((N**(1/2))//1)
s =[0]*(n+10)
for i in range(1,n+1):
  if N%i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)


Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
# 2020/01/23


# Input
n = int(input())

nsq = int(n ** (1/2)) + 1

x = nsq
y = nsq

while x >= 1:
    print(x, y)
    wkn = x * y
    if n == wkn:
        ans = (x - 1) + (y - 1)
        break
    elif n > wkn:
        y = y + 1
    else:
        x = x - 1

# Output
print(ans)


# 2020/01/23


# Input
n = int(input())

nsq = int(n ** (1/2)) + 1

x = nsq
y = nsq

while x >= 1:
    if n % x == 0:
        ans = (x - 1) + int( (n / x) - 1)
        break
    else:
        x = x - 1

# Output
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

lst = prime_factorize(N)
print(lst)
if len(lst) == 1:
    print(N - 1)
else:
    
    min_val = float('inf')
    for i in range(len(lst)):
        a = 1
        b = 1
        work_lst1 = lst[:i + 1]
        work_lst2 = lst[i + 1:]
        for i in range(len(work_lst1)):
            a *= work_lst1[i]
        for j in range(len(work_lst2)):
            b *= work_lst2[j]
        tmp_min = a + b - 2
        if min_val > tmp_min:
            min_val = tmp_min
    print(min_val)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

10
N = int(input())
divisors = make_divisors(N)
ans = float('inf')
div_len = len(divisors)
if div_len % 2 == 0:
    i = div_len // 2
    j = div_len // 2 - 1
    ans = divisors[i] + divisors[j] - 2
else:
    ans = divisors[div_len // 2] * 2 - 2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
N = int(input())
num_a = 1
num_b = N
i = 2

while num_a <= num_b and i < N:
    print(i)
    if num_b % i == 0:
        num_a = num_a * i
        num_b = num_b / i    
    else:
        i += 1
print(num_a+num_b-2)

N = int(input())
num_a = 1
num_b = N
i = 2

while num_a <= num_b and i < N**0.5:
    if num_b % i == 0:
        num_a = num_a * i
        num_b = num_b / i    
    else:
        i += 1
print(num_a+num_b-2)

N = int(input())

sqrt_N = N ** 0.5
ans = 10**18

for i in range(1, int(sqrt_N)+1):
    if N % i == 0:
        move_num = (i-1) + (N//i - 1)
        ans = min(move_num, ans)

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
import math

def divisor_generator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor

n = int(input())


divs = list(divisor_generator(n))
print(divs)
l = len(divs) - 1
best = 2 if n == 1 else min([divs[i] + divs[l-i] for i in range(len(divs)>>1)] )

print(best-2)

import math

def divisor_generator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor

n = int(input())


divs = list(divisor_generator(n))
l = len(divs) - 1
best = 2 if n == 1 else min([divs[i] + divs[l-i] for i in range(len(divs)>>1)] )

print(best-2)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
from math import sqrt
from functools import reduce
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*b//gcd(a, b)
n = int(input())
n2 = n
pfs = []
isP = True
i = 2
while i <= int(sqrt(n)):
    while n % i == 0:
        pfs.append(i)
        n //= i
        isP = False
    i += 1
pfs.append(n)
"print (pfs)
if isP:
    ans =  (n2-1)
elif len(pfs) > 2:
    l = reduce(lcm, pfs)
    ans = l-1 + n2//l-1
else:
    ans = pfs[-1]-1 + n2//pfs[-1]-1
print (ans)

from math import sqrt
n = int(input())
minSoFar = 10**12+1

for a in range(1, int(sqrt(n))+1):
    if n % a == 0:
        b = n // a
        minSoFar = min(minSoFar, a+b-2)
print(minSoFar)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())
a = [i for i in range(1,100)]
b = []
for j in range(100):
    if n%int(a[j]) == 0:
        b.append(int(a[j]) + n//int(a[j]) -2)
print(min(b))

n = int(input())
a = [i for i in range(1,int((n)**0.5 +1))]
a.reverse()
#print(a)
for j in range(len(a)):
    if n%int(a[j]) == 0:
        print(int(int(a[j]) + n//int(a[j]) -2))
        break

Verdicts: Runtime Error

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
pn=[2]
A=1000
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
print(pn)

n = int(input())

distance = 10 ** 12

i = 1

while i * i <= n:
  if n % i == 0:
    m = int(n / i)
    move = (m - 1) + (i - 1)
    if move < distance:
      distance = move
  i += 1

print(distance)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
n = int(input())
ans = n - 1
a = 1
while a * a <= n:
  if n % a == 0:
    ans = min(ans, a - 1 + (n / a) - 1)
print(ans)

n = int(input())
ans = n - 1
a = 1
while a * a <= n:
  if n % a == 0:
    ans = min(ans, a - 1 + (n / a) - 1)
  a += 1
print(ans)

n = int(input())
ans = n - 1
a = 1
while a * a <= n:
  if n % a == 0:
    ans = min(ans, a - 1 + (n // a) - 1)
  a += 1
print(ans)

Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: Takahashi is standing on a multiplication table with infinitely many rows and columns.  The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1).  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).  Given an integer N, find the minimum number of moves needed to reach a square that contains N.

Submission attempts (in order):
#!/usr/bin/env python3
import math
import numpy as np
 
n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))+1):
    if n%i==0:
        q = n/i 
        tmp = i+q 
        if tmp <= ans:
            ans = tmp 
print(ans)
print(int(ans-2))


#!/usr/bin/env python3
import math
import numpy as np
 
n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))+1):
    if n%i==0:
        q = n/i 
        tmp = i+q 
        if tmp <= ans:
            ans = tmp 
print(int(ans-2))


Verdicts: Wrong Answer

Accepted
Problem: Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)  We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.  When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.

Submission attempts (in order):
from math import pi, tan
EPS = 0.0000000001

def f(a, b, theta):
    if theta >= pi * 0.5:
        return 0.0
    elif tan(theta) >= b / a:
        return a * b**2 * 0.5 / tan(theta)
    else:
        return a**2 * b - a**2 *b * 0.5 * tan(theta)

a, b, x = map(int, input().split())

l = 0
r = pi * 0.5
while r - l >= EPS:
    mid = (l + r) * 0.5
    if f(a, b, theta) >= x:
        l = mid
    else:
        r = mid

print("{:.10f}".format(l / pi * 180))


from math import pi, tan
EPS = 0.0000000001

def f(a, b, theta):
    if theta >= pi * 0.5:
        return 0.0
    elif tan(theta) >= b / a:
        return a * b**2 * 0.5 / tan(theta)
    else:
        return a**2 * b - a**3 * 0.5 * tan(theta)

a, b, x = map(int, input().split())

l = 0
r = pi * 0.5
while r - l >= EPS:
    mid = (l + r) * 0.5
    if f(a, b, mid) >= x:
        l = mid
    else:
        r = mid

print("{:.10f}".format(l / pi * 180))


Verdicts: Runtime Error

Accepted
Problem: Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)  We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.  When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.

Submission attempts (in order):
import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x > 0.5 * a ** 2 * b:
        tmp = (a ** 3) / (2 * ((a **2) * b - x))
    else:
        tmp = (2 * x) / ((b ** 2) * a)

    return 90 - math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print(ans)






import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        tmp = (a ** 3) / (2 * ((a **2) * b - x))
    else:
        tmp = (2 * x) / ((b ** 2) * a)

    return 90 - math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print(ans)






import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x > 0.5 * a ** 2 * b:
        tmp = (a ** 3) / (2 * (a **2 * b - x))
    else:
        tmp = (2 * x) / (a ** 2 * b)
    return 90 - math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print(ans)






import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        
        tmp = (2/a)*(b-(x/a**2))
    else:
        tmp = (a * b * b) / (2 * x)
    return math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print('{:.10f}'.format(ans))






Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)  We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.  When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.

Submission attempts (in order):
from math import atan, pi

a, b, x = map(int, input().split())

h = x / a**2


border = a**2 * b / 2

if x < border:
    theta = atan(2 * a * b**2 / x) * 180 / pi
else:
    theta = atan(2 / a * (b - h)) * 180 / pi

print(theta)

from math import atan, pi

a, b, x = map(int, input().split())

h = x / (a**2)


border = a**2 * b / 2

if x < border:
    theta = atan(a * (b**2) / 2 / x) * 180 / pi
else:
    theta = atan(2 / a * (b - h)) * 180 / pi

print('{:.10f}'.format(theta))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)  We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.  When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.

Submission attempts (in order):
import math

a,b,x=map(int,input().split())
if b>a or x<a*a*b//2:
    q=math.acos(x/(a*a*b))
else:
    q=math.atan(2*(a*a*b-x)/(a**3))
print(math.degrees(q))

a,b,x=map(int,input().split())
if x<a*a*b//2:
    q=math.degrees(math.atan(a*b*b/(2*x)))
else:
    q=math.degrees(math.atan(2*(a*a*b-x)/(a**3)))
print('{:.10f}'.format(q))

import math

a,b,x=map(int,input().split())
if x<a*a*b//2:
    q=math.degrees(math.atan(a*b*b/(2*x)))
else:
    q=math.degrees(math.atan(2*(a*a*b-x)/(a**3)))
print('{:.10f}'.format(q))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)  We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.  When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.

Submission attempts (in order):
import math

a,b,x = map(int,input().split())
S = a * b / 2

if S >= x:
  change_length = 2*x/(a**2*b)
  rad = math.atan2(b, change_length)
else:
  change_length = (2*b - 2*x/a**2)
  rad = math.atan2(change_length, a)
Theta = math.degrees(rad)
print(Theta)

import math

a,b,x = map(int,input().split())
S = a * b / 2

if S >= x/a:
  change_length = 2*x/(a*b)
  rad = math.atan2(b, change_length)
else:
  change_length = (2*b - 2*x/(a**2))
  rad = math.atan2(change_length, a)
Theta = math.degrees(rad)
print('{:.10f}'.format(Theta))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a  = np.sort(np.array(a))
f = np.sort(np.array(f))[::-1]

l ,r = 0, 10 ** 12
x = 0
while l <= r:
	x = (l + r) // 2
	if np.clip(a - f // x, 0, None).sum() <= k:
		l += 1
	else:
		r -= 1
print(l)

import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a  = np.sort(np.array(a))
f = np.sort(np.array(f))[::-1]

l ,r = 0, 10 ** 12
x = 0
while l <= r:
	x = (l + r) // 2
	if np.sum(np.clip(a - f // x, 0, None)) <= k:
		l = x + 1
	else:
		r = x - 1
print(l)


import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a  = np.sort(np.array(a))
f = np.sort(np.array(f))[::-1]

l ,r = 0, 10 ** 12
while l <= r:
 x = (l + r) // 2
 if np.clip(a - x // f, 0, None).sum() <= k:
  r = x - 1
 else:
  l = x + 1
print(l)

Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

N,K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" "))) # consumption coefficient of members
F = list(map(int, input().split(" "))) # difficulty of food

# pair fastest eaters (low consumption coefficient) with most difficult foods
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)

def how_many_K(A,F,T,K):
    """
    Returns whether the number of training sessions needed for group A with foods F to have a score equal to T is less than K
    """
    num_trains = 0
    for i in range(len(A)):
        a = A[i]
        f = F[i]
        num_trains += max(0, a-T//f)

    if num_trains > K:
        return False
    else:
        return True

maxT = A[-1]*F[-1] # T with no training
# use binary search to find lowest possible T
left = -1
right = maxT + 1
while left+1< right:
    mid = (left+right)//2
    
    if np.maximum(0, A - (mid//F)).sum() <= K:
        right  = mid
    else:
        left = mid
print(mid)



import numpy as np

N,K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" "))) # consumption coefficient of members
F = list(map(int, input().split(" "))) # difficulty of food

# pair fastest eaters (low consumption coefficient) with most difficult foods
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)

maxT = np.max(A*F)
# use binary search to find lowest possible T
left = -1
right = maxT
while left+1< right:
    mid = (left+right)//2
    if np.maximum(0, A - (mid//F)).sum() <= K:
        right  = mid
    else:
        left = mid
print(right)



Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import sys
import math
input = sys.stdin.readline

_n, _k = map(int, input().split())
_a = input()[:-1]
_f = input()[:-1]
alist = [item for item in _a]
flist = [item for item in _f]


def chker(costs, diffs, max_k):
    if sum(costs) <= max_k:
        print(0)

    costs.sort()
    diffs.sort(reverse=True)
    sclist = [(item1, item2, item1 * item2) for item1, item2 in zip(costs, diffs)].sort(key=lambda x:x[2], reverse=True)
    k = max_k
    while k > 0:
        k -= 1
        sclist[0][0] = sclist[0][0] - 1
        if sclist[0][0] == 0:
            sclist = sclist[1:]
        else:
            sclist[0][2] = sclist[0][0] * sclist[0][1]
            sclist.sort(key=lambda x:x[2], reverse=True)

    print(sclist[0][2])


chker(alist, flist, _k)


import numpy as np
import sys
input = sys.stdin.readline

_n, _k = map(int, input().split())
alist = [int(item) for item in input().split()]
flist = [int(item) for item in input().split()]


def chker(costs, diffs, max_k):
	costs = np.sort(costs)[::-1]
	diffs = np.sort(diffs)
	
	_min, _max = 0, 10 ** 12
	while _min < _max:
		_mid = (_min + _max) // 2
		cnt = costs - _mid // diffs
		if cnt[cnt > 0].sum() <= max_k:
			_max = _mid
		else:
			_min = _mid + 1


	print(_min)


chker(alist, flist, _k)


Verdicts: Runtime Error

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
N,K=input().split()
A=list(map(int,input().split()))
F=list(map(int,input().split()))

A=sorted(A)
F=sorted(F,reverse=True)
time=list()

for i in range(N):
   time.append(A[i]*F[i])

while(K>0):
   cmax=max(time)
   if(cmax>0):
      A[time.index(cmax)]-=1
      time[time.index(cmax)]=A[time.index(cmax)]*F[time.index(cmax)]
      K-=1
   elif(cmax=0):
      break

cmax=max(time)
print(cmax)


from sys import stdin
import numpy as np
def main():
    
    readline=stdin.readline
    n,k=map(int,readline().split())
    A=np.array(list(map(int,readline().split())),dtype=np.int64)
    A=np.sort(A)[::-1]
    F=np.array(list(map(int,readline().split())),dtype=np.int64)
    F=np.sort(F)

    l=-1
    r=10**12
    while l<r-1:
        x=(l+r)//2
        A_after=np.minimum(x//F,A)
        cnt=(A-A_after).sum()
        if cnt<=k: r=x
        else: l=x

    print(r)

if __name__=="__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A.sort()
F.sort()
A = A[::-1]
left = 0
right = np.max(A * F)
judge = (left + right) // 2
for _ in range(50):
    rec = judge // F
    recK = np.sum(np.maximum(np.zeros(N), A - rec))
    if recK <= K:
        right = judge
    else:
        left = judge + 1
    if left == right:
        print(left)
        break

import numpy as np
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A.sort()
F.sort()
A = A[::-1]
left = 0
right = np.max(A * F)
for _ in range(50):
    judge = (left + right) // 2
    rec = judge // F
    recK = np.sum(np.maximum(np.zeros(N), A - rec))
    if recK <= K:
        right = judge
    else:
        left = judge + 1
    if left == right:
        print(left)
        break

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort()
    F.sort(reverse=True)
     
    l = 0
    r = max(a * f for a, f in zip(A, F))
     
    while l < r:
        m = (l + r) // 2
        if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
            r = m
        else:
            l = m + 1
     
    print(r)

import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)


Verdicts: Runtime Error

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, Nonw).sum()

    if req < k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff)


import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req < k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff)


import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req <= k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

n,k=map(int,input().split())

a=np.array(input().split(),dtype=np.int64)
f=np.array(input().split(),dtype=np.int64)
a.sort()
f.sort()
f=f[::-1]
af=a*f


def safe(r):
    return sum(np.maximum(0,af-r+f-1)//f)<=k
    
m=-1
M=10**12

while True:
    pos=(m+M)//2
    print(pos,safe(pos))
    if safe(pos):
        M=pos
    else:
        if m==pos:
            print(M)
            break
        m=pos



import numpy as np

n,k=map(int,input().split())

a=np.array(input().split(),dtype=np.int64)
f=np.array(input().split(),dtype=np.int64)

a.sort()
f.sort()
f=f[::-1]
af=a*f


def safe(r):
    return (np.maximum(0,(af-r+f-1)//f)).sum()<=k
    
m=-1
M=10**12

while m+1<M:
    pos=(m+M)//2
    if safe(pos):
        M=pos
    else:
        m=pos
print(M)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
import numpy as np
s_A = sum(A)
if s_A<=K:
  print(0)
  
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)
mi=0
ma=max(F)*max(A)
while mi+1<ma:
  mid = (mi+ma)//2
  print(ma)
  if s_A-np.minimum(A,mid//F).sum()<=K:
    ma=mid
  else:
    mi=mid
  
print(ma)

N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
import numpy as np
s_A = sum(A)
if s_A<=K:
  print(0)

else:
  A.sort()
  F.sort(reverse=True)
  A = np.array(A)
  F = np.array(F)
  mi=0
  ma=max(F)*max(A)
  while mi+1<ma:
    mid = (mi+ma)//2
    if s_A-np.minimum(A,mid//F).sum()<=K:
      ma=mid
    else:
      mi=mid

  print(ma)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

def is_ok(mid, k):
    s = a - mid // f
    print(s)
    s = s[s > 0].sum()
    if s <= k:
        return True
    else:
        return False

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a.sort()
f.sort(reverse=True)
a = np.array(a)
f = np.array(f)

l, r = -1, 10**12 # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)

import numpy as np

def is_ok(mid, k):
    s = np.maximum(a - mid // f, 0).sum()
    if s <= k:
        return True
    else:
        return False

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
f = np.array(list(map(int, input().split())))
a = np.sort(a)
f = np.sort(f)[::-1]

l, r = -1, np.max(a * f) # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))

s=A.sum()

x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=K:
    x=mid
  else:
    y=mid
print(mid)

N,K=map(int,input().split())
list_A=list(map(int,input().split()))
list_F=list(map()int,input().split())
list_A_sort=list_A.sort()
list_F_sort=list_F.sort()
list_F_reverse=list_F_sort.reverse()

list_A1=[]
for x in list_A_sort:
  list_A1.append(x-1)
  

import numpy as np

a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))

s=A.sum()

x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=b:
    y=mid
  else:
    x=mid
print(y)



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
from copy import deepcopy
from numpy import*
import sys
sys.setrecursionlimit(10**8)

 
def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)
    ng=0
    
    def check(a,mid,k):
        a=array(a)
        if sum(a[a>mid]-mid)<=k:
            return 1
        else:
            return 0
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if check(a,mid,k):
            ok=mid
        else:
            ng=mid
        #print(mid)
    a=array([ok if i>=ok else i for i in a])
    print(max(a*array(b)))

if __name__ == '__main__':
    main()

from numpy import*
import sys

 
def main():
    n,k=map(int,input().split())
    a=array(sorted(map(int,input().split())))
    b=array(sorted(map(int,input().split())))[::-1]
    ok=max(a)*max(b)
    ng=-1
    s=sum(a)
    def check(a,b,mid,k):
        if s-sum(minimum(a,mid//b))<=k:
            return 1
        else:
            return 0
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if check(a,b,mid,k):
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i.  In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows:    * A team should assign one member to each food, and should not assign the same member to multiple foods.   * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.   * The score of a team is the longest time it takes for an individual member to finish the food.  Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.  What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Submission attempts (in order):
import numpy as np

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

Asum = sum(A)

Asort = sorted(A)
Fsort = sorted(F,reverse=True)

def test(x):
    res = max(0,Asort-x//Fsort).sum()
    return res <= K

left = -1
right = 10**13

while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

ans = right

print(ans)



import numpy as np

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

Asum = sum(A)

Asort = np.array(sorted(A))
Fsort = np.array(sorted(F,reverse=True))

def test(x):
    res = np.maximum(0,Asort-x//Fsort).sum()
    return res <= K

left = -1
right = 10**13

while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

ans = right

print(ans)


Verdicts: Runtime Error

Accepted