Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02936 (python)

Fixed submission:
def main():
    N, Q = [int(s) for s in input().split()]
    adj = [[] for _ in range(N)]
    counters = [0] * N
    increments = [0] * N

    for _ in range(N - 1):
        a, b = [int(s) - 1 for s in input().split()]
        adj[a].append(b)
        adj[b].append(a)

    for _ in range(Q):
        p, x = [int(s) for s in input().split()]
        increments[p - 1] += x

    stack = [(0, 0, -1)]

    while stack:
        u, inc, parent = stack.pop()
        inc += increments[u]
        counters[u] += inc

        for v in adj[u]:
            if v != parent:
                stack.append((v, inc, u))

    print(' '.join(str(c) for c in counters))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, Q = [int(s) for s in input().split()]
    adj = [[] for _ in range(N)]
    counters = [0] * N
    increments = [0] * N

    for _ in range(N - 1):
        a, b = [int(s) - 1 for s in input().split()]
        adj[a].append(b)
        adj[b].append(a)

    for _ in range(Q):
        p, x = [int(s) for s in input().split()]
        increments[p - 1] += x

    dfs(0, -1, 0, increments, adj, counters)
    print(' '.join(str(c) for c in counters))


def dfs(vertex, parent, increment, increments, adj, counter):
    increment += increments[vertex]
    counter[vertex] += increment

    for other in adj[vertex]:
        if other != parent:
            dfs(other, vertex, increment, increments, adj, counter)


if __name__ == '__main__':
    main()
Problem p02957 (python)

Fixed submission:
a, b = map(int, input().split())
if ((a+b)/2).is_integer():
  print((a+b)//2)
  exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if ((a+b)/2)is_integer():
  print((a+b)//2)
  exit()
print("IMPOSSIBLE")
Problem p02999 (python)

Fixed submission:
a, b = map(int, input().split())
if a < b:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if x < a:
  print(0)
else:
  print(10)
Problem p03086 (python)

Fixed submission:
s = input()
ans = []
cnt = 0
for i in range(len(s)):
  if s[i] in set("ATCG"):
    cnt += 1
    ans.append(cnt)
  else:
    ans.append(cnt)
    cnt = 0
print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
cnt = 0
for i in range(len(s)):
  if s[i] in set("ATCG"):
    cnt += 1
  else:
    ans.append(cnt)
    cnt = 0
print(max(ans))
Problem p03239 (python)

Fixed submission:
a, b = map(int, input().split())
C = []
for _ in range(a):
  c, t = map(int, input().split())
  if t <= b:
    C.append(c)
if not C ==[]:
  print(min(C))
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
C = []
for _ in range(a):
  c, t = map(int, input().split())
  if t <= b:
    C.append(c)
print(min(C))
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if a%2 == 1 and b%2 == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if int(input())%2 == 1 and int(input())%2 == 1:
  print("Yes")
else:
  print("No")
Problem p03280 (python)

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
print((int(input())-1)*(int(input())-1))
Problem p03323 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
if int(input()) <= 8 and int(input()) <= 8:
  print("Yay!")
else:
  print(":(")
Problem p03485 (python)

Fixed submission:
import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input()))//2+1)
Problem p03493 (python)

Fixed submission:
count = 0
for i in str(input()):
  if i == "1":
    count+=1    
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count=0
while True:
  for i in A:
    if i%2 != 0:
      print(int(count))
      quit()
  
  A = list(map(lambda x: x/2, A))
  #print(A)
  count+=1
  #break
print(int(count))
Problem p03860 (python)

