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


def main():
    n = int(input())
    aa = list(map(int, input().split()))
    cs_a0 = Counter(a for i, a in enumerate(aa) if i % 2 == 0)
    cs_a1 = Counter(a for i, a in enumerate(aa) if i % 2 == 1)

    vs_a0 = sorted(((v, k) for k, v in cs_a0.items()), reverse=True)
    vs_a1 = sorted(((v, k) for k, v in cs_a1.items()), reverse=True)

    if vs_a0[0][1] != vs_a1[0][1]:
        print(n - vs_a0[0][0] - vs_a1[0][0])
    else:
        res = n // 2
        if len(vs_a0) > 1:
            res = min(n - vs_a0[1][0] - vs_a1[0][0])
        if len(vs_a1) > 1:
            res = min(n - vs_a0[0][0] - vs_a1[1][0])
        print(res)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter


def main():
    n = int(input())
    aa = list(map(int, input().split()))
    cs_a0 = Counter(a for i, a in enumerate(aa) if i % 2 == 0)
    cs_a1 = Counter(a for i, a in enumerate(aa) if i % 2 == 1)
    vs_a0 = sorted(((v, k) for k, v in cs_a0.items()), reverse=True)
    vs_a1 = sorted(((v, k) for k, v in cs_a1.items()), reverse=True)
    if vs_a0[0][1] != vs_a1[0][1]:
        print(n - vs_a0[0][0] - vs_a1[0][0])
    else:
        res = 1 << 30
        if len(vs_a0) == 1 and len(vs_a1) == 1:
            res = n // 2
        if len(vs_a0) > 1:
            res = min(res, n - vs_a0[1][0] - vs_a1[0][0])
        if len(vs_a1) > 1:
            res = min(res, n - vs_a0[0][0] - vs_a1[1][0])
        print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right


def main():
    n = int(input())
    aa = sorted(map(int, input().split()))
    bb = sorted(map(int, input().split()))
    cc = sorted(map(int, input().split()))

    res = 0
    for a in aa:
        i_b = bisect_right(bb, a)
        for b in bb[i_b:]:
            i_c = bisect_right(cc, b)
            res += n - i_c
    print(res)


if __name__ == '__main__':
    main()


Fixed submission:
from bisect import bisect_left, bisect_right


def main():
    n = int(input())
    aa = sorted(map(int, input().split()))
    bb = sorted(map(int, input().split()))
    cc = sorted(map(int, input().split()))
    res = 0
    for b in bb:
        i_a = bisect_left(aa, b)
        i_c = bisect_right(cc, b)
        res += i_a * (n - i_c)
    print(res)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from math import gcd


def lcm(a, b):
    return abs(a*b) // gcd(a, b)


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()


Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return abs(a * b) // gcd(a, b)


def main():
    n = int(input())
    ts = [int(input()) for _ in range(n)]
    res = ts[0]
    for t in ts[1:]:
        res = lcm(res, t)
    print(res)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    aa = [int(input()) - 1 for _ in range(n)]
    i = 0
    res = 0
    while True:
        if aa[i] == 1:
            print(res + 1)
            break
        if aa[i] == 0:
            print(-1)
            break
        i = aa[i]
        res += 1


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    aa = [int(input()) - 1 for _ in range(n)]
    visiteds = [False] * n
    i = 0
    res = 0
    while True:
        if visiteds[i]:
            print(-1)
            break
        if i == 1:
            print(res)
            break
        visiteds[i] = True
        res += 1
        i = aa[i]


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def solve(left, right):
    if right - left >= 2019:
        return 0
    l_mod = left % 2019
    r_mod = right % 2019
    if r_mod < l_mod:
        return 0
    ans = 2019
    for i in range(l_mod, r_mod + 1):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, i * j % 2019)
    return ans
 L, R = map(int, input().split())
 print(solve(L, R))


Fixed submission:
L,R = map(int,input().split())
l = L
m = (L *(L + 1)) % 2019
while l < min (R, L + 2019):
  r = l + 1
  while r <= min (R, L + 2019):
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
l = L
m = (L *(L + 1)) % 2019
while l < R:
  r = l + 1
  while r <= R:
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)  


