Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

l = ""
r = ""
for i in range(N):
    if l == "" and A[i] < 0: l = i
    if A[i] < 0:r = i
if (r-l+1) % 2 == 0 or (l == 0 and r == N-1):
    print(sum([abs(x) for x in A]))
else:
    a = [abs(x) for x in A]
    print(sum(a) - min(a)*2)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
m = 10 ** 9 #絶対値の最小
c = 0 #マイナスの数
for i in range(N):
  ans += abs(A[i])
  if m > abs(A[i]):
    m = abs(A[i])
  if A[i] < 0: c += 1
print(ans if c % 2 == 0 else ans - 2 * m)
Buggy python submission (verdict: Runtime Error):
b = input()
x = ["A", "C"]
y = ["T", "G"]
print(y[x.index(b)])

Fixed submission:
b = input()

if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
S = input()
l = []
a = ["A", "C", "G", "T"]
n = 0
for i in S:
  if i in a:
    n += 1
  else:
    l.append(n)
    n = 0
print(max(l))

Fixed submission:
S = input()
a = ["A", "C", "G", "T"]
ans = 0
count = 0
for i in S:
  if i in a:
    count += 1
  elif ans < count:
    ans = count
    count = 0

if count != 0:
  if ans < count:
    ans = count

print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
n,q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

numbers = []
for i in range(n-1):
    if s[i]+s[i+1] == "AC":
        numbers.append(i+1)
for l,r in lr:
    x,y = bisect_left(numbers, l), bisect_right(numbers, r)
    if numbers[y-1]+1 <= r:print(y-x)
    else: print(y-x-1)

Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0] * N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i] + 1)
    else:
        ans[i+1] = ans[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

I = [i+1 for i in range(n) if i+2 < n and s[i:i+2] == "AC"]

for l,r in lr:
  cnt = 0
  for i in I:
    if l<=i<=r and l<=i+1<=r: cnt += 1
  print(cnt)

Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0] * N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i] + 1)
    else:
        ans[i+1] = ans[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

for l,r in lr:
  S = s[l-1:r]
  print(S.count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0] * N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i] + 1)
    else:
        ans[i+1] = ans[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

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

for l, r in lr:
    a = S[l-1:r]
    print(a.count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0] * N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i] + 1)
    else:
        ans[i+1] = ans[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

a = b = 0
for i in range(N):
  if i % 2 == 0:
    AB.sort(key=lambda x:x[1])
    a += AB[-1][0]
  else:
    AB.sort()
    b += AB[-1][1]
  AB[-1] = [0, 0]
print(a-b)

Fixed submission:
import numpy as np
n = int(input())
A,B = np.array([input().split() for _ in range(n)], dtype=np.int64).T

ans = A.sum() #全部先手が取る
improve = A+B #後手がとると改善する量
improve.sort()
ans -= improve[::-1][1::2].sum()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

a = b = 0
for i in range(N):
  if i % 2 == 0: #高橋くんの番
    x, y = A, B
  else:#青木さんの番
    x, y = B, A
  indexes = [i for i, j in enumerate(y) if j == max(y)] #yの最大値のインデックスすべて
  l = len(indexes)
  m = 0
  ind = 0
  for j in indexes: #このうちxで最大値を取るインデックス
    if x[j] > m:
      m = x[j]
      ind = j
  if i % 2 == 0: a += x[ind]
  else: b += x[ind]
  x[ind] = y[ind] = 0
print(a-b)

Fixed submission:
import numpy as np
n = int(input())
A,B = np.array([input().split() for _ in range(n)], dtype=np.int64).T

ans = A.sum() #全部先手が取る
improve = A+B #後手がとると改善する量
improve.sort()
ans -= improve[::-1][1::2].sum()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
py = sorted(PY)

ans = [""] * m
b = ""
cnt = 1
for p,y in py:
  if b == p: cnt += 1
  else:
    b = p
    cnt = 1
  a = [str(p), str(cnt)]
  if len(str(p)) < 6: a[0] = "0"*(6-len(str(p))) + str(p)
  if len(str(cnt)) < 6: a[1] = "0"*(6-len(str(cnt))) + str(cnt)
  i = PY.index([p, y])
  ans[i] = a[0] + a[1]
for v in ans: print(v)

Fixed submission:
n,m = map(int, input().split())
pyi = [list(map(int, input().split())) + [i] for i in range(m)]
pyi.sort()

pnow = pyi[0][0]
cnt = 1

ans = [-1 for _ in range(m)]

for p,y,i in pyi:
  if pnow != p:
    cnt = 1
    pnow = p
  ans[i] = str(p).zfill(6) + str(cnt).zfill(6)
  cnt += 1
print("\n".join(ans))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int, input().split())
s = input()
t = input()
# Xの長さLはnとmで割り切れる
# Xの1, L/n + 1, ..., (n-1) * L/n + 1 番目の文字をつなげるとSになる
# Xの1, L/m + 1, ..., (m-1) * L/m + 1 番目の文字をつなげるとTになる

