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

ma = max(li)
cnts = []
for i in range(0, ma):
    cnt = li.count(i+1)
    cnt = str(cnt)
    cnts.append(cnt)

ans = '\n'.join(cnts)

if ma < n:
    ans += '\n' + '0\n'*(n-ma)
    print(ans)

else:
    print(ans)

Fixed submission:
n = int(input())
list = list(map(int, input().split()))
data = [0] * n

for i in list:
    i -= 1
    data[i] += 1

for j in data:
    print(j)

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

ma = max(li)
cnts = []
for i in range(0, ma):
    cnt = li.count(i+1)
    cnts.append(cnt)

for i in cnts:
    print(i)

if ma < n:
    ans = '0\n'*(n-ma)
    print(ans)

Fixed submission:
n = int(input())
list = list(map(int, input().split()))
data = [0] * n

for i in list:
    i -= 1
    data[i] += 1

for j in data:
    print(j)

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

for i in range(n):
    ans = li.count(i+1)
    print(ans)

Fixed submission:
n = int(input())
list = list(map(int, input().split()))
data = [0] * n

for i in list:
    i -= 1
    data[i] += 1

for j in data:
    print(j)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            ans += gcd(i, j, l)

print(ans)

Fixed submission:
import math

k = int(input())
ans = 0
chk_list = []
for i in range(1, k+1):
    for j in range(1, k+1):
        chk = math.gcd(i, j)
        chk_list.append(chk)

for l in range(1, k+1):
    for h in chk_list:
        ans += math.gcd(l, h)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
str = ''
while len(str) < n:
    str += 'b'*a + 'r'*b
ans_str = str[0:n]
print(ans_str.count('b'))

Fixed submission:
n, a, b = map(int, input().split())
quo = n // (a+b)
rem = n % (a+b)
ans = quo*a
if rem == 0:
    print(ans)
elif rem < a:
    print(ans + rem)
else:
    print(ans + a)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
x = str(x)
print(int(x, y))

Fixed submission:
n, k = map(int, input().split())
def digits(N, K):
    if (int(N/K)):
        return digits(int(N/K), K) + str(N%K)
    return str(N%K)
print(len(digits(n, k)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split()))
chk = True
for i in nums:
    if i%2==0:
        if i%3==0 and i%5==0:
            pass
        else:
            chk = False:
    else:
        pass
if chk == True:
    print('APPROVED')
else:
    print('DENIED')

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
chk = True
for i in nums:
    if i%2==0:
        if i%3==0 or i%5==0:
            pass
        else:
            chk = False
    else:
        pass
if chk == True:
    print('APPROVED')
else:
    print('DENIED')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
nums = list(map(int, input().split()))
if n <= k:
    print(0)
else:
    for i in range(k):
        nums.pop(max(nums))
    print(sum(nums))

