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

Fixed submission:
a,b=input().split()
a = int(a)
b = int(b)
ad = a+b
minus = a-b
cross = a*b
lis = [ad, minus, cross]
print(max(lis))

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
ad = a+b
minus = a-b
cross = a*b
lis = [ad, minus, cross]
print(max(lis))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ad = a+b
minus = a-b
cross = a*b
lis = [ad, minus, cross]
print(max(lis))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
add = a+b
minus = a-b
cross = a*b
lis = [add, minus, cross]
print(max(lis))

Buggy submission (verdict: Runtime Error):
import numpy as np
a = int(input())
b = int(input())
add = a+b
minus = a-b
cross = a*b
lis = np.array([add, minus, cross])
print(np.max(lis))
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
if A-2*B > 0:
    print(A-2*B)
else:
    print('0')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A-2*B > 0:
    print(A-2*B)
else:
    print('0')
Problem p02993 (python)

Fixed submission:
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
S = input()
if S[1] == S[2] or S[2] == S[3] or S[3] == S[4]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
S = input()
if S[1] == S[2]or S[2] == S[3]or S[3] == S[4]:
    print("Bad")
else:
    print("Good")
Problem p03076 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = []
a.append(10-(A % 10))
a.append(10-(B % 10))
a.append(10-(C % 10))
a.append(10-(D % 10))
a.append(10-(E % 10))
b = [0]
for i in range(5):
    if a[i] != 10:
        b.append(a[i])
c = A+B+C+D+E+sum(b)-max(b)
print(c)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = []
a.append(10-(A % 10))
a.append(10-(B % 10))
a.append(10-(C % 10))
a.append(10-(D % 10))
a.append(10-(E % 10))
b = []
for i in range(5):
    if a[i] != 10:
        b.append(a[i])
c = A+B+C+D+E+sum(b)-max(b)
print(c)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = []
a.append(10-(A % 10))
a.append(10-(B % 10))
a.append(10-(C % 10))
a.append(10-(D % 10))
a.append(10-(E % 10))
b = []
for i in range(5):
    if a[i] != 10:
        b.append(a[i])
c = A+B+C+D+E+sum(b)-max(b)
print(c)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
if N == 1:
    print("Hello World")
else:
    print(A+B)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
if N == "1":
    print("Hello World")
else:
    print(A+B)
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for n in range(C+1):
            if i*500+j*100+n*50 == X:
                count = count+1
print(count)

Buggy submission (verdict: Runtime Error):
A, B, C, X = map(int, input().split())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for n in range(C+1):
            if i*500+j*100+n*50 == X:
                count = count+1
print(count)
Problem p03206 (python)

Fixed submission:
c = int(input())

if c == 25:
    print("Christmas")
elif c == 24:
    print("Christmas Eve")
elif c == 23:
    print("Christmas Eve Eve")
elif c == 22:
    print("Christmas Eve Eve Eve")
else:
    pass

Buggy submission (verdict: Runtime Error):
pb_list = []
p_count = 0

def pb(n):
    if n == 0:
        pb_list.append('p')
        p_count = p_count + 1
        return
    elif n >= 0:
        pb_list.append('b')
        pb(n - 1)
        pb_list.append('p')
        p_count = p_count + 1
        pb(n - 1)
        pb_list.append('b')
    else:
        return

n, x = input().split(' ')
n = int(n)
x = int(x)
pb(n)

#for i in range(x):
#    if pb_list[i] == 'p':
#        p_count = p_count + 1

print(p_count)
Problem p02995 (python)

