Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int, input().split())

t = n**0.5

cnt = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        for k in range(n//b+1):
            if i*r + j*g + k*b == n:
                cnt += 1
print(cnt)

Fixed submission:
r,g,b,n = map(int, input().split())

cnt = 0
for i in range(3001):
    for j in range(3001):
        k = i*r + j*g
        if n >= k and (n-k) % b == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int, input().split())

t = n**0.5

cnt = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        for k in range(n//b+1):
            if i*r + j*g + k*b == n:
                cnt += 1
print(cnt)

Fixed submission:
r,g,b,n = map(int, input().split())

cnt = 0
for i in range(3001):
    for j in range(3001):
        k = i*r + j*g
        if n >= k and (n-k) % b == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math

lis = []
for _ in range(5):
    lis.append(int(input()))
    
def roundup(x):
    return int(math.ceil(x/10)) * 10
    

    
minind = 9
tmp2 = 0
for i in range(5):
    tmp = str(lis[i])
    if tmp[-1] != "0":
        minind = min(minind, int(tmp[-1]))
        if minind == int(tmp[-1]):
            tmp2 = lis[i]
lis.remove(tmp2)

for j in range(4):
    lis[j] = roundup(lis[j])
        
print(sum(lis)+tmp2)

Fixed submission:
import math

lis = []
for _ in range(5):
    lis.append(int(input()))
    
def roundup(x):
    return int(math.ceil(x/10)) * 10
    

    
minind = 9
tmp2 = 0
for i in range(5):
    tmp = str(lis[i])
    if tmp[-1] != "0":
        minind = min(minind, int(tmp[-1]))
        if minind == int(tmp[-1]):
            tmp2 = lis[i]
   
if tmp2 == 0:
    print(sum(lis))
    exit()

lis.remove(tmp2)

for j in range(4):
    lis[j] = roundup(lis[j])
        
print(sum(lis)+tmp2)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())

s = input()

for i in range(q):
    l,r = map(int, input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
n,q = map(int,input().split())

s = input()

t = [0]*(n+1)

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
    
for i in range(q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

c = [1]
for i in range(2, max(a, b)):
    if a % i == 0 and b % i == 0:
        c.append(i)

c = sorted(c, reverse = True)

print(c[k-1])

Fixed submission:
a, b, k = map(int, input().split())

c = [1]
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(1, 8):
    a, b = i, 7-i
    l, r = k[:i], k[i:]
    
    if l in s and r in s:
        print("YES")
        exit()

print('NO')


Fixed submission:
s = input()

k = 'keyence'

for i in range(len(s)):
    for j in range(i, len(s)):
        t = s[:i] + s[j:]
        if k == t:
            print('YES')
            exit()

print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

ans = 0

for i in range(len(s)):
    if s[i] == 'B':
        tmp = s[i:]
        ans += tmp.count('W')

print(ans)

Fixed submission:
s = list(input())

ans = 0
black = 0

for i in range(len(s)):
    if s[i] == 'W':
        ans += i - black
        black += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
lis = []
for _ in range(n):
    lis.append(int(input()))
    
lis = sorted(lis)

tmp = 10000000000

for i in range(n-k+1):
    ma = max(lis[i:i+k])
    mi = min(lis[i:i+k])
    
    tmp = min(tmp, ma-mi)
    
print(tmp)

Fixed submission:
n, k = map(int, input().split())
lis = []
for _ in range(n):
    lis.append(int(input()))
    
lis = sorted(lis)

tmp = 10000000000

for i in range(n-k+1):
    ma = lis[i+k-1]
    mi = lis[i]
    
    tmp = min(tmp, ma-mi)
    
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())

lis = list(map(int, input().split()))

nlis = sorted(lis)

a = math.floor((n-1)/2)

for i in range(n):
    nlis = sorted(nlis)
    tmp = lis[i]
    nlis.remove(lis[i])
    print(nlis[a])
    nlis.append(tmp)

Fixed submission:
import math
n = int(input())

lis = list(map(int, input().split()))

nlis = sorted(lis)

med1 = nlis[n//2-1]
med2 = nlis[n//2]

for i in lis:
    if i <= med1:
        print(med2)
    else:
        print(med1)
Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())
 
lis = list(range(a,b+1))
 


if (b-a+1)>= 2*k:
    nlis = []
    for i in range(a, min(b+1, a+k)):
        nlis.append(i)
        
    for j in range(max(a,b-k+1, a+k), b+1):
        nlis.append(j)
        
    for k in sorted(nlis):
        print(k)
else:
    for i in range(a,b+1):
        print(i)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())
 
lis = list(range(a,b+1))
 


if (b-a+1)>= 2*k:
    for i in lis:
        if (i >= a and i <a+k) or (i <=b and b-k < i):
            print(i)
else:
    for i in range(a,b+1):
        print(i)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())