Fixed submission:
L,R = map(int,input().split())
l = L
m = (L *(L + 1)) % 2019
while l < min (R, L + 2019):
  r = l + 1
  while r <= min (R, L + 2019):
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
nm = [int(i) for i in input().split()]
lr = [[int(i) for i in input().split()] for i in range(nm[1])]


a = [{j for j in range(lr[i][0], lr[0][1]+1)} for i in range(nm[1])]
b = set()
for i in range(len(a)):
    if b == set():
        b = a[i]
    b = b & a[i]
print(len(b))

Fixed submission:
nm = [int(i) for i in input().split()]
lr = [[int(i) for i in input().split()] for i in range(nm[1])]

l = [i[0] for i in lr]
r = [i[1] for i in lr]
print(len(range(max(l), min(r)+1)))

Buggy python submission (verdict: Time Limit Exceeded):
nm = [int(i) for i in input().split()]
lr = [[int(i) for i in input().split()] for i in range(nm[1])]

a = [{j for j in range(lr[i][0], lr[i][1]+1)} for i in range(nm[1])]
b = set()
for i in range(len(a)):
    if b == set():
        b = a[i]
    b = b & a[i]
print(len(b))

Fixed submission:
nm = [int(i) for i in input().split()]
lr = [[int(i) for i in input().split()] for i in range(nm[1])]

