Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = list(input())
L = 0
R = 0
tmp = []
for i in range(len(s)):
    if s[i] == "<":
        L += 1
    if s[i] == ">":
        R += 1
    if i == len(s)-1:
        if L == 0 or R == 0:
            tmp.append(L)
            tmp.append(R)
            L = 0
            R = 0
            break
        elif L > R:
            tmp.append(L)
            tmp.append(R-1)
            L = 0
            R = 0
            break
        elif L < R:
            tmp.append(L-1)
            tmp.append(R)
            L = 0
            R = 0
            break
    if s[i] == ">" and s[i+1] == "<":
        if L == 0 or R == 0:
            tmp.append(L)
            tmp.append(R)
            L = 0
            R = 0
        elif L > R:
            tmp.append(L)
            tmp.append(R-1)
            L = 0
            R = 0
        elif L < R:
            tmp.append(L-1)
            tmp.append(R)
            L = 0
            R = 0
ans = 0
for i in range(len(tmp)):
    if tmp[i] % 2 == 0:
        ans += (tmp[i] * (tmp[i] + 1) // 2)
    else:
        ans += ((tmp[i] - 1) * ((tmp[i] - 1) + 1) // 2 + tmp[i])
print(ans)

Fixed submission:
s = input()
n = len(s)
L=[0]
R=[0]
cnt = 0

for i in range(n):
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
    L.append(cnt)
cnt = 0
s = s[::-1]
for i in range(n):
    if s[i]  == '>':
        cnt += 1
    else:
        cnt = 0
    R.append(cnt)

R = R[::-1]
ans = 0
for i in range(n+1):
    ans += max(R[i], L[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
tmp = np.array(range(1, N, 1))
print(sum(tmp))

Fixed submission:
N = int(input())
if N % 2 == 0:
    print((1+N)*(N//2)-N)
else:
    print((1+N-1)*(N//2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

mx = max(H)
ind = H.index(max(H))

if ind != N - 1 and mx - min(H[ind+1:]) > 1:
    print("No")
    exit()

for i in range(N-1):
    if H[i] - min(H[i+1:]) > 1:
        print("No")
        exit()

print("Yes")

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
r_H = list(reversed(H))

for i in range(N-1):
    if r_H[i+1] - r_H[i] > 1:
        print("No")
        exit()
    if r_H[i+1] - r_H[i] == 1:
        r_H[i+1] = r_H[i+1] - 1
print("Yes")

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

for i in range(N-1):
    if H[i] - min(H[i+1:]) > 1:
        print("No")
        exit()

print("Yes")

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
r_H = list(reversed(H))

for i in range(N-1):
    if r_H[i+1] - r_H[i] > 1:
        print("No")
        exit()
    if r_H[i+1] - r_H[i] == 1:
        r_H[i+1] = r_H[i+1] - 1
print("Yes")
Buggy python submission (verdict: Runtime Error):
X, A = map(int,input().split())

if X < A:
    print(0)
else:
    pritnt(10)

Fixed submission:
X, A = map(int,input().split())

if X < A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
value_list = list(map(int, input().split()))
cost_list = list(map(int, input().split()))

value_result = []
for i in range(1,len(value_list)+1):
    for conb in itertools.combinations(value_list, i):
        value_result.append(list(conb)) 

cost_result = []
for i in range(1,len(cost_list)+1):
    for conb in itertools.combinations(cost_list, i):
        cost_result.append(list(conb)) 

ans_list = []
for i in range(len(value_result)):
    ans = sum(value_result[i]) - sum(cost_result[i])
    ans_list.append(ans)

if max(ans_list) > 0:
    print(max(ans_list))
else:
    print(0)

Fixed submission:
N = int(input())
value_list = list(map(int, input().split()))
cost_list = list(map(int, input().split()))
total = 0
for i in range(N):
    ans = value_list[i] - cost_list[i]
    if ans > 0:
        total += ans
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
cnt = 0
for i in range(len(S)):
    if S[i] == "W":
        cnt += S[:i].count("B")
print(cnt)

Fixed submission:
S = list(input())
cntb = 0
cntw = 0
for i in range(len(S)):
    if S[i] == "B":
        cntb +=1
    if S[i] == "W":
        cntw += cntb
print(cntw)
Buggy python submission (verdict: Runtime Error):
A, B, C, X, Y = map(int,input().split())

def piz(a, b, cost):
    if a >= X and b >= Y:
        print(cost)
    
    if a < X and b >= Y:
        piz(a+1, b, cost+A)
    if a >= X and b < Y:
        piz(a, b+1, cost+B)
    if a < X and b < Y and A + B < C * 2:
        piz(a+1, b+1, cost+A+B)
    if a < X and b < Y and A + B >= C * 2:
        piz(a+1, b+1, cost+C*2)

piz(0, 0, 0)

Fixed submission:
a, b, c, x, y = map(int, input().split())
print(min(a*x+b*y, c*2*x+b*max(0,y-x), c*2*y+a*max(0,x-y)))
Buggy python submission (verdict: Runtime Error):
print(input(),count("1"))

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(input()) for i in range(n)]
y = [j for j in set(x) if x.count(j) > 1]
z = [k for k in set(x) if x.count(k) == 1]
cnt = len(z)
for i in range(len(y)):
    if x.count(y[i]) % 2 == 1:
        cnt += 1
print(cnt)

Fixed submission:
import collections
n = int(input())
x = [int(input()) for i in range(n)]
c = collections.Counter(x)
cc = list(c.values())
cnt = 0
for i in range(len(cc)):
    if cc[i] % 2 == 1:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(input()) for i in range(n)]
y = list(set(x))
cnt = 0
for i in range(len(y)):
    if x.count(y[i]) % 2 == 1:
        cnt += 1
print(cnt)

Fixed submission:
import collections
n = int(input())
x = [int(input()) for i in range(n)]
c = collections.Counter(x)
cc = list(c.values())
cnt = 0
for i in range(len(cc)):
    if cc[i] % 2 == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))

cnt = 0
tmp = []
for i in range(N):
    for j in range(N):
        if P[i] - 1 <= P[j] <= P[i] + 1:
            cnt += 1
    tmp.append(cnt)
    cnt = 0

print(max(tmp))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = [0] * (max(A) + 2)
 
for a in A:
    if a == 0:
        ans[a] += 1
        ans[a + 1] += 1
    if a != 0:
        ans[a - 1] += 1
        ans[a] += 1
        ans[a + 1] += 1
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
i = 0
cnt = 1
cmpr = [0]
while A[i] != 2:
    if A[i] == i + 1:
        print(-1)
        exit()
    i = A[i] - 1
    if i in cmpr:
        print(-1)
        exit()
    cmpr.append(i)
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
i = 0
cnt = 1
cmpr = [0]
while A[i] != 2:
    if A[i] == i + 1:
        print(-1)
        exit()
    i = A[i] - 1
    cmpr.append(i)
    cnt += 1
    if cnt > N:
        print(-1)
        exit()
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
rate = {"a":0, "b":0, "c":0, "d":0, "e":0, "f":0, "g":0, "h":0}
ratez = {"z":0}
for i in range(N):
    if A[i] >=1 and A[i] <= 399:
        rate["a"] += 1
    if A[i] >=400 and A[i] <= 799:
        rate["b"] += 1
    if A[i] >=800 and A[i] <= 1199:
        rate["c"] += 1
    if A[i] >=1200 and A[i] <= 1599:
        rate["d"] += 1
    if A[i] >=1600 and A[i] <= 1999:
        rate["e"] += 1
    if A[i] >=2000 and A[i] <= 2399:
        rate["f"] += 1
    if A[i] >=2400 and A[i] <= 2799:
        rate["g"] += 1
    if A[i] >=2800 and A[i] <= 3199:
        rate["h"] += 1
    if A[i] >=3200:
        ratez["z"] += 1
keys = [k for k, v in rate.items() if v != 0]

if ratez["z"] == 0:
    print(len(keys), len(keys))
elif len(keys) == 8:
    print(8, 8)
elif ratez["z"] <= len(keys) and len(keys) != 8:
    print(len(keys), len(keys)+ratez["z"])
elif ratez["z"] > len(keys) and len(keys) != 8 and ratez["z"] + len(keys) <= 8:
    print(rate["z"], len(keys)+ratez["z"])
elif ratez["z"] > len(keys) and len(keys) != 8 and ratez["z"] + len(keys) > 8 and ratez["z"] <= 8:
    print(rate["z"], 8)
elif ratez["z"] > len(keys) and len(keys) != 8 and ratez["z"] + len(keys) > 8 and ratez["z"] > 8:
    print(8, 8)

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

cnt = [0] * 9
for i in a:
    x = min(i // 400, 8)
    if x >= 8:
        cnt[8] += 1
    else:
        cnt[x] = 1

if sum(cnt[:8]) == 0:
    l = 1
    r = cnt[8]
else:
    l = sum(cnt[:8])
    r = l+cnt[8]
print(l, r)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

p = 0
for i in range(100000000):
    p = (p*10+7) % K
    if p == 0:
        print(i+1)
        exit()
print(-1)



Fixed submission:

K = int(input())

p = 0
for i in range(100000000):
    p = (p*10+7) % K
    if p == 0:
        print(i+1)
        exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

st = 1
for i in range(K):
    st *= A[i]

for i in range(K, N):
    heru = A[i-K]
    hueru = A[i]
    if heru<hueru:
        print('Yes')
    else:
        print('No')


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

for i in range(K, N):
    if A[i-K]<A[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

st = 1
for i in range(K):
    st *= A[i]

for i in range(K, N):
    heru = A[i-K]
    hueru = A[i]
    if heru<hueru:
        print('Yes')
    else:
        print('No')


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

for i in range(K, N):
    if A[i-K]<A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = [0] * 10001
for x in range(1, n+1):
    for y in range(1, n+1):
        for z in range(1, n+1):
            t = x**2+y**2+z**2+x*y+y*z+z*x
            if t <= n:
                ans[t] += 1
for i in range(1, n+1):
    print(ans[i])

Fixed submission:
import math

n = int(input())
ans = [0] * 10001
for x in range(1, int(math.sqrt(n+1))):
    for y in range(1, int(math.sqrt(n+1))):
        for z in range(1, int(math.sqrt(n+1))):
            t = x**2+y**2+z**2+x*y+y*z+z*x
            if t <= n:
                ans[t] += 1
for i in range(1, n+1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
B *= 100
print(A*B//100)

Fixed submission:
A, B = input().split()
AA = int(A)
# BB = int(float(B)*100)
BB = int(B.replace('.', ''))
print(AA*BB//100)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [0] * (10**6+10)

nax = 0
for i in range(N):
    A, B = map(int, input().split())
    T[A] += 1
    T[B+1] -= 1
    nax = max(nax, B)

for i in range(1, nax+1):
    T[i] += T[i-1]

cnt = 0
for i in range(nax-1):
    if T[i] > 0:
        cnt+=1
        if T[i+1] > 0:
            cnt += N-1
else:
    if T[nax-1] > 0:
        cnt += 1

print(cnt)



Fixed submission:
N = int(input())

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

A.sort()
B.sort()

cnt = 0
if(N % 2 == 1):
    l = A[N//2]
    r = B[N//2]
    cnt = r - l + 1
else:
    l = A[N//2-1] + A[N//2]
    r = B[N//2-1] + B[N//2]
    cnt = r - l + 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [input() for i in range(h)]

# count min of color change cnt in the path
dp = [[0]*w for i in range(h)]
dp[0][0] = 1 if s[0][0] == '#' else 0
for i in range(w):
    for j in range(h):
        if i==j==0: continue
        a,b = h*w, h*w
        if i>0:
            a = dp[i-1][j] + (1 if s[i-1][j]!=s[i][j] else 0)
        if j>0:
            b = dp[i][j-1] + (1 if s[i][j-1]!=s[i][j] else 0)
        dp[i][j] = min(a,b)
if s[h-1][w-1] == '#':
    dp[h-1][w-1]+=1
print(int(dp[h-1][w-1]/2))

Fixed submission:
def solve():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    INF = 10 ** 9
    dp = [[0]*(w+10) for _ in range(h+10)]
    dp[0][0] = 1 if s[0][0] == '#' else 0

    for i in range(h):
        for j in range(w):
            if not i==j==0:
                dp[i][j] = INF
            if i>0:
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (1 if s[i-1][j]=='.' and s[i][j]=='#' else 0))
            if j>0:
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (1 if s[i][j-1]=='.' and s[i][j]=='#' else 0))

    # for i in range(h):
    #     for j in range(w):
    #         print(dp[i][j], end=' ')
    #     print()
    print(dp[h-1][w-1])


solve()
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
t = math.gcd(a, b)
print(a // t * b)


Fixed submission:
from fractions import gcd

a, b = map(int, input().split())
t = gcd(a, b)
print(a // t * b)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

def nax(a, b):
    if a == '-':
        return b
    if len(a) != len(b):
        return a if len(a)>len(b) else b
    return a if a>b else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 10001
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])

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

def nax(a, b):
    if a == '-':
        return b
    if len(a) != len(b):
        return a if len(a)>len(b) else b
    return a if a>b else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 11000
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

def nax(a, b):
    if a == '-':
        return b
    return a if int(a)>int(b) else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 10101
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])

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

def nax(a, b):
    if a == '-':
        return b
    if len(a) != len(b):
        return a if len(a)>len(b) else b
    return a if a>b else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 11000
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])
Buggy python submission (verdict: Runtime Error):
s = input()
print(s if len(s)==2 else s[::-1]

Fixed submission:
s = input()
print(s if len(s)==2 else s[::-1])
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = 1000000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
    ans = min(ans, c)
print(ans if ans < T else "TLE")


Fixed submission:
N, T = map(int, input().split())
ans = 1000000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)
print("TLE" if ans == 1000000 else ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

print(max(s.count(S) - t.count(S) for S in s) + [0])

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

print(max([s.count(S) - t.count(S) for S in s] + [0]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = len(str(N))
NS = str(N)
ans0 = 0
for i in range(NS):
    ans0 += int(i)
ans1 = int(NS[0])-1 + 9 * (n-1)
ans2 = 9 * (n-1)

print(max(ans0, ans1, ans2))


Fixed submission:
N = int(input())
n = len(str(N))
NS = str(N)
ans0 = 0
for i in NS:
    ans0 += int(i)
ans1 = int(NS[0])-1 + 9 * (n-1)
ans2 = 9 * (n-1)

print(max(ans0, ans1, ans2))
Buggy python submission (verdict: Runtime Error):
S = sorted(input())
T = sorted(input(), reversed=True)
print('Yes' if S<T else 'No')

Fixed submission:
S = input()
T = input()
S = sorted(S)
T = sorted(T, reverse=True)

print('Yes' if S<T else 'No')
Buggy python submission (verdict: Runtime Error):
s=input()
ans = 0
for c in s:
  if c=="1"
    ans+=1
print(ans)

Fixed submission:
s=input()
ans = 0
for c in s:
  if c=="1":
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [0] * 100010
for i in range(n):
    a = int(input())
    if l[a] == 0:
        l[a] = 1
    else:
        l[a] = 0
print(sum(l))

Fixed submission:
n = int(input())
l = [0] * 100010

mp = {}
for i in range(n):
    a = int(input())
    if a in mp:
        del mp[a]
    else:
        mp[a] = 1
print(len(mp))

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [0] * 100000
for i in range(n):
    a = int(input())
    if l[a] == 0:
        l[a] = 1
    else:
        l[a] = 0
print(sum(l))

Fixed submission:
n = int(input())
l = [0] * 100010

mp = {}
for i in range(n):
    a = int(input())
    if a in mp:
        del mp[a]
    else:
        mp[a] = 1
print(len(mp))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

c = Counter(A)
pair = []
print(c)
for x, cnt in c.items():
    pair += [x] * (cnt//2)

# print(pair)
pair.sort()

ans = 0
if len(pair) >= 2:
    ans = pair[-1] * pair[-2]
print ans

Fixed submission:
from collections import Counter

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

c = Counter(A)
pair = []
# print(c)
for x, cnt in c.items():
    pair += [x] * (cnt//2)

# print(pair)
pair.sort()

ans = 0
if len(pair) >= 2:
    ans = pair[-1] * pair[-2]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

def nlcm(t):
    res = 1
    for a in t:
        res *= a // math.gcd(a,res)
    return res

n = int(input())
T = [int(input()) for i in range(n)]

print(nlcm(T))

Fixed submission:
from fractions import gcd

def nlcm(t):
    res = 1
    for a in t:
        res *= a // gcd(a,res)
    return res

n = int(input())
T = [int(input()) for i in range(n)]

print(nlcm(T))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
print('Yes' ifa<=c<=b else 'No')

Fixed submission:
a,b,c = map(int, input().split())
print('Yes' if a<=c<=b else 'No')
Buggy python submission (verdict: Runtime Error):
import collections as col

N = int(input())
A = list(map(int, input().split()))

m = col.Counter(A)
ans = len(m) if m%2==1 else len(m)-1
print(ans)



Fixed submission:
import collections as col

N = int(input())
A = list(map(int, input().split()))

m = col.Counter(A)
ans = len(m) if len(m)%2==1 else len(m)-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
    exit()
    
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print(0)
    exit()    

ans = 1
for i in range(1, n+1):
    ans *= ((n+m+1-i) * pow(i, mod-2, mod)) % mod
print(ans%mod)

Fixed submission:
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
    exit()
    
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print(0)
    exit()    

ans = 1
for i in range(1, n+1):
    ans *= (n+m+1-i) * pow(i, mod-2, mod)
    ans %= mod
    
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import factorial

X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
else:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    print((factorial(n+m)%mod * pow(factorial(n)*factorial(m), mod-2, mod))%mod)

Fixed submission:
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3 != 0:
    print(0)
    exit()
    
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print(0)
    exit()    

ans = 1
for i in range(1, n+1):
    ans *= (n+m+1-i) * pow(i, mod-2, mod)
    ans %= mod
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for k in range(j+1, N):
            c = L[k]
            if a < b+c and b < c+a and c < a+b:
                ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        ans += i - bisect.bisect_right(L[:i], L[j]-L[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


N, M, L = map(int, input().split()) 
d = [[float('inf') for _ in range(N)] for _ in range(N)]
D = [[float('inf') for _ in range(N)] for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    d[A-1][B-1] = C
    d[B-1][A-1] = C
for i in range(N):
    d[i][i] = 0
d = warshall_floyd(d)

for i in range(N):
    for j in range(N):
        if 0 < d[i][j] <= L:
            D[i][j] = 1
        elif d[i][j] == 0:
            D[i][j] = 0
D = warshall_floyd(D)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    print(D[s-1][t-1] - 1 if D[s-1][t-1] != float('inf') else -1)


Fixed submission:
import sys
input = sys.stdin.readline

def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


N, M, L = map(int, input().split())
INF = 10 ** 10
d = [[INF for _ in range(N)] for _ in range(N)]
D = [[INF for _ in range(N)] for _ in range(N)]

for i in range(N):
    d[i][i] = 0
for i in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    d[A][B] = C
    d[B][A] = C
d = warshall_floyd(d)

for i in range(N):
    for j in range(N):
        if 0 < d[i][j] <= L:
            D[i][j] = 1
        elif d[i][j] == 0:
            D[i][j] = 0
D = warshall_floyd(D)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    print(D[s][t] - 1 if D[s][t] != INF else -1)
Buggy python submission (verdict: Runtime Error):
S = input()

flag = 'Yes'
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break
    if i%2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            brake

print(flag)

Fixed submission:
S = input()

flag = 'Yes'
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break
    if i%2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break

print(flag)

Buggy python submission (verdict: Runtime Error):
S = input()

flag = 'Yes'
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break
    if i%2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            brake

print(flag)

Fixed submission:
S = input()

flag = 'Yes'
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break
    if i%2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break

print(flag)