Fixed submission:
def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x
a,b,c,d=map(int,input().split())
total=b-a+1
f1=(b//c)-(a//c)
if a%c==0:
    f1+=1
f2=(b//d)-(a//d)
if a%d==0:
    f2+=1
gcd=gcd(c,d)
lcm=(c*d)//gcd
f3=(b//lcm)-(a//lcm)
if a%lcm==0:
    f3+=1
f=f1+f2-f3
print(total-f)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
total=b-a+1
f1=(b//c)-(a//c)
if a%c==0:
    f1+=1
f2=(b//d)-(a//d)
if a%d==0:
    f2+=1
gcd=math.gcd(c,d)
lcm=(c*d)//gcd
f3=(b//lcm)-(a//lcm)
if a%lcm==0:
    f3+=1
f=f1+f2-f3
print(total-f)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
total=b-a+1
f1=(b//c)-(a//c)
if a%c==0:
    f1+=1
f2=(b//d)-(a//d)
if a%d==0:
    f2+=1
gcd=math.gcd(c,d)
lcm=(c*d)//gcd
f3=(b//lcm)-(a//lcm)
if a%lcm==0:
    f3+=1
f=f1+f2-f3
print(total-f)
Problem p02812 (python)

Fixed submission:
from sys import stdin
#stdin = open("input.txt")

if __name__ == "__main__":
  N = int(stdin.readline())
  S = stdin.readline().rstrip()
  
  print(S.count("ABC"))

Buggy submission (verdict: Runtime Error):
from sys import stdin
stdin = open("input.txt")

if __name__ == "__main__":
  N = int(stdin.readline())
  S = stdin.readline().rstrip()
  
  print(S.count("ABC"))
Problem p02842 (python)

Fixed submission:
import math
def resolve():
  found = False
  N = int(input())
  for x in range(int(N/1.08), int((N+1)/1.08+1)):
    if N == math.floor(x*1.08):
      print(x)
      found = True
      break
  
  if not found:
    print(":(")

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
  found = False
  N = int(input())
  for x in range(int(N/1.08), int((N+1)/1.08+1)):
    if N == math.floor(x*1.08):
      print(x)
      found = True
      break
  
  if not found:
    print(":(")
  
resolve()
Problem p03160 (python)

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

inf = float("inf")
cost = [inf]*N

cost[0] = 0
for i in range(1, N):
  cost[i] = min(cost[i], cost[i-1] + abs(h[i] - h[i-1]))
  
  if i - 2 >= 0:
    cost[i] = min(cost[i], cost[i-2] + abs(h[i] - h[i-2]))

print(cost[-1])

Buggy submission (verdict: Runtime Error):
def main_C1():

  N = int(input())
  a = [[int(item) for item in input().split()] for i in range(N)]
  
  dp = [[0, 0, 0] for i in range(N+1)]

  for i in range(N):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
  
  print(max(dp[-1]))

if __name__ == "__main__":
  main_C1()
  # print(list(input_gen()))
Problem p03162 (python)

Fixed submission:
def main_C1():

  N = int(input())
  a = [[int(item) for item in input().split()] for i in range(N)]
  
  dp = [[0, 0, 0] for i in range(N+1)]

  for i in range(N):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
  
  print(max(dp[-1]))

if __name__ == "__main__":
  main_C1()
  # print(list(input_gen()))

Buggy submission (verdict: Runtime Error):
def main_C1():

  N = int(input())
  a = [[int(item) for item in line.split()] for line in input()]
  
  dp = [[0, 0, 0] for i in range(N+1)]

  for i in range(N):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
  
  print(max(dp[-1]))

if __name__ == "__main__":
  main_C1()
  # print(list(input_gen()))
Problem p03254 (python)

Fixed submission:
from sys import stdin, exit
import itertools
#stdin = open("input.txt")

if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().split()]
    
    li.sort()
    
    if sum(li) == K:
        print(N)
    elif sum(li) < K:
        print(N-1)
    else:
        cumsum = itertools.accumulate(li)
        index = [i for i, item in enumerate(cumsum) if item<=K]
        print(len(index))

Buggy submission (verdict: Runtime Error):
from sys import stdin, exit
import itertools
#stdin = open("input.txt")

if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().split()]
    
    li.sort()
    
    if sum(li) == K:
        print(N)
    elif sum(li) < K:
        print(N-1)
    else:
        cumsum = itertools.accumulate(li)
        index = [i for i, item in enumerate(cumsum) if item<=K]
        print(index[-1] + 1)
Problem p03387 (python)

Fixed submission:
from sys import stdin

if __name__ == "__main__":
  l = [int(i) for i in stdin.readline().split(' ')]
  l = sorted(l)
  if l[0]%2 == l[1]%2:
    ex = 0
  else:
    ex = 2
  print((l[-1]*2 - (l[0] + l[1]))//2 + ex)

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

if __name__ == "__main__":
  l = [int(i) for i in stdin.readline().split(' ')]
  sort(l)
  if l[0]%2 == l[1]%2:
    ex = 2
  else:
    ex = 0
  print((l[-1]*2 - (l[0] + l[1]))/2 + ex)
Problem p03361 (python)

Fixed submission:
height,width = map(int, input().split())
map_list = []
flag = False
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)
#print(map_list)

for h in range(height):
    for w in range(width):
        if map_list[h][w] == '#':
            #print("a")
            if '#' in [map_list[h-1][w], map_list[h+1][w], map_list[h][w-1], map_list[h][w+1]]:
                flag = True
                #print("b")
                if flag == True:
                    flag = False
                    #print("c")
            else:
                print("No")
                exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
height,width = map(int, input().split())
map_list = []
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)

for h in range(height):
    for w in range(width):
        if map_list[h][w] == '#':
            if '#' in [map_list[h-1][w], map_list[h+1][w], map_list[h][w-1], map_list[h][w+1]]:

            else:
                print("No")
                exit()

print("Yes")
Problem p04043 (python)

Fixed submission:
a, b, c = map(int, input().split())

list_iroha = [a, b, c]
count = 0
if a + b + c == 17:
    for i in list_iroha:
        if i == 5:
            count += 1
            if count == 2:
                print("YES")
                exit()
print("NO")
exit()

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

list_irioha = [a, b, c]
count = 0
if a + b + c == 17:
    for i in list_iroha:
        if i == 5:
            count += 1
            if count == 2:
                print("YES")
                exit()
print("NO")
exit()
Problem p02900 (python)

Fixed submission:
from math import sqrt


def solve(n):
    res = set()
    for i in range(2, int(sqrt(n))+1):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1): break
    if n>1:
        res.add(n)
    res.add(1)
    return res


A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))

Buggy submission (verdict: Runtime Error):
def solve(n):
    res = set()
    for i in range(2, n):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1) break
    res.add(1)
    return res
 
 
A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))
Problem p02936 (python)