l = [i[0] for i in lr]
r = [i[1] for i in lr]
print(len(range(max(l), min(r)+1)))
Buggy python submission (verdict: Runtime Error):
print(-(-(int(input())) // min([int(input() for i in range(5))])) + 4)


Fixed submission:
N = int(input())
tr = [int(input()) for i in range(5)]
# s = -(-N // tr[0])
# cnt = 5 + s - 1
# for i in range(1, 5):
#    # print(cnt, s, (-(-N // tr[i]) - s))
#    if (-(-N // tr[i]) - (-(-N // tr[i-1]))) > 0:
#        cnt += -(-N // tr[i]) - (-(-N // tr[i-1]))
print(-(-N // min(tr)) + 4)
Buggy python submission (verdict: Runtime Error):
from collections import Counter;N, M = map(int, input().split());print(len([i for i in Counter([flatten for inner in [i[1:] for i in [[int(i) for i in input().split()] for i in range(N)]] for flatten in inner]).most_common() if i[1] == N]))

Fixed submission:
A, B = map(int, input().split())
print(A+B if B%A == 0 else B-A)
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
P=[list(map(int,input().split())) for i in range(D)]

def distance(a,b):
    result=0
    for i in range(D):
        result+=(a[i]-b[i])**2
    result=result**0.5
    return result

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        if distance(P[i],P[j]).is_integer():
            ans+=1

print(ans)

Fixed submission:
N,D=map(int,input().split())
P=[list(map(int,input().split())) for i in range(N)]

def distance(a,b):
    result=0
    for i in range(D):
        result+=(a[i]-b[i])**2
    result=result**0.5
    return result

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        if distance(P[i],P[j]).is_integer():
            ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
min=0
result=[]
num_range=R-L
if L>=2019 and R>=2019:
    for i in range(num_range-1):
        for j in range(i+1,num_range):
            result.append((L+i-2019)*(L+j-2019))
    result.sort()
elif L<2019 and R<2019:
    result.append(L*R)
print(result[0])

Fixed submission:
L,R=map(int,input().split())
if R-L>=2018:
    print(0)
else:
    ans=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
min=0
result=[]
num_range=R-L
print(num_range)
for i in range(num_range-1):
    for j in range(i+1,num_range):
        if (L+i)>=2019 and (L+j)>=2019:
            result.append((L+i-2019)*(L+j-2019))
        else: result.append(L*R)    
result.sort()
print(result[0])

Fixed submission:
L,R=map(int,input().split())
if R-L>=2018:
    print(0)
else:
    ans=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = (int(x) for x in input().split())
s = input()
print ''.join(x for i,x in enumerate(s) if i != K-1 else x.lower())

Fixed submission:
N,K = (int(x) for x in input().split())
s = input()
print(''.join([x if i != K-1 else x.lower() for i,x in enumerate(s) ]))
Buggy python submission (verdict: Runtime Error):
myArray = list()
for n in range(5):
    myArray.append(int(input()))
Jouyo  = 9

for i,j in enumerate(myArray):
    if 0 < j % 10 <= Jouyo:
        Jouyo = j % 10
        jouyoi = i

times = 0
for i,j in enumerate(myArray):
    if i != jouyoi:
        if j % 10 != 0:
            times += ((j // 10) + 1) * 10
        else:
            times += j
    else:
        times += j
print(times)

Fixed submission:
myArray = list()
for n in range(5):
    myArray.append(int(input()))
Jouyo  = 9
jouyoi = 0

for i,j in enumerate(myArray):
    if 0 < j % 10 <= Jouyo:
        Jouyo = j % 10
        jouyoi = i
times = 0
for i,j in enumerate(myArray):
    if i != jouyoi:
        if j % 10 != 0:
            times += ((j // 10) + 1) * 10
        else:
            times += j
    else:
        times += j
print(times)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counti = 0

for a in range(A)+1:
  for b in range(B)+1:
    for c in range(C)+1:
      if 500*a + 100*b + 50*c == X:
        counti += 1

print(counti)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counti = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        counti += 1

print(counti)
Buggy python submission (verdict: Time Limit Exceeded):
N,Y = (int(x) for x in input().split())
temp = [-1 for n in range(3)]
myflag = False
for x in range(N+1):
  if myflag:break
  for y in range(N+1-x):
    if myflag:break
    for z in range(N+1-x-y):
      if myflag :break
      if x+y+z == N and 10000*x + 5000*y + 1000*z ==Y:
        temp = [x,y,z]
        myflag = True

print('{} {} {}'.format(temp[0],temp[1],temp[2]))

Fixed submission:
N,Y = (int(x) for x in input().split())
temp = [-1 for n in range(3)]
myflag = False
for x in range(N+1):
  if myflag:break
  for y in range(N+1-x):
    if myflag:break
    z = N - x - y
    if 10000*x + 5000*y + 1000*z == Y:
      temp=[x,y,z]

print('{} {} {}'.format(temp[0],temp[1],temp[2]))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
import datetime

def main():
    S = str(input())
    tdatetime = datetime.datetime.strptime(S, '%Y%m%d')

    if tdatetime.month <= 4:
        print('HEISEI')
    else:
        print('TBD')

if __name__ == "__main__":
    main()

Fixed submission:
#!/usr/bin/python
import datetime

def main():
    S = str(input())
    tdatetime = datetime.datetime.strptime(S, '%Y/%m/%d')

    if tdatetime.month <= 4:
        print('Heisei')
    else:
        print('TBD')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
  	lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(len[-1])


nlcm(t)


Fixed submission:
# coding: utf-8

a = input()
if a[0] == a[-1]:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())

if c <= b:
  if b <= d:
    print(b - c)
  else:
    print(d - c)
else:
  print(0)


Fixed submission:
# coding: utf-8

a = input()
if a[0] == a[-1]:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())

if c <= b:
	print(b - c)
else:
	print(0)


Fixed submission:
# coding: utf-8

a = input()
if a[0] == a[-1]:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(pushed_time - 1)

Fixed submission:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
	print(0)
else:
	print(pushed_time - 1)

Fixed submission:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())

alice_time = range(a, b+1)
bob_time = range(c, d+1)
pushed_time = set(alice_time) & set(bob_time)

print(alice_time)
print(bob_time)

if not pushed_time:
  print (pushed_time[0] - pushed_time[-1])

Fixed submission:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())

alice_time = range(a, b+1)
bob_time = range(c, d+1)
pushed_time = set(alice_time) & set(bob_time)

print(alice_time)
print(bob_time)

if not pushed_time:
	print (pushed_time[0] - pushed_time[-1])

Fixed submission:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b, c, d = map(int, input().split())

if c <= b:
	if c <= d:
	  print(b - c)
	 else:
	 	print(d - c)
else:
	print(0)


Fixed submission:
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x:x[1])
for i in range(n):
    if a[i]<l[-1][1]:
        a[i]=l[-1][1]
        l[-1][0]-=1
        if l[-1][0]==0:l.pop(-1)
    else:break
print(sum(a))

Fixed submission:
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x:x[1])
for i in range(n):
    if a[i]<l[-1][1]:
        a[i]=l[-1][1]
        l[-1][0]-=1
        if l[-1][0]==0:
            l.pop(-1)
            if len(l)==0:break
    else:break
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ai=a[:i]+a[i+1:]
    while len(ai)>1:ai.append(fractions.gcd(ai.pop(),ai.pop()))
    ans=max(ans,ai[0])
print(ans)

Fixed submission:
import fractions
n=int(input())
a=list(map(int,input().split()))
l=[a[0]]
for i in range(1,n):
    l.append(fractions.gcd(l[-1],a[i]))
    if l[-1]==1:
        for j in range(n-len(l)):l.append(1)
        break
r=[a[-1]]
for i in range(n-2,-1,-1):
    r.append(fractions.gcd(r[-1],a[i]))
    if r[-1]==1:
        for j in range(n-len(r)):r.append(1)
        break
r=r[::-1]
ans=max(l[-2],r[1])
for i in range(1,n-1):ans=max(ans,(fractions.gcd(l[i-1],r[i+1])))
print(ans)
Buggy python submission (verdict: Runtime Error):
import re
s=input()
s=s.replace("A","1").replace("C","1").replace("G","1").replace("T","1")
s=list(map(int,re.sub('[A-Z]+', ' ', s).split()))
print(len(str(max(s))))

Fixed submission:
import re
s=input()
s=s.replace("A","1").replace("C","1").replace("G","1").replace("T","1")
s=list(map(int,re.sub('[A-Z]+', ' ', s).split()))
print(0 if s==[] else len(str(max(s))))
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for i in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
n,m=map(int,input().split())
s=input()
l=[0]
x,y=0,0
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":x+=1
    l.append(x)
l.append(x)
for i in range(m):
    a,b=map(int,input().split())
    print(l[b-1]-l[a-1])
Buggy python submission (verdict: Runtime Error):
from math import factorial
a,b,k=map(int,input().split())
n=math.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[k-1])

Fixed submission:
import fractions
a,b,k=map(int,input().split())
n=fractions.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[-k])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ls=len(s)
while "01" in s or "10" in s:s=s.replace("01","").replace("10","")
print(ls-len(s))

