Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin

li = [int(stdin.readline().rstrip()) for _ in range(5)]
k = int(stdin.readline().rstrip())

from itertools import combinations
lin = list(combinations(li, 2))

for i in li:
    if abs(lin[i][0]-lin[i][1]) > k:
        print(":(")
        exit()

print("Yay!")

Fixed submission:
from sys import stdin

li = [int(stdin.readline().rstrip()) for _ in range(5)]
k = int(stdin.readline().rstrip())

from itertools import combinations
lin = list(combinations(li, 2))

for i in range(len(lin)):
    if abs(lin[i][0]-lin[i][1]) > k:
        print(":(")
        exit()

print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
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()))

li  = []

for i in a:
    for j in b:
        li.append(i+j)

li.sort(reverse=True)
li = li[:k]

lin = []

for i in li:
    for j in c:
        lin.append(i+j)

lin.sort(reverse=True)

for i in range(k):
    print(lin[i])

Fixed submission:
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()))

li  = []

for i in a:
    for j in b:
        li.append(i+j)

li.sort(reverse=True)
li = li[:k]

lin = []

for i in li:
    for j in c:
        lin.append(i+j)

lin.sort(reverse=True)

for i in range(k):
    print(lin[i])
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.cound("R") > s.count("B"):
    print("Yes")
else:
    print("No")

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.count("R") > s.count("B"):
    print("Yes")
else:
    print("No")

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

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.cound("R") > s.count("B"):
    print("YES")
else:
    print("NO")

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.count("R") > s.count("B"):
    print("Yes")
else:
    print("No")

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

s = stdin.readline().rstrip()

if s.cound("R") > s.count("B"):
    print("Yes")
else:
    print("No")

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.count("R") > s.count("B"):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

for i in range(q):
    kotoba = s[li[i][0]-1:li[i][1]]
    kai = kotoba.count("AC")
    print(kai)

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()

li = ["A","T"]
li2 = ["C","G"]

if s in li:
    li.pop(li.index(s))
    print(li[0])
else:
    li2.pop(li2.index(s))
    print(li2[0])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]
lin = [0]*n
point = 0
for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        for k in range(i+1,n):
            lin[k] += 1
for j in range(q):
    print(lin[li[j][1]-1]-lin[li[j][0]-1])

Fixed submission:
from sys import stdin
import bisect

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]
lin = []
point = 0
for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        lin.append(i+1)
for j in range(q):
    hi = bisect.bisect(lin,li[j][1]-1)
    lo = bisect.bisect(lin,li[j][0]-1)
    print(hi-lo)

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

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

for i in range(q):
    kotoba = s[li[i][0]-1:li[i][1]]
    kai = kotoba.count("AC")
    print(kai)

Fixed submission:
from sys import stdin
import bisect

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]
lin = []
point = 0
for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        lin.append(i+1)
for j in range(q):
    hi = bisect.bisect(lin,li[j][1]-1)
    lo = bisect.bisect(lin,li[j][0]-1)
    print(hi-lo)

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

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

for i in range(q):
    kotoba = s[li[i][0]-1:li[i][1]]
    kai = kotoba.count("AC")
    print(kai)

Fixed submission:
from sys import stdin
import bisect

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]
lin = []
point = 0
for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        lin.append(i+1)
for j in range(q):
    hi = bisect.bisect(lin,li[j][1]-1)
    lo = bisect.bisect(lin,li[j][0]-1)
    print(hi-lo)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
a,b = map(int,stdin.readline().rstrip().split())
point = a
for i in range(a+1,b+1):
    point ^= i
print(point)

Fixed submission:
from sys import stdin
a,b = map(int,stdin.readline().rstrip().split())
#0からnまでの排他的論理和の和
def xor(n):
    point = ((n+1)//2)%2
    if n%2 == 0:
        if point == 0:
            return 0^n
        else:
            return 1^n
    else:
        if point == 0:
            return 0
        else:
            return 1
print(xor(a-1)^xor(b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))

li.sort()

if sum(li[:-1]) > li[i]:
    print("Yes")
else:
    print("No")

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

if sum(li[:n-1]) > li[-1]:
    print("Yes")
    exit()

print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))

pra = []
mai = []
kosuu = 0
for i in range(n):
    if a[i]-b[i] < 0:
        mai.append(b[i]-a[i])
        continue
    elif a[i]-b[i] > 0:
        pra.append(a[i]-b[i])
    kosuu += 1

pra.sort(reverse=True)

if sum(pra) < sum(mai):
    print(-1)
    exit()

if kosuu == n:
    print(0)
    exit()

count = 1
now = 0
while mai:
    if pra[now] < mai[0]:
        count += 1
        now += 1
        continue
    else:
        pra[now] -= mai[0]
        count += 1
    mai.pop(0)
print(count)

Fixed submission:
from sys import stdin
from itertools import accumulate
import bisect

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))

pra = []
mai = 0
kosuu = 0
atari = 0

for i in range(n):
    if a[i]-b[i] < 0:
        mai += b[i]-a[i]
        kosuu += 1
        continue
    elif a[i]-b[i] > 0:
        pra.append(a[i]-b[i])
    atari += 1