Fixed submission:
import sys
from collections import deque

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N, Q = [int(_) for _ in input().split()]

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

P = [0] * (N + 1)

for q in range(Q):
    p, x = [int(_) for _ in input().split()]
    P[p] += x

que = deque()
que.append((1, 0))

while que:
    v, parent = que.popleft()
    P[v] += P[parent]
    for next_v in edges[v]:
        if next_v == parent: continue
        que.append((next_v, v))

# def f(v, parent=0):
#     P[v] += P[parent]
#
#     for next_v in edges[v]:
#         if next_v == parent: continue
#         f(next_v, v)
#
#
# f(1)
print(*[P[i] for i in range(1, N + 1)])

Buggy submission (verdict: Runtime Error):
class Node:
    def __init__(self, idx):
        self.idx = idx
        self.v = 0
        self.parent = None
        self.children = []
        self.connections = []
        self.level = -1

    def set_children(self):
        self.children = self.connections
        for node in self.connections:
            if self in node.connections:
                node.connections.remove(self)
            node.set_children()

    def add(self, x):
        self.v += x
        for c in self.children:
            c.add(x)

    def __str__(self):
        return str(self.v)


N, Q = [int(_) for _ in input().split()]
nodes = [Node(i) for i in range(1, N + 1)]

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

nodes[0].set_children()

# for n in nodes:
#     print(n.v, [str(c) for c in n.children])
for i in range(Q):
    p, x = [int(_) for _ in input().split()]
    nodes[p - 1].add(x)

print(*[n.v for n in nodes])

Buggy submission (verdict: Runtime Error):
class Node:
    def __init__(self, idx):
        self.idx = idx
        self.v = 0
        self.parent = None
        self.children = []
        self.connections = []
        self.level = -1

    def set_children(self):
        self.children = self.connections
        for node in self.connections:
            if self in node.connections:
                node.connections.remove(self)
            node.set_children()

    def add(self, x):
        self.v += x
        for c in self.children:
            c.add(x)

    def __str__(self):
        return str(self.v)


N, Q = [int(_) for _ in input().split()]
nodes = [Node(i) for i in range(1, N + 1)]

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

nodes[0].set_children()

# for n in nodes:
#     print(n.v, [str(c) for c in n.children])
for i in range(Q):
    p, x = [int(_) for _ in input().split()]
    nodes[p - 1].add(x)

print(*[n.v for n in nodes])
Problem p03014 (python)

Fixed submission:
H, W = [int(_) for _ in input().split()]

S = [input() for _ in range(H)]
memo = [[0] * W for _ in range(H)]

for h in range(H):
    done = [False] * W
    for w in range(W):
        if S[h][w] == '#': continue
        if done[w]: continue

        tmp = w
        cnt = 0
        while tmp < W:
            if S[h][tmp] == '#': break
            cnt += 1
            tmp += 1

        for i in range(w, tmp):
            memo[h][i] += cnt
            done[i] = True