lis = list(range(a,b+1))


nlis = []
for i in range(a, min(b+1, a+k)):
    nlis.append(i)
    
for j in range(max(a,b-k+1, a+k), b+1):
    nlis.append(j)
    
for k in sorted(nlis):
    print(k)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())

lis = list(range(a,b+1))


nlis = []
for i in range(a, min(b+1, a+k)):
    nlis.append(i)
    
for j in range(max(b-k+1, a+k), b+1):
    nlis.append(j)
    
for k in sorted(nlis):
    print(k)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())

lis = list(range(a,b+1))


for i in lis:
    if (i >= a and i <a+k) or (i <=b and b-k < i):
        print(i)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b, k = map(int,input().split())

lis = list(range(a,b+1))


for i in lis:
    if (i >= a and i <a+k) or (i <=b and b-k < i):
        print(i)

Fixed submission:
a,b,k = map(int, input().split())
if k*2+a-1<=b:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
n = input()

op_cnt = len(n) -1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt -1 -j] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(f'{formula}=7')
        break

Fixed submission:
n = input()

op_cnt = len(n) -1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt -1 -j] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        s = formula+"=7"
        print(s)
        break

Buggy python submission (verdict: Runtime Error):
n = input()

op_cnt = len(n) -1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt -1 -j] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(f'{formula}=7')
        break

Fixed submission:
n = input()

op_cnt = len(n) -1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt -1 -j] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        s = formula+"=7"
        print(s)
        break
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

if len(t) > len(s):
    print('UNRESTORABLE')
    exit()

lis = []
flag = 0
for i in range(len(s)):
    if s[i] == t[0]:
        for j in range(i+1, i+len(t)-1):
            if s[j] == '?' or s[j] == t[j-i]:
                flag = 1
            else:
                flag = 0
                break
    
    if flag:
        lis.append(i)
        flag = 0

if len(lis) == 0:
    print('UNRESTORABLE')
    exit()

tmp = max(lis)
s[tmp:tmp+len(t)+1] = t

for k in range(len(s)):
    if s[k] == '?':
        s[k] = 'a'


print(''.join(s))

Fixed submission:
s = input()
t = input()

if len(t) > len(s):
    print('UNRESTORABLE')
    exit()

s = s[::-1]
t = t[::-1]

for i in range(len(s) - len(t) + 1):
    j = 0
    while True:
        if j == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans[::-1].replace('?', 'a', len(ans)))
            exit()
        if t[j] == s[i+j] or s[i+j] == '?':
            j += 1
        else:
            break
print("UNRESTORABLE")

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

if len(t) > len(s):
    print('UNRESTORABLE')
    exit()

flag = 0
for i in range(len(s)):
    if s[i] == t[0]:
        for j in range(i+1, i+len(t)-1):
            if s[j] == '?':
                flag = 1
            else:
                flag = 0
                break
    
    if flag:
        s[i:i+len(t)+1] = t
        break

if flag == 0:
    print('UNRESTORABLE')
    exit()

for k in range(len(s)):
    if s[k] == '?':
        s[k] = 'a'


print(''.join(s))

Fixed submission:
s = input()
t = input()

if len(t) > len(s):
    print('UNRESTORABLE')
    exit()

s = s[::-1]
t = t[::-1]

for i in range(len(s) - len(t) + 1):
    j = 0
    while True:
        if j == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans[::-1].replace('?', 'a', len(ans)))
            exit()
        if t[j] == s[i+j] or s[i+j] == '?':
            j += 1
        else:
            break
print("UNRESTORABLE")

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

flag = 0
for i in range(len(s)):
    if s[i] == t[0]:
        for j in range(i+1, i+len(t)-1):
            if s[j] == '?':
                flag = 1
            else:
                flag = 0
                break
    
    if flag:
        s[i:i+len(t)+1] = t
        break