if sum(pra) < mai:
    print(-1)
    exit()
if atari == n:
    print(0)
    exit()
pra.sort(reverse=True)

pra = list(accumulate(pra))
print(bisect.bisect(pra,mai)+kosuu+1)
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[-1] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = 0
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))

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

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n,k):
    dp = [-1 for _ in li]
    dp[0] = 0
    if n == 1:
        return 0
    elif n <= k:
        return abs(li[-1]-li[0])
    for i in range(1,n):
        dp[i] = min([dp[j] + abs(li[j] - li[i]) for j in range(max(0, i - k), i)])
    return dp[n-1] 

print(score(li,n,k))

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = 0
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

s = stdin.readline().rstrip()
li = []

for i in range(len(s)):
    if s[i] == "B":
        li.append(0)
    else:
        li.append(1)
count = 0

while True:
    flag = 0
    for i in range(len(li)-1):
        if li[i] == 0 and li[i+1] == 1:
            li[i],li[i+1] = 1,0
            flag = 1
            count += 1
    if flag == 0:
        print(count)
        exit()

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()

now = 0
count = 0

for i in range(len(s)):
    if s[i] == "W":
        count += (i-now)
        now += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort()
sa = 10**10
for i in range(n-k+1):
    s = h[i:i+k]
    sa = min(sa,s[-1]-s[0])
print(sa)

Fixed submission:
from sys import stdin
from itertools import groupby

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

mi = 10**10
for i in range(n-k+1):
    mi = min(mi,li[i+k-1]-li[i])

print(mi)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import groupby

n,x = [int(x) for x in stdin.readline().rstrip().split()]

s = "P"

def morimori(s):
    m = "B" + s + "P" + s[::-1] + "B"
    return m

for i in range(n):
    s = morimori(s)

print(s[:x].count("P"))

Fixed submission:
from sys import stdin

n,x = [int(x) for x in stdin.readline().rstrip().split()]
p = [1]
t = [1]
for i in range(1,n+1):
    p.append(p[i-1]*2+1)
    t.append(t[i-1]*2+3)

def f(n,x):
    if n == 0:
        return 1 if x == 1 else 0
    elif x == 1:
        return 0
    elif 1 < x <= 1 + t[n-1]:
        return f(n-1,x-1)
    elif x == t[n-1] + 2:
        return p[n-1] + 1
    elif t[n-1]+2 < x <= 2*t[n-1]+2:
        return f(n-1,x-2-t[n-1]) + p[n-1] + 1
    else:
        return 2*p[n-1]+1

print(f(n,x))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import bisect


n = int(stdin.readline().rstrip())

li = [7,5,3]
point = 0
for i in range(n+1):
    s = str(i)
    if s.count("7") > 0 and s.count("5") > 0 and s.count("3") > 0 and s.count("0") == 0 and  s.count("1") == 0 and s.count("2") == 0 and s.count("4") == 0 and s.count("6") == 0 and s.count("8") == 0 and s.count("9") == 0:
        point += 1
print(point)

Fixed submission:
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)
    exit()

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        if int(k) <= n:
            point += 1
    kazu += 1
print(point)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for _ in range(n)]
lin2 = []
for i in range(m):
    lin[li[j][0]-1].append(li[i][1])

for j in range(n):
    liv = sorted(lin[j])
    lin2.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(lin2[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)

Fixed submission:
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for i in range(n)]
lin2 = []
li3 = []
for j in range(m):
    lin[li[j][0]-1].append(li[j][1])
    lin2.append(li[j][0]-1)

for j in range(n):
    liv = sorted(lin[j])
    li3.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(li3[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for i in range(n)]
lin2 = []
li3 = []
for j in range(m):
    lin[li[j][0]-1].append(li[j][1])
    lin2.append(li[j][0]-1)

for j in range(n):
    liv = sorted(lin[j])
    li3.append(liv)

for k in range(m):
    s = len(str(li[k][1]))
    v = len(str(li[j][0]))
    print("0"*(6-v)+str(li[k][0])+"0"*(6-s)+str(bisect.bisect(li3[li[k][0]-1],li[k][1])))

Fixed submission:
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for i in range(n)]
lin2 = []
li3 = []
for j in range(m):
    lin[li[j][0]-1].append(li[j][1])
    lin2.append(li[j][0]-1)

for j in range(n):
    liv = sorted(lin[j])
    li3.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(li3[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)
Buggy python submission (verdict: Runtime Error):
n = int(input())
low = 0
hi = 10**9

li = []
lin = []

for _ in range(n):
    x,y,h = map(int,input().split())
    if h != 0:
        li.append((x,y,h))
    lin.append((x,y,h))

for i in range(101):
    for j in range(101):
        flag = True
        h = li[0][2]+abs(i-li[0][0])+abs(j-li[0][1])
        for a,b,c in lin:
            if max(h-abs(i-a)-abs(j-b),0) != c:
                flag = False
                break
        if flag:
            print(i,j,h)
            exit()

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())

if n == 1:
    print("Hello World")
    exit()

li = [int(stdin.readline().rstrip()) for _ in range(n)]

