Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()

    sm = 0
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            sm += (a[i]% (10**9+7) * a[j% (10**9+7)]) % (10**9+7)
    
    print(sm% (10**9+7))




if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    mod = 10**9+7

    s = sum(a)

    sm = 0

    for i in a:
        s -= i
        sm += i * s % mod

    print(sm % mod)


if __name__ == '__main__':
    main()

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


def main():
    n = int(input())
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    l = []
    for i in range(len(a)):
        l.append(i)

    c_list = list(itertools.combinations(l, 2))

    sm = 0
    for tpl in c_list:
        sm += (a[tpl[0]] * a[tpl[1]]) % (10**9+7)

    print(sm % (10**9+7))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    mod = 10**9+7

    s = sum(a)

    sm = 0

    for i in a:
        s -= i
        sm += i * s % mod

    print(sm % mod)


if __name__ == '__main__':
    main()

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

    sm = 0
    for i in range(len(a)):
        for j in range(i+1, len(a)):
            sm += (a[i] * a[j]) % (10**9+7)

    print(sm % (10**9+7))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    mod = 10**9+7

    s = sum(a)

    sm = 0

    for i in a:
        s -= i
        sm += i * s % mod

    print(sm % mod)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    sums = []
    amount = 1
    for i in range(0, k):
        amount = amount * a[i]
    sums.append(amount)

    for i in range(1, n-k+1):
        sums.append(sums[i-1]/a[i-1]*a[i+k-1])
        if sums[i-1] < sums[i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

    for i in range(0, n-k):
        if a[i] < a[k+i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    sums = []
    amount = 1
    for i in range(0, k):
        amount = amount * a[i]
    sums.append(amount)

    for i in range(1, n-k+1):
        sums.append(sums[i-1]/a[i-1]*a[i+k-1])

    for i in range(1, n-k+1):
        if sums[i-1] < sums[i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

    for i in range(0, n-k):
        if a[i] < a[k+i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a_sum = []
    b_sum = []
    for i in range(1, len(a)+1):
        a_sum.append(sum(a[0:i]))
    for i in range(1, len(b)+1):
        b_sum.append(sum(b[0:i]))

    ans = 0
    j = m - 1
    for i in range(n):
        if a_sum[i] > k:
            break
        while b_sum[j] > k - a_sum[i]:
            j -= 1
        ans = max(ans, (i+1)+(j+1))

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a_sum = [0]
    b_sum = [0]
    for i in range(len(a)):
        a_sum.append(a_sum[i]+a[i])
    for i in range(len(b)):
        b_sum.append((b_sum[i]+b[i]))

    ans = 0
    j = m
    for i in range(n+1):
        if a_sum[i] > k:
            break
        while b_sum[j] > k - a_sum[i]:
            j -= 1
        ans = max(ans, (i+j))

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a_sum = []
    b_sum = []
    for i in range(1, len(a)+1):
        a_sum.append(sum(a[0:i]))
    for i in range(1, len(b)+1):
        b_sum.append(sum(b[0:i]))

    ans = 0
    j = m - 1
    for i in range(n):
        if a_sum[i] > k:
            break
        while b_sum[j] > k - a_sum[i]:
            j -= 1
        print(i, j)
        ans = max(ans, (i+1)+(j+1))

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a_sum = [0]
    b_sum = [0]
    for i in range(len(a)):
        a_sum.append(a_sum[i]+a[i])
    for i in range(len(b)):
        b_sum.append((b_sum[i]+b[i]))

    ans = 0
    j = m
    for i in range(n+1):
        if a_sum[i] > k:
            break
        while b_sum[j] > k - a_sum[i]:
            j -= 1
        ans = max(ans, (i+j))

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    bc = []
    for _ in range(q):
        bc.append(list(map(int, input().split())))

    for element in bc:
        for i in range(len(a)):
            if a[i] == element[0]:
                a[i] = element[1]
        print(sum(a))


if __name__ == '__main__':
    main()


Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    bc = []
    for _ in range(q):
        bc.append(list(map(int, input().split())))

    a_i = [0]*(10**5 + 10)
    for num in a:
        a_i[num] += 1

    amount = 0
    for i, num in enumerate(a_i):
        amount += num * i

    for element in bc:
        amount = amount - a_i[element[0]] * \
            element[0] + a_i[element[0]] * element[1]
        a_i[element[1]] += a_i[element[0]]
        a_i[element[0]] = 0

        print(amount)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    while True:
        c = 360
        if c % n == 0:
            print(c // n)
            exit()
        c += 360


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    # n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    x = int(input())
    i = 1
    while (x*i) % 360 != 0:
        i += 1
    print(i)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    while True:
        c = 360
        if c % n == 0:
            print(c // n)
            exit()
        c *= 2


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    # n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    x = int(input())
    i = 1
    while (x*i) % 360 != 0:
        i += 1
    print(i)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
for i in range(n):
    ans *= l[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

if ng:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


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

ans = 1
for i in range(n):
    ans *= l[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

if ng:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

n = int(input())
l = list(map(int, input().split()))
ans = reduce(lambda x, y: x * y, l)

if ans > 10**18:
    print (-1)
else:
    print(ans)

Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

if ng:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from operator import mul

n = int(input())
l = list(map(int, input().split()))
ans = reduce(mul, l)

if ans > 10**18:
    print (-1)
else:
    print(ans)

Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

if ng:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = float(b)
print(math.floor(a*b))

Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal

a, b = input().split()
a = int(a)
b = Decimal(b)
print(math.floor(a*b))
Buggy python submission (verdict: Runtime Error):
import itertools
import math
import fractions
import functools
import copy
from collections import deque

n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

ans = [-1] * n
d = deque([0])

while d:
    f = d.popleft()
    for i in ab[f]:
        if ans[i] == -1:
            ans[i] = f
            d.append(i)

print("Yes")
for i in range(1,n):
    print(ans[i]+1)


Fixed submission:
import itertools
import math
import fractions
import functools
import copy
from collections import deque

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


a = [-1]*n
d = deque([0])
while d:
    f = d.popleft()
    for i in g[f]:
        if a[i] == -1:
            a[i] = f
            d.append(i)

print("Yes")
for i in range(1,n):
    print(a[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = []
for i in range(m):
    ai, bi = map(int, input().split())
    ab.append([ai-1,bi-1])

v = [True]*n
for i in range(m):
    for j in range(n):
        if ab[i][0] == j or ab[i][1] == j:
            if h[ab[i][0]] > h[ab[i][1]]:
                v[ab[i][1]] = False
            elif h[ab[i][0]] < h[ab[i][1]]:
                v[ab[i][0]]= False
            else:
                v[ab[i][0]]= False
                v[ab[i][1]]= False

print(v.count(True))

Fixed submission:
import math
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
h_count = [0] * n
ab_list = []
count = 0
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ab_list.append([a, b])


for i in range(m):
    if h_list[ab_list[i][0]] > h_list[ab_list[i][1]]:
        h_count[ab_list[i][1]] += 1
    elif h_list[ab_list[i][0]] < h_list[ab_list[i][1]]:
        h_count[ab_list[i][0]] += 1
    else:
        h_count[ab_list[i][1]] += 1
        h_count[ab_list[i][0]] += 1


print(h_count.count(0))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
vote = list(map(int, input().split()))
sum = sum(vote)
cnt = 0


for i in range(0,len(vote)):
    if sum / 4 / M <= vote[i]:
        cnt++


if cnt >= M:
    print("Yes")
else: print("No")


Fixed submission:
N, M = map(int, input().split())
vote = list(map(int, input().split()))
sum = sum(vote)
allowedList = []


for i in range(0,len(vote)):
    if sum / 4 / M <= vote[i]:
        allowedList.append(vote[i])


if len(allowedList) >= M:
    print("Yes")
else: print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    if (s[i] in dic.keys()):
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

result.sort()
for i in range(len(result)):
    print(result[i])

Fixed submission:
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

result.sort()
for i in range(len(result)):
    print(result[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
pn = list(map(int, input().split()))
count = 1

for i in range(1,len(pn)):
    if min(pn[:i]) > pn[i]: count += 1
print(count)


Fixed submission:
n = int(input())
pn = list(map(int, input().split()))
count = 1
min = pn[0]

for i in range(1,len(pn)):
    if min > pn[i - 1]: min = pn[i - 1]
    if min > pn[i]: count += 1
print(count)

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

for i in range(0, len(pn)):
    icount = 0
    for j in range(0, i):
        if pn[i] <= pn[j]:
            icount += 1
    if icount == i:
        count += 1

print(count)

Fixed submission:
n = int(input())
pn = list(map(int, input().split()))
count = 1
min = pn[0]

for i in range(1,len(pn)):
    if min > pn[i - 1]: min = pn[i - 1]
    if min > pn[i]: count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
for num in range(x,10**6):
    ok = True
    for i in range(2,num):
        if num % i == 0:
            ok = False
    if ok:
        print(num)
        break

Fixed submission:
x = int(input())
isPrime = False


def isP(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True


isPrime = isP(x)

if isPrime:
    print(x)
else:
    while isPrime == False:
        x += 1
        isPrime = isP(x)
    print(x)
Buggy python submission (verdict: Runtime Error):

n = int(input())
x = []
y = []
index = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    index.append(i)

distance = 0
for v in itertools.permutations(index):
    for i in range(n-1):
        distance += math.sqrt((x[v[i]] - x[v[i+1]]) **
                              2 + (y[v[i]]-y[v[i+1]])**2)


print(distance/math.factorial(n))

Fixed submission:
import itertools
import math

n = int(input())
x = []
y = []
index = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    index.append(i)

distance = 0
for v in itertools.permutations(index):
    for i in range(n-1):
        distance += math.sqrt((x[v[i]] - x[v[i+1]]) **
                              2 + (y[v[i]]-y[v[i+1]])**2)


print(distance/math.factorial(n))
Buggy python submission (verdict: Runtime Error):
n = int(input())

maximum = math.ceil(math.sqrt(n))
minimum = 10**20
for i in range(1,maximum):
    j = 0
    if n % i == 0:
        j = n / i
        minimum = min(minimum,i+j)

print(int(minimum-2))

Fixed submission:
import math
import itertools
n = int(input())
x = 1
for i in reversed(range(1, math.ceil(math.sqrt(n))+1)):
    if n % i == 0:
        x = n / i
        break

print(math.floor(x - 1 + n / x - 1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
result = []

minNum = min(nums)
while(len(result) != n):
    result.append(str(nums.index(minNum) + 1))
    nums[nums.index(minNum)] = 10**5 + 1
    minNum += 1

print((" ").join(result))

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
pairlist = []
for i in range(len(nums)):
    pairlist.append([i, nums[i]])

sortedPairList = sorted(pairlist, key=lambda item: item[1])

result = []
for i in sortedPairList:
    result.append(str(i[0]+1))
print(" ".join(result))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
result = []

while(len(result) != n):
    result.append(str(nums.index(min(nums)) + 1))
    nums[nums.index(min(nums))] = 10**5 + 1

print((" ").join(result))

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
pairlist = []
for i in range(len(nums)):
    pairlist.append([i, nums[i]])

sortedPairList = sorted(pairlist, key=lambda item: item[1])

result = []
for i in sortedPairList:
    result.append(str(i[0]+1))
print(" ".join(result))
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
scores = [k] * n


for i in range(q):
    a = int(input())
    for j in range(len(scores)):
        if(j != a - 1):
            scores[j] -= 1

for i in scores:
    if(i <= 0):
        print("No")
    else:
        print("Yes")

Fixed submission:
n, k, q = map(int, input().split())
scores = [k - q] * n


for i in range(q):
    a = int(input())
    scores[a - 1] += 1

for i in scores:
    if(i <= 0):
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))

Fixed submission:
import math
a, b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))
clm = [0] * n

for i in range(n):
    for j in range(i, n-1):
        if h[j] >= h[j+1]:
            clm[i] += 1
        else:
            break


print(max(clm))

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

count = 0
maxcount = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
        maxcount = max(count, maxcount)
    else:
        count = 0

print(maxcount)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for i in range(n):
    temp = 0
    if(max(a) == a[i]):
        temp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = temp
    else: print(max(a))

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

maxR = [0] * n
maxL = [0] * n
maximum = 0
for i in range(n):
    maximum = max(maximum,a[i])
    maxL[i] = maximum
maximum = 0
for i in range(n):
    maximum = max(maximum,a[n-i-1])
    maxR[n-i-1] = maximum



for i in range(n):
    if i == 0:
        print(maxR[1])
    elif i == n-1:
        print(maxL[n-2])
    else:
        print(max(maxL[i-1],maxR[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
l, r = map(int, input().split())

num = []
for i in range(l,r+1):
    num.append(i)

minimum = 10**9
for v in itertools.combinations(num, 2):
    minimum = min(minimum,v[0]*v[1]%2019)

print(minimum)

Fixed submission:
import itertools
import math
l, r = map(int, input().split())


if(abs(l-r) > 2050): print(0)
else:
    num = []
    for i in range(l,r+1):
        num.append(i)
    minimum = 10**9
    for v in itertools.combinations(num, 2):
        minimum = min(minimum,v[0]*v[1]%2019)
    print(minimum)