Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

# 最大公約数を求めてWを何とか小さくする
gcd_num = W
for i in range(N):
    gcd_num = fractions.gcd(gcd_num, wv[i][0])

W = W // gcd_num
for i in range(N):
    wv[i][0] = wv[i][0] // gcd_num

# 重さiでの価値の最大
# 品物の重複選択を許さない
dp = [[0] * (W+10) for _ in range(N+10)]

for i in range(N):
    weight, value = wv[i]
    dp[i+1] = dp[i][:]
    for j in range(weight, W+1):
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight]+value)

print(dp[N][W])

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

max_weight = W+1
max_cost = sum([v for w, v in wv])

# cost時の最小の重さ
# dp[cost] = weight
# 計算量は最大でもN=100*vi=10^3の10^5
dp = [INF for _ in range(max_cost+10)]
dp[0] = 0

for w, v in wv:
    # 前からやると重複を許してしまうことになるので後ろから
    # max_cost~v
    for i in reversed(range(v, max_cost+1)):
        dp[i] = min(dp[i], dp[i-v]+w)

# max_cost~0
for i in reversed(range(max_cost+1)):
    if dp[i] <= W:
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

# 最大公約数を求めてWを何とか小さくする
gcd_num = W
for i in range(N):
    gcd_num = fractions.gcd(gcd_num, wv[i][0])

W = W // gcd_num
for i in range(N):
    wv[i][0] = wv[i][0] // gcd_num

# 重さiでの価値の最大
# 品物の重複選択を許さない
dp = [[0] * (W+10) for _ in range(N+10)]

for i in range(N):
    weight, value = wv[i]
    dp[i+1] = dp[i][:]
    for j in range(weight, W+1):
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight]+value)

print(dp[N][W])

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

max_weight = W+1
max_cost = sum([v for w, v in wv])

# cost時の最小の重さ
# dp[cost] = weight
# 計算量は最大でもN=100*vi=10^3の10^5
dp = [INF for _ in range(max_cost+10)]
dp[0] = 0

for w, v in wv:
    # 前からやると重複を許してしまうことになるので後ろから
    # max_cost~v
    for i in reversed(range(v, max_cost+1)):
        dp[i] = min(dp[i], dp[i-v]+w)

# max_cost~0
for i in reversed(range(max_cost+1)):
    if dp[i] <= W:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if (A==B + B==C + C==A) =1:
  print("Yes")
else:
  print("No")

Fixed submission:
A,B,C=map(int,input().split())
if (A==B or B==C or C==A) and not(A==B and B==C and C==A):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S=input()
if S="Sunny":
  	print("Cloudy")
elif S="Cloudy":
  	print("Rainy")
elif S="Rainy":
	print("Sunny")

Fixed submission:
S=input()
if S=="Sunny":
  	print("Cloudy")
elif S=="Cloudy":
  	print("Rainy")
elif S=="Rainy":
	print("Sunny")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = input().split()
L.sort()
c = 0
for a in range(N):
    if a == 0:
        c = c + float(L[0])*pow(0.5, N - 1)
    else:
        c = c + float(L[a])*pow(0.5, N - a)
print(c)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")

Buggy python submission (verdict: Runtime Error):
N = int(input())
L = input().split()
L.sort()
c = 0
for a in range(N):
    if a == 0:
        c = c + float(L[0])/pow(2, N - 1)
    else:
        c = c + float(L[a])/pow(2, N - a)
print(c)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [input() for i in range(N)]
L = list(map("".join, list(map(sorted, list(map(list, L))))))
count = 0
for j in range(N):
    for k in range(j + 1, N):
        if L[j] == L[k]:
            count = count + 1
print(count)

Fixed submission:
import math
N = int(input())
L = [input() for i in range(N)]
L = sorted(list(map("".join, list(map(sorted, list(map(list, L)))))))
c = 0
ans = 0
for j in range(1,N):
    if not L[j] == L[j - 1]:
        ans += (j - c)*(j - c - 1)/2
        c = j
    elif j + 1 == N:
        ans += (j + 1 - c)*(j - c)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
if (A-B)%2 == 1:
    print("IMPOSSIBLE")
