Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        buf = l[i]+l[j]
        Min = j+1
        Max = n
        while(Min!=Max):
            Mid = math.floor((Min+Max)/2)
            if l[Mid] < buf:
                Min = Mid+1
            elif l[Mid] == buf:
                Min = Mid
                Max = Mid
            else:
                Max = Mid
        ans += Min-(j+1)
print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        buf = l[i]+l[j]
        Min = j+1
        Max = n
        while(Min!=Max):
            Mid = math.floor((Min+Max)/2)
            if l[Mid] < buf:
                Min = Mid+1
            else:
                Max = Mid
        ans += Min-(j+1)
print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i]+l[j] > l[k]:
                ans += 1
            else:
                break

print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            triangle = [l[i],l[j],l[k]]
            triangle.sort()
            if triangle[0]+triangle[1] > triangle[2]:
                ans += 1

print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [None]*n
ans = 0

for i in range(n):
    s = input()
    s_s = ''.join(sorted(s))
    S[i] = s_s
S.sort()
for i in range(n-1):
    f = True
    F = True
    t = 1
    while F:
        for j in range(10):
            if S[i][j] != S[i+t][j]:
                f = False
                F = False
                break
        if f:
            ans += 1
            t += 1
            if t+i >= n:
                break
print(ans)

Fixed submission:
n = int(input())
S = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    if s_s in S:
        ans += S[s_s]
        S[s_s] += 1
    else:
        S[s_s] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [None]*n
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    S[i] = s_s
S.sort()
#print(S)
for i in range(n-1):
    f = True
    F = True
    t = 1
    while F:
        for j in range(10):
            if S[i][j] != S[i+t][j]:
                f = False
                F = False
                break
        if f:
            ans += 1
            t += 1
            if t+i >= n:
                break
print(ans)

Fixed submission:
n = int(input())
S = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    if s_s in S:
        ans += S[s_s]
        S[s_s] += 1
    else:
        S[s_s] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [None]*n
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    S[i] = s_s
S.sort()
#print(S)
for i in range(n-1):
    f = True
    F = True
    t = 1
    while F:
        for j in range(10):
            if S[i][j] != S[i+t][j]:
                f = False
                F = False
                break
        if f:
            ans += 1
            t += 1
            if t+i >= n:
                break
print(ans)

Fixed submission:
n = int(input())
S = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s_s = ''.join(s)
    if s_s in S:
        ans += S[s_s]
        S[s_s] += 1
    else:
        S[s_s] = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

last_ans = 0

for i in range(2 ** N):
    hako = [0]*N
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            hako[j] = 1

    #print(hako)
    ans = 0
    for kijun in range(1,N+1):
        baisuu = 1
        total = 0
        while kijun*baisuu <= N:
            if hako[kijun*baisuu-1] == 1:
                total += 1
            baisuu += 1

        total %= 2
        if a[kijun-1] != total:
            ans = 1
            break

    if ans == 0:
        last_ans = 1
        break

if last_ans == 1:
    print(hako.count(1))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print(' '.join(map(str, buf)))
else:
    print(-1)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))

hako = [0]*N
last_ans = 1

for i in range(N-1, -1, -1):
    #print(i)
    check = 0
    kijun = i+1
    baisuu = 1
    total = 0
    while kijun*baisuu <= N:
        if hako[kijun*baisuu-1] == 1:
            total += 1
        baisuu += 1
    total %= 2
    if total != a[i]:
        hako[i] = 1

if last_ans == 1:
    print(hako.count(1))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print(' '.join(map(str, buf)))
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
else if L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)

Fixed submission:
L, R = map(int, input().split())

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

MOD = 2019
MIN = float('inf')
for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        MIN = min(buf, MIN)

print(MIN)

Fixed submission:
L, R = map(int, input().split())

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())

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

dis = 0
ans = 1
for i in range(n+1):
    dis += L[i]
    if dis > x:
        dis -= L[i]
        break
    ans += 1

print(ans)

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

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

dis = 0
ans = 1
for i in range(n):
    dis += L[i]
    if dis > x:
        dis -= L[i]
        break
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int, input().split()))
b = []

for i in range(n):
    t = i%2
    if t == 0:
        b.append(a[i])
    else:
        b.insert(0, a[i])

if n%2 == 1:
    for i in range(1,n+1):
        print(b[-i], end=' ')
