Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import Counter
    from functools import lru_cache
    from copy import deepcopy
    N = int(input())
    X = [i for i in range(N + 1)]
    prime = [2, ]
    for i in range(3, N + 1):
        x = int(i ** 0.5) + 1
        for p in prime:
            if p > x:
                prime.append(i)
                break
            if i % p == 0:
                X[i] = p
                break
        else:
            prime.append(i)

    @lru_cache(maxsize=None)
    def lis(n):
        if n == 1:
            return dict()
        a = X[n]
        if a == n:
            C = dict()
            C[a] = 1
        else:
            C = deepcopy(lis(n // a))
            if C.get(a):
                C[a] += 1
            else:
                C[a] = 1
        return C

    A = 0

    for i in range(1, N + 1):
        Cl = lis(i)
        ans = 1
        for v in Cl.values():
            ans *= v + 1
        A += ans * i

    print(A)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    ans = 0
    x = n // 2
    for i in range(1, n + 1):
        m = n // i
        ans += i * ((m + 1) * m) // 2
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import Counter
    N = int(input())
    X = [i for i in range(N + 1)]
    prime = [2, ]
    for i in range(3, N + 1):
        x = int(i ** 0.5) + 1
        for p in prime:
            if p > x:
                prime.append(i)
                break
            if i % p == 0:
                X[i] = p
                break
        else:
            prime.append(i)


    def cnt(n):
        L = list()
        while n != 1:
            L.append(X[n])
            n //= X[n]
        C = Counter(L)
        ans = 1
        for v in C.values():
            ans *= v + 1
        return ans


    A = 0

    for i in range(1, N + 1):
        A += cnt(i) * i

    print(A)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ans = 0
    x = n // 2
    for i in range(1, n + 1):
        m = n // i
        ans += i * ((m + 1) * m) // 2
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
N = map(int. input().split())
for x, n in enumarate(N, 1):
  if n == 0:
    print(x)
    break

Fixed submission:
N = map(int, input().split())
for x, n in enumerate(N, 1):
  if n == 0:
    print(x)
    break
Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit
N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if ans > 10 ** 18:
  print(-1)
  exit()
print(ans)

Fixed submission:
from sys import exit
N = int(input())
A = list(map(int, input().split()))
ans = 1
A.sort(reverse=True)
if A[-1] == 0:
  print(0)
  exit()
for a in A:
  ans *= a
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
if A >= K:
  print(K)
elif A + B >= K:
  print(A)
else:
  print(A = (K - A - B))

Fixed submission:
A, B, C, K = map(int, input().split())
if A >= K:
  print(K)
elif A + B >= K:
  print(A)
else:
  print(A - (K - A - B))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Fixed submission:
s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
sum(flag)


Fixed submission:
s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy python submission (verdict: Runtime Error):
if imput() = "ABC":
  print("ADC")
else:
  print("ABC")

Fixed submission:
s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  a = map(int, input().split(" "))
  for j in a:
    flag[a - 1] = 0
print(sum(flag))

Fixed submission:
N, K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
print(sum(flag))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
flag = [for 1 in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
sum(flag)

Fixed submission:
N, K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
print(sum(flag))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
flag = [for 1 in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split()):
    flag[j-1] = 0
sum(flag)


Fixed submission:
N, K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
print(sum(flag))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
flag = [1 for i in range(M)]
height = list(map(int, input().split(" ")))
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] < height[b - 1]:
    flag[a - 1] = 0
  elif height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Fixed submission:
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
flag = [1 for i in range(M)]
height = list(map(int, input().split(" ")))
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] < height[b - 1]:
    flag[a - 1] = 0
  elif height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  else:
    flag[a - 1] = flag[b - 1] = 0
print(sum(flag))

Fixed submission:
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
height = map(int, input().split(" "))
flag = [1 for i in renge(len(height))]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
print(sum(flag))

Fixed submission:
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Runtime Error):
import intertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in intertools.conbinations_with_replacemant(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in intertools.conbinations_with_replacemant(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
print(count(set(S)))

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
print(len(set(S)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N + 1):
  print(A.count(i))

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N + 1):
  print(A.count(i))


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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N - 1)]
for i in range(1, N + 1):
  print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for a in A:
  ans[a - 1] += 1
for a in ans:
  print(a)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
K = int(input())
ans = 0
for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      ans += gcds(a, b, c)
print(ans)

Fixed submission:
from math import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
K = int(input())
ans1 = 0
ans2 = 0
ans3 = 0
for a in range(1, K + 1):
  for b in range(a, K + 1):
    for c in range(b, K + 1):
      if a == b and b == c:
        ans1 += gcds(a, b, c)
      elif a == b or b == c or c == a:
        ans2 += gcds(a, b, c)
      else:
        ans3 += gcds(a, b, c)
print(ans1 + 3 * ans2 + 6 * ans3)

Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
def gcds(numbers):
  return reduce(gcd, numbers)
