Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for a in A:
    # 約数列挙(1,N)も含まれる
    prime, i = set(), 1
    while i * i <= a:
        if a % i == 0:
            d[i] += 1
            d[a//i] += 1
        i += 1

ans = 1
for i, v in d.items():
    if v+1 >= N:
        ans = max(ans, i)
print(ans)


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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
A.sort()
for i in range(A[1], -1, -1):
    if len(A[np.where(A % i == 0)]) >= len(A)-1:
        res = i
        break

print(res)


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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])

res = np.where(A % 2 == 0)
for i in range(max(A), -1, -1):
    if len(A[np.where(A % i == 0)]) >= len(A)-1:
        res = i
        break

print(res)


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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
def u(a, b):
    if b == 0:
        return a
    return u(b, a % b)

if len(A) <= 2:
    res = max(A)
else:
    res = 0
    for i in range(len(A)):
        tmp = list(A)
        if tmp.index(tmp[i]) < i:
            continue
        tmp.pop(i)
        for k in range(len(tmp)-1):
            tmp[k+1] = u(tmp[k], tmp[k+1])
        res = max(res, tmp[len(tmp)-1])
print(res)


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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

dot = S.count(".")
sha = 0
res = 10**9
for i in range(1,N):
    if i == "#":
        sha += 1
    else:
        dot -= 1
    tmp = sha + dot
    res = min(res, tmp)

print(res)

Fixed submission:
a,b,c = map(int, input().split())
if (a <= c and c <= b) or (b <= c and c <= a):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
 
res = 0
tmp = ""

for i in range(N-1,-1,-1):
    if S[i] == "#":
        continue
    dot = S[:i+1].count(".")
    sha = S[:i+1].count("#")
    break
print(min(dot, sha))

Fixed submission:
N = int(input())
S = input()

res = dot = S.count(".")
sha = 0
for i in range(N):
    if S[i] == "#":
        sha += 1
    else:
        dot -= 1
    tmp = sha + dot
    res = min(res, tmp)

