Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
ans=1
if p[0]==min(p):
    print(ans)
else:
    l=[p[0]]
    for i in range(1,n):
        l.append(p[i])
        if p[i]==min(l):
            ans+=1
    print(ans)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
ans=1
if p[0]==min(p):
    print(ans)
else:
    l=[p[0]]
    for i in range(1,n):
        l.append(p[i])
        if p[i]==min(l):
            ans+=1
    print(ans)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
for i in range(1,n):
    l.append(p[i])
    if p[i]==min(l):
        ans+=1
    else:
        continue
print(ans)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int, input().split()))
ans=0
for i in range(n):
    buf=0
    for j in range(i+1):
        if p[j]>=p[i]:
            buf+=1
    if buf==i+1:
        ans+=1
print(ans)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
ac,wa=0,0
if m==0:
    print(ac,wa)
else: #一度飛ばして新たな問題を解いたうえで戻ってくる場合があるのか？
    l=[0]*n #正解処理の配列
    r=[0]*n #誤答カウンター
    for i in range(m):
        pa,s=map(str, input().split())
        p=int(pa)
        if l[p-1]==0 and s=='AC': #初正解時の処理
            l[p-1]=1
            ac+=1
        elif s=='WA': #誤答時の処理
            r[p-1]+=1
        else:
            continue
    for i in range(n):
        if l[i]==1:
            wa+=w[i]
        else:
            continue
    print(ac,wa)

Fixed submission:
n,m=map(int, input().split())
ac,wa=0,0
if m==0:
    print(ac,wa)
else: #一度飛ばして新たな問題を解いたうえで戻ってくる場合があるのか？
    l=[0]*n #正解処理の配列
    r=[0]*n #誤答カウンター
    for i in range(m):
        pa,s=map(str, input().split())
        p=int(pa)
        if l[p-1]==0 and s=='AC': #初正解時の処理
            l[p-1]=1
            ac+=1
        elif l[p-1]==0 and s=='WA': #誤答時の処理
            r[p-1]+=1
        else:
            continue
    for i in range(n):
        if l[i]==1:
            wa+=r[i]
        else:
            continue
    print(ac,wa)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int, input().split())
if k>=a+b:
    print(0,0)
else:
    for i in range(k):
        if a>0:
            a-=1
        elif b>0:
            b-=1
        else:
            break
    print(a,b)

Fixed submission:
a,b,k=map(int, input().split())
if k>=a+b:
    print(0,0)
elif a>=k:
    print(a-k,b)
else:
    print(0,a+b-k)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s,t=str(input().split())
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')

Fixed submission:
n=int(input())
s,t=input().split(' ')
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=str(input())
t=str(input())
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')

Fixed submission:
n=int(input())
s,t=input().split(' ')
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
ans=0
if n%2==1:
    print(ans)