else:
    for i in range(n):
        print(b[i], end=' ')

Fixed submission:
n = int(input())

a = list(map(int, input().split()))
b = [None]*n

half = int(n/2)
for i in range(1,n+1):
    t = i%2
    if t != 0:
        b[half+int(i/2)] = a[i-1]
    else:
        b[half-int(i/2)] = a[i-1]

if n%2 == 1:
    for i in range(1,n+1):
        print(b[-i], end=' ')
else:
    for i in range(n):
        print(b[i], end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int, input().split()))
b = []

for i in range(n):
    t = i%2
    if t == 0:
        b.append(a[i])
    else:
        b.insert(0, a[i])

if n%2 == 1:
    for i in range(int(n/2)):
        b[i], b[-(i+1)] = b[-(i+1)], b[i]
    
for i in range(n):
    print(b[i], end=' ')

Fixed submission:
n = int(input())

a = list(map(int, input().split()))
b = [None]*n

half = int(n/2)
for i in range(1,n+1):
    t = i%2
    if t != 0:
        b[half+int(i/2)] = a[i-1]
    else:
        b[half-int(i/2)] = a[i-1]

if n%2 == 1:
    for i in range(1,n+1):
        print(b[-i], end=' ')
else:
    for i in range(n):
        print(b[i], end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

s = []

for i in range(n):
    a, b = map(int, input().split())
    for j in range(b):
        s.append(a)

s = sorted(s)

print(s[k-1])

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

A = []

for i in range(n):
    c = []
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
    A.append(c)

A.sort(key=lambda x:x[0])


f = k
i = 0
while f > 0:
    f -= A[i][1]
    i += 1

print(A[i-1][0])
Buggy python submission (verdict: Runtime Error):
import math

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

if c%math.gcd(a, b) == 0:
    print('YES')
else:
    print('NO') 

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

if c%gcd(a, b) == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j+1]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]

ans = ''.join(sorted(ans))
print(ans)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]
        for j in range(1,n):
            re = s[0][i]
            s[j] = s[j].replace(re , '', 1)

ans = ''.join(sorted(ans))
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()

ans = a+b

if ans > 24:
    ans -=24

print(ans)

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

ans = a+b

if ans > 23:
    ans = ans - 24

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n*2 < m:
    c = m - (n*2)
    ans = int(c/4) + n
else:
    ans = int(c/2)

print(ans)

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

if n*2 < m:
    c = m - (n*2)
    ans = int(c/4) + n