print(res)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
print(math.ceil(N/min(A,B,C,D,E)+4)


Fixed submission:
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
print(math.ceil(N/min(A,B,C,D,E)+4))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
msg = 'Yes' if A == B and B == C else 'No'
print(mssg)

Fixed submission:
A, B, C = map(int, input().split())
msg = 'Yes' if A == B and B == C else 'No'
print(msg)

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
msg = 'YES' if A == B and B == C else 'NO'
print(mssg)

Fixed submission:
A, B, C = map(int, input().split())
msg = 'Yes' if A == B and B == C else 'No'
print(msg)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
r = s.count('R')
b = s.count('B')
msg = 'Yes' if r > b else 'No'
print(msg)

Fixed submission:
N = int(input())
S = input()
r = S.count('R')
b = S.count('B')
msg = 'Yes' if r > b else 'No'
print(msg)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
array = [0,0]
for i in range(len(S)-2):
    s = S[i]+S[i+1]
    array.append(array[i]+s.count("AC"))
array.append(array[i+1])
for i in range(Q):
    s, e = map(int, input().split())
    print(array[e] - array[s])


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
array = [0,0]
for i in range(len(S)-2):
    s = S[i]+S[i+1]
    array.append(array[i]+s.count("AC"))
array.append(array[i+1])
for i in range(Q):
    s, e = map(int, input().split())
    print(array[e-1] - array[s-1])


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
array = [0]
for i in range(len(S)-2):
    s = S[i]+S[i+1]
    array.append(array[i]+s.count("AC"))
array.append(array[i+1])
for i in range(Q):
    s, e = map(int, input().split())
    print(array[e-1] - array[s-1])


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
for i in range(Q):
    s,e = map(int, input().split())
    print(S[s-1:e].count("AC"))


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
for i in range(Q):
    start,end = map(int, input().split())
    print(S[start-1:end].count("AC"))


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

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

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

for q in qlist:
    sparts = S[q[0]-1:q[1]]
    print(sparts.count("AC"))


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


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

for _ in range(Q):
	l, r = map(int, input().split())
	print(cnt[r-1] - cnt[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
result = [i for i in range(A, B + 1)]
for index, i in enumerate(range(A, B + 1)):
    if index == 0:
        continue
    result[index] = result[index-1] ^ result[index]
print(result[len(result) - 1])


Fixed submission:
A, B = map(int, input().split())

def calc(n):
    mod = n % 4
    if mod == 0:
        return n
    elif mod == 1:
        return n ^ (n-1) 
    elif mod == 2:
        return n ^ 1
    elif mod == 3:
        return 0
a = calc(A - 1)
b = calc(B)

print(a ^ b)

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
result = 0
def calc(A, B, N):
    if N >= B:
        return A
    A = A ^ (N + 1)
    return calc(A, B, N + 1)
print(calc(A, B, A))


Fixed submission:
A, B = map(int, input().split())

def calc(n):
    mod = n % 4
    if mod == 0:
        return n
    elif mod == 1:
        return n ^ (n-1) 
    elif mod == 2:
        return n ^ 1
    elif mod == 3:
        return 0
a = calc(A - 1)
b = calc(B)

print(a ^ b)
Buggy python submission (verdict: Runtime Error):
# n, a, b = map(int, input().split())
print(min(a, b), max((a+b-10), 0))

Fixed submission:
n, a, b = map(int, input().split())
print(min(a, b), max((a+b-n), 0))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())
c1, c2 = map(int,input().split())
import math
a = [a1, b1, c1]
b = [a2, b2, c2]

def combinationListRecursive(data, r):
  if r == 0 or r > len(data):
    return []

  result = []
  _combinationListRecursive(data, r, 0, [], result)
  return result


def _combinationListRecursive(data, r, start, progress, result):
  if r == 0:
    result.append(progress)
    return

  for i in range(start, len(data)):
    _combinationListRecursive(data, r - 1, i + 1, progress + [data[i]], result)

result = combinationListRecursive(range(n), math.ceil(n/2))
best = 0
for i in result:
    atmp = 0
    btmp = 0
    for k in range(n):
        if k in i:
            atmp += a[k]
        else:
            btmp += b[k]
    if best < atmp - btmp:
        best = atmp - btmp
print(best)

Fixed submission:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:sum(x), reverse=True)
tk = 0
ak = 0
for i, (a, b) in enumerate(AB):
    if i % 2 == 0:
        tk += a
    else:
        ak += b
print(tk-ak)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
import numpy as np

h = np.array(h)
zero = np.array([int(0) for i in range(len(h))])

def calc(h, zero, minus):
    for k in range(len(h)):
        if minus[k] != 0:
            if k == len(h) - 1:
                zero[k] = zero[k] + 1
                return
            for w in range(k+1, len(h)):
                if minus[w] == 0:
                    zero[k:w] = zero[k:w] + 1
                    return
                elif w == len(h) - 1:
                    zero[k::] = zero[k::] + 1
                    return

def main(h, zero):
    i = 0
    minus = h - zero
    while np.sum(minus) != 0:
        calc(h ,zero, minus)
        i += 1
        minus = h - zero
    print(i)

main(h, zero)

Fixed submission:
a, b, c = map(int, input().split())
print(int(a*b/2))
Buggy python submission (verdict: Runtime Error):
s = int(input())
def functionF(n):
    result = n/2 if n % 2 == 0 else 3 * n + 1
    return int(result)
def calc(s):
  array = []
  for i in range(1,1000000):
    if i == 1:
      array.append(s)
      elif i > 1:
        array.append(functionF(array[i - 2]))
        return array
def result(s):
    result = calc(s)
    for i in range(1, 1000000):
#         print('i',i)
        for k in range(i):
#             print('k',k)
#             print(result[i], result[k])
            if result[i] == result[k]:
                print(i - 1)
                return

Fixed submission:
s = int(input())
def functionF(n):
    result = n/2 if n % 2 == 0 else 3 * n + 1
    return int(result)

def calc(s):
    array = []
    for i in range(1,1000000):
        if i == 1:
            array.append(s)
        elif i > 1:
            array.append(functionF(array[i - 2]))
            for k in range(1, i):
#                 print(i, k)
#                 print(array[i-1], array[k-1])
                if array[i-1] == array[k-1]:
                    print(i)
                    return
calc(s)
Buggy python submission (verdict: Runtime Error):
N = [int(i) in input().split()]
res = "NO"
if 1 in N and 9 in N and 7 in N and 4 in N:
  res = "YES"

print(res)

Fixed submission:
N = [int(i)for i in input().split()]
res = "NO"
if 1 in N and 9 in N and 7 in N and 4 in N:
  res = "YES"

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))
for _ in range(K+2):
    H.append(10**9)
dp = [10**9] * (N+K+1)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])



Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
for _ in range(K+2):
    H.append(10**9)
dp = [10**9] * (N+K+1)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())

MAX_V = N * (10 ** 3)
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [10**9+7 for _ in range(MAX_V + 1)]
dp[0] = 0