else:
    print(int((A-B)/2)

Fixed submission:
A,B = map(int,input().split())
if (A-B)%2 == 1:
    print("IMPOSSIBLE")
else:
    print(int((A+B)/2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] = B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] = B[0]:
            print(B[1])
        else:
            print(B[0])

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] == B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] == B[0]:
            print(B[1])
        else:
            print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    A_1 = A.copy()
    A_1.pop(i)
    print(max(A_1))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] == B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] == B[0]:
            print(B[1])
        else:
            print(B[0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
T = sum(A)
print(T-2*sum(A[1::2]),end=" ")
for i in range(1,N):
    print(T-2*(sum(A[i+1::2])+sum(A[i%2:i-1:2])),end=" ")

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
X = []
X.append(sum(A)-2*sum(A[1::2]))
print(X[0],end=" ")
for i in range(1,N):
    X.append(A[i-1]*2-X[i-1])
    print(X[i],end=" ")
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
H = list(map(int, input().split()))
dp = [-1]*N
for i in range(1, N):
    if i <= K:
        mi = abs(H[i] - H[0])
        for j in range(1, i):
            if dp[j] + abs(H[i] - H[j]) < mi:
                mi = dp[j] + abs(H[i] - H[j])
        dp[i] = mi
    else:
        mi = dp[i - K] + abs(H[i] - H[i - K])
        for j in range(i - K, i):
            if dp[j] + abs(H[i] - H[j]) < mi:
                mi = dp[j] + abs(H[i] - H[j])
        dp[i] = mi
print(dp[N - 1])

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
dp = [0, abs(L[0] - L[1])]
if N == 2:
    print(dp[1])
else:
    for i in range(2, N):
        dp.append(min(dp[i - 2] + abs(L[i] - L[i - 2]), dp[i - 1] + abs(L[i] - L[i - 1])))
    print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 = 1:
  print("Odd")
else:
  print("Even")

Fixed submission:
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 == 1:
  print("Odd")
else:
  print("Even")

Buggy python submission (verdict: Runtime Error):
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 = 1:
  print(Odd)
else:
  print(Even)

Fixed submission:
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 == 1:
  print("Odd")
else:
  print("Even")

Buggy python submission (verdict: Runtime Error):
l = input().split()
a = l[0]
b = l[1]
if (a * b) % 2 = 1:
  print(Odd)
else:
  print(Even)

Fixed submission:
l = input().split()
a = int(l[0])
b = int(l[1])
if (a * b) % 2 == 1:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Runtime Error):
NH = input().split()
N = int(NH[0])
H = int(NH[1])
a = []
b = []
for v in range(N):
    L = input().split()
    a.append(L[0])
    b.append(L[1])
a = list(map(int, a))
b = list(map(int, b))
a.sort(reverse = True)
b.sort(reverse = True)
c = 0
count = 0
while c < H:
    if a[0] >= b[0] or len(b) == 0:
        c = c + a[0]
        count = count + 1
    else:
        c = c + b.pop(0)
        count = count + 1 
print(count)

Fixed submission:
NH = input().split()
N = int(NH[0])
H = int(NH[1])
a = []
b = []
for v in range(N):
    L = input().split()
    a.append(L[0])
    b.append(L[1])
a = list(map(int, a))
b = list(map(int, b))
a.sort(reverse = True)
b.sort(reverse = True)
c = 0
count = 0
while c < H:
    if len(b) > 0 and a[0] < b[0]:
        c = c + b.pop(0)
        count = count + 1 
    else:
        break
if c < H:
    count = count -(-(H - c)//a[0])
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)

Fixed submission:
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)

if len(lst) == 0:
    print(1)
    exit()
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = [int(x) for x in input().split()]
ret = 1
for x in lst:
    ret *= x

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


Fixed submission:
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)

