Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int(input().split()))
if a == b:
  print(a + b)
else:
  print(max(a, b) * 2 - 1)

Fixed submission:
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 文字列の入力
s = [2*a-1, 2*b-1, a+b]
# 出力
print("{}".format(max(s)))
Buggy python submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [0] * (K * K)
for itra, a in enumerate(A):
  if itra >= K:
    break
  for itrb, b in enumerate(B):
    AB[itra * K + itrb] = (a + b)
    if itrb >= K - 1:
      break
    
AB.sort(reverse=True)    
    
ABC = [0] * (K * K)
for itrab, ab in enumerate(AB):
  if itrab >= K:
    break
  for itrc, c in enumerate(C):
    ABC[itrab * K + itrc] = (ab + c)
    if itrc >= K - 1:
      break
    
ABC.sort(reverse=True)
for itr, i in enumerate(ABC):
  print(i)
  if itr >= K - 1:
    break


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  ans = 'Yay!'
else:
  ans = ':('
print(ans)
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)]

# print(N, Q)
# print(S)
# print(lr)

for i in lr:
  print(S[i[0]-1:i[1]].count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int, input())
print(min(C,B//A))

Fixed submission:
A,B,C = map(int, input().split())
print(min(C,B//A))
Buggy python submission (verdict: Runtime Error):
A,B =map(int, input())
if B % A == 0:
  print(A+B)
else:
  print(B-A)

Fixed submission:
A,B =map(int, input().split())
if B % A == 0:
  print(A+B)
else:
  print(B-A)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
  print(0)
else:
  X.sort()
  D = []
  for i in range(len(X)-1):
    D.append(abs(X[i] - X[i+1]))
    D.sort()
  print(sum(D[0:M-N]))

Fixed submission:
import numpy as np

N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
  print(0)
else:
  X.sort()
  npX = np.array(X)
  D = npX[1:] - npX[:-1]
  D.sort()
  print(sum(D[0:M-N]))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 各桁について、"1"の数が n // 2 以下だったら "1"、 そうでなければ "0"

from math import log2
num = int(log2(k))
box = [0] * (num + 1)
for i in a:
  l = bin(i)[2:][::-1]
  for itr, val in enumerate(l):
    box[itr] += int(val)

X = 0
for itr, val in enumerate(box[::-1]):
  if val <= n // 2 and X + 2 ** (num - itr) <= k:
    X += 2 ** (num - itr)

ans = 0
for i in a:
  ans += X ^ i
  
print(ans)
    

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

# 各桁について、"1"の数が n // 2 以下だったら "1"、 そうでなければ "0"

from math import log2
num = int(log2(10**12) + 1)
box = [0] * (num + 1)
for i in a:
  l = bin(i)[2:][::-1]
  for itr, val in enumerate(l):
    box[itr] += int(val)

X = 0
for itr, val in enumerate(box[::-1]):
  if val <= n // 2 and X + 2 ** (num - itr) <= k:
    X += 2 ** (num - itr)

ans = 0
for i in a:
  ans += X ^ i
  
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b , c = map(int(input().split()))
ans = a * b // 2
print(ans)

Fixed submission:
e = list(map(int, input().split()))
e.sort()
print(int(e[0]*e[1]*(1/2)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
import itertools
hoges = {}
for i in itertools.combinations(xy, 2):
    if i[0][0] - i[1][0] >= 0:
        hoge = (i[0][0] - i[1][0], i[0][1] - i[1][1])
    else:
        hoge = (i[1][0] - i[0][0], i[1][1] - i[0][1])
    hoges.setdefault(hoge, 0)
    hoges[hoge] += 1
# print(hoges)
max_v = max(hoges.values())
print(N - max_v)

Fixed submission:
def fn(n):
  if n % 2 == 0:
    return n/2
  else:
    return 3*n + 1

s = int(input())
  
al = []
al.append(s)
cnum = s
for i in range(2,1000000):
  cnum = fn(cnum)
  if cnum in al[:-1]:
    print(i)
    exit()
  else:
    al.append(cnum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a-b for a,b in zip(A, B)]
orderdiff = sorted(diff, reverse=True)

# 浮いている分からマイナスを補填、何個使ったかを管理するためのリスト
plsdiffcnt = []
for i in orderdiff:
  if i > 0:
    plsdiffcnt.append(i + sum(plsdiffcnt))

#マイナス値の合計とその個数を取得
mnscnt = 0
mnssum = 0
for i in diff:
  if i < 0:
    mnscnt += 1
    mnssum -= i
    
if all([i >= 0 for i in diff]):
  print(0)
  exit()
    
if sum(diff) < 0:
  print(-1)
  exit()
     
for i, v in enumerate(plsdiffcnt):
  if mnssum <= v:
    ans = i + 1
    break
print(mnscnt+ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a-b for a,b in zip(A, B)]
orderdiff = sorted(diff, reverse=True)

# 浮いている分からマイナスを補填、何個使ったかを管理するためのリスト
plsdiffcnt = [0] * (N + 1)
plsdiffcnt[0] = orderdiff[0]
for i in range(len(orderdiff)-1):
  if orderdiff[i] > 0:
    plsdiffcnt[i+1] = plsdiffcnt[i] + orderdiff[i+1]

#マイナス値の合計とその個数を取得
mnscnt = 0
mnssum = 0
for i in diff:
  if i < 0:
    mnscnt += 1
    mnssum -= i
    
if all([i >= 0 for i in diff]):
  print(0)
  exit()
    
if sum(diff) < 0:
  print(-1)
  exit()
     
for i, v in enumerate(plsdiffcnt):
  if mnssum <= v:
    ans = i + 1
    break
print(mnscnt+ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
H = list(map(int, input().split()))

dp = [10 ** 12] * (n)
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(1, n-1):
  dp[i+1] = min([dp[i-j] + abs(H[i+1] - H[i-j]) for j in range(min(k, i+1))])
  
ans = dp[n-1]

print(ans)

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

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(1, n):
  dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, k + 1) if i - j >= 0)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
  dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, k + 1) if i - j >= 0)
print(dp[-1])

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

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(1, n):
  dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, k + 1) if i - j >= 0)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
  for j in range(w + 1):
    if j + wv[i][0] <= w:
      dp[i + 1][j + wv[i][0]] = max(dp[i + 1][j + wv[i][0]], dp[i][j] + wv[i][1])
    dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
print(max(dp[-1]))

Fixed submission:
N, W = [int(i) for i in input().split()]
WV = [[int(i) for i in input().split()] for j in range(N)]

import numpy as np
max_value = np.sum(np.array(WV), axis=0)[1]

# dp[v]: 価値vを達成するのに必要な重さの最小値
dp = np.full(max_value + 1, W + 1, dtype='int64')

dp[0] = 0
for w, v in WV:
    # 価値i(0 <= i <= max_value - v)のときの重さの最小値に対し
    # 次の荷物を入れて、価値i+vのときの重さの最小値を更新
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

V_MAX = 10 ** 5 + 1
INF = 10 **18

dp = [[INF] * (V_MAX) for _ in range(n + 1)]
for i in range(n):
  for j in range(V_MAX):
    if wv[i][1] > j:
      dp[i + 1][j + wv[i][1]] = min(dp[i + 1][j + wv[i][0]], dp[i][j] + wv[i][0])
    dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
print(min([i for i, v in enumerate(dp[-1]) if v <= w]))
      

Fixed submission:
N, W = [int(i) for i in input().split()]
WV = [[int(i) for i in input().split()] for j in range(N)]

import numpy as np
max_value = np.sum(np.array(WV), axis=0)[1]

# dp[v]: 価値vを達成するのに必要な重さの最小値
dp = np.full(max_value + 1, W + 1, dtype='int64')

dp[0] = 0
for w, v in WV:
    # 価値i(0 <= i <= max_value - v)のときの重さの最小値に対し
    # 次の荷物を入れて、価値i+vのときの重さの最小値を更新
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
  for j in range(w + 1):
    if j + wv[i][0] <= w:
      dp[i + 1][j + wv[i][0]] = max(dp[i + 1][j + wv[i][0]], dp[i][j] + wv[i][1])
    dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
print(max(dp[-1]))
      

Fixed submission:
N, W = [int(i) for i in input().split()]
WV = [[int(i) for i in input().split()] for j in range(N)]

import numpy as np
max_value = np.sum(np.array(WV), axis=0)[1]

# dp[v]: 価値vを達成するのに必要な重さの最小値
dp = np.full(max_value + 1, W + 1, dtype='int64')

dp[0] = 0
for w, v in WV:
    # 価値i(0 <= i <= max_value - v)のときの重さの最小値に対し
    # 次の荷物を入れて、価値i+vのときの重さの最小値を更新
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(np.max(np.where(dp <= W)))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

dp = [[0] * (len(s) + 1) for _ in range(len(t) + 1)]

for i in range(1, len(s) + 1):
  for j in range(1, len(t) + 1):
    if s[i-1] == t[j-1]:
      dp[j][i] = max(dp[j][i-1], dp[j-1][i], dp[j-1][i-1] + 1)
    else:
      dp[j][i] = max(dp[j][i-1], dp[j-1][i], dp[j-1][i-1])


ans = ""
x = len(s)
y = len(t)
d = dp[-1][-1]
while True:
  if d == 0:
    break
  if dp[y - 1][x] == d:
    y -= 1
  elif dp[y][x - 1] == d:
    x -= 1
  else:
    ans += t[y - 1]
    x -= 1
    y -= 1
    d -= 1
print(ans[::-1])

Fixed submission:
s = input()
t = input()

dp = [[0] * (len(s) + 1) for _ in range(len(t) + 1)]

for i in range(1, len(s) + 1):
  for j in range(1, len(t) + 1):
    if s[i-1] == t[j-1]:
      dp[j][i] = max(dp[j][i-1], dp[j-1][i], dp[j-1][i-1] + 1)
    else:
      dp[j][i] = max(dp[j][i-1], dp[j-1][i], dp[j-1][i-1])

ans = ""
x = len(s)
y = len(t)
d = dp[-1][-1]
while True:
  if d == 0:
    break
  if dp[y - 1][x] == d:
    y -= 1
  elif dp[y][x - 1] == d:
    x -= 1
  else:
    ans += t[y - 1]
    x -= 1
    y -= 1
    d -= 1
print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = list(map(float, input().split()))

#dp[i][j] i枚投げた時にj枚表の確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
  for j in range(i + 1):
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1 - P[i])
    
