Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = list(input())
Q = int(input())

ans = collections.deque(S)

for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        ans.reverse()
    else:
        if query[1] == '1':
            ans.appendleft(query[2])
        else:
            ans.append(query[2])
            

print("".join(ans))
        

Fixed submission:
import collections
S = list(input())
Q = int(input())

ans = collections.deque(S)
rev = False

for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        rev = not rev
    else:
        if query[1] == '1':
            if rev:
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
        else:
            if rev:
                ans.appendleft(query[2])
            else:
                ans.append(query[2])

if rev:
    print("".join(reversed(ans)))
else:
    print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
from queue import Queue

N, Q = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    adj[x].append(y)
    adj[y].append(x)

score = [0 for _ in range(N+1)]
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev):
    for target in adj[now]:
        if target == prev:
            continue
        score[target] += score[now]
        dfs(target, now)

dfs(1, 0)

print(" ".join(map(str, score[1:])))


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
from queue import Queue

def input():
    return sys.stdin.readline()

N, Q = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    adj[x].append(y)
    adj[y].append(x)

score = [0 for _ in range(N+1)]
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev):
    for target in adj[now]:
        if target == prev:
            continue
        score[target] += score[now]
        dfs(target, now)

dfs(1, 0)

print(" ".join(map(str, score[1:])))

Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue

N, Q = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    adj[x].append(y)
    adj[y].append(x)

score = [0 for _ in range(N+1)]
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

searched = [False for _ in range(N+1)]
searched[1] = True
q = Queue()

def bfs(i, add_point):
    if i > N:
        return
    if searched[i]:
        return
    searched[i] = True
    score[i] += add_point
    q.put([i, score[i]])
    return
    
q.put([1, score[1]])
    
while not q.empty():
    i, p = q.get()
    for j in adj[i]:
        bfs(j, p)

print(" ".join(map(str, score[1:])))


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
from queue import Queue

def input():
    return sys.stdin.readline()

N, Q = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    adj[x].append(y)
    adj[y].append(x)

score = [0 for _ in range(N+1)]
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev):
    for target in adj[now]:
        if target == prev:
            continue
        score[target] += score[now]
        dfs(target, now)

dfs(1, 0)

print(" ".join(map(str, score[1:])))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

now_col = []

for i in range(n):
    now_k = -1
    now_v = -1
    for k, v in enumerate(now_col):
        if now_v < v < a[i]:
            now_v = v
            now_k = k
    if now_k != -1:
        now_col[now_k] = a[i]
    else:
        now_col.append(a[i])

print(len(now_col))

Fixed submission:
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]
dp = [-1 for _ in range(n)]
for i in a:
    dp[bisect.bisect_left(dp, i) - 1] = i

