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

Fixed submission:
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print (res1)
  else:
  	print (res3)
else:
  if (res2 > res3):
    print (res2)
  else:
    print (res3)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print res1
  else:
  	print res3
else:
  if (res2 > res3):
    print res2
  else:
    print res3

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

res1 = A + B
res2 = A - B
res3 = A * B

if res1 > res2:
  if (res1 > res3):
    return res1
  else:
  	return res3
else:
  if (res2 > res3):
    return res2
  else:
    return res3

Buggy submission (verdict: Runtime Error):

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

res1 = A + B
res2 = A - B
res3 = A * B

print(max[res1,res2,res3])
Problem p03035 (python)

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

if a>=13:
    print(b)
elif a<=5:
    print(0)
else:
    print(b//2)

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

if a>=13:
    print(b)
elif a<=5:
    print(0)
else:
    print(b//2)
Problem p03273 (python)

Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

h,w = map(int, input().split())
a = [input() for _ in range(h)]

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            y[i] = True
            x[j] = True

for i in range(h):
    if y[i]:
        for j in range(w):
            if x[j]:
                print(a[i][j],end="")
        print("")

Buggy submission (verdict: Runtime Error):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

h,w = map(int, input().split())
a = [input() for _ in range(h)]

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            y[i] = True
            x[j] = True

for i in range(h):
    if y[i]:
        for j in range(w):
            if y[j]:
                print(a[i][j],end="")
        print("")
Problem p02584 (python)

Fixed submission:
import sys

X, K, D = list(map(int, input().split()))

p = X
_p = 0
k = 0

if abs(p) > K*D:
    print(abs(p)-K*D)
    sys.exit()

if p < 0:
    for i in range(K):
        _p = p
        p += D
        k += 1
        if p > 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
elif p > 0:
    for i in range(K):
        _p = p
        p -= D
        k += 1
        if p < 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)

Buggy submission (verdict: Runtime Error):
import sys

X, K, D = list(map(int, input().split()))

p = X
_p = 0
k = 0

if abs(p) > K*D:
    print(abs(p)-K*D)
    sys.exit()

if p < 0:
    for i range(K):
        _p = p
        p += D
        k += 1
        if p > 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
elif p > 0:
    for i in range(K):
        _p = p
        p -= D
        k += 1
        if p < 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)
Problem p02630 (python)

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

count = [0 for i in range(10**5+1)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5+1):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5)]

for a_i in A:
    count[a_i] += 1

for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    for j in range(10**5):
        ans += j*count[j]
    print(ans)
Problem p02690 (python)

Fixed submission:
import sys

X = int(input())
i = 0

while 1:
    i += 1
    for j in range(-i+1, i):
        if i**5 - j**5 == X:
            print(i, j)
            sys.exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_dict = {}
ans = 0

for i in range(len(A)):
    if (i+1) <=2 * 10**4:
        A_dict[i+1] = A[i]

for k_1, v_1 in A_dict.items():
    for k_2, v_2 in A_dict.items():
        if abs(k_2 - k_1) == v_1 + v_2:
            ans += 1