for w in range(W):
    done = [False] * H
    for h in range(H):
        if S[h][w] == '#': continue
        if done[h]: continue

        tmp = h
        cnt = 0
        while tmp < H:
            if S[tmp][w] == '#': break
            cnt += 1
            tmp += 1

        for i in range(h, tmp):
            memo[i][w] += cnt
            done[i] = True

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, memo[i][j] - 1)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]

S = [input() for _ in range(H)]
memo = [[[-1] * 4 for _ in range(W)] for _ in range(H)]

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


def walk(h, w, d):
    if not (0 <= h < H and 0 <= w < W):
        return 0

    if memo[h][w][d] >= 0:
        return memo[h][w][d]

    if S[h][w] == '#':
        for i in range(4):
            memo[h][w][i] = 0
        return 0
    v = walk(h + D[d][0], w + D[d][1], d)
    memo[h][w][d] = v + 1
    return memo[h][w][d]


def solve():
    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = 0
            for d in range(4):
                tmp += walk(h, w, d)
            ans = max(ans, tmp - 3)
    print(ans)

    # for i in range(H):
    #     print(memo[i])


solve()

Buggy submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]

S = [input() for _ in range(H)]
memo = [[[-1] * 4 for _ in range(W)] for _ in range(H)]

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


def walk(h, w, d):
    if not (0 <= h < H and 0 <= w < W):
        return 0

    if memo[h][w][d] >= 0:
        return memo[h][w][d]

    if S[h][w] == '#':
        for i in range(4):
            memo[h][w][i] = 0
        return 0
    v = walk(h + D[d][0], w + D[d][1], d)
    memo[h][w][d] = v + 1
    return memo[h][w][d]


def solve():
    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = 0
            for d in range(4):
                tmp += walk(h, w, d)
            ans = max(ans, tmp - 3)
    print(ans)

    # for i in range(H):
    #     print(memo[i])


solve()
Problem p03029 (python)