for w, v in range(N):
    for j in range(MAX_V + 1):
        if j - v >= 0:
            dp[j] = min(dp[j],dp[j - v] + w)
        else:
            dp[j] = dp[j]

mv = 0
for i in range(MAX_V + 1):
    if dp[i] <= W:
        mv = i

print(mv)


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

MAX_V = N * (10 ** 3)
w, v = [], []
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[10**9+7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(MAX_V + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j],dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]

mv = 0
for i in range(MAX_V + 1):
    if dp[N][i] <= W:
        mv = i
print(mv)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0] * (ls+1) for _ in range(lt+1)]

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

ret = []
while ls > 0 and lt > 0:
    # dpテーブルの番号が一致しているということは、今評価対象の文字は最長共通部分列に含まれないということになる
    # そのため評価対象の文字を変更して次のループに入る
    # dpテーブルを右下から左上になめるように見ていくのは、評価対象以降の文字列の影響を除くため
    if dp[lt][ls] == dp[lt][ls-1]:
        ls -= 1
    elif dp[lt][ls] == dp[lt-1][ls]:
        lt -= 1
    else:
        ret.append(s[ls])
        ls -= 1
        lt -= 1

ret.reverse()
print("".join(ret))


Fixed submission:
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0] * (ls+1) for _ in range(lt+1)]

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

ret = []
while ls > 0 and lt > 0:
    if dp[lt][ls] == dp[lt][ls-1]:
        ls -= 1
    elif dp[lt][ls] == dp[lt-1][ls]:
        lt -= 1
    else:
        ret.append(s[ls-1])
        ls -= 1
        lt -= 1

ret.reverse()
print("".join(ret))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
MOD = 10 ** 9 + 7
dp = [0] * (1<<N)
dp[0] = 1
for i in range(1, 1<<N):
    for j in range(N):
        if i>>j&1 == 0: continue
        cnt = bin(i).count("1")
        dp[i] += dp[i - (1<<j)] * A[cnt-1][j]
        dp[i] %= MOD
print(dp[-1])


Fixed submission:
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
MOD = 10 ** 9 + 7
dp = [0] * (1<<N)
dp[0] = 1
for i in range(1, 1<<N):
    cnt = bin(i).count("1")
    for j in range(N):
        if (i>>j)&1 == 0: continue
        dp[i] += dp[i - (1<<j)] * A[cnt-1][j]
        dp[i] %= MOD
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

MOD = 10 ** 9 + 7
def dfs(v, pv):
    dp[v][0] = dp[v][1] = 1
    for nv in edge[v]:
        if nv == pv: continue
        dfs(nv, v)
        dp[v][0] *= dp[nv][0] + dp[nv][1]
        dp[v][0] %= MOD
        dp[v][1] *= dp[nv][0]
        dp[v][1] %= MOD

N = int(input())
edge = [[] for _ in range(N)]

for i in range(N-1):
    x, y = map(lambda x:int(x)-1, input().split())
    edge[x].append(y)
    edge[y].append(x)

dp = [[0] * 2 for _ in range(10**5+10)]
dfs(0,-1)

print((dp[0][1] + dp[0][0]) % MOD)


Fixed submission:
import sys
sys.setrecursionlimit(10**9)

MOD = 10 ** 9 + 7
def dfs(v, pv):
    white, black = 1, 1
    for nv in edge[v]:
        if nv == pv: continue
        rw, rb = dfs(nv, v)
        white *= rw + rb
        white %= MOD
        black *= rw
        black %= MOD
    return white, black

N = int(input())
edge = [[] for _ in range(N)]

for i in range(N-1):
    x, y = map(lambda x:int(x)-1, input().split())
    edge[x].append(y)
    edge[y].append(x)

print(sum(dfs(0, -1)) % MOD)

Buggy python submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
def dfs(v, pv):
    dp[v][0] = dp[v][1] = 1
    for nv in edge[v]:
        if nv == pv: continue
        dfs(nv, v)
        dp[v][0] *= dp[nv][0] + dp[nv][1]
        dp[v][0] %= MOD
        dp[v][1] *= dp[nv][0]
        dp[v][1] %= MOD

N = int(input())
edge = [[] for _ in range(N)]

for i in range(N-1):
    x, y = map(lambda x:int(x)-1, input().split())
    edge[x].append(y)
    edge[y].append(x)

dp = [[0] * 2 for _ in range(10**5+10)]
dfs(0,-1)

print(dp[0][1] + dp[0][0])


Fixed submission:
import sys
sys.setrecursionlimit(10**9)