Fixed submission:
A, B, C = input().split()
print("A"+B[0]+"C")

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
if a%x == 0:
  print(b//x-a//x+1)
else:
  print(b//x-a//x)
Problem p03060 (python)

Fixed submission:
n=input()
def ina():
  return map(int,raw_input().split())
a=ina()
b=ina()
c=0
for i in range(n):
  if a[i]>b[i]:
  	c+=a[i]-b[i]
print c

Buggy submission (verdict: Runtime Error):
n=input()
def ina():
  return map(int,raw_input().split())
a=ina()
b=ina()
c=0
for i in range(n):
  if a[i]>b[i]
  	c+=a[i]-b[i]
print c
Problem p02957 (python)

Fixed submission:
A,B=(int(x) for x in input().split())
K=(A+B)//2
if abs(A-K) == abs(B-K):
    print(K)
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B=(int(x) for x in input().split())
A!=B

if abs(A-K)==abs(B-K):
    print(K)
else:
    print('IMPOSSIBLE')
Problem p02993 (python)

Fixed submission:
S=list(int(i) for i in input())
for i in range(len(S)-1):
  if S[i]==S[i+1]:
    print('Bad')
    break
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S=list(int(i) for i in input().split())
for x in range(len(S)-1):
  if S[x]==S[x+1]:
    print('Bad')
  break
  else:
    print('Good')

Buggy submission (verdict: Runtime Error):
S=list(int(i) for i in input().split())
for x in range(len(S)+1):
  if S[x]==S[x+1]:
    print('Bad')
  break 
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S=list(int(i) for i in input().split())
for x in range(len(S)+1):
  if S[x]==S[x+1]:
    print('Bad')
    break 
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S=list(int(i) for i in input().split())
for x in range(len(S)+1):
  if S[x]==S[x+1]:
    print('Bad')
  else:
    print('Good')

Buggy submission (verdict: Runtime Error):
S=list(int(i) for i in input().split())
if S[i]==S[i+1]:
  print('Bad')
else:
  print('Good')
Problem p02999 (python)

Fixed submission:
X,A=(int(x) for x in input().split())
if X>=A:
  print(10)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
X,A=(inx(x) for x in input().split())
if X>=A:
  print(10)
else:
  print(0)
Problem p03145 (python)

Fixed submission:
a,b,c=(int(x) for x in input().split())
print(int((a*b)/2))

Buggy submission (verdict: Runtime Error):
a,b,c=(int(X) for x in input().split())
print(int((a*b)/2))
Problem p03206 (python)

Fixed submission:
d=int(input())
if d == 22:
  print('Christmas Eve Eve Eve')
elif d == 23:
  print('Christmas Eve Eve')
elif d == 24:
  print('Christmas Eve')
elif d == 25:
  print('Christmas')

Buggy submission (verdict: Runtime Error):
d=int(input())
if d == 22:
  print('Christmas Eve Eve Eve')
elif d == 23:
  print('Christmas Eve Eve')
elif d == 24:
  print('Christmas Eve')
eilf d == 25:
  print('Christmas')
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
    print('Hello World')
elif n==2:
    a=int(input())
    b=int(input())
    print(int(a + b))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print('Hello World')
elif n==2:
    a,b=(int(x) for x in input().split())
    print(int(a + b))
Problem p03501 (python)

Fixed submission:
t,a,b=map(int,input().split())
print(min(t*a,b))

Buggy submission (verdict: Runtime Error):
t,a,b=int(input())
print(min(t*a,b))
Problem p03555 (python)

Fixed submission:
x=str(input())
y=str(input())
X=x[::-1]
if X==y:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
x,y=map(str,input().split())
X=x[::-1]
if X==y:
    print('YES')
else:
    print('NO')
Problem p03399 (python)

Fixed submission:
def AtCoder_A():
    Prices=[]
    for i in range(4):
        Prices.append(input())
    Train=min(int(Prices[0]),int(Prices[1]))
    Bus=min(int(Prices[2]),int(Prices[3]))
    print(Train+Bus)
    return

AtCoder_A()

Buggy submission (verdict: Runtime Error):
def AtCoder_A():
    Prices=input().split()
    print(Prices)
    Train=min(int(Prices[0]),int(Prices[1]))
    Bus=min(int(Prices[2]),int(Prices[3]))
    print(Train+Bus)
    return

AtCoder_A()
Problem p03470 (python)

Fixed submission:
import math as M
N=int(input())
list=[]
for i in range(N):
    n=int(input())
    if n not in list:
        list.append(n)

print(list.__len__())

Buggy submission (verdict: Runtime Error):
import math as M
N=input()
List=[]
for i in range(N):
    n=int(input())
    if n not in List:
        List.append(int(input()))

print(List.count())
Problem p02945 (python)

Fixed submission:
s = input()
l = [int(x) for x in s.split()]
a, b = l[0], l[1]
print(max(a+b, max(a-b, a*b)))

Buggy submission (verdict: Runtime Error):
s = input()
l = [int(x) for x in input().split()]
a, b = l[0], l[1]
print(max(a+b, max(a-b, a*b)))
Problem p02958 (python)

Fixed submission:
input()
g = input()
a = list(map(str, g.split()))
b = list(map(int, g.split()))
if sorted(b) == b:
    print("YES")
else:
    m = 0
    for i in range(len(b)):
        if b[i] == sorted(b)[i]:
            m+=1
    if m==len(b)-2:
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
input()
a = list(map(str, input().split()))
b = list(map(int, input().split()))
if sorted(b) == a:
    print("YES")
else:
    m = 0
    for i in range(len(a)):
        if a[i] in sorted(b)[i]:
            m+=1
    if m==len(a)-2:
        print("YES")
    else:
        print("NO")
Problem p02999 (python)

Fixed submission:
d = list(map(int, input().split()))
if d[0] < d[1]:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
d = list(map(int, d.split()))
if d[0] < d[1]:
  print(0)
else:
  print(10)
Problem p03029 (python)

Fixed submission:
l = [int(i) for i in input().split() if i.isdigit()]
print(int((3 * l[0] + l[1]) / 2))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
  s,p=[x for x in input().rstrip().split()]
  l.append([s,int(p),i+1])
l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])