ans = [""] * (n*m//gcd(n,m))
N,M = 1,1
for i in range(len(ans)):
    if i == 0: 
        if s[i] != t[i]:
            print(-1)
            exit()
        ans[0] = s[i]
    else:
        if i % (len(ans)//n) == 0: 
            ans[i] = s[N]
            N += 1
        if i % (len(ans)//m) == 0:
            if ans[i] == "" or ans[i] == t[M]:
                ans[i] = t[M]
                M += 1
            else:
                print(-1)
                exit()
print(n*m//gcd(n,m))

Fixed submission:
from fractions import gcd
n,m = map(int, input().split())
s = input()
t = input()
# Xの長さLはnとmで割り切れる
# Xの1, L/n + 1, ..., (n-1) * L/n + 1 番目の文字をつなげるとSになる
# Xの1, L/m + 1, ..., (m-1) * L/m + 1 番目の文字をつなげるとTになる

ans = -1
if n==m:
    if s==t: ans= n
else:
    gcd_nm = gcd(n,m)
    for i in range(gcd_nm):
        if s[n//gcd_nm*i] != t[m//gcd_nm*i]: break
    else: ans = n*m//gcd_nm
print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy
n,m = map(int, input().split())

N = sympy.divisors(m)

for i in range(len(N)):
    if N[i] <= m/n:
        print(N[i])
        break

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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.append(i)
      if i != n//i:
        divisors.append(n//i)
  divisors.sort(reverse=True)
  return divisors

numbers = make_divisors(m)
for i in range(len(numbers)):
  if numbers[i] <= m/n:
    print(numbers[i])
    break
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(N):
 ans.append(abs(X- x[i]))
print(np.gcd.reduce(ans))

Fixed submission:
import math
import fractions
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(N):
 ans.append(abs(X- x[i]))
ans = tuple(ans)

print(reduce(fractions.gcd, ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 8 * K
for i in range(N-K+1):
  for j in range(i+(K-1), N):
    a = min(abs(x[i]), abs(x[j])) + abs(x[i] - x[j])
    if ans > a:ans = a
print(ans)

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

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 8 * K
for i in range(N-K+1):
  for j in range(i+(K-1), N):
    a = abs(x[i]) + abs(x[i] - x[j])
    b = abs(x[j]) + abs(x[i] - x[j])
    if min(a, b) < ans:
      ans = min(a, b)
print(ans)

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

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 8 * K
for v in itertools.combinations(x, K):
  a = abs(v[0]) + abs(v[-1] - v[0])
  b = abs(v[-1]) + abs(v[-1] - v[0])
  if min(a, b) < ans:
    ans = min(a, b)
print(ans)

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

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 8 * K
for v in itertools.permutations(x, K):
  v = list(v)
  v.sort()
  a = abs(v[0]) + abs(v[-1] - v[0])
  b = abs(v[-1]) + abs(v[-1] - v[0])
  if min(a, b) < ans:
    ans = min(a, b)
print(ans)

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

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
count = 0
n = 0
l = []

for i in range(10):
  n += count + 1
  count += 1
  if n > min(a, b):
    l.append(n-min(a,b))
  if n > max(a, b) and n-max(a,b) in l:
    N = n-max(a,b)
    break
if len(l) == 1:
  print(1)
else:
  print(N)

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

ans = round((b - a) * (b - a + 1) / 2 - b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = []
for x in range(2,n//2+1):
    y = n-x
    X = sum(list(map(int, list((str(x))))))
    Y = sum(list(map(int, list((str(y))))))
    ans.append(X+Y)
print(min(ans))

Fixed submission:
n = int(input())
N = n//2
ans = float("INF")
for i in range(1,N+1):
  a,b = list(str(i)), list(str(n-i))
  A,B = sum(list(map(int, a))), sum(list(map(int, b)))
  if ans > A+B: ans = A+B
print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
ans = [1]
b = 2
p = 2
while b**p < x:
  while b**p<x:
    ans.append(b**p)
    p += 1
  b += 1
  p = 2
print(ans[-1] if ans[-1]<x else ans[-2])

Fixed submission:
X = int(input())
l = [1]
for i in range(2,32):
  p = 2
  while i ** p <= 1000:
   l.append(i ** p)
   p += 1

while not X in l:
  X -= 1

print(X)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
ans = []
for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    ans.append(s[i:j])
ans = sorted(list(set(ans)))
print(ans[k-1])

Fixed submission:
s = input()
k = int(input())
ans = []
for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    if j-i > k:break
    ans.append(s[i:j])
ans = sorted(list(set(ans)))
print(ans[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
s = input()
k = int(input())
ans = [[] for _ in range(k)]
x = list(set(s))
cnt = 0
for i in range(1,k+1):
    for v in itertools.product(x, repeat=i):
        y = "".join(v)
        if y in s and y not in ans[i-1]: 
            ans[i-1].append(y)
ans = list(itertools.chain.from_iterable(ans))
ans.sort()
print(ans[k-1])

Fixed submission:
s = input()
k = int(input())
word = []
for i in range(len(s)):
  for j in range(i+1, i+k+1):
    word.append(s[i:j])
word = sorted(list(set(word)))
print(word[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
word = []
for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    word.append(s[i:j])
word = sorted(list(set(word)))
print(word[k-1])

Fixed submission:
s = input()
k = int(input())
word = []
for i in range(len(s)):
  for j in range(i+1, i+k+1):
    word.append(s[i:j])
word = sorted(list(set(word)))
print(word[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])
ans = 0
for i in range(n):
  x = [j for j in A[i+1:] if j==A[i]]
  if len(x) > 0: ans += len(x)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])
A = Counter(A)
ans = 0
for x,y in A.items():
  if y >= 2: ans += (y-1)*y//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])

ans = A[1:].count(0)
for i in range(1, n-1):
  for j in range(i+1, n):
    if A[i]-A[i-1] + A[j]-A[i] == 0: ans += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])
A = Counter(A)
ans = 0
for x,y in A.items():
  if y >= 2: ans += (y-1)*y//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
X = sorted(x)

for i in x:
    I = X.index(i)
    l,r = I, n-I
    if I+1 <= n//2:
       print(X[I+n//2-l])
    else:
        print(X[n//2-1])

Fixed submission:
import statistics
n = int(input())-1
a = list(map(int, input().split()))
N = sorted([[x,y] for y, x in enumerate(a)])

ans = [0] * (n+1)
for i in range(n+1):
    if i < n//2+1: 
        ans[N[i][1]] = N[n//2+1][0]
    else: ans[N[i][1]] = N[n//2][0]
for x in ans: print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import statistics
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    print(statistics.median(x[:i]+x[i+1:]))

Fixed submission:
import statistics
n = int(input())-1
a = list(map(int, input().split()))
N = sorted([[x,y] for y, x in enumerate(a)])

ans = [0] * (n+1)
for i in range(n+1):
    if i < n//2+1: 
        ans[N[i][1]] = N[n//2+1][0]
    else: ans[N[i][1]] = N[n//2][0]
for x in ans: print(x)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

Fixed submission:
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A = list(map(int, input().split()))
A.sort()
ans = 0
while A[0] not in A[1:]:
  A[0] += 2
  ans += 1

if A[0] == A[1]:
  while A[1] != A[2]:
    A[1] += 1
    ans += 1
else:
  A.sort()
  while A[0] < max(A):
    A[0] += 2
    ans += 1
  A.sort()
  if A[0] == A[1]:
    while A[1] != A[2]:
      A[1] += 1
      ans += 1
print(ans)

Fixed submission:
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [0] * 5
for _ in range(N):
  s = input()
  if s[0] == "M": S[0] += 1
  elif s[0] == "A": S[1] += 1
  elif s[0] == "R": S[2] += 1
  elif s[0] == "C": S[3] += 1
  elif s[0] == "H": S[4] += 1

ans = 0
for x in range(3):
  for y in range(x+1, N-1):
    for z in range(y+1, N):
      ans += S[x] * S[y] * S[z]
print(ans)

Fixed submission:
N = int(input())
m = a = r = c = h = 0
for _ in range(N):
  s_in = input()
  if s_in[0] == "M": m += 1
  elif s_in[0] == "A": a += 1
  elif s_in[0] == "R": r+= 1
  elif s_in[0] == "C": c += 1
  elif s_in[0] == "H": h += 1

all_l = [m, a, r, c, h]
ans = 0
import itertools
for v in itertools.combinations(all_l, 3):
  if v[0] * v[1] * v[2] > 0:
    ans += v[0] * v[1] * v[2]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
ans = [sum(map(int, s)), 9*(len(s)-1) + int(s[0]-1)]
print(max(ans))

Fixed submission:
s = list(input())
ans = [sum(map(int, s)), 9 * (len(s) - 1) + int(s[0]) - 1]
print(max(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [2, 1]
if N > 2:
  for i in range(N - 1):
    L.append(L[i]+L[i+1])
print(L[N])

Fixed submission:
N = int(input())
L = [2, 1]
if N >= 2:
  for i in range(N-1):
    L.append(L[i]+L[i+1])
print(L[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for _ in range(3):
  a = list(map(int, input().split()))
  a.sort()
  A.append(a)

ans = 0
for b in A[1]:
  a = sum(x<b for x in A[0])
  c = sum(x>b for x in A[2])
  ans += a * c
print(ans)

Fixed submission:
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
C.sort()

ans = 0
for i in range(N):
  b = B[i]
  a = bisect.bisect_left(A, b)
  c = N - bisect.bisect_right(C, b)
  ans += a * c
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

ans = "YES"
for t in T:
    if t not in d: 
        ans = "NO"
        break
    d.pop(d.index(t))
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d = Counter(sorted(d))
cnt = 0
for i in range(m):
    if t[i] in d and d[t[i]] > 0:
        d[t[i]] -= 1
        cnt += 1
    else: break
print("YES" if cnt == m else "NO")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

for i in range(m):
    if t[i] not in d:
        break
    else:
        d.pop(d.index(t[i]))
print("YES" if len(d) == n-m else "NO")

Fixed submission:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d = Counter(sorted(d))
cnt = 0
for i in range(m):
    if t[i] in d and d[t[i]] > 0:
        d[t[i]] -= 1
        cnt += 1
    else: break
print("YES" if cnt == m else "NO")
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
ans = "No"
if k%(m-1)==0 and k//(m-1) > 1:
  if k//(m-1) <= n: ans = "Yes"
if k%(n-1)== 0 and k//(n-1) > 1:
  if k//(n-1) <= m: ans = "Yes"
print(ans)

Fixed submission:
n,m,k = map(int, input().split())

for i in range(n+1):
  for j in range(m+1):
    if i*(m-j)+j*(n-i)==k:
      print("Yes")
      exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a_m1 = list(map(lambda x: x-1, a))
a_p1 = list(map(lambda x:x+1, a))

ans = 0
for i in range(N):
  n = a[i]
  A = a.count(n) + a_m1.count(n) + a_p1.count(n)
  if ans < A:
    ans = A
print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)

counter = np.bincount(A)
B = counter.copy()
B[1:] += counter[:-1]
B[:-1] += counter[1:]

ans = B.max()
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N):
  if p[i] - 1 == i:
    a = p[i]
    b = p[i + 1]
    p[i] = b
    p[i + 1] = a
    ans += 1
print(ans)

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

ans = 0
for i in range(N):
  if p[i] - 1 == i:
    ans += 1
    if i != N - 1:
      a = p[i]
      b = p[i + 1]
      p[i] = b
      p[i + 1] = a
print(ans)
Buggy python submission (verdict: Runtime Error):
s = sorted(set(input()))
x = [chr(i) for i in range(ord("a"), ord("z")+1)]
for i in range(len(x)):
    if x[i] != s[i]:
        print(x[i])
        exit()
print("None")

Fixed submission:
S = input()
l = sorted(list(set(S)))

ans = ""
for i in range(len(l)):
  if ord(l[i]) !=  97 + i:
    ans = chr(97+i)
    break
  elif i == 25 and l[i] == "z":
    ans = "None"

if ans != "":
 print(ans)
else:
  print(chr(ord(l[-1])+1))

Buggy python submission (verdict: Runtime Error):
S = input()
l = sorted(list(set(S)))

ans ="None"
number = [96]
for i in range(len(S)):
  if ord(l[i]) ==  number[-1] + 1:
    number.append(ord(l[i]))
  else:
    ans = chr(number[-1]+1)
    break

print(ans)

Fixed submission:
S = input()
l = sorted(list(set(S)))

ans = ""
for i in range(len(l)):
  if ord(l[i]) !=  97 + i:
    ans = chr(97+i)
    break
  elif i == 25 and l[i] == "z":
    ans = "None"

if ans != "":
 print(ans)
else:
  print(chr(ord(l[-1])+1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

a = list(set(A))
ans = []
for i in range(len(a)):
  if A.count(a[i]) < 2:
    continue
  if A.count(a[i]) >= 4:
    ans += [a[i] , a[i]]
  else:
    ans.append(a[i])
ans.sort()
print(ans[-1]* ans[-2] if len(ans) >= 2 else 0)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = []
s = A[0]
n = 1
for i in range(1, N):
  if len(ans) == 2: break
  if A[i] == s:
    n += 1
    if n == 2 or n == 4:
      ans.append(s)
  else:
    s = A[i]
    n = 1
print(ans[0] * ans[1] if len(ans) != 0 else 0)