ans = sum([dp[n][j] for j in range(n + 1) if j * 2 > n])
      
print(ans)


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

#dp[i][j] i枚投げた時にj枚表の確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
  for j in range(i + 1):
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1 - P[i])
    
ans = sum([dp[n][j] for j in range(n + 1) if j * 2 > n])
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k  = map(int, input().split())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

# dp[i][j] i人目までの子供にj個のアメを配る数
dp = [[0] * (ｋ + 1) for _ in range(n + 1)]

for i in range(n + 1):
  dp[i][0] = 1
  
for i in range(1, n + 1):
  for j in range(1, k + 1):
    if j-1-A[i-1] >= 0:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1-A[i-1]]) % MOD
    else:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD

ans = dp[n][k]
print(ans)


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

MOD = 10 ** 9 + 7

# dp[i][j] i人目までの子供にj個のアメを配る数
dp = [[0] * (ｋ + 1) for _ in range(n + 1)]

for i in range(n + 1):
  dp[i][0] = 1
  
for i in range(1, n + 1):
  for j in range(1, k + 1):
    if j-1-A[i-1] >= 0:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1-A[i-1]]) % MOD
    else:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD

ans = dp[n][k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
dp = [[0] * (N + 1) for _ in range(N+ 1)]

accum = [0] * (N + 1)
for i in range(N):
    accum[i + 1] = accum[i] + A[i]

for m in range(1, N+1):
    for l in range(N):
        if m == 1:
            dp[l][l + m] = 0
        else:
            if l + m < N + 1:
                r = l + m
                dp[l][r] = min([dp[l][l+k] + dp[l+k][r] for k in range(1, m)]) + accum[r] - accum[l]

print(dp[0][N])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
dp = [[0] * (N + 1) for _ in range(N+ 1)]

accum = [0] * (N + 1)
for i in range(N):
    accum[i + 1] = accum[i] + A[i]

for m in range(1, N+1):
    for l in range(N):
        if m == 1:
            dp[l][l + m] = 0
        else:
            if l + m < N + 1:
                r = l + m
                dp[l][r] = min([dp[l][l+k] + dp[l+k][r] for k in range(1, m)]) + accum[r] - accum[l]

print(dp[0][N])
Buggy python submission (verdict: Time Limit Exceeded):
from math import log
n = int(input())
A = list(map(int, input().split()))
num = {}
for a in A:
	if a in num:
		num[a] += 1
	else:
		num[a] = 1

ans = 0
cnt = int(log(max(A), 2)) + 5 
for i in range(cnt, 0, -1):
	b = {}
	for x in num:
		if 2 ** i - x in b:
			b[2 ** i - x] += 1
		else:
			b[2 ** i - x] = 1
	for x in num:
		if x in b and num[x] > 0:
			if x * 2 == 2 ** i:
				ans += num[x] // 2
				num[x] %= 2
			else:
				small = min(num[x], num[2 ** i - x])
				ans += small
				num[x] -= small
				num[2 ** i - x] -= small
print(ans)


Fixed submission:
from math import log
n = int(input())
A = list(map(int, input().split()))
num = {}
for a in A:
	if a in num:
		num[a] += 1
	else:
		num[a] = 1

ans = 0
cnt = int(log(max(A), 2)) + 5 
for i in range(cnt, 0, -1):
	b = {}
	for x in num:
		if 2 ** i - x in b:
			b[2 ** i - x] += 1
		else:
			b[2 ** i - x] = 1
	for x in num:
		if x in b and num[x] > 0:
			if x * 2 == 2 ** i:
				ans += num[x] // 2
				num[x] %= 2
			else:
				small = min(num[x], num[2 ** i - x])
				ans += small
				num[x] -= small
				num[2 ** i - x] -= small
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
for i, v in enumerate(s):
  if v != "1":
    pos1 = i
    break
  
if k < pos1 + 1:
  print(1)
else:
  print(s[pos1])


Fixed submission:
s = input()
k = int(input())

pos1 = len(s)
for i, v in enumerate(s):
  if v != "1":
    pos1 = i
    break
  
if k < pos1 + 1:
  print(1)
else:
  print(s[pos1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(0, 101):
  for j in range(0, 101):
    if i * 4 + j * 7 = N:
      print("Yes")
      exit()
print("No")

Fixed submission:
N = int(input())
for i in range(0, 101):
  for j in range(0, 101):
    if i * 4 + j * 7 == N:
      print("Yes")
      exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n, m, d = map(int,input().split())
if d == 0:
  print(1/n)
else:
  print((2*(n-d))**(m-1)/(n**2))


Fixed submission:
n, m, d = map(int,input().split())
if d == 0:
  print((m-1)/n)
else:
  print((2*(n-d))*(m-1)/(n**2))
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
S = input()

ans = 0
for i in range(1, N):
  l = S[:i]
  r = S[i:]
  lc = collections.Counter(l)
  rc = collections.Counter(r)
  ans = max(ans, lc, rc)

print(ans)


Fixed submission:
from collections import Counter
n = input()
s = input()
ans = 0
for i in range(len(s)):
  l = s[:i]
  r = s[i:]
  cnt = 0
  cl = Counter(l)
  for i in cl.keys():
    if i in r:
      cnt += 1
  if ans < cnt:
    ans = cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
 
def hoge(x, p):
  return int((math.floor(x**(1/p)))**p)
 
x = int(input())
 
max_bp = 0
for b in range(2, x):
  for p in range(2, x):
    bp = b ** p
    if bp > x:
      break
    max_bp = max(max_bp, bp)

print(max_bp)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
drc = [[0,1],[0,-1],[1,0],[-1,0]]
for i in range(h):
  for j in range(w):
    if S[i][j] == "#":
      if all([S[i+x][j+y] =="." for x, y in drc if 0 <= i+x < w and 0 <= j+y < h]):
        print("No")
        exit()
print("Yes")

Fixed submission:
import numpy as np

h, w = map(int,input().split())
hw = [input() for i in range(h)]

isPaintable = [[1]*w for _ in range(h)]

predList = [[0,1],[0,-1],[1,0],[-1,0]]

for i in range(h):
  for j in range(w):
    if hw[i][j] == "#":
      for x, y in predList:
        if i+y in range(h) and j+x in range(w):
#          print(hw[i][j],hw[i+y][j+x],i,j,y,x)
          if hw[i+y][j+x]=="#":
            isPaintable[i][j] = 0
            break
    elif hw[i][j] == ".":
      isPaintable[i][j] = 0

if np.array(isPaintable).sum() == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
print(700 + s.count(o) * 100)

Fixed submission:
s = input()
print(700 + s.count("o") * 100)
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum([1 for i in a if > x]), sum([1 for i in a if < x])))

Fixed submission:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
print(min(sum([1 for x in A if x>X]) , sum([1 for x in A if x<X])))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
# print(a)

# iは除く番号
for i in range(1, N + 1):
  s = 0
  for j in range(N + 1):
    if j + 1 == i:
      s += abs(a[j] - a[j+2])
    elif j != i:
      s += abs(a[j] - a[j+1])      
  print(s)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
# print(a)

li = [abs(a[i] - a[i+1]) for i in range(N + 1)]
sumli = sum(li)

# iは除く番号
for i in range(1, N + 1):
  print(sumli - (li[i-1] + li[i]) + abs(a[i-1]-a[i+1]))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A + B => C:
  print("Yes")
else:
  print("No")

Fixed submission:
A, B, C = map(int, input().split())
if A + B >= C:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]
cs = collections.Counter(s)
ct = collections.Counter(t)
print(max(0, cs.most_common()[0][1] - ct.most_common()[0][1]))