Fixed submission:
n, k = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for i in range(n-k):
    ans += nums[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
nums = list(map(int, input().split()))
if n <= k:
    print(0)
else:
    nums.sort(reverse = True)
    for i in range(0, k):
        nums.pop(0)
    print(sum(nums))

Fixed submission:
n, k = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for i in range(n-k):
    ans += nums[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, k = map(int, input().split())
As = list(map(int, input().split()))
try:
    for i in range(k):
        As_max = max(As)
        #print(As_max)
        As.remove(As_max)
    As_sum = sum(As)
    #print(As)
    print(As_sum)

except ValueError:
    print(0)

Fixed submission:
n, k = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for i in range(n-k):
    ans += nums[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
ans = (a*b)/math.gcd(a, b)
print(int(ans))

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

def lcm(a,b):
    return a*b//gcd(a,b)

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

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print((a*b)//math.gcd(a, b))

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

def lcm(a,b):
    return a*b//gcd(a,b)

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

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print((a*b)//math.gcd(a, b))

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

def lcm(a,b):
    return a*b//gcd(a,b)

a, b = map(int, input().split())
print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
N = input().rsplit().split('')
N1 = N[0]
N2 = N[1]

if N1 >=10 or N2 >= 10:
  print(-1)
  
else:
  print(N1 * N2)

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

if a >= 10:
    print(-1)
elif b >= 10:
    print(-1)
else:
    print(a*b)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n%2==0:
    print(n/2/n)
else:
    print(((n/2)+1)/n

Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n/2/n)
else:
    chi = n//2 + 1
    print(chi/n)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
hs = input().split()
count = 0
for i in range(0, N):
    h = int(hs[i])
    if h >= k:
        count += 1
print(count)

Fixed submission:
n, k = map(int, input().split())
hs = input().split()
count = 0
for i in range(0, n):
    h = int(hs[i])
    if h >= k:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
sCnt = s.count('S')
if sCnt != 2:
    print('No')
else:
    s = s.sort()
    if s[0]=='S':
        if s[2]==s[3]:
            print('Yes')
        else:
            print('No')
    elif  s[3]=='S':
        if s[0]==s[1]:
            print('Yes')
        else:
            print('No')
    else:
        if s[1]==s[2]:
            print('Yes')
        else:
            print('No')

Fixed submission:
s = input()
s_sort = ''.join(sorted(s))
s1 = s[0]
s1cnt = s_sort.count(s1)
if s1cnt == 2:
    s2 = s[2]
    s2cnt = s_sort.count(s2)
    if s2cnt == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main () {
    int n, x;
    cin >> n >> x;
    int count = 1;
    int sum = 0;
    int l;
    for (int i=0; i < n; i++) {
        cin >> l;
        sum += l;
        if (sum <= x) {
            count += 1;
        }
    }
    cout << count << endl;
}

Fixed submission:
n, x = map(int, input().split())
ls = input().split()
count = 1
sum = 0
for i in range(0, n):
    l = int(ls[i])
    sum += l
    if sum <= x:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a. b = map(int, input().split())
if a*b % 2 == 0:
    print('No')
else:
    print('Yes')

Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
a. b = map(int, input().split())
if a*b % 2 == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
while True:
    for i in range(n):
        for j in range(2, 10):
            if n == i**j:
                print(n)
                exit()
    n -= 1

Fixed submission:
n = int(input())
if  n == 1 or n == 2 or n == 3:
    print(1)
    exit()
while n > 0:
    for i in range(n):
        for j in range(2, 10):
            if n == i**j:
                print(n)
                exit()
    n -= 1
Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)

Fixed submission:
s = input()
print('2018'+s[4:])
Buggy python submission (verdict: Time Limit Exceeded):
def ryuka(n):
    a = 2
    b = 1
    if n == 0:
        return a
    elif n == 1:
        return b
    else:
        return ryuka(n-1)+ryuka(n-2)
n = int(input())
print(ryuka(n))

Fixed submission:
n = int(input())
l = [2, 1]
if n == 1:
    print(1)
else:
    for i in range(n):
        l.append(l[i+1]+l[i])
    print(l[n])
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s) - 1
for i in range(2**n):
    tmp = []
    for j in range(n):
        tmp.append(s[i])
        if i >> j & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    tmp.append(s[-1])
    for k in tmp:
        if eval(k) == 7:
            print(k + "=7")

Fixed submission:
s = input()
n = len(s)
for i in range(2**(n-1)):
    op = ["-"] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            op[n - 2 -j] = "+"
    #print(op)
    chk = ""
    for p_n, p_o in zip(s, op + [""]):
        chk += (p_n + p_o)
    if eval(chk) == 7:
        print(chk + "=7")
        exit()

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

Fixed submission:
s = input()
n = len(s)
for i in range(2**(n-1)):
    op = ["-"] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            op[n - 2 -j] = "+"
    #print(op)
    chk = ""
    for p_n, p_o in zip(s, op + [""]):
        chk += (p_n + p_o)
    if eval(chk) == 7:
        print(chk + "=7")
        exit()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a == b:
    print("EQUAL")
elif a > b:
    print("GREATER")
else:
    print("LESS")

Fixed submission:
a = int(input())
b = int(input())
if a == b:
    print("EQUAL")
elif a > b:
    print("GREATER")
else:
    print("LESS")
Buggy python submission (verdict: Time Limit Exceeded):
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
for i in range(n):
    pro *= (i+1)
print(pro%mod)

Fixed submission:
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())

print(math.factorial(n)%mod)
Buggy python submission (verdict: Runtime Error):
s = input().split()
print(s[0]+' '+s[1]+' '+s[2])

Fixed submission:
s = input().split(',')
print(s[0]+' '+s[1]+' '+s[2])
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == x+y+z:
                ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>=0 and z<=k:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == x+y+z:
                ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>=0 and z<=k:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
sl = []
for i in range(n):
    s = input()
    sl.append(s)
sl.sort()
"print(sl)
ans = ""
for i in range(n):
    ans += sl[i]
print(ans)

Fixed submission:
n, l = map(int, input().split())
sl = []
for i in range(n):
    s = input()
    sl.append(s)
sl.sort()
#print(sl)
ans = ""
for i in range(n):
    ans += sl[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
X, D = map(int, input().split())
n = 0
for i in range(N):
  x, y = map(int, input().split())
  if math.sqrt(x**2+y**2) <= D:
    n += 1
print(n)

Fixed submission:
import sys
import math

count = 0
N, D = map(int, input().split())
for _ in range(N):
  x, y = map(int, input().split())
  dis = math.sqrt(x ** 2 + y ** 2)
  if dis <= D:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    if input() == 'AC':
        C_0 += 1
    elif input() == 'WA':
        C_1 += 1
    elif input() == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))


Fixed submission:
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    S = input()
    if S == 'AC':
        C_0 += 1
    elif S == 'WA':
        C_1 += 1
    elif S == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))