if len(lst) == 0:
    print(1)
    exit()
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)
Buggy python submission (verdict: Runtime Error):
from math import pi
print(int(input() * 2 * pi)

Fixed submission:
from math import pi
print(int(input()) * 2 * pi)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")

ret = r * g * b
for i in range(N - 2):
    for j in range(1, N):
        if i + j + j >= N:
            break
        a = S[i]
        b = S[i + j]
        c = S[i + j + j]
        if a != b and b != c and c != a:
            ret -= 1
print(ret)

Fixed submission:
N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret -= 1

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b
for i in range(N - 2):
    for j in range(1, N - i):
        if N > i + j + j:
            a = S[i]
            b = S[i + j]
            c = S[i + j + j]
            if a != b and b != c and c != a:
                ret -= 1
print(ret)

Fixed submission:
N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret -= 1

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")

ret = r * g * b
for i in range(N - 2):
    for j in range(1, N):
        if N > i + j + j:
            a = S[i]
            b = S[i + j]
            c = S[i + j + j]
            if a != b and b != c and c != a:
                ret -= 1
print(ret)


Fixed submission:
N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret -= 1

print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
counters = Counter(lst)
dic = {}
for k, v in dict(counters).items():
    if v > 1:
        dic[k] = v

m = {}
for x in lst:
    n = m.get(x)
    if n is None:
        n = 0
        for k, v in dic.items():
            if k == x:
                v -= 1
            n += v * (v - 1) // 2

    m[x] = n
    print(n)


Fixed submission:
from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
dic = dict(Counter(lst))

ret = 0
for k, v in dic.items():
    ret += v * (v - 1) // 2


for x in lst:
    n = dic[x]
    if n == 1:
        print(ret)
    else:
        print(ret - (n * (n - 1) // 2) + ((n - 1) * (n - 2) // 2))
Buggy python submission (verdict: Runtime Error):
S = input()
for _ in range(int(input())):
    l = input().split()
    if len(l) == 1:
        S = S[::-1]
    else:
        if l[1] == "1":
            S = l[2] + S
        else:
            S = S + l[2]
print(S)

Fixed submission:
if len(set(input())) == 1:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
for _ in range(int(input())):
    l = input().split()
    if len(l) == 1:
        S = S[::-1]
    else:
        if l[1] == "1":
            S = l[2] + S
        else:
            S = S + l[2]
print(S)

Fixed submission:
S = input()
l1 = []
l2 = []
rev = False
for _ in range(int(input())):
    l = [s for s in input().split()]
    if l[0] == "1":
        rev = not rev
    elif l[1] == "1":
        if rev:
            l2.append(l[2])
        else:
            l1.append(l[2])
    else:
        if rev:
            l1.append(l[2])
        else:
            l2.append(l[2])

if rev:
    ret = "".join(l2)[::-1] + S[::-1] + "".join(l1)
else:
    ret = "".join(l1)[::-1] + S + "".join(l2)

print(ret)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = [0] * N
if M == 0 and N != 1:
    lst[0] = 1
else:
    dic = {}
    for _ in range(M):
        s, c = map(int, input().split())
        n = dic.get(s)
        if n is not None and n != c:
            print(-1)
            exit()
        dic[s] = c

for k, v in dic.items():
    lst[k - 1] = v

if N != 1 and lst[0] == 0:
    print(-1)
    exit()

if len(lst) != 0 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))


Fixed submission:
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print("1" + "0" * (N - 1))
    exit()

dic = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    n = dic.get(s)
    if n is not None and n != c:
        print(-1)
        exit()
    dic[s] = c

lst = [0] * N
for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 1 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = [0] * N
if M == 0 and N != 1:
    lst[0] = 1
else:
    dic = {}
    for _ in range(M):
        s, c = map(int, input().split())
        n = dic.get(s)
        if n is not None and n != c:
            print(-1)
            exit()
        dic[s] = c

if N != 1 and lst[0] == 0:
    print(-1)
    exit()

for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 0 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))


Fixed submission:
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print("1" + "0" * (N - 1))
    exit()

dic = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    n = dic.get(s)
    if n is not None and n != c:
        print(-1)
        exit()
    dic[s] = c

lst = [0] * N
for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 1 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ll = [x / 2 * (x + 1) / x for x in ret_lst]
print(sum(ll))


Fixed submission:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ll = [sum(range(1, x + 1)) / x for x in ret_lst]
print(sum(ll))


Fixed submission:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ret = 0
for x in ret_lst:
    ret += sum(range(1, x + 1)) / x
print(ret)


Fixed submission:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
n = 0
ret_lst = []
for i in range(len(lst) - K + 1):
    if n < sum(lst[i : i + K]):
        n = sum(lst[i : i + K])
        ret_lst = lst[i : i + K]

ret = 0
for x in ret_lst:
    ret += sum(range(1, x + 1)) / x
print(ret)


Fixed submission:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
s = set()
max_count = len(set(S)) ** 3
for x in range(N - 2):
    for y in range(x + 1, N  - 1):
        for z in set(S[y + 1:]):
            s.add(f"{S[x]}{S[y]}{z}")
            if len(s) == max_count:
                print(max_count)
                exit()