else:
    m=math.ceil(math.log(n, 5))
    for i in range(1, m):
        ans +=(n//2)//(5**i)
    print(ans)

Fixed submission:
import math
n=int(input())
ans=0
if n==0 or n%2==1:
    print(ans)
else:
    m=math.ceil(math.log(n, 5))
    for i in range(1, m):
        ans +=(n//2)//(5**i)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
k,a,b=map(int, input().split())
if a>=b or (a<b and b-a==1):
    bis=1
    for i in range(k):
        bis+=1
    print(bis)
    sys.exit()
if a<b and (k-a+1)%2==0:
    bis=(b-a)*((k-a+1)//2-1)+b
    print(bis)
    sys.exit()
if a<b and (k-a+1)%2!=0:
    bis=(b-a)*((k-a+1)//2-1)+b+1
    print(bis)

Fixed submission:
import sys
k,a,b=map(int, input().split())
if a>=b or (a<b and b-a==1):
    bis=1+k
    print(bis)
    sys.exit()
if a<b and (k-a+1)%2==0:
    bis=(b-a)*((k-a+1)//2-1)+b
    print(bis)
    sys.exit()
if a<b and (k-a+1)%2!=0:
    bis=(b-a)*((k-a+1)//2-1)+b+1
    print(bis)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[2,1]
if n>2:
    for i in range(2,n+1):
        li=l[i-1]+l[i-2]
        l.append(li)
    print(l[n])
else:
    print(l[n])

Fixed submission:
n=int(input())
l=[2,1]
if n>1:
    for i in range(2,n+1):
        li=l[i-1]+l[i-2]
        l.append(li)
    print(l[n])
else:
    print(l[n])
Buggy python submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int, input().split()))
    ud=[]
    ans=1
    cnt=[0,0]
    for i in range(n-1):
        if a[i]==a[i+1]:
            ud.append('eq')
        elif a[i]<a[i+1]:
            ud.append('up')
        elif a[i]>a[i+1]:
            ud.append('down')
    if ud[0]=='up':
        cnt[0]=1
    elif ud[0]=='down':
        cnt[1]=1
    for i in range(1,n-1):
        if (cnt[0]==cnt[1]==0 or cnt[0]!=0) and ud[i]=='up':
            cnt[0]+=1
        elif (cnt[0]==cnt[1]==0 or cnt[1]!=0) and ud[i]=='down':
            cnt[1]+=1
        elif cnt[0]!=0 and ud[i]=='down':
            ans+=1
            cnt[0]=0
        elif cnt[1]!=0 and ud[i]=='up':
            ans+=1
            cnt[1]=0
        elif cnt[0]!=0 and cnt[1]==0 and i==n-2:
            ans+=1
        elif cnt[1]!=0 and cnt[0]==0 and i==n-2:
            ans+=1
    print(ans)
    
if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    n=int(input())
    a=list(map(int, input().split()))
    ud=[]
    ans=1
    cnt=[0,0]
    if n==1:
        print(ans)
        sys.exit()
    for i in range(n-1):
        if a[i]==a[i+1]:
            ud.append('eq')
        elif a[i]<a[i+1]:
            ud.append('up')
        elif a[i]>a[i+1]:
            ud.append('down')
    if len(set(ud))==1 or (len(set(ud))==2 and 'eq' in set(ud)):
        print(ans)
        sys.exit()
    if ud[0]=='up':
        cnt[0]=1
    elif ud[0]=='down':
        cnt[1]=1
    for i in range(1,n-1):
        if (cnt[0]==cnt[1]==0 or cnt[0]!=0) and ud[i]=='up':
            cnt[0]+=1
        elif (cnt[0]==cnt[1]==0 or cnt[1]!=0) and ud[i]=='down':
            cnt[1]+=1
        elif cnt[0]!=0 and ud[i]=='down':
            ans+=1
            cnt[0]=0
        elif cnt[1]!=0 and ud[i]=='up':
            ans+=1
            cnt[1]=0
        elif cnt[0]!=0 and cnt[1]==0 and i==n-2:
            ans+=1
        elif cnt[1]!=0 and cnt[0]==0 and i==n-2:
            ans+=1
    print(ans)
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    x=int(input())
    cnt=0
    if x==1:
        print(1)
        sys.exit()
    for i in range(1,x):
        if cnt<x:
            cnt+=i
        else:
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    x=int(input())
    cnt=0
    if x==1:
        print(1)
        sys.exit()
    if x==2:
        print(2)
        sys.exit()
    for i in range(1,x):
        if cnt<x:
            cnt+=i
        else:
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    x=int(input())
    cnt=0
    for i in range(1,x):
        if cnt<x:
            cnt+=i
            print(i,cnt)
        else:
            print(i,cnt)
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    x=int(input())
    cnt=0
    if x==1:
        print(1)
        sys.exit()
    if x==2:
        print(2)
        sys.exit()
    for i in range(1,x):
        if cnt<x:
            cnt+=i
        else:
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, M = tuple(map(int, input().split()))
Hs = tuple(map(int, input().split()))

# good = [False] * N

# for _ in range(M):
#     A, B = tuple(map(int, input().split()))
#     H_A, H_B = Hs[A-1], Hs[B-1]
#     if H_A < H_B:
#         good[B-1] = True
#         good[A-1] = False
#     elif H_B < H_A:
#         good[A-1] = True
#         good[B-1] = False
#     else:
#         good[A-1] = good[B-1] = False

# print(sum([v == True for v in good]))

path = [[0] * N for _ in range(N)]
for _ in range(M):
    A, B = tuple(map(int, input().split()))
    H_A, H_B = Hs[A-1], Hs[B-1]
    path[A-1][B-1] = H_B
    path[B-1][A-1] = H_A

print(sum(all(Hs[i] > h for h in p) for i, p in enumerate(path)))


Fixed submission:
N, M = tuple(map(int, input().split()))
Hs = tuple(map(int, input().split()))

good = [True] * N

for _ in range(M):
    A, B = tuple(map(int, input().split()))
    H_A, H_B = Hs[A-1], Hs[B-1]
    if H_A < H_B:
        good[A-1] = False
    elif H_B < H_A:
        good[B-1] = False
    else:
        good[A-1] = good[B-1] = False

print(sum([v == True for v in good]))

# path = [[0] * N for _ in range(N)]
# for _ in range(M):
#     A, B = tuple(map(int, input().split()))
#     H_A, H_B = Hs[A-1], Hs[B-1]
#     path[A-1][B-1] = H_B
#     path[B-1][A-1] = H_A

# print(sum(all(Hs[i] > h for h in p) for i, p in enumerate(path)))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(x) for x in input().split()]

val = (int(A * i / B) - A * int(i / B) for i in range(1, N+1))
print(max(val))


Fixed submission:
A, B, N = [int(x) for x in input().split()]

# val = (int(A * i / B) - A * int(i / B) for i in range(1, N+1))
# print(max(val))

x = B - 1
if x > N:
    x = N
print(int(A * x / B) - A * int(x / B))
Buggy python submission (verdict: Time Limit Exceeded):
K, N = tuple(int(v) for v in input().split())

A_list = tuple(int(a) for a in input().split())

# 各点の距離
x_iter = iter(A_list)
y_iter = iter(A_list)
next(y_iter)

d_list = [y - x for x, y in zip(x_iter, y_iter)]
d_list.append(K - A_list[-1] + A_list[0])
d_list += d_list

l = len(d_list) // 2
sum_d = [sum(d_list[i:i+l-1]) for i in range(l)]

print(min(sum_d))


Fixed submission:
K, N = tuple(int(v) for v in input().split())

A_list = list(int(a) for a in input().split())

# # 各点の距離
# x_iter = iter(A_list)
# y_iter = iter(A_list)
# next(y_iter)
# 
# d_list = [y - x for x, y in zip(x_iter, y_iter)]
# d_list.append(K - A_list[-1] + A_list[0])
# d_list += d_list
# 
# l = len(d_list) // 2
# # sum_d = [sum(d_list[i:i+l-1]) for i in range(l)]
# min_d = min(sum(d_list[i:i+l-1]) for i in range(l))
# 
# print(min_d)

A_list += [a + K for a in A_list[:-1]]
print(min(A_list[i+N-1] - A_list[i] for i in range(N)))
Buggy python submission (verdict: Runtime Error):
N, K = [int(v) for v in input().split(" ")]
Ai = [int(v) for v in input().split(" ")]
assert len(Ai) == N


path = [0]
while True:
  next_city = Ai[path[len(path) - 1]] - 1
  if next_city in path:
    break
  path.append(next_city)

for i, city in enumerate(path):
  if city == next_city:
    start = path[:i]
    circle = path[i:]

if K <= len(start):
  print(start[K] + 1)
else:
  K -= len(start)
  print(circle[K % len(circle)] + 1)


Fixed submission:
S = input()
T = input()

if len(T) != len(S) + 1:
  print("Yes")
else:
  if T.startswith(S):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
A, B, C, K = [int(v) for v in s.split(" ")]

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A - B))

Fixed submission:
S = input()
T = input()

if len(T) != len(S) + 1:
  print("Yes")
else:
  if T.startswith(S):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
A, B, C, K = s.split(" ")
 
if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A - B))