K = int(input())
ans = 0
for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      ans += gcds(a, b, c)
print(ans)

Fixed submission:
from math import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
K = int(input())
ans1 = 0
ans2 = 0
ans3 = 0
for a in range(1, K + 1):
  for b in range(a, K + 1):
    for c in range(b, K + 1):
      if a == b and b == c:
        ans1 += gcds(a, b, c)
      elif a == b or b == c or c == a:
        ans2 += gcds(a, b, c)
      else:
        ans3 += gcds(a, b, c)
print(ans1 + 3 * ans2 + 6 * ans3)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = deque(sorted(list(map(int, input().split()))))
for a in A:
  if N / (4 * M) > a:
    A.pop()
  else:
    break
print("Yes" if len(A) >= M else "No")

Fixed submission:
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
all = sum(A)
L = len(A)
for a in A:
  if all / (4 * M) > a:
    L -= 1
  else:
    break
print("Yes" if L >= M else "No")
Buggy python submission (verdict: Runtime Error):
S = input()
if S[3] == S[4] and S[5]==S[6]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
if S[3] == S[2] and S[5]==S[4]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
longest = 0
for i in range(N):
  longest = max(longest, A[i + 1] - A[i])
longest = max(longest, A[0] + K - A[-1])
print(K - longest)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
longest = 0
for i in range(N - 1):
  longest = max(longest, A[i + 1] - A[i])
longest = max(longest, A[0] + K - A[-1])
print(K - longest)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
T = tuple(map(int, input().split()))
C = Counter(T)
C = C.most_common()
for t in T:
  ans = 0
  for c in C:
    if c[1] == 1:
      break
    if c[0] == t:
      ans += ((c[1] - 1) * (c[1] - 2)) // 2
    else:
      ans += (c[1] * (c[1] - 1)) // 2
  print(ans)

Fixed submission:
from collections import Counter
N = int(input())
T = tuple(map(int, input().split()))
C = Counter(T)
d = dict()
sum = 0
for c in C.most_common():
  if c[1] == 0:
    break
  if d.get(c[1]):
    sum += d[c[1]]
  else:
    x = (c[1] * (c[1] - 1)) // 2
    d[c[1]] = x
    sum += x
for t in T:
  x = C[t]
  if x >= 2:
    if d.get(x):
      minus = d[x]
    else:
      minus = (x * (x - 1)) // 2
      d[x] = minus
    if d.get(x-1):
      plus = d[x - 1]
    else:
      plus = ((x - 1) * (x - 2)) // 2
      d[x - 1] = plus
    print(sum - minus + plus)
  else:
    print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    Q = int(input())
    flag = False
    for _ in range(Q):
        A = tuple(map(str, input().split()))
        if A[0] == "1":
            flag = not(flag)
        else:
            if (A[1] == "1" and not(flag)) or (A[1] == "2" and flag):
                S = A[2] + S
            else:
                S = S + A[2]
    if flag:
        print(S[::-1])
    else:
        print(S)
if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque
def main():
    S = deque(map(str, input()))
    Q = int(input())
    flag = False
    for _ in range(Q):
        A = tuple(map(str, input().split()))
        if A[0] == "1":
            flag = not(flag)
        else:
            if (A[1] == "1" and not(flag)) or (A[1] == "2" and flag):
                S.appendleft(A[2])
            else:
                S.append(A[2])
    if flag:
        print("".join(S)[::-1])
    else:
        print("".join(S))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for _ in range(Q):
    A = list(map(str, input().split()))
    if A[0] == "1":
        S = S[::-1]
    else:
        if A[1] == "1":
            S = A[2] + S
        else:
            S = S + A[2]
print(S)

Fixed submission:
from collections import deque
def main():
    S = deque(map(str, input()))
    Q = int(input())
    flag = False
    for _ in range(Q):
        A = tuple(map(str, input().split()))
        if A[0] == "1":
            flag = not(flag)
        else:
            if (A[1] == "1" and not(flag)) or (A[1] == "2" and flag):
                S.appendleft(A[2])
            else:
                S.append(A[2])
    if flag:
        print("".join(S)[::-1])
    else:
        print("".join(S))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
L = ()
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append((L[0][0], L[1][0], L[2][0]))
L.append((L[0][1], L[1][1], L[2][1]))
L.append((L[0][2], L[1][2], L[2][2]))
L.append((L[0][0], L[1][1], L[2][2]))
L.append((L[0][2], L[1][1], L[2][0]))
N = int(input())
B = (int(input()) for i in range(N))
if any(B >= l for l in L):
  print("Yes")
else:
  print("No")

Fixed submission:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
L = []
L.append({a, b, c})
L.append({d, e, f})
L.append({g, h, i})
L.append({a, d, g})
L.append({b, e, h})
L.append({c, f, i})
L.append({a, e, i})
L.append({c, e, g})
N = int(input())
B = {int(input()) for i in range(N)}
if any(l <= B for l in L):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from sys import exit
n, m = map(int, input().split())
X = ["" for _ in range(10)]
for _ in range(m):
    c, s = map(int, input().split())
    if X[c] != "" and X[c] != str(s):
        print(-1)
        exit()
    X[c] = str(s)
