Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
arr = [0 for i in range(n)]
for i in a:
    arr[a - 1] += 1
for i in range(n):
    print(arr[i])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
arr = [0 for i in range(n)]
for i in a:
    arr[i - 1] += 1
for i in range(n):
    print(arr[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = str(input())
for i in range(n):
    print(a.count(str(i + 1)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
arr = [0 for i in range(n)]
for i in a:
    arr[i - 1] += 1
for i in range(n):
    print(arr[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0

def gcd(x, y):
    if x / y == 0: return y
    return gcd(y, x % y)

for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(gcd(i, j), k)
print(ans)

Fixed submission:
import math
k = int(input())
ansA, ansB, ansC = 0, 0, 0
for a in range(k):
    ansC += a+1
    for b in range(k-a-1):
        GCDab = math.gcd(a+1, a+b+2)
        ansB += GCDab
        for c in range(k-a-b-2):
            GCDabc = math.gcd(GCDab, a+b+c+3)
            ansA += GCDabc
ans = ansA * 6 + ansB * 6 + ansC
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1,n+1):
        for k in range(1, n + 1):
            ans += math.gcd(math.gcd(i, j), k)
print(ans)

Fixed submission:
import math
k = int(input())
ansA, ansB, ansC = 0, 0, 0
for a in range(k):
    ansC += a+1
    for b in range(k-a-1):
        GCDab = math.gcd(a+1, a+b+2)
        ansB += GCDab
        for c in range(k-a-b-2):
            GCDabc = math.gcd(GCDab, a+b+c+3)
            ansA += GCDabc
ans = ansA * 6 + ansB * 6 + ansC
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(gcd(i,j),k)
print(ans)

Fixed submission:
import math
k = int(input())
ansA, ansB, ansC = 0, 0, 0
for a in range(k):
    ansC += a+1
    for b in range(k-a-1):
        GCDab = math.gcd(a+1, a+b+2)
        ansB += GCDab
        for c in range(k-a-b-2):
            GCDabc = math.gcd(GCDab, a+b+c+3)
            ansA += GCDabc
ans = ansA * 6 + ansB * 6 + ansC
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for a in range(k):
    for b in range(k):
        for c in range(k):
            GCDab = math.gcd(a+1, b+1)
            GCDabc = math.gcd(GCDab, c+1)
            ans += GCDabc
print(ans)

Fixed submission:
import math
k = int(input())
ansA, ansB, ansC = 0, 0, 0
for a in range(k):
    ansC += a+1
    for b in range(k-a-1):
        GCDab = math.gcd(a+1, a+b+2)
        ansB += GCDab
        for c in range(k-a-b-2):
            GCDabc = math.gcd(GCDab, a+b+c+3)
            ansA += GCDabc
ans = ansA * 6 + ansB * 6 + ansC
print(ans)
Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i + 1 <= n - 1:
        if arr[i + 1] - arr[i] > ans:
            ans = arr[i + 1] - arr[i]
    else:
        if arr[i] - arr[0] > ans:
            ans = arr[i] - arr[0]
print(ans)

Fixed submission:
s = str(input())
if s[3] == s[2] and s[5] == s[4]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i + 1 <= n - 1:
        if arr[i + 1] - arr[i] > ans:
            ans = arr[i + 1] - arr[i]
    else:
        if arr[i] - arr[0] > ans:
            ans = arr[i] - arr[0]
print(ans)

Fixed submission:
s = str(input())
if s[3] == s[2] and s[5] == s[4]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = str(input())
if s[3] == s[4] and s[5] == s[6]:
    print('Yes')
else:
    print('No')

Fixed submission:
s = str(input())
if s[3] == s[2] and s[5] == s[4]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input().replace(' ', ''))
cnt = [0 for i in range(n)]
conb = [0 for i in range(n)]
for i in range(n):
    cnt[i] = s.count(str(i + 1))
    conb[i] = cnt[i] * (cnt[i] - 1) // 2
Sum = sum(conb)
for k in range(n):
    ans = Sum - conb[int(s[k]) - 1] + (cnt[int(s[k]) - 1] - 1) * (cnt[int(s[k]) - 1] - 2) // 2
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
    cnt[a[i]] += 1
conb1, conb2 = [], []
for i in range(n + 1):
    conb1.append(cnt[i] * (cnt[i] - 1) // 2)
    if cnt[i] == 0:
        conb2.append(0)
    else:
        conb2.append((cnt[i] - 2) * (cnt[i] - 1) // 2)
sumall = sum(conb1)
for i in range(n):
    ans = sumall - conb1[a[i]] + conb2[a[i]]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input().replace(' ', ''))
cnt = [0 for i in range(n)]
conb = [0 for i in range(n)]
for i in range(n):
    cnt[i] = s.count(str(i + 1))
    conb[i] = cnt[i] * (cnt[i] - 1) // 2
for k in range(n):
    ans = sum(conb) - conb[int(s[k]) - 1] + (cnt[int(s[k]) - 1] - 1) * (cnt[int(s[k]) - 1] - 2) // 2
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
    cnt[a[i]] += 1
conb1, conb2 = [], []
for i in range(n + 1):
    conb1.append(cnt[i] * (cnt[i] - 1) // 2)
    if cnt[i] == 0:
        conb2.append(0)
    else:
        conb2.append((cnt[i] - 2) * (cnt[i] - 1) // 2)
sumall = sum(conb1)
for i in range(n):
    ans = sumall - conb1[a[i]] + conb2[a[i]]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input().replace(' ', ''))
cnt = [0 for i in range(n)]
conb = [0 for i in range(n)]
for i in range(n):
    cnt[i] = s.count(str(i + 1))
    conb[i] = cnt[i] * (cnt[i] - 1) // 2
for k in range(n):
    ans = sum(conb) - conb[int(s[k]) - 1] + (cnt[int(s[k]) - 1] - 1) * (cnt[int(s[k]) - 1] - 2) // 2
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
    cnt[a[i]] += 1
conb1, conb2 = [], []
for i in range(n + 1):
    conb1.append(cnt[i] * (cnt[i] - 1) // 2)
    if cnt[i] == 0:
        conb2.append(0)
    else:
        conb2.append((cnt[i] - 2) * (cnt[i] - 1) // 2)
sumall = sum(conb1)
for i in range(n):
    ans = sumall - conb1[a[i]] + conb2[a[i]]
    print(ans)
Buggy python submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 100
a, b, c = map(int, input().split())
if Decimal(str((c - a - b) ** 2)) - Decimal(str(4 * a * b)) > 0:
    print('Yes')
else:
    print('No')


Fixed submission:
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k - 1])

Buggy python submission (verdict: Runtime Error):
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k + 1])

Fixed submission:
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k - 1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [-1 for i in range(n)]
possibility = True
for i in range(m):
    s, c = map(int, input().split())
    if a[s - 1] == -1:
        a[s - 1] = c
    elif a[s - 1] == c:
        pass
    else:
        possibility = False
if a[0] == 0:
    possibility = False

if possibility == True:
    ans = ''
    for i in range(n):
        ans += a[i]
    print(ans)
else:
    print('-1')

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

for i in range(m):
    s, c = map(int, input().split())
    if a[s - 1] == -1:
        a[s - 1] = c
    elif a[s - 1] == c:
        pass
    else:
        print('-1')
        exit()

if n == 1 and a[0] == 0:
    print('0')
    exit()
if n == 1 and a[0] == -1:
    print('0')
    exit()
if n != 1 and a[0] == 0:
    print('-1')
    exit()

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

if a[0] == 0:
    a[0] = 1
ans = ''
for i in range(n):
    ans += str(a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, r  = map(int, input().split())
if n >=10:
	print(r)
else:
	print(r-1000+100n)

Fixed submission:
n, r  = map(int, input().split())
if n >=10:
	print(r)
else:
	print(r+1000-100*n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(n):
    HP = 0
    for j in range(100):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(max(a)):
    HP = 0
    for j in range(n):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(n):
    HP = 0
    for j in range(max(a)):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(max(a)):
    HP = 0
    for j in range(n):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)
Buggy python submission (verdict: Runtime Error):
n = int(input())

S = list(str(input()) for i in range(n))
SortedS = sorted(S) #辞書式にソート
s = [] #各文字列の回数
S2 = [] #各文字列
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1
ans = []
M = max(s)
for i in range(len(s)):
    if s[i] == M:
        print(ans[i])

Fixed submission:
n = int(input())

S = list(str(input()) for i in range(n))
SortedS = sorted(S) #辞書式にソート
s = [] #各文字列の回数
S2 = [] #各文字列
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1

M = max(s)
for i in range(len(s)):
    if s[i] == M:
        print(S2[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
List = list(map(int, input().split()))
ans = 'YES'
for i in range(n - 1):
    for j in range(n - i - 1):
        if List[i] == List[i + j + 1]:
            ans = 'NO'
            break
    if ans == 'NO':
        break

print(ans)

Fixed submission:
n = int(input())
List = list(map(int, input().split()))
Sorted = sorted(List)
ans = 'YES'
for i in range(n - 1):
    if Sorted[i] == Sorted[i + 1]:
        ans = 'NO'
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
List = list(map(int, input().split()))
ans = 'YES'
for i in range(n - 1):
    for j in range(n - i - 1):
        if List[i] == List[i + j + 1]:
            ans = 'NO'
            break

print(ans)

Fixed submission:
n = int(input())
List = list(map(int, input().split()))
Sorted = sorted(List)
ans = 'YES'
for i in range(n - 1):
    if Sorted[i] == Sorted[i + 1]:
        ans = 'NO'
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
List = list(map(int, input().split()))

for i in range(n - 1):
    for j in range(n - i - 1):
        if List[i] == List[i + j + 1]:
            ans = 'NO'

print(ans)ß

Fixed submission:
n = int(input())
List = list(map(int, input().split()))
Sorted = sorted(List)
ans = 'YES'
for i in range(n - 1):
    if Sorted[i] == Sorted[i + 1]:
        ans = 'NO'
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
H, n = map(int, input().split())
List = [[0 for i in range(4)] for j in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    List[i][0] = b / a
    List[i][1] = b / H
    List[i][2] = a
    List[i][3] = b

def recal():
    for i in range(n):
        b = List[i][3]
        List[i][1] = b / H

sList = sorted(List)
MP = 0
k = 0
while H > 0:
    if sList[k][2] <= H:
        H -= sList[k][2]
        MP += sList[k][3]
        recal()
    else:
        if sList[k + 1][2] <= H:
            if sList[k][1] <= sList[k + 1][0]:
                H -= sList[k][2]
                MP += sList[k][3]
                recal()
                break
            else:
                H -= sList[k + 1][2]
                MP += sList[k + 1][3]
                recal()
                k += 1
        else:
            if sList[k][1] <= sList[k + 1][1]:
                H -= sList[k][2]
                MP += sList[k][3]
                recal()
                break
            else:
                H -= sList[k + 1][2]
                MP += sList[k + 1][3]
                recal()
                k += 1
print(MP)

Fixed submission:
h, a = map(int, input().split())
ans = h // a
if h % a != 0:
    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
H, n = map(int, input().split())
List = [[0 for i in range(4)] for j in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    List[i][0] = b / a
    List[i][1] = b / H
    List[i][2] = a
    List[i][3] = b

def recal():
    for i in range(n):
        b = List[i][3]
        List[i][1] = b / H

sList = sorted(List)
MP = 0
k = 0
while H > 0:
    if sList[k][2] <= H:
        H -= sList[k][2]
        MP += sList[k][3]
        recal()
    else:
        if sList[k + 1][2] <= H:
            if sList[k][1] <= sList[k + 1][0]:
                H -= sList[k][2]
                MP += sList[k][3]
                recal()
                break
            else:
                H -= sList[k + 1][2]
                MP += sList[k + 1][3]
                recal()
                k += 1
        else:
            if sList[k][1] <= sList[k + 1][1]:
                H -= sList[k][2]
                MP += sList[k][3]
                recal()
                break
            else:
                H -= sList[k + 1][2]
                MP += sList[k + 1][3]
                recal()
                k += 1
print(MP)

Fixed submission:
n, k = map(int, input().split())
H = list(map(int, input().split()))
sH = sorted(H, reverse=True)
ans = sum(sH[k::])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    x = str(n + 1)
    c[int(x[0])][int(x[-1])] += 1
ans = 0
for i in range(n):
    for j in range(n):
       ans += c[i][j] * c[j][i]
print(ans)

Fixed submission:
n = int(input())
c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    x = str(i + 1)
    c[int(x[0])][int(x[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
       ans += c[i][j] * c[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
P = list(map(int, input().replace(' ', '')))
Q = list(map(int, input().replace(' ', '')))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in per:
    lis.append(int(''.join(map(str, list(oc)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))

Fixed submission:
import itertools
n = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in per:
    lis.append(int(''.join(map(str, list(oc)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))

Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
P = list(map(int, input().replace(' ', '')))
Q = list(map(int, input().replace(' ', '')))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in range(per):
    lis.append(int(''.join(map(str, list(per)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))

Fixed submission:
import itertools
n = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in per:
    lis.append(int(''.join(map(str, list(oc)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))

Buggy python submission (verdict: Runtime Error):
n = int(input())
P = list(map(str, input().split()))
Q = list(map(str, input().split()))
p, q = '' , ''
for i in range(n):
    p += P[i]
    q += Q[i]

a, b = 0, 0
num = 10 ** (n - 1)
count = 0
found = False
while found == False:
    num += 1
    waru = num
    conv_num = ''
    while waru != 0:
        conv_num = str(waru % (n + 1)) + conv_num
        waru = waru // (n + 1)
    if 0 in conv_num:
        pass
    else:
        count += 1
        if conv_num == p:
            a = count
        if conv_num == q:
            b = count
    if p != 0 and q != 0:
        found = True
ans = a - b
if ans < 0:
    ans *= -1
print(ans)

Fixed submission:
import itertools
n = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in per:
    lis.append(int(''.join(map(str, list(oc)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = str(input())
score = 0
lose = []
def janken(hand):
    if hand == 'r':
        return(p)
    if hand == 's':
        return(r)
    if hand == 'p':
        return(s)

for i in range(n):
    if i <= k - 1:
        score += janken(T[i])
    else:
        if T[i] == T[i - k]:
            if i - k not in lose:
                lose.append(i)
            else:
                score += janken(T[i])
        else:
            score += janken(T[i])
print(score)

Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = str(input())
score = 0
lose = []
def janken(hand):
    if hand == 'r':
        return(p)
    if hand == 's':
        return(r)
    if hand == 'p':
        return(s)

for i in range(n):
    if i <= k - 1:
        score += janken(T[i])
    else:
        if T[i] == T[i - k]:
            if i - k not in lose:
                lose.append(i)
            else:
                score += janken(T[i])
        else:
            score += janken(T[i])
print(score)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(input().split())
print(a * b / gcd(a, b))

Fixed submission:
import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
if int(ord(s)) + n > 122:
    print(chr(int(ord(s)) + n - 26))
else:
    print(chr(int(ord(s)) + n))

Fixed submission:
n = int(input())
s = str(input())
ans = ''
for i in s:
    t = (int(ord(i) + n - 64)) % 26
    if t == 0:
        ans += 'Z'
    else:
        ans += chr(t + 64)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
if int(ord(s)) + n > 122:
    print(chr(int(ord(s)) + n - 26))
else:
    print(int(ord(s)) + n)

Fixed submission:
n = int(input())
s = str(input())
ans = ''
for i in s:
    t = (int(ord(i) + n - 64)) % 26
    if t == 0:
        ans += 'Z'
    else:
        ans += chr(t + 64)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
def bin_search(key, list):
    ok = n
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if list[mid] > key:
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for i in range(1, n - 1):
    for j in range(i + 1, n):
        c_min_len = l[j] - l[i]
        x = i - bin_search(c_min_len, l)
        ans += max(0, x)
print(ans)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
def bin_search(key, list):
    ok = n
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if list[mid] > key:
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for i in range(1, n - 1):
    for j in range(i + 1, n):
        c_min_len = l[j] - l[i]
        x = i - bin_search(c_min_len, l)
        ans += max(0, x)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
def bin_search(key, list):
    ok = len(list)
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if list[mid] > key:
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for i in range(1, n - 1):
    for j in range(i + 1, n):
        c_min_len = l[j] - l[i]
        x = i - bin_search(c_min_len, l)
        if x > 0:
            ans += x
print(ans)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
def bin_search(key, list):
    ok = n
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if list[mid] > key:
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for i in range(1, n - 1):
    for j in range(i + 1, n):
        c_min_len = l[j] - l[i]
        x = i - bin_search(c_min_len, l)
        ans += max(0, x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
attend = 1
for i in range(n):
    print(a.index(attend) + 1, end=' ')
    attend += 1

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [-1] * n
for i in range (n):
    ans[a[i] - 1] = i + 1
[print(i, end=' ') for i in ans]
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n = int(input())
v = list(map(int, input().split()))
M = 0
for i in permutations(v):
    m = i[0]
    for j in i:
        m = (m + j) / 2
    M = max(m, M)
print(M)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
v.sort()
ans = v[0]
for i in range(1, n):
    ans = (ans + v[i]) / 2
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial
def comb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)
n, blue = map(int, input().split())
red = n - blue
mod = 10 ** 9 + 7
for i in range(1, blue + 1):
    ans = comb(red + 1, i)
    ans %= mod
    ans *= comb(blue - 1, i - 1)
    ans %= mod
    print(ans)

Fixed submission:
from math import factorial
def comb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)
n, blue = map(int, input().split())
red = n - blue
mod = 10 ** 9 + 7
for i in range(1, blue + 1):
    if red + 1 - i < 0:
        print('0')
        continue
    ans = comb(red + 1, i)
    ans %= mod
    ans *= comb(blue - 1, i - 1)
    ans %= mod
    print(ans)