Fixed submission:
S = input()
T = input()

if len(T) != len(S) + 1:
  print("Yes")
else:
  if T.startswith(S):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
return T.startswith(S)

Fixed submission:
S = input()
T = input()

if len(T) != len(S) + 1:
  print("Yes")
else:
  if T.startswith(S):
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
A B C K = s.split(" ")

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A))

Fixed submission:
s = input()
A, B, C, K = [int(v) for v in s.split(" ")]

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A - B))
Buggy python submission (verdict: Runtime Error):
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == M:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Fixed submission:
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == N:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == M:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Fixed submission:
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == N:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

l = [i for i in range(n+1)]
r = list(reversed(l))

cnt = 0

for i in range(k, n+2):
  min = sum(l[:i])
  max = sum(r[:i])

  if min == max:
    cnt += 1
  else:
    cnt += max - min + 1

print(cnt)


Fixed submission:
n, k = map(int, input().split())
cnt = 0
mod = 10**9+7

for i in range(k, n+2):
  min = int(i * (i - 1) / 2) #等差数列の和
  max = int(i * (2 * n - i + 1) / 2)
  cnt += max - min + 1

print(cnt % mod)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
s, t = input().split()
print(t+s)


Fixed submission:
#!/usr/bin/env python3
a, b, c = map(int, input().split())