MOD = 10 ** 9 + 7
def dfs(v, pv):
    white, black = 1, 1
    for nv in edge[v]:
        if nv == pv: continue
        rw, rb = dfs(nv, v)
        white *= rw + rb
        white %= MOD
        black *= rw
        black %= MOD
    return white, black

N = int(input())
edge = [[] for _ in range(N)]

for i in range(N-1):
    x, y = map(lambda x:int(x)-1, input().split())
    edge[x].append(y)
    edge[y].append(x)

print(sum(dfs(0, -1)) % MOD)
Buggy python submission (verdict: Runtime Error):
print(input().conut("2"))

Fixed submission:
print(input().count("2"))
Buggy python submission (verdict: Runtime Error):
cri = {"25":"Christmas",
	"24":"Christmas Eve",
	"23":"Christmas Eve Eve",
	"22":"Christmas Eve Eve Eve"}
print(cri[nput()])

Fixed submission:
cri = {"25":"Christmas",
	"24":"Christmas Eve",
	"23":"Christmas Eve Eve",
	"22":"Christmas Eve Eve Eve"}
print(cri[input()])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
ret = 10 ** 9
for i in range(N-K+1):
    ret = min(H[i+2] - H[i], ret)

print(ret)

Fixed submission:
N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
ret = 10 ** 9
for i in range(N-K+1):
    ret = min(H[i+K-1] - H[i], ret)
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1, 2):
    t = list(set(str(i)))
    t.sort()
    if t == a:
        ret += 1
print(ret)

Fixed submission:
N = int(input())
cnt = 0
def dfs(n, cnt):
    if int(n) > N:
        return cnt
    if n.count("3") >= 1 and n.count("5") >= 1 and n.count("7") >= 1:
        cnt += 1

    for i in ("3","5","7"):
        cnt = max(cnt, dfs(n+i, cnt))
    return cnt

print(dfs("0", 0))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i)))
    t.sort()
    if t == a:
        ret += 1
print(ret)

Fixed submission:
N = int(input())
cnt = 0
def dfs(n, cnt):
    if int(n) > N:
        return cnt
    if n.count("3") >= 1 and n.count("5") >= 1 and n.count("7") >= 1:
        cnt += 1

    for i in ("3","5","7"):
        cnt = max(cnt, dfs(n+i, cnt))
    return cnt

print(dfs("0", 0))
Buggy python submission (verdict: Runtime Error):
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] == 0:
        continue
    XYH.append(tmp)

def calc(XYH):
    tmp = 0
    res = [0,0,0]
    for tarx in range(101):
        for tary in range(101):
            xyh = XYH[0]
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(h - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                print(" ".join(x,y,h))
                return
    
calc(XYH)

Fixed submission:
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] != 0:
        xyh = tmp
    XYH.append(tmp)

def calc(XYH, xyh):
    for tarx in range(101):
        for tary in range(101):
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(tarh - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                return list(map(str, [tarx, tary, tarh]))
    
print(" ".join(calc(XYH, xyh)))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
ea = N // 2
e1 = e[0][1]
e2 = e[1][1]
oa = N - ea
o1 = o[0][1]
o2 = o[1][1]
cnt = 0
if e1 != o1:
    cnt = N - e1 - o1
else:
    if o2 > e1:
        cnt = N - e2 - o1
    else:
        cnt = N - e1 - o2
print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    o = N - e1 - o2
    e = N - e2 - o1
    cnt = min(o, e)
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
o = {}
e = {}
for i, v in enumerate(V):
    if i % 2 == 1:
        if not v in e.keys():
            e[v] = 0
        e[v] += 1
    else:
        if not v in o.keys():
            o[v] = 0
        o[v] += 1

o = sorted(o.values(), reverse=True)
e = sorted(e.values(), reverse=True)

e1 = sum(e[1:])
e2 = sum(e[0] + e[2:])
o1 = sum(o[1:])
o2 = sum(o[2:])
ret = min(e1+o2, e2+o1)
print(ret)


Fixed submission:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    o = N - e1 - o2
    e = N - e2 - o1
    cnt = min(o, e)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
v = [int(i) for i in input().split()]

l = []
cnt = [0] * N

for ind, i in enumerate(v):
	if not i in l:
		l.append(i)
	cnt[ind] = l.index(i)

ret = 0
for i, c in enumerate(cnt):
	if i % 2 == 0:
		if c != 0:
			ret += 1
	else:
		if c != 1:
			ret += 1

print(ret)


Fixed submission:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    o = N - e1 - o2
    e = N - e2 - o1
    cnt = min(o, e)
print(cnt)