print(sum(li))

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 1:
    print("Hello World")
else:
    a,b = map(int,input().split())
    print(a+b)

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())

if n == 1:
    print("Hello World")
    exit()

li = [int(stdin.readline().rstrip()) for _ in range(n)]

print(sum(li))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import bisect

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li2 = []
for i in range(n):
    if li[i][0] <= t:
        li2.append(li[i][0])

li2.sort()

print(li2[0])

Fixed submission:
from sys import stdin
import bisect

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li2 = []
for i in range(n):
    if li[i][1] <= t:
        li2.append(li[i][0])
if len(li2) == 0:
    print("TLE")
    exit()
li2.sort()
print(li2[0])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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()
    return divisors
li = make_divisors(m)
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Fixed submission:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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()
    return divisors
li = make_divisors(m)
point = 1
if n == 1:
    print(m)
    exit()
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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()
    return divisors
li = make_divisors(m)
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Fixed submission:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().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()
    return divisors
li = make_divisors(m)
point = 1
if n == 1:
    print(m)
    exit()
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

li1 = []
li2 = []

for i in range(n):
    if i % 2 == 0:
        li1.append(li[i])
    else:
        li2.append(li[i])

li1.sort()
li2.sort()

lin = []
lin2 = []

for key, value in groupby(li1):
    lin.append((key,len(list(value))))
for key, value in groupby(li2):
    lin2.append((key,len(list(value))))

lin.sort(key=lambda x:(x[1]))
lin2.sort(key=lambda x:(x[1]))

point = 0

if lin[-1][0] == lin2[-1][0] and lin[-1][1] == lin2[-1][1]:
    if len(lin) == 1:
        print(n//2)
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-2][1]-lin2[-1][1])
        else:
            print(n-lin[-1][1]-lin2[-2][1])

elif lin[-1][0] == lin2[-1][0]:
    if len(lin) == 1:
        print(n//2-lin2[-2][1])
    elif len(lin2) == 1:
        print(n//2-lin[-2][1])
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-1][1]-lin2[-2][1])
        else:
            print(n-lin[-2][1]-lin2[-1][1])
else:
    print(n-lin[-1][1]-lin2[-1][1])

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
ns = ""
for i in s:
    if i =="1":
        ns += "9"
    else:
        ns += "1"

print(ns)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))

ki = li[::2]
gu = li[1::2]

ki.sort()
gu.sort()

from itertools import groupby

ki_li = []
gu_li = []

for key, value in groupby(ki):
    ki_li.append((key,len(list(value))))

for key, value in groupby(gu):
    gu_li.append((key,len(list(value))))

ki_li.sort(key=lambda x:(x[1]*(-1)))
gu_li.sort(key=lambda x:(x[1]*(-1)))

if ki_li[0][0] == gu_li[0][0]:
    if ki_li[0][1] > gu_li[0][1]:
        if len(gu_li) >= 2:
            ans = n-ki_li[0][1]-gu_li[1][1]
        else:
            ans = n-ki_li[0][1]
    elif ki_li[0][1] == gu_li[0][1]:
        if ki_li[1][1] >= gu_li[1][1]:
            ans = n-gu_li[0][1]-ki_li[1][1]
        else:
            ans = n-ki_li[0][1]-gu_li[1][1]
    else:
        if len(ki_li) >= 2:
            ans = n-gu_li[0][1]-ki_li[1][1]
        else:
            ans = n-gu_li[0][1]
else:
    ans = n-gu_li[0][1]-ki_li[0][1]

print(ans)

Fixed submission:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

li1 = []
li2 = []

for i in range(n):
    if i % 2 == 0:
        li1.append(li[i])
    else:
        li2.append(li[i])

li1.sort()
li2.sort()

lin = []
lin2 = []

for key, value in groupby(li1):
    lin.append((key,len(list(value))))
for key, value in groupby(li2):
    lin2.append((key,len(list(value))))

lin.sort(key=lambda x:(x[1]))
lin2.sort(key=lambda x:(x[1]))

point = 0

if lin[-1][0] == lin2[-1][0] and lin[-1][1] == lin2[-1][1]:
    if len(lin) == 1:
        print(n//2)
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-2][1]-lin2[-1][1])
        else:
            print(n-lin[-1][1]-lin2[-2][1])

elif lin[-1][0] == lin2[-1][0]:
    if len(lin) == 1:
        print(n//2-lin2[-2][1])
    elif len(lin2) == 1:
        print(n//2-lin[-2][1])
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-1][1]-lin2[-2][1])
        else:
            print(n-lin[-2][1]-lin2[-1][1])
else:
    print(n-lin[-1][1]-lin2[-1][1])
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
li = list(map(int,input().split()))
lin = [abs(i-x) for i in li]
print(lin)
import fractions#python3.4ではmathではなくこちらのライブラリを用いる
def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
gcd = gcd_all(lin)

print(gcd)

Fixed submission:
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import fractions
import sys
sys.setrecursionlimit(10**6) 

n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
gcd = gcd_all(lin)
print(gcd)

Fixed submission:
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import fractions

n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
gcd = gcd_all(lin)
print(gcd)

Fixed submission:
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)