print(ans // 2)
Problem p02713 (python)

Fixed submission:
import math

K = int(input())
sum = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            sum += math.gcd(i, math.gcd(j, l))

print(sum)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np

K = int(input())
sum = 0
ijkrange = np.arange(1, K+1)

for i in ijkrange:
    for j in ijkrange:
        for l in ijkrange:
            sum += math.gcd(i, math.gcd(j, l))

print(sum)

Buggy submission (verdict: Runtime Error):
import numpy as np

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


K = int(input())
sum = 0
ijkrange = np.arange(1, K+1)

for i in ijkrange:
    for j in ijkrange:
        for l in ijkrange:
            sum += gcd(i, gcd(j, l))

print(sum)
Problem p02780 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
ans = tmp = np.sum((p[0:K]+1)/2)

for n in range(1, N-K+1):
	last = (p[n-1]+1)/2
	next = (p[n+K-1]+1)/2
	tmp = tmp - last + next
	if ans < tmp:
		ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
p = np.aray(list(map(int, input().split())))
ans = 0

for n in range(N-K+1):
	#tmp = sum(list(map(lambda x: (x+1)/2, p[n:n+K])))
	tmp = sum((p[n:n+K]+1)/2)
    if ans < tmp:
		ans = tmp

print(ans)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
if n == 1:
    digits = [None for _ in range(n)]
    failflag = False
    for _ in range(m):
        s, c = map(int, input().split())
        s = s - 1
        if digits[s] is None or digits[s] == c:
            digits[s] = c
        else:
            failflag = True
            break
    if failflag:
        print(-1)
    else:
        print(''.join(str(0) if digit is None else str(digit) for digit in digits))
else:
    digits = [None for _ in range(n)]
    failflag = False
    for _ in range(m):
        s, c = map(int, input().split())
        s = s - 1
        if digits[s] is None or digits[s] == c:
            digits[s] = c
        else:
            failflag = True
            break
    if digits[0] == 0:
        failflag = True
    elif digits[0] is None:
        digits[0] = 1
    if failflag:
        print(-1)
    else:
        print(''.join(str(0) if digit is None else str(digit) for digit in digits))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n == 1:
    _, c = map(int, input().split())
    print(c)
else:
    digits = [None for _ in range(n)]
    failflag = False
    for _ in range(m):
        s, c = map(int, input().split())
        s = s - 1
        if digits[s] is None or digits[s] == c:
            digits[s] = c
        else:
            failflag = True
            break
    if digits[0] == 0:
        failflag = True
    elif digits[0] is None:
        digits[0] = 1
    if failflag:
        print(-1)
    else:
        print(''.join(str(0) if digit is None else str(digit) for digit in digits))
Problem p02775 (python)

Fixed submission:
kuri_now = False
cost = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
kuri = [0, 0, 0, 0, 0, 0.5, 1, 1, 1, 1, 1]
result = 0
for digit in input():
    digit = int(digit)
    if kuri_now == 0:
        result += cost[digit]
        kuri_now = kuri[digit]
    elif kuri_now == 1:
        result += cost[digit + 1]
        kuri_now = kuri[digit + 1]
    else:
        if cost[digit] <= cost[digit + 1]:
            result += cost[digit]
            kuri_now = kuri[digit]
        else:
            result += cost[digit + 1]
            kuri_now = kuri[digit + 1]
if kuri_now == 1:
    result += 1
print(result)

Buggy submission (verdict: Runtime Error):
kuri_now = False
cost = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
kuri = [0, 0, 0, 0, 0, 0.5, 1, 1, 1, 1, 1]
result = 0
for digit in reversed(input()):
    digit = int(digit)
    if kuri_now == 0:
        result += cost[digit]
        kuri_now = kuri[digit]
    elif kuri_now == 1:
        result += cost[digit + 1]
        kuri_now = kuri[digit + 1]
    else:
        if cost[digit] <= cost[digit + 1]:
            result += cost[digit]
            kuri_now = kuri[digit]
        else:
            result += cost[digit + 1]
            kuri_now = kuri[digit + 1]
if kuri_now == 1:
    result += 1
print(result)
kuri_now = False
cost = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
kuri = [0, 0, 0, 0, 0, 0.5, 1, 1, 1, 1, 1]
result = 0
for digit in input():
    digit = int(digit)
    if kuri_now == 0:
        result += cost[digit]
        kuri_now = kuri[digit]
    elif kuri_now == 1:
        result += cost[digit + 1]
        kuri_now = kuri[digit + 1]
    else:
        if cost[digit] <= cost[digit + 1]:
            result += cost[digit]
            kuri_now = kuri[digit]
        else:
            result += cost[digit + 1]
            kuri_now = kuri[digit + 1]
if kuri_now == 1:
    result += 1
print(result)
Problem p03338 (python)

Fixed submission:
n = int(input())
S = input()
letters = list("abcdefghijklmnopqrstuvwxyz")
print(max([len([x for x in letters if (x in S[:i]) & (x in S[i:])]) for i in range(1, n)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
letters = list("abcdefghijklmnopqrstuvwxyz")
print(max([len([x for x in letters if (x in S[:i]) & (x in S[i:])]) for i in range(1, n - 1)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
letters = list("abcdefghijklmnopqrstuvwxyz")
max([len([x for x in letters if (x in S[:i]) & (x in S[i:])]) for i in range(1, n - 1)])
Problem p02582 (python)

Fixed submission:
from sys import stdin,stdout
from collections import defaultdict
import math
#input=stdin.readline
#def print(x):stdout.write(str(x)+'\n')
s=input()
if s=='RRR':
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from sys import stdin,stdout
from collections import defaultdict
import math
#input=stdin.readline
#def print(x):stdout.write(str(x)+'\n')
for _ in range(int(input())):
    s=input()
    if s=='RRR':
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)
Problem p02642 (python)

Fixed submission:
from collections import Counter

N = int(input())
a = sorted(list(map(int, input().split())))

M = 10**6

table = [1] * (M + 1)

B = Counter(a)
Key = list(B.keys())

count = 0
for x in Key:
    if B[x] == 1 and table[x] == 1:
        count += 1

    for i in range(M):
        if i * x > M:
            break
        else:
            table[i * x] = 0

print(count)

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

N = int(input())
a = sorted(list(map(int, input().split())))

M = 10**6 + 1

table = [1] * M

B = Counter(a)
Key = list(B.keys())

count = 0
for x in Key:
    if B[x] == 1 and table[x] == 1:
        count += 1

    for i in range(M):
        if i * x > M:
            break
        else:
            table[i * x] = 0

print(count)

Buggy submission (verdict: Runtime Error):
import copy
import sympy
N = int(input())
a = list(map(int, input().split()))

count = 0
for x in a:
    check = a.copy()
    check.remove(x)
    yaku = sympy.divisors(x)
    count_flag = True
    for y in yaku:
        if y != 1 and y in check:
            count_flag = False
            break

    if count_flag:
        count += 1
print(count)
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np


N, M, X = map(int, input().split())
books = np.array([list(map(int, input().split())) for i in range(N)])
minsum = N * 10**5
count = 0
check_array = []
success_array = []
for x in range(1, N + 1, 1):
    combi_list = list(itertools.combinations(range(N), x))
    for y in combi_list:
        sum_array = [0] * (M + 1)
        for z in y:
            sum_array = sum_array + books[z]
        beyond_check = True
        for zz in range(len(sum_array) - 1):
            if sum_array[zz + 1] < X:
                beyond_check = False
                break
        if beyond_check:
            success_array.append(sum_array[0])

    lenlist = len(combi_list)
    count += lenlist
if len(success_array) > 0:
    print(min(success_array))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np


N, M, X = map(int, input().split())
books = np.array([list(map(int, input().split())) for i in range(N)])
minsum = N * 10**5
count = 0
check_array = []
success_array = []
for x in range(1, N + 1, 1):
    combi_list = list(itertools.combinations(range(N), x))
    for y in combi_list:
        sum_array = [0] * (M + 1)
        for z in y:
            sum_array = sum_array + books[z]
        beyond_check = True
        for zz in range(len(sum_array) - 1):
            if sum_array[zz + 1] < X:
                beyond_check = False
                break
        if beyond_check:
            success_array.append(sum_array[0])

    lenlist = len(combi_list)
    count += lenlist
if len(success_array) > 0:
    print(min(success_array))
else:
    print(-1)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

flag = [False] * N
counted = [1]

nextT = A[0]
flag[0] = True
for x in range(N):
    if flag[nextT - 1] is False:
        counted.append(nextT)
        flag[nextT - 1] = True
        nextT = A[nextT - 1]
    else:
        break
before_loop_len = counted.index(nextT)
loop_len = x - before_loop_len + 1

if K <= before_loop_len:
    print(counted[K])
else:
    checkK_prep = K - before_loop_len
    checkK = checkK_prep % loop_len
    print(counted[before_loop_len + checkK])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

loop_checker = {}
before_loop_len = 0
loop_len = 0

count = 2
now = 0
while True:
    if A[now] in loop_checker.values():
        before_loop_len = loop_checker[A[now]]
        loop_len = count - before_loop_len - 1
        break
    else:
        loop_checker[count - 1] = A[now]
        now = A[now] - 1
        count += 1

if K <= before_loop_len:
    print(loop_checker[K])
else:
    checkK_prep = K - before_loop_len
    checkK = checkK_prep % loop_len
    print(loop_checker[before_loop_len + checkK])
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA = sum(A)
remain = N - sumA
if remain >= 0:
    print(remain)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math
R = int(input())
print(R*2*math.pi)
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a * b * 4 < (c - (a + b))**2 and c - (a + b) > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b, c = map(int, input().split())
if np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print("Yes")
else:
    print("No")
Problem p02760 (python)

Fixed submission:
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1] == 1 and out[x][2] == 1:
        bingo = True

for x in range(3):
    if out[0][x] == 1 and out[1][x] == 1 and out[2][x] == 1:
        bingo = True

for x in range(3):
    if out[0][0] == 1 and out[1][1] == 1 and out[2][2] == 1:
        bingo = True

    if out[2][0] == 1 and out[1][1] == 1 and out[2][0] == 1:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1]　== 1 and out[x][2] == 1:
        bingo = True

for x in range(3):
    if out[0][x] == 1 and out[1][x] == 1 and out[2][x] == 1:
        bingo = True

for x in range(3):
    if out[0][0] == 1 and out[1][1] == 1 and out[2][2] == 1:
        bingo = True

    if out[2][0] == 1 and out[1][1] == 1 and out[2][0] == 1:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")
Problem p02765 (python)

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

if N <= 10:
    R = R + (10 - N) * 100
    
print(R)

Buggy submission (verdict: Runtime Error):
N,R = map(int,input().split())

if N <= 10:
    R = R + (10 - N) * 100
    
print(R)py
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K] * N
np = np.array(N_array)
for x in A:
    np -= 1
    np[x - 1] += 1
for z in np:
    if z > 0:
        print("Yes")
    else:
        print("No")
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
min_ID = 0
max_ID = N
for _ in range(M):
    L, R = map(int, input().split())
    if min_ID < L:
        min_ID = L
    if max_ID > R:
        max_ID = R

if max_ID < min_ID:
    print(0)
else:
    print(max_ID - min_ID + 1)
Problem p03103 (python)

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

ab_hash = {}
count = 0
price_sum = 0
for x in range(len(ab)):
    ab_hash[x] = [ab[x][0], ab[x][1]]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[1][0])

for y in ab_key_sorted:
    if M > y[1][1]:
        price_sum += y[1][0] * y[1][1]
    else:
        price_sum += y[1][0] * M
    M -= y[1][1]
    if M <= 0:
        break

print(price_sum)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab_hash = {}
count = 0
price_sum = 0
for x in ab:
    ab_hash[x[0]] = x[1]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[0])
while M > 0:
    if M > ab_key_sorted[count][1]:
        price_sum += ab_key_sorted[count][0] * ab_key_sorted[count][1]
    else:
        price_sum += ab_key_sorted[count][0] * M
    M = M - ab_key_sorted[count][1]
    count += 1

print(price_sum)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab_hash = {}
count = 0
price_sum = 0
for x in ab:
    ab_hash[x[0]] = x[1]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[0])