for s,p,i in l:
  print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
list_shop = []
 
for i in range(n):
  t = []
  a, b = input().split()
  t.append(a)
  t.append(b)
  t.append(str(i + 1))
  list_shop.append(t)
 
check = 0
c = []
 
list_shop = sorted(list_shop, key=lambda x: x[0])
 
for i in range(len(list_shop) - 1):
  if(list_shop[i][0] == list_shop[i + 1][0]):
    check = 1
  else:
    check = 0
 
  c.append(list(map(int, list_shop[i][1:3])))
  if(check == 1):
    continue
  else:
    c.sort(key=lambda x:x[0], reverse=True)
    for j in c:
      print(int(j[1]))
    c = []
 
if(check == 1):
  c.append(list(map(int, list_shop[n - 1][1:3])))
  c.sort(key=lambda x:x[0], reverse=True)
  for i in c:
    print(i[1])
else:
  print(int(list_shop[n - 1][2]))
Problem p04043 (python)

Fixed submission:
list1 = input().split()
ans = int(list1[0]) * int(list1[1]) * int(list1[2])
 
if ans == 5*5*7:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
list = input().split()
ans = list[0] * list[1] * list[2]

if ans == 5*5*7:
  Print('YES')
else:
  Print('NO)

Buggy submission (verdict: Runtime Error):
list = input().split()
ans = input[0] * input[1] * input[2]

if ans == 5*5*7:
  Print('YES')
else:
  Print('NO)
Problem p02918 (python)

Fixed submission:
N,K = (int(i) for i in input().split())
S = list(input())

cnt = 0
x = 1
tmp = S[0]
while cnt < K and x <= N-1:
    if S[x] != tmp:
        S[x] = tmp
        x += 1
        if x > N-1:
            break
        while S[x] != tmp and x <= N-1:
            S[x] = tmp
            x += 1
            if x > N-1:
                break
        cnt += 1
        if x > N-1:
            break

    else:
        x += 1


ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = (int(i) for i in input().split())
S = list(input())

cnt = 0
x = 1
tmp = S[0]
while cnt < K and x <= N-1:
    if S[x] != tmp:
        S[x] = tmp
        x += 1
        while S[x] != tmp and x <= N-1:
            S[x] = tmp
            x += 1
            if x > N-1:
                break
        cnt += 1
        if x > N-1:
            break

    else:
        x += 1


ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = (int(i) for i in input().split())
S = list(input())

cnt = 0
x = 1
tmp = S[0]
while cnt < K and x <= N-1:
    if S[x] != tmp:
        S[x] = tmp
        x += 1
        while S[x] != tmp and x <= N-1:
            S[x] = tmp
            x += 1
            if x > N-1:
                break
        cnt += 1

    else:
        x += 1

    if x > N-1:
        break

ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1

print(ans)
Problem p02960 (python)

Fixed submission:
import math
S=input()
dp=[0]*13
dp[0]=1
# dp[k] 13で割った余りkのパターン数
mod = 1000000007

for i in range(len(S)):
    nextDp=[0]*13
    if S[i] == "?":
        for j in range(13):
            for k in range(10):
                nextDp[((10*j) + k) % 13] += dp[j]
                nextDp[((10*j) + k) % 13] %= mod
    else:
        k = int(S[i])
        for j in range(13):
            nextDp[((10*j) + k) % 13] += dp[j]
            nextDp[((10*j) + k) % 13] %= mod
    for j in range(13):
        dp[j] = nextDp[j]

print(dp[5])

Buggy submission (verdict: Runtime Error):
import math
S=input()
hatena = S.count("?")
S_temp = int(S.replace("?","0"))
Q = 10 ** hatena
S_temp_amari =(S_temp-5) %13
temp = math.floor((Q-S_temp_amari)/13)
print(temp%(1000000000+7))
Problem p02995 (python)

Fixed submission:
import fractions

A,B,C,D = map(int,input().split())

E =C*D//fractions.gcd(C,D)

if A%C == 0:
    C_div = B//C - A//C + 1
else:
    C_div = B//C - A//C

if A%D == 0:
    D_div = B//D - A//D + 1
else:
    D_div = B//D- A//D


if A%E == 0:
    CandD_div  = B//E - A//E + 1
else:
    CandD_div  = B//E- A//E


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())

E =C*D//math.gcd(C,D)

if A%C == 0:
    C_div = B//C - A//C + 1
else:
    C_div = B//C - A//C

if A%D == 0:
    D_div = B//D - A//D + 1
else:
    D_div = B//D- A//D


if A%E == 0:
    CandD_div  = B//E - A//E + 1
else:
    CandD_div  = B//E- A//E


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = (int(i) for i in input().split())

E =C*D//math.gcd(C,D)

if A%C == 0:
    C_div = B//C - A//C + 1
else:
    C_div = B//C - A//C

if A%D == 0:
    D_div = B//D - A//D + 1
else:
    D_div = B//D- A//D


if A%E == 0:
    CandD_div  = B//E - A//E + 1
else:
    CandD_div  = B//E- A//E


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = (int(i) for i in input().split())

E =int(C*D/math.gcd(C,D))

if A%C == 0:
    C_div = B//C - A//C + 1
else:
    C_div = B//C - A//C

if A%D == 0:
    D_div = B//D - A//D + 1
else:
    D_div = B//D- A//D


if A%E == 0:
    CandD_div  = B//E - A//E + 1
else:
    CandD_div  = B//E- A//E


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = (int(i) for i in input().split())
C_div = int(0)
D_div = int(0)
CandD_div = int(0)
E =int(C*D/math.gcd(C,D))

if A%C == 0:
    C_div = int(B/C) - int(A/C) + 1
else:
    C_div = int(B/C) - int(A/C)

if A%D == 0:
    D_div = int(B/D) - int(A/D) + 1
else:
    D_div = int(B/D)- int(A/D)


if A%E == 0:
    CandD_div  = int(B/E) - int(A/E) + 1
else:
    CandD_div  = int(B/E)- int(A/E)


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = (int(i) for i in input().split())
C_div = int(0)
D_div = int(0)
CandD_div = int(0)
E =int(C*D/math.gcd(C,D))

if A%C == 0:
    C_div = int(B/C) - int(A/C) + 1
else:
    C_div = int(B/C) - int(A/C)

if A%D == 0:
    D_div = int(B/D) - int(A/D) + 1
else:
    D_div = int(B/D)- int(A/D)


if A%E == 0:
    CandD_div  = int(B/E) - int(A/E) + 1
else:
    CandD_div  = int(B/E)- int(A/E)


ans = B - A + 1 - (C_div + D_div - CandD_div)
print(ans)
Problem p03161 (python)

Fixed submission:
def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

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

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def main():
    with open("input.txt", "r") as f:
        t = f.readlines()
        N = int(t[0].split()[0])
        K = int(t[0].split()[1])
        h = t[1].split()
        h = [int(i) for i in h]
#    N, K  = map(int, input().split())
#    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        if i == 0:
            pass
        elif i == 1:
            dp[i] = h[0]
        else:
            dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def main():
    with open("input.txt", "r") as f:
        t = f.readlines()
        N = int(t[0].split()[0])
        K = int(t[0].split()[1])
        h = t[1].split()
        h = [int(i) for i in h]
#    N, K  = map(int, input().split())
#    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        if i == 0:
            pass
        elif i == 1:
            dp[i] = h[1]
        else:
            dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

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

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def main():
    with open("input.txt", "r") as f:
#        t = f.readlines()
#        N = int(t[0].split()[0])
#        K = int(t[0].split()[1])
#        h = t[1].split()
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
#    print(h)
#    print(len(h))
    dp = [10**9] * max(N,K)
    dp[0] = 0

    for i in range(N):
        j = 0
        L = min(K, i)
        while j <= L:
            #print(i)
            if dp[i] > dp[i-j] + abs(int(h[i])-int(h[i-j])):
                dp[i] = dp[i-j] + abs(int(h[i])-int(h[i-j]))
            j += 1
    print(dp[N-1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K  = map(int, input().split())
    h = [int(i) for i in input().split()]
    dp = [10**5] * N
    dp[0] = 0

    for i in range(N):
        j = 0
        while j <= K:
            if dp[i] > dp[i-j] + abs(h[i]-h[i-j]):
                dp[i] = dp[i-j] + abs(h[i]-h[i-j])
            j += 1
    print(dp[N-1])

if __name__ == "__main__":
    main()
Problem p03076 (python)

Fixed submission:
'''input
101
86
119
108
57
'''

a=[]

for i in range(5):
	a.append(int(input()))
# print(a)
flag=[]

for i in range(5):
	if a[i]%10!=0:
		flag.append(a[i]%10)
	else:
		flag.append(-1)
# print(flag)

endInd=-1
end=float('inf')

for i in range(5):
	if flag[i]>0 and end>flag[i]:
		end=flag[i]
		endInd=i
# print(a[endInd])

if endInd==-1:
	print(sum(a))
else:
	s=a[endInd]
	# print(s)
	a.pop(endInd)
	flag.pop(endInd)
	# print(a)
	for i in range(4):
		if flag[i]>0:
			a[i]=(a[i]//10+1)*10
	# print(a)
	s+=sum(a)
	print(s)

Buggy submission (verdict: Runtime Error):
'''input
123
123
123
123
123
'''

a=[]

for i in range(5):
	a.append(int(input()))
# print(a)
flag=[]

for i in range(5):
	if a[i]%10!=0:
		flag.append(a[i]%10)
	else:
		flag.append(-1)
# print(flag)

endInd=float('inf')
end=float('inf')

for i in range(5):
	if flag[i]>0 and end>flag[i]:
		end=flag[i]
		endInd=i
# print(a[endInd])

if endInd=='inf':
	print(sum(a))
else:
	s=a[endInd]
	# print(s)
	a.pop(endInd)
	flag.pop(endInd)
	# print(a)
	for i in range(4):
		if flag[i]>0:
			a[i]=(a[i]//10+1)*10
	# print(a)
	s+=sum(a)
	print(s)
Problem p03244 (python)

Fixed submission:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0][1] - m2[0][1])

Buggy submission (verdict: Runtime Error):
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0
Problem p03262 (python)

Fixed submission:
f = lambda: map(int,input().split())


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


n, X = f()
x = list(f())
ans = x[0]-X

for i in range(1,n):
    ans = gcd(ans,x[i]-X)
print(abs(ans))

Buggy submission (verdict: Runtime Error):
f = lambda: map(int,input().split())
import math
n, X = f()
x = list(f())
ans = abs(x[0]-X)

for i in range(1,n):
    ans = math.gcd(ans,x[i]-X)
print(ans)
Problem p03263 (python)

Fixed submission:
f = lambda: map(int,input().split())
h,w = f()
a = [list(f()) for _ in range(h)]
for i in range(h):
    if i%2 == 0:
        a[i].reverse()

count = 0
ans = []

for i in range(h):
    for j in range(w):
        if i == h-1 and j == w-1:
            break
        if i&1:
            if a[i][j]&1:
                count += 1
                if j == w-1:
                    ans.append([i+1,w,i+2,w])
                    a[i+1][0] += 1
                else:
                    ans.append([i+1,j+1,i+1,j+2])
                    a[i][j+1] += 1
        else:
            if a[i][j] & 1:
                count += 1
                if j == w - 1:
                    ans.append([i + 1, 1, i + 2, 1])
                    a[i+1][0] += 1
                else:
                    ans.append([i+1, w-j, i+1, w-j-1])
                    a[i][j+1] += 1
print(count)
for i in range(count):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
f = lambda: map(int,input().split())
h,w = f()
a = [list(f()) for _ in range(h)]
for i in range(h):
    if i%2 == 0:
        a[i].reverse()

for i in range(h):
    for j in range(w):
        if i == w-1 and j == h-1:
            break
        if i&1:
            if a[i][j]&1:
                if j == w-1:
                    print(i+1,w,i+2,w)
                    a[i+1][0] += 1
                else:
                    print(i+1,j+1,i+1,j+2)
                    a[i][j+1] += 1
        else:
            if a[i][j] & 1:
                if j == w - 1:
                    print(i + 1, 1, i + 2, 1)
                    a[i+1][0] += 1
                else:
                    print(i+1, w-j, i+1, w-j-1)
                    a[i][j+1] += 1