print(len(s))

Fixed submission:
N = int(input())
S = input()

ret = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            a = S.find(str(x))
            if a != -1:
                b = S.find(str(y), a + 1)
                if b != -1:
                    c = S.find(str(z), b + 1)
                    if c != -1:
                        ret += 1
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
s = set()
for x in range(N - 2):
    for y in range(x + 1, N  - 1):
        for z in set(S[y + 1:]):
            s.add(f"{S[x]}{S[y]}{z}")
print(len(s))

Fixed submission:
N = int(input())
S = input()

ret = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            a = S.find(str(x))
            if a != -1:
                b = S.find(str(y), a + 1)
                if b != -1:
                    c = S.find(str(z), b + 1)
                    if c != -1:
                        ret += 1
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
s = set()
for x in range(N - 2):
    for y in range(x + 1, N  - 1):
        for z in range(y + 1, N):
            s.add(S[x] + S[y] + S[z])
print(len(s))

Fixed submission:
N = int(input())
S = input()

ret = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            a = S.find(str(x))
            if a != -1:
                b = S.find(str(y), a + 1)
                if b != -1:
                    c = S.find(str(z), b + 1)
                    if c != -1:
                        ret += 1
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
ret = 0
for idx_a, a in enumerate(lst[:-2]):
    for idx_b, b in enumerate(lst[idx_a + 1:-1]):
        for idx_c, c in enumerate(lst[idx_a + idx_b + 2:]):
            if a < b + c and b < c + a and c < a + b:
                ret += 1
print(ret)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A - B * 2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
ret = 0
for idx_a, a in enumerate(lst[:-2]):
    for idx_b, b in enumerate(lst[idx_a + 1:-1]):
        for idx_c, c in enumerate(lst[idx_a + idx_b + 2:]):
            if a < b + c and b < c + a and c < a + b:
                ret += 1
print(ret)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A - B * 2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = sorted(list(map(int, input().split())))
ret = 0
for idx_a, a in enumerate(lst[:-2]):
    for idx_b, b in enumerate(lst[idx_a + 1:-1]):
        for idx_c, c in enumerate(lst[idx_a + idx_b + 2:]):
            if a < b + c and b < c + a and c < a + b:
                ret += 1
            else:
                break
print(ret)

Fixed submission:
import bisect

N = int(input())
lst =list(map(int, input().split()))
lst.sort()
ret = 0
for i in range(N):
    for j in range(i + 1, N):
        n = lst[i] + lst[j]
        idx = bisect.bisect_left(lst, n)
        ret += max(0, idx - j - 1)
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def is_prime(n):
    for p in range(2, int(math.sqrt(n)) + 1):
        if n % p == 0:
            return False
    return True

def prime_factorize(n):
    lst = []
    while n % 2 == 0:
        lst.append(2)
        n = n / 2
    a = 3
    while n > 1:
        if n % a == 0:
            lst.append(a)
            n = n / a
        else:
            a += 2
    return lst

A, B = map(int, input().split())
lst = prime_factorize(min(A, B))
ret = 1
for n in set(lst):
    if is_prime(n) and A % n == 0 and B % n == 0:
        ret += 1

print(ret)

Fixed submission:
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)
 
def prime_factorize(n):
    a = 2
    lst = []
    while a * a <= n:
        if n % a == 0:
            n = n / a
            lst.append(a)
        else:
            a += 1
    if n > 1:
        lst.append(n)
    return lst
 
A, B = map(int, input().split())
n = gcd(A, B)
lst = prime_factorize(n)
print(len(set(lst)) + 1)

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

def is_prime(n):
    for p in range(2, int(math.sqrt(n)) + 1):
        if n % p == 0:
            return False
    return True

A, B = map(int, input().split())
N = min(A, B) // 2
lst = [1]
for n in  range(2, N + 1):
    if A % n == 0 and B % n == 0:
        lst.append(n)

ret = 1
for n in lst[1:]:
    if is_prime(n):
        ret += 1
print(ret)

Fixed submission:
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)
 
def prime_factorize(n):
    a = 2
    lst = []
    while a * a <= n:
        if n % a == 0:
            n = n / a
            lst.append(a)
        else:
            a += 1
    if n > 1:
        lst.append(n)
    return lst
 
A, B = map(int, input().split())
n = gcd(A, B)
lst = prime_factorize(n)
print(len(set(lst)) + 1)