Fixed submission:
s=input()
print(min(s.count("0"),s.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
print("YNEOS"[::2])print("YNEOS"[eval(input().replace(" ","<")+"*2-1")::2])

Fixed submission:
print("YNEOS"[eval(input().replace(" ","<-1+2*"))::2])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
s=[]
for i in range(m-1):s.append(l[i+1]-l[i])
s.sort(reverse=True)
ans=l[-1]-l[0]
if m>1:
    for i in range(n-1):ans-=s[i]
print(ans)

Fixed submission:
n,m=map(int,input().split())
if n<m:
    l=sorted(list(map(int,input().split())))
    s=[]
    for i in range(m-1):s.append(l[i+1]-l[i])
    s.sort(reverse=True)
    ans=l[-1]-l[0]
    if m>1:
        for i in range(n-1):ans-=s[i]
    print(ans)
else:print(0)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
cnt=0
while "BW" in s:
    s=s.replace("BW","WB",1)
    cnt+=1
    if s[0]=="W":s=s[1:]
    if s[-1]=="B":s=s[:-1]
print(cnt)

Fixed submission:
s=input()
b=0
ans=0
for i in range(len(s)):
    if s[i]=="B":b+=1
    else:ans+=b
print(ans)
Buggy python submission (verdict: Runtime Error):
print(int(input())+int(input())//2)

Fixed submission:
n,m=map(int,input().split())
print(n+m//2)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(list(map(int,input().split())))
asd=a[:]
asd.sort(key=lambda x:x[1])
asd.sort(key=lambda x:x[0])
keep,ki=0,1
for i in asd:
    if keep==i[0]:ki+=1
    else:keep,ki=i[0],1
    a[a.index(i)]=str(i[0]).zfill(6)+str(ki).zfill(6)
for i in a:
    print(i)

Fixed submission:
n,m=map(int,input().split())
l=[]
for i in range(m):
    a=list(map(int,input().split()))
    a.append(i)
    l.append(a)
l.sort(key=lambda x:x[1])
l.sort(key=lambda x:x[0])
j,y=0,1
for i in range(m):
    x=l[i].pop(0)
    y=y+1 if j==x else 1
    j=x
    l[i][0]=str(x).zfill(6)+str(y).zfill(6)
l.sort(key=lambda x:x[1])
for i in l:print(i[0])
Buggy python submission (verdict: Runtime Error):
def search():
    for i in range(0,101):
        for j in range(0,101):
            h=l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
            for a,b,c in l[1:]:
                hi=c+abs(i-a)+abs(j-b)
                if h!=hi:break
            else:
                return [i,j,hi]

l=[list(map(int,input().split())) for i in range(int(input()))]
a,b,c=search()
print(a,b,c)

Fixed submission:
l=[list(map(int,input().split())) for i in range(int(input()))]
l.sort(key=lambda x:x[2])
for i in range(0,101):
    for j in range(0,101):
        h=l[-1][2]+abs(i-l[-1][0])+abs(j-l[-1][1])
        for a,b,c in l[:-1]:
            if c!=max(0,h-abs(i-a)-abs(j-b)):break
        else:
            print(i,j,h)
            exit()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
if len(set(v))==1:print(n//2)
else:
    voc=Counter(v[::2]).most_common(2)
    vec=Counter(v[1::2]).most_common(2)
    if len(voc)==len(vec)==1:print(0)
    elif voc[0][0]==vec[1][0]:
        if len(voc)==len(vec)==2:print(n-max(voc[0][1]+vec[1][1],voc[1][1]+vec[0][1]))
        elif len(voc)==1:print(n-voc[0][1]-vec[1][1])
        else:print(n-voc[1][1]-vec[0][1])
    else:
        print(n-voc[0][1]-vec[0][1])

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
if len(set(v))==1:print(n//2)
else:
    v.extend([0,0])
    voc=Counter(v[::2]).most_common(2)
    vec=Counter(v[1::2]).most_common(2)
    if len(voc)==len(vec)==1:print(0)
    elif voc[0][0]==vec[0][0]:print(n-max(voc[0][1]+vec[1][1],voc[1][1]+vec[0][1]))
    else:print(n-voc[0][1]-vec[0][1])
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:b.append(abs(x-i))
while len(b)>1:b.append(fractions.gcd(b.pop(-1),b.pop(-1)))
print(b[0])

Fixed submission:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in a:b.append(abs(x-i))
while len(b)>1:b.append(fractions.gcd(b.pop(-1),b.pop(-1)))
print(b[0])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
a=[]
for i in range(h):
    if i%2==0:
        for j in range(w-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j+2])
                l[i][j+1]+=1
        j=w-1
        if l[i][j]%2==1:
            a.append([i+1,j+1,i+2,j+1])
            l[i+1][j]+=1
    else:
        for j in range(w-1,0,-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j])
                l[i][j-1]+=1
        j=0
        if l[i][j]%2==1:
            a.append([i+1,1,i+2,1])
            l[i+1][j]+=1
print(len(a))
for i in a:print(' '.join(map(str,i)))

Fixed submission:
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
a=[]
for i in range(h):
    if i%2==0:
        for j in range(w-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j+2])
                l[i][j+1]+=1
        j=w-1
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,j+1,i+2,j+1])
            l[i+1][j]+=1
    else:
        for j in range(w-1,0,-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j])
                l[i][j-1]+=1
        j=0
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,1,i+2,1])
            l[i+1][j]+=1

print(len(a))
for i in a:print(' '.join(map(str,i)))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=n
for i in range(0,n):
    sl=s[:i].count("W")
    sr=s[i+1:].count("E")
    ans=min(ans,sl+sr)
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=n
sl=[0]
sr=[0]
c=0
for i in s:
    if i=="W":c+=1
    sl.append(c)
s=s[::-1]
c=0
for i in s:
    if i=="E":c+=1
    sr.append(c)
sr=sr[::-1]
for i in range(n):ans=min(ans,sl[i]+sr[i+1])
print(ans)