if flag == 0:
    print('UNRESTORABLE')
    exit()

for k in range(len(s)):
    if s[k] == '?':
        s[k] = 'a'


print(''.join(s))

Fixed submission:
s = input()
t = input()

if len(t) > len(s):
    print('UNRESTORABLE')
    exit()

s = s[::-1]
t = t[::-1]

for i in range(len(s) - len(t) + 1):
    j = 0
    while True:
        if j == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans[::-1].replace('?', 'a', len(ans)))
            exit()
        if t[j] == s[i+j] or s[i+j] == '?':
            j += 1
        else:
            break
print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
n = int(input())

lis = list(map(int, input().split()))

count = [0] * (10**5)

for i in lis:
    count[i] += 1

t1 = 0
t2 = 0
  
for i in range(len(count)):
    if count[i] >= 2 and i+1 > t1:
        t2 = t1
        t1 = i

if count[t1] >= 4:
    a1 = t1*t1
    print(a1)
    exit()

print(t1*t2)



Fixed submission:
from collections import Counter

n = int(input())

lis = list(map(int, input().split()))

a = Counter(lis)

slis = sorted(set(lis))

t1 = 0
t2 = 0

for k, v in a.items():
    if v >=2 and k > t1:
        t2 = t1
        t1 = k

if a[t1] >= 4:
    print(t1*t1)
    exit()

print(t1*t2)
Buggy python submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
k=0
a=K
while a<=N:
    k=+1
    a=K**k
break
print(k+1)

Fixed submission:
N,K=(int(x) for x in input().split())
b=1
a=1
if N==1:
    print(1)
else:
     while a<=N:
          b=b+1
          a=K**b
     else:
          print(b)

Buggy python submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
k=0
while a<=x:
    a=K*10**k
    k=+1
print(k)

Fixed submission:
N,K=(int(x) for x in input().split())
b=1
a=1
if N==1:
    print(1)
else:
     while a<=N:
          b=b+1
          a=K**b
     else:
          print(b)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(raw_input())
if n % 10 == 3:
  print('bon')
elif n % 10 == 0 or n % 10 ==10 or n % 10 == 6 or n % 10 == 8:
  print('pon')
else:
  print('hon')

Fixed submission:
n = int(input())
if n % 10 == 3:
  print('bon')
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
n = str(input())
m = n[2]
if m == '2' or m == '4' or m == '5' or m == '7' or m == '9':
    print('hon')
elif m == '0' or m == '1' or m == '6' or m == '8':
    print('pon')
else:
    print('bon')

Fixed submission:
n = str(input())
m = n[-1]
if m == '2' or m == '4' or m == '5' or m == '7' or m == '9':
    print('hon')
elif m == '0' or m == '1' or m == '6' or m == '8':
    print('pon')
else:
    print('bon')
Buggy python submission (verdict: Time Limit Exceeded):
#E
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(N):
    B.append([A[i],i+1])
    
B.sort(reverse=True)

DP = [[0 for _ in range(N+1)] for _ in range(N+1)] #dp[x][y] x->1,2,3... y->N,N-1,N-2...
for i in range(N):
    I = i+1
    b,ind = B[i]
    
    for j in range(I+1):
        if j == 0:
            DP[j][I-j] = DP[j][I-j-1] + b*abs(N-(I-j)-ind+1)
        elif I-j == 0:
            DP[j][I-j] = DP[j-1][I-j] + b*abs(ind-j)
        else:
            DP[j][I-j] = max(DP[j][I-j-1]+b*abs(N-(I-j)-ind+1),DP[j-1][I-j]+b*abs(ind-j))
        
        
ans = 0
for i in range(N+1):
    ans = max(ans,DP[i][N-i])
    
#print(B)
print(ans)

Fixed submission:
#E
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(N):
    B.append([A[i],i+1])
    
B.sort(reverse=True)

DP = [[0 for _ in range(N+1)] for _ in range(N+1)] #dp[x][y] x->1,2,3... y->N,N-1,N-2...
for i in range(N):
    I = i+1
    b,ind = B[i]
    
    for j in range(I+1):
        if j == 0:
            DP[j][I-j] = DP[j][I-j-1] + b*abs(N-(I-j)-ind+1)
        elif I-j == 0:
            DP[j][I-j] = DP[j-1][I-j] + b*abs(ind-j)
        else:
            DP[j][I-j] = max(DP[j][I-j-1]+b*abs(N-(I-j)-ind+1),DP[j-1][I-j]+b*abs(ind-j))
        
        