Fixed submission:
a,p = [int(_) for _ in input().split()]
print((a*3+p)//2)

Buggy submission (verdict: Runtime Error):
a,p = [int(_) for _ in input()]
print((a*3+p)//2)

Buggy submission (verdict: Runtime Error):
a,p = [int(_) for _ in input()]
print((a*3+p)//2)
Problem p03044 (python)

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

N = int(input())
nodes = [[[], -1] for _ in range(N + 1)]

for i in range(N - 1):
    u, v, w = [int(_) for _ in input().split()]
    nodes[u - 1][0].append((v - 1, w))
    nodes[v - 1][0].append((u - 1, w))


def f(i, c):
    if nodes[i][1] >= 0: return
    nodes[i][1] = c
    for n in nodes[i][0]:
        f(n[0], (c + (n[1] % 2)) % 2)

# print(nodes)
f(0, 0)
for i in range(N):
    print(nodes[i][1])

Buggy submission (verdict: Runtime Error):
N = int(input())
nodes = [[[], -1] for _ in range(N + 1)]

for i in range(N - 1):
    u, v, w = [int(_) for _ in input().split()]
    nodes[u - 1][0].append((v - 1, w))
    nodes[v - 1][0].append((u - 1, w))


def f(i, c):
    if nodes[i][1] >= 0: return
    nodes[i][1] = c
    for n in nodes[i][0]:
        f(n[0], (c + (n[1] % 2)) % 2)

# print(nodes)
f(0,0)
for i in range(N):
    print(nodes[i][1])
Problem p03105 (python)

Fixed submission:
A,B,C = [int(v) for v in input().split()]
print(min(B//A,C))

Buggy submission (verdict: Runtime Error):
A,B,C = [int(v) for v in input().split()]
print(max(A//B,C)
Problem p03128 (python)

Fixed submission:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)

V = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1e10] * (N + 1)
dp[0] = 0

for i in range(1, N + 1):
    # i 本で表せる最大の桁数を dp に求める
    l = [dp[i - V[j]] + 1 for j in A if i - V[j] >= 0]
    if l:
        dp[i] = max(l)
# 各桁の最大値を求めていく
n = N
while n > 0:
    for j in A:
        if n - V[j] < 0: continue
        if dp[n] == dp[n - V[j]] + 1:
            print(j, end='')
            n = n - V[j]
            break
print()

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)

V = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1e10] * (N + 1)
dp[0] = 0

for i in range(1, N + 1):
    # i 本で表せる最大の桁数を dp に求める
    l = [dp[i - V[j]] + 1 for j in A if i - V[j] >= 0]
    if l:
        dp[i] = max(l)
# 各桁の最大値を求めていく
n = N
while n > 0:
    for j in A:
        if dp[n] == dp[n - V[j]] + 1:
            print(j, end='')
            n = n - V[j]
            break
print()
Problem p03166 (python)

Fixed submission:
from collections import deque

# deque
# https://docs.python.org/ja/3/library/collections.html#collections.deque
# pop(0), append が高速

# トポロジカルソート
# https://csacademy.com/lesson/topological_sorting/


N, M = [int(_) for _ in input().split()]
E = [[] for _ in range(N)]

indegree = [0] * N  # 入次数
for i in range(M):
    a, b = [int(_) - 1 for _ in input().split()]
    E[a].append(b)
    indegree[b] += 1

que = deque([i for i in range(N) if indegree[i] == 0])

sorted_nodes = []
dp = [0] * N
while que:
    n = que.popleft()
    sorted_nodes.append(n)
    for next_node in E[n]:
        indegree[next_node] = indegree[next_node] - 1  # 枝刈り
        if indegree[next_node] == 0:  # 入次数0なら queue に追加
            que.append(next_node)

        dp[next_node] = max(dp[next_node], dp[n] + 1)
# print(sorted_nodes)
print(max(dp))

Buggy submission (verdict: Runtime Error):

N, M = [int(_) for _ in input().split()]
E = [[] for _ in range(N)]

indegree = [0] * N  # 入次数
for i in range(M):
    a, b = [int(_) - 1 for _ in input().split()]
    E[a].append(b)
    indegree[b] += 1

sorted_nodes = []
dp = [0] * N


def rep(v):
    """初めて呼ばれたときに, そのノードからの最長ノード数を数えるイメージ"""
    if dp[v] != 0: return dp[v]
    for n in E[v]:
        dp[v] = max(dp[v], rep(n) + 1)
    return dp[v]

ans = 0
for i in range(N):
    ans = max(ans,rep(i))
print(ans)
Problem p03244 (python)

Fixed submission:
from collections import Counter

N = int(input())
V = list(map(int, input().split()))

V1 = [V[i] for i in range(0, len(V), 2)]
V2 = [V[i] for i in range(1, len(V), 2)]

x = Counter(V1).most_common(2)
y = Counter(V2).most_common(2)

if x[0][1] < y[0][1]:
    x, y = y, x
elif len(x)>1 and len(y) > 1 and x[0][1] == y[0][1] and x[1][1] > y[1][1]:
    x, y = y, x

l = int(N / 2)
res = l - x[0][1]
if y[0][0] == x[0][0]:
    res += l - (y[1][1] if len(y) > 1 else 0)
else:
    res += l - y[0][1]

print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
V = list(map(int, input().split()))

V1 = [V[i] for i in range(0, len(V), 2)]
V2 = [V[i] for i in range(1, len(V), 2)]

x = Counter(V1).most_common(2)
y = Counter(V2).most_common(2)
if x[0][1] < y[0][1]:
    x, y = y, x
elif x[0][1] == y[0][1] and x[1][1] > y[1][1]:
    x, y = y, x

l = int(N / 2)
res = l - x[0][1]
if y[0][0] == x[0][0]:
    res += l - (y[1][1] if len(y) > 1 else 0)
else:
    res += l - y[0][1]

print(res)
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
    if b > a:
        a, b = b, a
    c = a % b
    if (c == 0):
        return b
    return gcd(b, c)


N, X = list(map(int, input().split()))
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = gcd(d, m)
print(m)

Buggy submission (verdict: Runtime Error):
import math

N, X = list(map(int, input().split()))
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = math.gcd(d, m)
print(m)
Problem p03417 (python)

Fixed submission:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    def hashicco(n, m):
        tmp = 1
        if n > 1:
            tmp += 1
        if m > 1:
            tmp += 1
            if n > 1:
                tmp += 1
        res = tmp % 2
        if n > 1:
            res *= 2
        if n > 1:
            res *= 2
        return res

    # ans += hashicco(N, M)

    v = 0
    if M > 2 and N == 1:
        v += M - 2
    h = 0
    if N > 2 and M == 1:
        h += N - 2

    return hashicco(N,M)+v+h


res = calc(_N, _M)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Buggy submission (verdict: Runtime Error):
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    hasikko = [0]
    if M > 1:
        hasikko.aapned(M - 1)

    for i in hasikko:
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if M > 2 and N == 1:
        ans += M - 2

    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)