else:
    ans = int(m/2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

f = 1

if n%2 == 0:
    for i in range(n//2):
        if a.count((2*i)+1) != 2:
            f = 0
            break

else:
    if a.count(0) != 1:
        f == 0
    for i in range(n//2):
        if a.count((2*i)+2) != 2:
            f = 0
            break
if f == 0:
    print(f)
else:
    print(2**(n//2))

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

f = 1

if n%2 == 0:
    ans = [2]*(n//2)
    #print(ans)
    for i in range(n):
        if a[i]%2 == 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

else:
    ans = [2]*((n+1)//2)
    ans[0] -= 1
    for i in range(n):
        if a[i]%2 != 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

for i in range(len(ans)):
    if ans[i] != 0:
        f = 0
        break

if f == 0:
    print(f)
else:
    print((2**(n//2))%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

f = 1

if n%2 == 0:
    for i in range(n//2):
        if a.count(i*2+1) != 2:
            f = 0
            break

else:
    if a.count(0) != 1:
        f = 0
    for i in range(n//2):
        if a.count((i+1)*2) != 2:
            f = 0
            break

if f == 0:
    print(f)
else:
    print(2**(n//2))

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

f = 1

if n%2 == 0:
    ans = [2]*(n//2)
    #print(ans)
    for i in range(n):
        if a[i]%2 == 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

else:
    ans = [2]*((n+1)//2)
    ans[0] -= 1
    for i in range(n):
        if a[i]%2 != 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

for i in range(len(ans)):
    if ans[i] != 0:
        f = 0
        break

if f == 0:
    print(f)
else:
    print((2**(n//2))%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

ar = UnionFind(n)
br = UnionFind(n)
ans = [0]*n

#print(ar.parents)

for i in range(k):
    p, q = map(int, input().split())
    ar.union(p-1,q-1)

for i in range(l):
    p, q = map(int, input().split())
    br.union(p-1,q-1)

for i in range(n):
    s = set(ar.members(i)) & set(br.members(i))
    ans[i] = len(s)
    print(len(s), end=" ")

Fixed submission:
import sys

#UnionFine　ネットの解答

def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

def union(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)

    if x != y:
        #xとyの属している集合が異なる場合
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x,y,par):
    return find(x,par) == find(y,par)

input = sys.stdin.readline
n, k, l = map(int, input().split())    
apar = []
bpar = []
arank = [0]*n
brank = [0]*n

for i in range(n):
    apar.append(i)
    bpar.append(i)


for i in range(k):
    p,q = map(int, input().split())
    union(p-1,q-1,apar,arank)

for i in range(l):
    p,q = map(int, input().split())
    union(p-1,q-1,bpar,brank)

num = []
d = {}
for i in range(n):
    num.append(find(i,apar)+find(i,bpar)*10**6)
    if num[-1] in d:
        d[num[-1]] += 1
    else:
        d[num[-1]] = 1

res = ''
for i in range(n):
    if i != 0:
        res += ' '

    res += str(d[num[i]])

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

ans = 0
p = a
while p <= b:
    if p%x == 0:
        break
    p += 1

t = b-p
s = t//x
ans = s + 1

print(ans)

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

p = 0
y = int(b//x) + 1

i = 1
#for i in range(1,y):
while x*i <= b:
    if a <= x*i:
        p = x*i
        break
    i += 1

if p != 0:
    t = b-p
    s = t//x
    ans = s + 1
    if a == 0:
        ans += 1
    print(ans)
elif a == 0:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
a = list(map(int,input().split()))

ans = 0

for i in range(n-1):
    if i == 0:
        q = 0
    else:
        q = a[i-1]
    if i == n-2:
        r = 0
    else:
        r = a[i+2]

    while a[i]+a[i+1] > x:
        if q+a[i] < a[i+1]+r:
            a[i+1] -= 1
            ans += 1
        else:
            a[i] -= 1
            ans += 1

print(ans)

Fixed submission:
n, x = map(int, input().split())
a = list(map(int,input().split()))

ans = 0
for i in range(n-1):
    if a[i] > x:
        ans += a[i]-x
        a[i] = x
    if a[i]+a[i+1] > x:
        ans += a[i+1] - (x-a[i])
        a[i+1] = x-a[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, t = map(int, input().split())
a = list(map(int, input().split()))

saeki = []
maxsaeki = 0
ans = 0
maxringo = max(a)

for i in range(len(a)-1):
    if a[i] == maxringo:
        maxringo = max(a[i+1:])
    s = maxringo - a[i]
    if s == maxsaeki:
        ans += 1
    if s > maxsaeki:
        ans = 1
        maxsaeki = s

print(ans)

Fixed submission:
n, t = map(int, input().split())
a = list(map(int, input().split()))

ma = a[-1]
m = 1
maxsaeki = 0
ans = 0

for i in range(n-2,-1,-1):
    if a[i] > ma:
        ma = a[i]
        m = 1
    elif a[i] < ma:
        if (ma - a[i]) > maxsaeki:
            maxsaeki = ma-a[i]
            ans = 1
        elif (ma - a[i]) == maxsaeki:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, t = map(int, input().split())
a = list(map(int, input().split()))

saeki = []
maxsaeki = 0
ans = 0

for i in range(len(a)-1):
    hikaku = a[i]
    m = max(a[i+1:])
    s = m - hikaku
    if s == maxsaeki:
        ans += 1
    if s > maxsaeki:
        ans = 1
        maxsaeki = s

print(ans)

Fixed submission:
n, t = map(int, input().split())
a = list(map(int, input().split()))

ma = a[-1]
m = 1
maxsaeki = 0
ans = 0

for i in range(n-2,-1,-1):
    if a[i] > ma:
        ma = a[i]
        m = 1
    elif a[i] < ma:
        if (ma - a[i]) > maxsaeki:
            maxsaeki = ma-a[i]
            ans = 1
        elif (ma - a[i]) == maxsaeki:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, t = map(int, input().split())
a = list(map(int, input().split()))

saeki = []

for i in range(len(a)-1):
    hikaku = a[i]
    m = max(a[i+1:])
    s = m - hikaku
    if s > 0:
        saeki.append(s)
    else:
        saeki.append(0)

saidaisaeki = max(saeki)
ans = saeki.count(saidaisaeki)
print(ans)

Fixed submission:
n, t = map(int, input().split())
a = list(map(int, input().split()))

ma = a[-1]
m = 1
maxsaeki = 0
ans = 0

for i in range(n-2,-1,-1):
    if a[i] > ma:
        ma = a[i]
        m = 1
    elif a[i] < ma:
        if (ma - a[i]) > maxsaeki:
            maxsaeki = ma-a[i]
            ans = 1
        elif (ma - a[i]) == maxsaeki:
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

for i in range(n-1):
    s,t = map(int,input().split())
    while float(a/b) != float(s/t):
        if float(a/b) > float(s/t):
            b += 1
        elif float(a/b) < float(s/t):
            a += 1

print(a+b)

Fixed submission:
from math import ceil

n = int(input())
a = 1
b = 1

for i in range(n):
    s,t = map(int,input().split())
    #x = max([ceil(a/s), ceil(b/t)])
    x = max((a+s-1)//s, (b+t-1)//t)

    a = x*s
    b = x*t

print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
h, w, n = map(int, input().split())

ans = [0]*10

a = []

if n != 0:
    for i in range(n):
        s = input()
        a.append(s)


for i in range(1,h-1):
    for j in range(1,w-1):
        s = 0
        for p in range(3):
            for q in range(3):
                st = str(i+p) + " " + str(j+q)
                if st in a:
                    s += 1
        if s == 0:
            ans[0] += 1
        else:
            ans[s] += 1

for i in range(10):
    print(ans[i])

Fixed submission:
f=lambda:map(int,input().split())
h,w,n = f()

d={}
while n:
 n-=1
 x,y=f()
 for i in range(9):
     a=(x+i%3,y+i//3)
     d[a]=d.get(a,0)+(h>=a[0]>2<a[1]<=w)

c=[list(d.values()).count(i+1)for i in range(9)]

print((h-2)*(w-2)-sum(c))
for i in range(9):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

length = len(s)
f = 0

for p in range(length-1):
    for q in range(p+2,length+1):
        hikaku = s[p:q]
        #print(hikaku)
        for i in range(len(hikaku)):
            num = hikaku.count(hikaku[i])
            if num > len(hikaku)/2:
                print(str(p+1) + ' ' + str(q))
                f = 1
                break
        if f == 1:
            break
    if f == 1:
        break
if f == 0:
    print('-1 -1')


Fixed submission:
s = input()

length = len(s)
f = 0

for p in range(length-1):
    for q in range(p+2,p+4):
        hikaku = s[p:q]
        #print(hikaku)
        for i in range(len(hikaku)):
            num = hikaku.count(hikaku[i])
            if num > len(hikaku)/2:
                print(str(p+1) + ' ' + str(q))
                f = 1
                break
        if f == 1:
            break
    if f == 1:
        break
if f == 0:
    print('-1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = [int(i) for i in input().split()]

q = 1

for i in num:
    q=q*i
    if i == 0:
        q=0
        break

if q>1e18: print(-1)
else: print(q)
        


Fixed submission:
n = int(input())
num = [int(i) for i in input().split()]

cont=0
ans=1

for j in num:
    if j == 0: cont+=1

if cont > 0: print(0)
else:
    for i in num:
        ans=ans*i
        if ans>1e18:
            ans=-1
            break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = [int(i) for i in input().split()]

q = 1

for i in num:
    q=q*i

if q>1e18: print(-1)
else: print(q)
        


Fixed submission:
n = int(input())
num = [int(i) for i in input().split()]

cont=0
ans=1

for j in num:
    if j == 0: cont+=1

if cont > 0: print(0)
else:
    for i in num:
        ans=ans*i
        if ans>1e18:
            ans=-1
            break
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = [int(i) for i in input().split()]
#k=n//(a+b)
#ans=a*k+a*(n-(a+b))
ans=0
while n >= 0:
    ans+=min(a,n)
    n-=(a+b)
print(ans)


Fixed submission:
n,a,b = [int(i) for i in input().split()]
if n!=(a+b): print(a*(n//(a+b))+min(a,n%(a+b)))
else: print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

if n<k: print(0)
else:
    for i in range(k):
        h.pop(h.index(max(h)))

    print(sum(h))


Fixed submission:
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

h.sort()

if n<=k: print(0)
else:
    for i in range(k):
        h.pop(-1)

    print(sum(h))