ans = 0
for i in range(N+1):
    ans = max(ans,DP[i][N-i])
    
#print(B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#C
N,K = map(int,input().split())
old = N
while True:
    new = abs(K-old)
    if old < new:
        break
    else:
        old = new
print(old)



Fixed submission:
#C
N,K = map(int,input().split())
r = N%K
if N <= K:
    print(min(K-N,N))
else:
    print(min(r,K-r))
Buggy python submission (verdict: Time Limit Exceeded):
#D
from collections import deque
N,X,Y = map(int,input().split())
dist = [0 for _ in range(N)]

for i in range(N):
    s = i+1
    sdist = [-1 for _ in range(N)]
    d = deque([])
    d.append([s,0])
    while d:
        x,n = d.popleft()
        if sdist[x-1] == -1:
            sdist[x-1] = n
            
            if x < N:
                d.append([x+1,n+1])
            if x > 1:
                d.append([x-1,n+1])
            if x == X:
                d.append([Y,n+1])
            if x == Y:
                d.append([X,n+1])
    
    for sd in sdist:
        dist[sd]+=1
        
for i in range(N-1):
    print(dist[i+1]//2)
        
    



Fixed submission:
#D
from collections import deque
N,X,Y = map(int,input().split())
dist = [0 for _ in range(N)]

for i in range(N):
    s = i+1
    sdist = [-1 for _ in range(N)]
    d = deque([])
    d.append([s,0])
    while d:
        x,n = d.popleft()
        if sdist[x-1] == -1:
            sdist[x-1] = n
            
            if x < N:
                d.append([x+1,n+1])
            if x > 1:
                d.append([x-1,n+1])
            if x == X:
                d.append([Y,n+1])
            if x == Y:
                d.append([X,n+1])
    
    for sd in sdist:
        dist[sd]+=1
        
for i in range(N-1):
    print(dist[i+1]//2)
Buggy python submission (verdict: Time Limit Exceeded):
#D
N = int(input())
S = list(str(input()))
count = 0
for i in range(1000):
    si = str(i)
    while len(si) < 3:
        si = "0"+si
        
    flag = 0
    for j in range(N):
        if S[j] == si[flag]:
            flag+=1
            if flag == 3:
                break
            
    if flag == 3:
        count+=1
    
print(count)

Fixed submission:
#D
N = int(input())
S = list(str(input()))
count = 0
for i in range(1000):
    si = str(i)
    while len(si) < 3:
        si = "0"+si
        
    flag = 0
    for s in S:
        if s == si[flag]:
            flag+=1
            if flag == 3:
                break
            
    if flag == 3:
        count+=1
    
print(count)
Buggy python submission (verdict: Runtime Error):
#D
from collections import deque
#import bisect
#import math
#import heapq
#import sys
#input = sys.stdin.readline

#inf = float("inf")
#mod = 10**9 + 7
#mod = 998244353

#list(map(int,input().split()))

N = int(input())
AB = [list(map(int,input().split())) for i in range(N-1)]
K = [0]*N
for ab in AB:
    a,b = ab
    K[a-1]+=1
    K[b-1]+=1
k = max(K)
print(k)

C = [0]*N
D = deque(AB)
flag = 0
visited = [-1]*N
#print(D)
while D:
    a,b = D.popleft()
    if visited[a-1] == -1 and visited[b-1] == -1:
        if flag == 0:
            flag = 1
            visited[a-1] = 0
            visited[b-1] = 0
            print(1)
            C[a-1] = 1
            C[b-1] = 1
        else:
            D.append([a,b])
    else:
        if visited[b-1] == -1:
            if C[a-1] == k:
                print(1)
                C[a-1] = 1
                C[b-1] = 1
            else:
                print(C[a-1]+1)
                C[a-1]+=1
                C[b-1] = C[a-1]
            visited[b-1] = 0
        else:
            visite[a-1] = 0
            if C[b-1] == k:
                print(1)
                C[a-1] = 1
                C[b-1] = 1
            else:
                print(C[b-1]+1)
                C[b-1]+=1
                C[a-1] = C[b-1]
        

            




Fixed submission:
#D
from collections import deque
#import bisect
#import math
#import heapq
#import sys
#input = sys.stdin.readline

#inf = float("inf")
#mod = 10**9 + 7
#mod = 998244353

#list(map(int,input().split()))

N = int(input())
AB = []
for i in range(N-1):
    a,b = map(int,input().split())
    AB.append([a,b,i])

K = [0]*N
for ab in AB:
    a,b,i = ab
    K[a-1]+=1
    K[b-1]+=1
k = max(K)
print(k)
AB.sort()
C = [0]*N
D = deque(AB)
flag = 0
visited = [-1]*N
ans = [0]*(N-1)
while D:
    a,b,i = D.popleft()
    if visited[a-1] == -1 and visited[b-1] == -1:
        if flag == 0:
            flag = 1
            visited[a-1] = 0
            visited[b-1] = 0
            ans[i] = 1
            C[a-1] = 1
            C[b-1] = 1
        else:
            D.append([a,b,i])
    else:
        if visited[b-1] == -1:
            if C[a-1] == k:
                ans[i] = 1
                C[a-1] = 1
                C[b-1] = 1
            else:
                ans[i] = C[a-1]+1
                C[a-1]+=1
                C[b-1] = C[a-1]
            visited[b-1] = 0
        else:
            visited[a-1] = 0
            if C[b-1] == k:
                ans[i] = 1
                C[a-1] = 1
                C[b-1] = 1
            else:
                ans[i] = C[b-1]+1
                C[b-1]+=1
                C[a-1] = C[b-1]
                
for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
#E
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort(reverse=True)
F.sort()

left = 0
right = 10**12
while True:
    mid = (left+right)//2
    if right - left <= 1:
        count = 0
        for i in range(N):
            a = left//F[i]
            count+=max(0,A[i]-a)
        if count <= K:
            ans = left
        else:
            ans = right
        break
    
    
    count = 0
    for i in range(N):
        a = mid//F[i]
        count+=max(0,A[i]-a)
    #print(right,left,count)
    if count <= K:
        right = mid
    else:
        left = mid
        
        

print(ans)
        
            



Fixed submission:
#E
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort(reverse=True)
F.sort()

left = 0
right = 10**12
while True:
    mid = (left+right)//2
    if right - left <= 1:
        count = 0
        for i in range(N):
            a = left//F[i]
            count+=max(0,A[i]-a)
        if count <= K:
            ans = left
        else:
            ans = right
        break
    
    
    count = 0
    for i in range(N):
        a = mid//F[i]
        count+=max(0,A[i]-a)
    if count <= K:
        right = mid
    else:
        left = mid
        
        

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D問題
N = int(input())
L = list(map(int,input().split()))
L.sort()
T = []

for i in range(N):
    for j in range(N):
        if j <= i:
            pass
        else:
            for k in range(N):
                if k <= j:
                    pass
                else:
                    I,J,K = L[i],L[j],L[k]
                    if I < J+K and J < I+K and K < I+J:
                        if [I,J,K] not in T:
                            T.append([I,J,K])
                                
                                
print(len(T))
            



Fixed submission:
#D問題
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        a,b = L[i],L[j]
        left = bisect.bisect_left(L,b-a+1)
        right = bisect.bisect_right(L,a+b-1)
        if i >= left and i <= right:
            ans-=1
        if j >= left and j <= right:
            ans-=1
        ans+=right-left

print(ans//3)

Buggy python submission (verdict: Time Limit Exceeded):
#D問題
N = int(input())
L = list(map(int,input().split()))
L.sort()
T = []

for i in range(N):
    for j in range(N):
        if j <= i:
            pass
        else:
            for k in range(N):
                if k <= j:
                    pass
                else:
                    I,J,K = L[i],L[j],L[k]
                    if I < J+K and J < I+K and K < I+J:
                        if [I,J,K] not in T:
                            T.append([I,J,K])
                                
                                
print(len(T))
            



Fixed submission:
#D問題
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        a,b = L[i],L[j]
        left = bisect.bisect_left(L,b-a+1)
        right = bisect.bisect_right(L,a+b-1)
        if i >= left and i <= right:
            ans-=1
        if j >= left and j <= right:
            ans-=1
        ans+=right-left

print(ans//3)