Buggy python submission (verdict: Runtime Error):
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    if input() == 'AC':
        C_0 += 1
    elif input() == 'WA':
        C_1 += 1
    elif input() == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))

Fixed submission:
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    S = input()
    if S == 'AC':
        C_0 += 1
    elif S == 'WA':
        C_1 += 1
    elif S == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
N = len(S)
ans = 0
for i in range(N):
    if not S[i] == T[i]:
        S[i] = T[i]
        ans += 1
print(ans)


Fixed submission:
S = input()
T = input()
N = len(S)
ans = 0
for i in range(N):
    if S[i] != T[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

for i in range(1, X+1):
    for j in range(1, X-i):
        if 2*i + 4*j == Y:
            print('Yes')
            exit(0)
print('No')


Fixed submission:
x = list(map(int, input().split()))
print(15 - sum(x))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))[]
print(sum(A[-1::-2])-sum(A[-2::-2]))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice - Bob)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [map(int, input().split()) for _ in range(N)]
a = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice - Bob)
  


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice - Bob)
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
res_x = -1, res_y = -1, res_z = -1
for x in range(N):
  for j in range(N-x):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      res_x = x
      res_y = y
      res_z = z
print('{} {} {}'.format(res_x, res_y, res_z))

Fixed submission:
N, Y = map(int, input().split())
res_x = -1
res_y = -1
res_z = -1
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      res_x = x
      res_y = y
      res_z = z
print('{} {} {}'.format(res_x, res_y, res_z))
Buggy python submission (verdict: Runtime Error):
rgb = int(''.join(input()))
if rgb % 4 == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
r, g, b = map(int, input().split())
if (r*100 + g*10 + b) % 4 == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
A[0] = 0
d = 0
for i in range(1, N+1):
    d += A[i] - A[i-1]
print(d)


Fixed submission:
N = int(input())
A = sorted(map(int, input().split()))
d = 0
for i in range(1, N):
    d += A[i] - A[i-1]
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

MOD = 10**9 + 7

n = int(input())

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

sum = 0
for index, i in enumerate(a[:n - 1]):
    for j in a[index + 1:n]:
        sum = (sum + (i * j)) % MOD

print(sum)

Fixed submission:
import sys

MOD = 10**9 + 7

n = int(input())

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

x = pow(sum(a), 2)
y = sum((a[i]**2 for i in range(n)))

sum = (x - y) // 2 % MOD

print(sum)

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

MOD = 10**9 + 7

n = int(input())

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

sum = 0
for index, i in enumerate(a[:n - 1]):
    for j in a[index + 1:n]:
        sum += (i * j)

print(sum % MOD)

Fixed submission:
import sys

MOD = 10**9 + 7

n = int(input())

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

x = pow(sum(a), 2)
y = sum((a[i]**2 for i in range(n)))