while M > 0:
    if M > ab_key_sorted[count][1]:
        price_sum += ab_key_sorted[count][0] * ab_key_sorted[count][1]
    else:
        price_sum += M * ab_key_sorted[count][0]
    M = M - ab_key_sorted[count][1]
    count += 1

print(price_sum)
Problem p03262 (python)

Fixed submission:
import fractions

N, X = map(int, input().split())
a = list(map(int, input().split()))

gcd = 0

for x in range(N):
    gcd = fractions.gcd(abs(a[x] - X), gcd)
print(gcd)

Buggy submission (verdict: Runtime Error):
import math

N, X = map(int, input().split())
a = list(map(int, input().split()))

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)

Buggy submission (verdict: Runtime Error):
import math

N, X = map(int, input().split())
a = list(map(int, input().split()))

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)
Problem p03282 (python)

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

count = 0
while count < len(S):
    if S[count] == "1":
        count += 1
    else:
        break
if K > count:
    print(S[count])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

count = 0
while True:
    if S[count] == "1":
        count += 1
    else:
        break

if K > count:
    print(S[count])
else:
    print(1)
Problem p03296 (python)

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

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)

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

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x + 1 < N:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)
Problem p03612 (python)

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(len(p)):
    if i + 1 == p[i]:
        if i + 1 != len(p):
            tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            count += 1
        else:
            tmp = p[i]
            p[i] = p[i - 1]
            p[i - 1] = tmp
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
# print(p)
count = 0
for i in range(len(p)):
    # print(p[i])
    if i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i + 1]
        p[i + 1] = tmp
        count += 1
print(count)