print(sum([i >= 0 for i in dp]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

water_sum = sum(a)
kotae = [water_sum for _ in range(n)]

for i in range(n):
    for j in range(n // 2):
        kotae[i] -= 2*a[(i+1+2*j) % n]

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

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

water_sum = sum(a)
kotae = [-1 for _ in range(n)]

# 和を足しておく
kotae[0] = water_sum

# 全体の和からほかの山の水量を引いて行って山0の水量を求める
for i in range(n // 2):
    kotae[0] -= 2*a[(1+2*i) % n]

# 漸化式でほかのすべてを求める
for i in range(1, n):
    kotae[i] = 2*a[i-1] - kotae[i-1]

print(" ".join(map(str, kotae)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(50000)


waru = 10**9 + 7

memo_ind = []
memo_val = []

def ball_narabe(n, k, i):
    if i == 0:
        if k == 0:
            return 1
        else:
            return 0
    if i > k:
        return 0
    if n < k:
        return 0
    if n == k:
        if i == 1:
            return 1
        else:
            return 0
            
    if i==1:
        # (n-k+1)C(1) を求める
        return n-k+1
    
    put_ball = k - (i-1)
    sum_of_patterns = 0
    while put_ball >= 1:
        sum_of_patterns += ball_narabe(n-put_ball-1, k-put_ball, i-1)
        put_ball -= 1
    
    return (ball_narabe(n-1, k, i) + sum_of_patterns) % waru
    
_n, _k = map(int, input().split())
memo_ind = []
for _i in range(1, _k+1):
    print(ball_narabe(_n, _k, _i))
            

Fixed submission:
import math

def combi(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

def count(n, k, i):
    if n-k+1 < i:
        return 0
    return combi(n-k+1, i) * combi(k-1, i-1)

n, k = map(int, input().split())
for i in range(1, k+1):
    print(count(n, k, i) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
import math
 
def lcm(x, y):
  return (x * y) // math.gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)

Fixed submission:
from fractions import gcd
 
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())

yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)

Fixed submission:
from fractions import gcd
 
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)
Buggy python submission (verdict: Runtime Error):
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10

Fixed submission:
x, a = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
now = 0
i = 0

while now <= x:
    now += l[i]
    i += 1
    
print(i)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
now = 0

for i in range(len(l)):
    now += l[i]
    if now > x:
        break
else:
    i += 1
    
print(i+1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
dp = [-1 for i in range(n+1)]
dp[0] = 1
dp[1] = 1
for b in broken:
    dp[b] = 0
for i in range(2, n+1):
    if memo[i] == -1:
      memo[i] = memo[i-1] + memo[i-2]
print(memo[n] % (10**9+7))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    
    one = memo[n-1] if memo[n-1] != -1 else steps(n-1)    
    two = memo[n-2] if memo[n-2] != -1 else steps(n-2)

    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1
for b in broken:
    memo[b] = 0

print(steps(n) % (10**9+7))

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

sys.setrecursionlimit(1000000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    if n-1 not in broken:
        one = memo[n-1] if memo[n-1] != -1 else steps(n-1)
    else:
        one = 0
        
    if n-2 not in broken:
        two = memo[n-2] if memo[n-2] != -1 else steps(n-2)
    else:
        two = 0
    
    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1

print(steps(n) % (10**9+7))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    
    one = memo[n-1] if memo[n-1] != -1 else steps(n-1)    
    two = memo[n-2] if memo[n-2] != -1 else steps(n-2)

    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1
for b in broken:
    memo[b] = 0

print(steps(n) % (10**9+7))

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

sys.setrecursionlimit(100000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    if n-1 not in broken:
        one = memo[n-1] if memo[n-1] != -1 else steps(n-1)
    else:
        one = 0
        
    if n-2 not in broken:
        two = memo[n-2] if memo[n-2] != -1 else steps(n-2)
    else:
        two = 0
    
    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1

print(steps(n) % (10**9+7))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

def steps(n):
    if memo[n] != -1:
        return memo[n]
    
    one = memo[n-1] if memo[n-1] != -1 else steps(n-1)    
    two = memo[n-2] if memo[n-2] != -1 else steps(n-2)

    memo[n] = one + two
    return memo[n]

n, m = map(int, input().split())
broken = [int(input()) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1
for b in broken:
    memo[b] = 0

print(steps(n) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
lines = list(map(int, input().split())
lines.sort()
             
print(lines[0] * lines[1])

Fixed submission:
lines = list(map(int, input().split()))
lines.sort()
 
print((lines[0] * lines[1]) // 2)

Buggy python submission (verdict: Runtime Error):
lines = map(int, input().split())
lines.sort()

print(lines[0] * lines[1])

Fixed submission:
lines = list(map(int, input().split()))
lines.sort()
 
print((lines[0] * lines[1]) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**10 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    mincost = 10 ** 10
    for j in range(1, min(i, k)+1):
        cost = dp[i-j] + abs(h[i] - h[i-j])
        if cost < mincost:
            mincost = cost
    
    dp[i] = mincost

print(dp[-1])


Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**10 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    mincost = 10 ** 10
    for j in range(1, min(i, k)+1):
        cost = dp[i-j] + abs(h[i] - h[i-j])
        if cost < mincost:
            mincost = cost
    
    dp[i] = mincost

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
links = [list(map(int, input().split())) for _ in range(M)]

dp = [-1 for _ in range(N+1)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    
    paths = 0
    for _, t in filter(lambda x: x[0] == i, links):
        paths = max(paths, search(t)+1)
    
    dp[i] = paths
    return paths

for i in range(1, N+1):
    search(i)

print(max(dp))

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
links = [[] for _ in range(N+1)]
for _ in range(M):
    s, t = map(int, input().split())
    links[s].append(t)

dp = [-1 for _ in range(N+1)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    
    paths = 0
    for t in links[i]:
        paths = max(paths, search(t)+1)
    
    dp[i] = paths
    return paths

for i in range(1, N+1):
    search(i)

print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
links = [list(map(int, input().split())) for _ in range(M)]

dp = [-1 for _ in range(N+1)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    
    paths = 0
    for _, t in filter(lambda x: x[0] == i, links):
        paths = max(paths, search(t)+1)
    
    dp[i] = paths
    return paths

for i in range(1, N+1):
    search(i)

print(max(dp))

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
links = [[] for _ in range(N+1)]
for _ in range(M):
    s, t = map(int, input().split())
    links[s].append(t)

dp = [-1 for _ in range(N+1)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    
    paths = 0
    for t in links[i]:
        paths = max(paths, search(t)+1)
    
    dp[i] = paths
    return paths

for i in range(1, N+1):
    search(i)

print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

patterns = [[0 for _ in range(W)] for __ in range(H)]
searched = [[False for _ in range(W)] for __ in range(H)]
q = Queue()

div = 10**9+7

def search(x, y):
    if not (0 <= x < W and 0 <= y < H):
        return
    if searched[y][x]:
        return
    searched[y][x] = True
    if field[y][x] == '#':
        return
    res = 0
    if x > 0:
        res += patterns[y][x-1] % div
    if y > 0:
        res += patterns[y-1][x] % div
    patterns[y][x] = res % div
    q.put([x, y])
    return

patterns[0][0] = 1
q.put([0, 0])

while not searched[-1][-1]:
    x, y = q.get()
    search(x+1, y)
    search(x, y+1)
    
print(patterns[-1][-1] % div)


Fixed submission:
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

div = 10**9+7

patterns = [[0 for _ in range(W)] for __ in range(H)]
patterns[0][0] = 1


for y in range(H):
    for x in range(W):
        if x + 1 < W and field[y][x+1] != '#':
            patterns[y][x+1] += patterns[y][x] % div
        if y + 1 < H and field[y+1][x] != '#':
            patterns[y+1][x] += patterns[y][x] % div

print(patterns[-1][-1] % div)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
kukan = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x: x[1])
ans = 0

while kukan:
    cut = kukan[0][1] - 1
    kukan = list(filter(lambda x: not x[0] <= cut < x[1], kukan))
    ans += 1

print(ans)

Fixed submission:
def main():
    N, M = map(int, input().split())
    kukan_list = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x: x[1])
    ans = 0
    cut = 0
    
    for kukan in kukan_list:
        if cut >= kukan[0]:
            continue
        ans += 1
        cut = kukan[1] - 1
    
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
 S = input()
print(min(abs(int(S[i:i+3]) - 753) for i in range(len(S) - 2)))


Fixed submission:
S = input()
print(min(abs(int(S[i:i+3]) - 753) for i in range(len(S) - 2)))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().strip().split())
if k==0:
    if abs(a-b)>10**18:
        print('Unfair')
    else:
        print(a-b)
else:
    for i in range(k):
        x=b+c 
        y=a+c 
        z=a+b 
        a=x
        b=y
        c=z
    if abs(x-y)>10**18:
        print('Unfair')
    else:
        print(x-y)






Fixed submission:
a,b,c,k=map(int,input().strip().split())
if k%2==0:
    print(a-b)
else:
    print(-(a-b))
Buggy python submission (verdict: Runtime Error):
n= int(input())
kk=set()
for i in range(n):
  s=input()
  kk.add()
print(len(kk))

Fixed submission:
n=int(input())
d=dict()

for i in range(n):
  s="".join(input())
  #print(s)
  if s in d:
    d[s]+=1
  else:
    d[s]=1
ans=0
for x in d.values():
  ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())

dic=dict()
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
a=max(dic)
b=dic[a]
keys = [k for k, v in dic.items() if v == b]
keys.sort()
for i in range(n):
  print(keys[i])


Fixed submission:
n=int(input())

dic=dict()
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
a=(max(dic, key=dic.get))
b=dic[a]
keys = [k for k, v in dic.items() if v == b]
keys.sort()

for i in range(len(keys)):
  print(keys[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
a= list(map(int, input().split()))
maxans=0
for i in range(len(a)):
  ans=sum(a[i:i+k])
  maxans=max(ans,maxans)
print((maxans+k)/2)
  

Fixed submission:
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=sum(l[0:k])
ans=sum(l[0:k])
for i in range(len(l)-k):
  ans=ans+l[i+k]-l[i]
  maxans=max(ans,maxans)
 
print(maxans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
a= list(map(int, input().split()))
maxans=0
for i in range(len(a)):
  ans=sum(a[i:i+k])
  maxans=max(ans,maxans)
print((maxans+k)/2)

Fixed submission:
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=sum(l[0:k])
ans=sum(l[0:k])
for i in range(len(l)-k):
  ans=ans+l[i+k]-l[i]
  maxans=max(ans,maxans)
 
print(maxans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=0
for i in range(len(l)):
  ans=sum(l[i:i+k])
  maxans=max(ans,maxans)
print(maxans)
  

Fixed submission:
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=sum(l[0:k])
ans=sum(l[0:k])
for i in range(len(l)-k):
  ans=ans+l[i+k]-l[i]
  maxans=max(ans,maxans)
 
print(maxans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=0

for i in range(len(l)):
  ans=sum(l[i:i+k])
  maxans=max(ans,maxans)
print(maxans)

Fixed submission:
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=sum(l[0:k])
ans=sum(l[0:k])
for i in range(len(l)-k):
  ans=ans+l[i+k]-l[i]
  maxans=max(ans,maxans)
 
print(maxans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split())) 
count=0
for i in range(len(p)):
    if min(p[:(1+i)])==p[i]:
      count+=1
print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split())) 
count=0
minmin=100000000
for i in range(len(p)):
  if p[i]<minmin:
    count+=1
    minmin=p[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

count=0
for i in range(n):
  count+=(ans//a[i])
print(count%(10**9+7))
  


Fixed submission:
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

count=0
for i in range(n):
  count+=(ans//a[i])
print(count%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

count=0
for i in range(n):
  count+=(ans//a[i])
print(count%(10**9+7))
  

Fixed submission:
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

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

 
for i in range(n):
  if a[0]-b[-1]==1:
    b.append(a.pop(0))
  else:
    a.pop(0)
if n-len(b)+1==n:
  print(-1)
else:
  print(n-len(b)+1)

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

count=1
for i in range(n):
  if a[i]==count:
    count+=1
if count==1:
  print(-1)
else:
  print(n-count+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a= list((map(int, input().split()))) 
b=[0]
c=[]
 
for i in range(n):
  if a[0]-b[-1]==1:
    b.append(a.pop(0))
  else:
    c.append(a.pop(0))
if n-len(b)+1==n:
  print(-1)
else:
  print(n-len(b)+1)

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

count=1
for i in range(n):
  if a[i]==count:
    count+=1
if count==1:
  print(-1)
else:
  print(n-count+1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a= list((map(int, input().split()))) 
b=[0]
c=[]
if 1 not in a:
  print(-1)
else:  
  for i in range(n):
    if a[0]-b[-1]==1:
      b.append(a.pop(0))
    else:
      c.append(a.pop(0))
  print(n-len(b)+1)

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

count=1
for i in range(n):
  if a[i]==count:
    count+=1
if count==1:
  print(-1)
else:
  print(n-count+1)
Buggy python submission (verdict: Runtime Error):
aa

Fixed submission:
n=int(input())
s=input()
for i in range(len(s)):
  ss=(ord(s[i])+n)
  if ss>90:
    ss=ss-26
  print(chr(ss),end="")
Buggy python submission (verdict: Runtime Error):
ああ

Fixed submission:
a,b=map(int, input().split())
s=0
t=400000-100000*a
if t>0:
  s=t
u=400000-100000*b
if u>0:
  s+=u
if a+b==2:
  s+=400000
print(s)
Buggy python submission (verdict: Runtime Error):
kk

Fixed submission:
from itertools import permutations
 
n = int(input())
n_ = 1
for i in range(n):
    n_ *= i+1
c = [tuple(map(int,input().split())) for _ in range(n)]
tot = 0
 
def dis(c,x,y):
  x1,y1 = c[x]
  x2,y2 = c[y]
  return ((x1-x2)**2 + (y1-y2)**2)**.5
 
for l in permutations(range(n)):
    d = 0
    cur = l[0]
    for x in l:
        d += dis(c,cur,x)
        cur = x
    tot += d/n_
print(tot)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%2==0:
  ans=n//2-1
else:
  ans==n//2

print(ans)

Fixed submission:
n=int(input())
if n%2==0:
  ans=n//2-1
else:
  ans=n//2

print(ans)