sum = (x - y) // 2 % MOD

print(sum)
Buggy python submission (verdict: Runtime Error):
import sys

x = abs(int(input()))
k = int(input())
d = int(input())

move_cnt = int(x / d)
if (move_cnt <= k):
    k -= move_cnt
    amari = x - move_cnt * d

else:
    amari = x - k * d
    k = 0

if (k > 0):
    if (k % 2 == 1):
        if (amari > 0):
            amari -= d
        else:
            amari += d

print(abs(amari))

Fixed submission:
import sys

# x = abs(int(input()))
# k = int(input())
# d = int(input())

array = list(map(int, input().strip().split()))
x = abs(array[0])
k = array[1]
d = array[2]
if (d == 0):
    amari = abs(x)

else:
    move_cnt = int(x / d)
    if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

    if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d

print(abs(amari))

Buggy python submission (verdict: Runtime Error):
import sys

x = abs(int(input()))
k = int(input())
d = int(input())

move_cnt = float(x / d)
if (move_cnt <= k):
    k -= move_cnt
    amari = x - move_cnt * d

else:
    k = 0
    amari = x - move_cnt * d

if (k > 0):
    if (k % 2 == 1):
        if (amari > 0):
            amari -= d
        else:
            amari += d

print(int(abs(amari)))

Fixed submission:
import sys

# x = abs(int(input()))
# k = int(input())
# d = int(input())

array = list(map(int, input().strip().split()))
x = abs(array[0])
k = array[1]
d = array[2]
if (d == 0):
    amari = abs(x)

else:
    move_cnt = int(x / d)
    if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

    if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d

print(abs(amari))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
A = []
for i in range(len(s)-len(t)):
    s_i = s[i:i+len(t)+1]
    count = 0
    for j in range(len(t)):
        if s_i[j] == t[j]:
            count += 1
    A.append(count)
ans = len(t) - max(A)
print(ans)

Fixed submission:
s = input()
t = input()
ans = 0
A = []
for i in range(len(s)-len(t)+1):
    s_i = s[i:i+len(t)+1]
    count = 0
    for j in range(len(t)):
        if s_i[j] == t[j]:
            count += 1
    A.append(count)

ans = len(t) - max(A)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
for i in range(n-1):
    ans += A[i] * (sum(A[i+1:]))
    ans %= M
ans %= M
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
B = [A[0]]
for j in range(1,n):
    B.append(A[j]+B[j-1])
for i in range(n-1):
    ans += A[i] * (B[-1]-B[i])
    ans %= M
ans %= M
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
for i in range(n-1):
    ans += A[i] * (sum(A[i+1:]))
    ans %= M
ans %= M
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
B = [A[0]]
for j in range(1,n):
    B.append(A[j]+B[j-1])
for i in range(n-1):
    ans += A[i] * (B[-1]-B[i])
    ans %= M
ans %= M
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += A[i] * A[j]
ans %= (10**9+7)
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
B = [A[0]]
for j in range(1,n):
    B.append(A[j]+B[j-1])
for i in range(n-1):
    ans += A[i] * (B[-1]-B[i])
    ans %= M
ans %= M
print(ans)
Buggy python submission (verdict: Runtime Error):
lst = list(map(int, input().split()))

for i in lst:
  i == 0:
    print(i)
    exit()

Fixed submission:
lst = list(map(int, input().split()))
for i in range(5):
    if lst[i] == 0:
        print(i + 1)
        exit()
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
print(a * b)

Fixed submission:
a, b = map(int, input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N+1):
    print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in A:
    ans[i-1] += 1
for j in ans:
    print(j)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N+1):
    print(A.count(i))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in A:
    ans[i-1] += 1
for j in ans:
    print(j)
Buggy python submission (verdict: Runtime Error):
k = int(input()) 
 
 lunlun = [i for i in range(1, 10)]
 
 p = 0 

 def generate_lunlun(p):
     last = p % 10
     if last - 1 >= 0:
         yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1 

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])

Fixed submission:
k = int(input()) 
 
lunlun = [i for i in range(1, 10)]
 
p = 0 

def generate_lunlun(p):
    last = p % 10
    if last - 1 >= 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1 

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])