flag = False
for i in range(1, 11):
    if X[-i] == "":
        if flag:
            X[-i] = "0"
    else:
        flag = True
X = int("".join(X))
print(X if 10 ** (n - 1) <= X < 10 ** n else - 1)

Fixed submission:
from sys import exit
N, M = map(int, input().split())
ans = ["a" for i in range(N)]
if M == 0:
  print(10 ** (N - 1) if N > 1 else 0)
  exit()
for i in range(M):
  s, c = map(int, input().split())
  if ans[s - 1] == "a":
    ans[s - 1] = str(c)
  elif ans[s - 1] != str(c):
    print(-1)
    exit()
if ans[0] == "a":
  ans[0] = "1"
if ans[0] == "0":
  if N != 1:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = [a.replace("a", "0") for a in ans]
ans = int("".join(ans))
print(ans if 10 ** N > ans >= 10 ** (N - 1) else -1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int, input().split()))
sum = 1000000 ** 10000000
for i in range(1, 101):
  tmp = 0
  for x in X:
    tmp += (x - i) ** 2
  if tmp < sum:
    sum = tmp
    ans = i
print(ans)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
sum = 1000000
for i in range(1, 101):
  tmp = 0
  for x in X:
    tmp += (x - i) ** 2
  sum = min(sum, tmp)
print(sum)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = counter([input() for i in range(N)])
most = S.most_common()[0][1]
ans = []
for name num in S.items:
  if num != most:
    break
  ans.append(name)
ans.sort()
for a in ans:
  print(a)

Fixed submission:
from collections import Counter
N = int(input())
S = Counter([input() for i in range(N)])
most = S.most_common()[0][1]
ans = []
for name, num in S.items():
  if num != most:
    continue
  ans.append(name)
ans.sort()
for a in ans:
  print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(N - K + 1):
  ans = max(sum(P[i:i + K]), ans)
print((ans + K) / 2)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = tuple(map(int, input().split()))
ans = 0
for i in range(N - K + 1):
  ans = max(sum(P[i:i + K]), ans)
print((ans + K) / 2)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(N - K + 1):
  ans = max(sum(P[i:i + K]), ans)
print((ans + K) / 2)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(len(P) - K):
  ans = max(sum(P[i:i + K - 1], ans))
print((ans + K) / 2)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
INF = 10 ** 9
dp = [INF for _ in range(2*10**4)]
AB = [tuple(map(int, input().split())) for _ in range(n)]
dp[0] = 0
for a, b in AB:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

Fixed submission:
def main():
    h, n = map(int, input().split())
    INF = 10 ** 9
    dp = [INF for _ in range(2*10**4)]
    AB = [tuple(map(int, input().split())) for _ in range(n)]
    dp[0] = 0
    for a, b in AB:
        for i in range(h):
            dp[i + a] = min(dp[i + a], dp[i] + b)
    print(min(dp[h:]))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
ans = 1
for i in range(1, N):
  flag = 0
  for j in range(i):
    if P[j] < P[i]:
      flag += 1
      break
  if flag == 0:
    ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 0
minimum = 200001
for p in P:
  if p <= minimum:
    minimum = p
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [S if i <= K - 1 else 1 for i in range(N)]
print(" ".join(ans))

Fixed submission:
N, K, S = map(int, input().split())
U = str(S + 1) if S != 10 ** 9 else "1"
S = str(S)
ans = [S if i <= K - 1 else U for i in range(N)]
print(" ".join(ans))

Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [S for i in range(N) if i =< K - 1 else 0]
print(" ".join(ans))

Fixed submission:
N, K, S = map(int, input().split())
U = str(S + 1) if S != 10 ** 9 else "1"
S = str(S)
ans = [S if i <= K - 1 else U for i in range(N)]
print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B / gcd(A, B))


Fixed submission:
import fractions
A, B = map(int, input().split())
print(int(A * B / fractions.gcd(A, B)))

Buggy python submission (verdict: Runtime Error):
from math import gcd
A, B = map(int, input().split())
print(A * B / gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print(int(A * B / fractions.gcd(A, B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
broken = 0
flag = [0, 0]
for i in range(1,N + 1):
  if flag[1] != 0:
    break
  for j in len(A):
    if A[j] == i:
      if len(A) != 1:
      	A = A[j + 1:]
      else:
        A = []
        flag[0] += 1
      break
    else:
      broken += 1
    if len(A) == i + 1:
      flag[1] += 1
if broken == 0 and flag[0] != 1:
  print(-1)
else:
  print(broken)

Fixed submission:
from collections import deque
N = int(input())
A = deque(map(int, input().split()))
num = 1
ans = 0
while A:
  a = A.popleft()
  if a == num:
    num += 1
  else:
    ans += 1
print(-1 if num == 1 else ans)