if a + b + c >= 22:
  print('bust')
else:
  print('win')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
l, r = map(int, input().split())

r = min(r, l+4038)
ans = 2018

for i in range(l, r+1, 1):
  for j in range(i+1, r+1, 1):
    x = i*j%2019
    ans = min(ans, x)

print(ans)


Fixed submission:
#!/usr/bin/env python3
l, r = map(int, input().split())

r = min(r, l+673)
ans = 2018

for i in range(l, r+1, 1):
  for j in range(i+1, r+1, 1):
    x = i*j%2019
    ans = min(ans, x)

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
p

Fixed submission:
#!/usr/bin/env python3
n = int(input())
d = list(map(int, input().split()))

d.sort()
h = n // 2 - 1

a = d[h]
b = d[h + 1]

print(b - a)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    S=input()
    days=['SAN','MON','TUE','WED','THU','FRI','SAT']
    print(7-days.index(S))


if __name__ == "__main__":
    main()

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    S=input()
    days=['SUN','MON','TUE','WED','THU','FRI','SAT']
    print(7-days.index(S))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    A,B=mis()
    print(A*b if 0<A<10 and 0<B<10 else '-1')


if __name__ == "__main__":
    main()

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    A,B=mis()
    print(A*B if 0<A<10 and 0<B<10 else '-1')


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    A,B=mis
    print(A*b if 0<A<10 and 0<B<10 else '-1')


if __name__ == "__main__":
    main()

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    A,B=mis()
    print(A*B if 0<A<10 and 0<B<10 else '-1')


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

import itertools as it

def main():
    N=ii()
    L=lmis()
    ans=0
    for a,b,c in it.combinations(L,3):
        m=max(a,b,c)
        if m<a+b+c-m:
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

import itertools as it

def main():
    N=ii()
    L=sorted(lmis(),reverse=True)

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


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

import itertools as it

def main():
    N=ii()
    L=lmis()
    ans=0
    for a,b,c in it.combinations(L,3):
        if a+b>c and a+c>b and b+c>a:
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

import itertools as it

def main():
    N=ii()
    L=sorted(lmis(),reverse=True)

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


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a=['Sunny','Cloudy','Rainy']
s=input()
x=a.index(s)
print(a[x+1])

Fixed submission:
a=['Sunny','Cloudy','Rainy']
s=input()
x=a.index(s)
print(a[x+1] if x<2 else 'Sunny')
Buggy python submission (verdict: Runtime Error):
import heapq as hq

def solve(m,a):
    v=hq.heapify(a)
    for _ in range(m):
        x=hq.heappop(v)
        x//=-2
        hq.heappush(v,x)
        return -sum(v)

n,m=map(int,input().split())
a=list(map(int,input().split()))
print(solve(m,a))

Fixed submission:
import heapq as hp

n,m=map(int,input().split())
a=list(map(lambda x: -x ,map(int,input().split())))
hp.heapify(a)
for _ in range(m):
    tmp=hp.heappop(a)
    tmp//=-2
    hp.heappush(a,-tmp)
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
i=0
for _ in range(m):
    a[i]//=2
    i=a.index(max(a))
    print(a)
print(sum(a))

Fixed submission:
import heapq as hp

n,m=map(int,input().split())
a=list(map(lambda x: -x ,map(int,input().split())))
hp.heapify(a)
for _ in range(m):
    tmp=hp.heappop(a)
    tmp//=-2
    hp.heappush(a,-tmp)
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
cnt=0
i=0
for _ in range(m):
    if i==len(a): i=0
    a[i]//=2
    if a[i]<a[i+1]: i+=1
print(sum(a))

Fixed submission:
import heapq as hp

n,m=map(int,input().split())
a=list(map(lambda x: -x ,map(int,input().split())))
hp.heapify(a)
for _ in range(m):
    tmp=hp.heappop(a)
    tmp//=-2
    hp.heappush(a,-tmp)
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
print(sum(range(1,N)))

Fixed submission:
N=int(input())
print(N*(N-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
for i in range(N):
    ans+=i
print(ans)

Fixed submission:
N=int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if i in a: dp[i]=0
    else: dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if i in a: dp[i]=0
    else: dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n])