Fixed submission:
import collections

N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
cs = collections.Counter(s)
ct = collections.Counter(t)
ans = 0
for k in cs.keys():
#  print(k, cs[k], ct[k])
  c = cs[k] - ct[k]
  if c > ans:
    ans = c
print(max(ans, 0))
Buggy python submission (verdict: Runtime Error):
N = input()
s = list(map(int, input().split()))
if "Y" in s:
  print("Four")
else:
  print("Three")

Fixed submission:
N = input()
s = list(input().split())
if "Y" in s:
  print("Four")
else:
  print("Three")
Buggy python submission (verdict: Time Limit Exceeded):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

li = [[]] * (H * W)
for i in range(H):
  for j in range(W):
    li[A[i][j] - 1] = [j, i]

cost = [[0 for _ in range(H * W)] for _ in range(D)]
for i in range(H * W):
  d, m = divmod(i, D)
  if d > 0:
    cost[m][d] = cost[m][d - 1] + abs(li[i][0] - li[i - D][0]) + abs(li[i][1] - li[i - D][1]) 

# print(cost)

for l, r in LR:
  print(cost[(l - 1) % D][(r - 1) // D] - cost[(l - 1) % D][(l - 1) // D])

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

li = [[]] * (H * W)
for i in range(H):
  for j in range(W):
    li[A[i][j] - 1] = [j, i]

cost = [[0 for _ in range((H * W) // D + 1)] for _ in range(D)]
for i in range(H * W):
  d, m = divmod(i, D)
  if d > 0:
    cost[m][d] = cost[m][d - 1] + abs(li[i][0] - li[i - D][0]) + abs(li[i][1] - li[i - D][1]) 

# print(cost)

for l, r in LR:
  print(cost[(l - 1) % D][(r - 1) // D] - cost[(l - 1) % D][(l - 1) // D])

Buggy python submission (verdict: Runtime Error):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

li = [[]] * (H * W)
for i in range(H):
  for j in range(W):
    li[A[i][j] - 1] = [j, i]

cost = [[0 for _ in range(H * W)] for _ in range(D)]
for i in range(H * W):
  d, m = divmod(i, D)
  if d > 0:
    cost[m][d] = cost[m][d - 1] + abs(li[i][0] - li[i - D][0]) + abs(li[i][1] - li[i - D][1]) 

# print(cost)

for l, r in LR:
  print(cost[(l - 1) % D][r // D] - cost[(l - 1) % D][l // D])

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

li = [[]] * (H * W)
for i in range(H):
  for j in range(W):
    li[A[i][j] - 1] = [j, i]

cost = [[0 for _ in range((H * W) // D + 1)] for _ in range(D)]
for i in range(H * W):
  d, m = divmod(i, D)
  if d > 0:
    cost[m][d] = cost[m][d - 1] + abs(li[i][0] - li[i - D][0]) + abs(li[i][1] - li[i - D][1]) 

# print(cost)

for l, r in LR:
  print(cost[(l - 1) % D][(r - 1) // D] - cost[(l - 1) % D][(l - 1) // D])
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ]
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ]
print(a - b)

Fixed submission:
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ])
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ])
print(a - b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = list(map(int, input().split()))
c.sort(rexerse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ]
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ]
print(a - b)

Fixed submission:
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ])
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ])
print(a - b)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a % 2 == 1 and b % 2 == 1:
  print("Odd")
else:
  print("Even)


Fixed submission:
a, b = map(int, input().split())
if a % 2 == 1 and b % 2 == 1:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Runtime Error):
ab = int(input().replace(" ", "")
if ab ** (1 / 2) % 1 == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
ab = int(input().replace(" ", ""))
if ab ** (1 / 2) % 1 == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

flg = -1
for i in range(N+1):
  for j in range(N+1):
    goke = 9000*i + 4000*j
    if (goke == Y - 1000*N) and (A + B <= N):
      A = i
      B = j
      flg = 1
      break

if flg == 1:
  C = N - A -B
  print('{} {} {}'.format(A, B, C))
else:
  print('-1 -1 -1')


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

flg = -1
for i in range(N+1):
  for j in range(N+1):
    goke = 9000*i + 4000*j
    if (goke == Y - 1000*N) and (i + j <= N):
      A = i
      B = j
      flg = 1
      break

if flg == 1:
  C = N - A -B
  print('{} {} {}'.format(A, B, C))
else:
  print('-1 -1 -1')