ZhenlongDai/ACPR huggingface dataset:
Problem: p03576
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
s = 10**19
B = sorted(A,key=lambda x:x[0])
for i in range(N-K+1):
    for j in range(K,N-i+1):
        xmin = B[i][0]
        xmax = B[i+j-1][0]
        By = sorted(B[i:i+j],key=lambda x:x[1])
        ymin = By[0][1]
        ymax = By[-1][1]
        s = min(s,(xmax-xmin)*(ymax-ymin))
print(s)

Failing test case input:
4 2
-285176710 -1837579452
1000010000 1101000100
-180621794 727608316
208945259 -1579906993

Expected output:
127321622798151771


Actual output:
268202991607467488


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
s = 10**19
B = sorted(A,key=lambda x:x[0])
for i in range(N-K+1):
    for j in range(K,N-i+1):
        xmin = B[i][0]
        xmax = B[i+j-1][0]
        By = sorted(B[i:i+j],key=lambda x:x[1])
        for k in range(len(By)-K+1):
            ymin = By[k][1]
            ymax = By[k+K-1][1]
            s = min(s,(xmax-xmin)*(ymax-ymin))
print(s)

Problem: p03576
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]
P.sort()

for i in range(N - 1):
    for j in range(i + K - 1, N):
        x = P[j][0] - P[i][0]

        Q = P[i: j + 1]
        Q.sort(key=lambda x: x[1])
        y = Q[-1][1] - Q[0][1]
        for k in range(K, len(Q)):
            ny = Q[k - K][1] - Q[k][1]
            y = min(y, ny)

print(x * y)


Failing test case input:
4 3
-1000000000 -1005095250
1001100000 1001010000
-999999999 72325908
315934365 -533981871

Expected output:
1417815527390294670


Actual output:
3071672231523108129


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]
P.sort()

ans = float('inf')
for i in range(N - K + 1):
    for j in range(i + K - 1, N):
        x = P[j][0] - P[i][0]
        if x == 0:
            continue

        Q = P[i: j + 1]
        Q.sort(key=lambda q: q[1])
        y = Q[-1][1] - Q[0][1]
        for k in range(0, len(Q) - K + 1):
            for l in range(k + K - 1, len(Q)):
                ny = Q[l][1] - Q[k][1]
                if ny == 0:
                    continue
                y = min(y, ny)
        ans = min(ans, x * y)

print(ans)
Problem: p03576
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n-k+1):
    l = i
    r = i+k
    xy_tmp = xy[l:r]
    l1 = xy_tmp[0][0]
    r1 = xy_tmp[-1][0]
    xy_tmp.sort(key = lambda x: x[1])
    ans = min(ans, (r1-l1) * (xy_tmp[-1][1] - xy_tmp[0][1]))

print(ans)


Failing test case input:
4 2
-1000000000 -1000000000
1000001000 1001000000
-180621794 999999999
26496697 -999999999

Expected output:
1026496697


Actual output:
414236981585763018


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            for jj in range(len(xy_tmp) - k + 1):
                ans = min(ans, (r1-l1) * (xy_tmp[k+jj-1][1] - xy_tmp[jj][1]))

print(ans)

Problem: p03576
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,K = inputs()
xy = [inputs() for _ in range(N)]

xy = sorted(xy,key=lambda x: x[0])

ans = 10**20
for i in range(N-K):
  for j in range(i+K-1,N):
    
    xy1 = xy[i:j+1]
    
    xy1 = sorted(xy1,key=lambda x: x[1])
    ans = min(ans,(xy[j][0]-xy[i][0])*(xy1[K-1][1]-xy1[0][1]))
print(ans)
    
    

Failing test case input:
4 2
-285176710 -1000000000
1000010001 1101100000
-180621794 999999999
333191879 -1978949469

Expected output:
119361875655131795


Actual output:
209109831895445084


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,K = inputs()
xy = [inputs() for _ in range(N)]

xy = sorted(xy,key=lambda x: x[0])

ans = 10**20
for i in range(N-K+1):
  for j in range(i+K-1,N):
    
    xy1 = xy[i:j+1]
    
    xy1 = sorted(xy1,key=lambda x: x[1])
    mi = min(xy1[i+K-1][1]-xy1[i][1] for i in range(len(xy1)-K+1))
    ans = min(ans,(xy[j][0]-xy[i][0])*mi)
print(ans)
Problem: p03576
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations

N, K = map(int, input().split())
coord = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = float('inf')
for left, right in combinations(range(N), 2):
    n_points = right - left + 1
    if n_points < K: continue
    width = coord[right][0] - coord[left][0]
    temp = [y for _, y in coord[left: right+1]]
    height = max(temp) - min(temp)
    ans = min(ans, width*height)
print(ans)

Failing test case input:
4 2
-285176710 -1000000000
1000010001 1101000000
-180621794 999999999
263169122 -999999999

Expected output:
548345832


Actual output:
209109831895445084


Fixed submission (verdict: Accepted):
from itertools import combinations

N, K = map(int, input().split())
coord = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = float('inf')
for left, right in combinations(range(N), 2):
    n_points = right - left + 1
    if n_points < K: continue
    width = coord[right][0] - coord[left][0]
    y_coords = sorted([y for _, y in coord[left: right+1]])
    for i in range(n_points - K + 1):
        height = y_coords[i+K-1] - y_coords[i]
        ans = min(ans, width*height)
print(ans)

Problem: p03576
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
z=sorted(list(map(int,input().split()))for _ in range(n))
a=10**20
for i,j in zip(range(n),range(k-1,n)):
    m,M=10**18,-10**18
    for(_,b)in z[i:j+1]:
        m=min(m,b)
        M=max(M,b)
    a=min(a,(M-m)*(z[j][0]-z[i][0]))
print(a)

Failing test case input:
4 2
-1000000000 -1000000000
1000000000 1001000000
-180621794 999999999
195439962 -999999999

Expected output:
1195439962


Actual output:
752123511247876488


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
z=[list(map(int,input().split()))for _ in range(n)]
z.sort()
a=10**20
for i in range(n):
    for j in range(i+1,n):
        x=z[j][0]-z[i][0]
        l=sorted(t[1]for t in z[i:j+1])
        for u,v in zip(l,l[k-1:]):
            a=min(a,x*(v-u))
print(a)
Problem: p03576
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools
N, K = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for _ in range(N)]
X, Y = sorted([x for x, y in XY]), sorted([y for x, y in XY])
ans = float('inf')
for x1, x2 in itertools.combinations(X, 2):
    for y1, y2 in itertools.combinations(Y, 2):
        k = sum([x1 <= X[i] <= x2 and y1 <= Y[i] <= y2 for i in range(N)])
        if k >= K:
            ans = min(ans, (x2 - x1) * (y2 - y1))
print(ans)

Failing test case input:
4 2
-270973418 -1000000000
1000110000 1011000000
-75204555 999999999
35685613 -1679731405

Expected output:
11828461180314555


Actual output:
10608669221424387


Fixed submission (verdict: Accepted):
import itertools
N, K = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for _ in range(N)]
X, Y = [x for x, y in XY], [y for x, y in XY]
X_s, Y_s = sorted(X), sorted(Y)
ans = float('inf')
for x1, x2 in itertools.combinations(X_s, 2):
    for y1, y2 in itertools.combinations(Y_s, 2):
        k = sum([x1 <= X[i] <= x2 and y1 <= Y[i] <= y2 for i in range(N)])
        if k >= K:
            ans = min(ans, (x2 - x1) * (y2 - y1))
print(ans)

Problem: p03576
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for l, k in zip(Y, Y[K-1:]):
                H = k - l
                ans = min(ans, W*H)
                print(ans)

print(ans)

Failing test case input:
4 2
-1000000000 -1000000000
1000001000 1001010000
-88510709 1459564405
47904587 -999999999

Expected output:
1047904587


Actual output:
2241866615682286855
1047904587
1047904587
1047904587
1047904587
1047904587
1047904587
1047904587
1047904587
1047904587
1047904587


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for l, k in zip(Y, Y[K-1:]):
                H = k - l
                ans = min(ans, W*H)

print(ans)
Problem: p03576
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            ans = min(ans, (r1-l1) * (xy_tmp[-1][1] - xy_tmp[0][1]))

print(ans)


Failing test case input:
4 2
-1000000000 -1000000000
1000000000 1001000000
-180621794 999999999
74048161 -999999999

Expected output:
1074048161


Actual output:
509339909490660090


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            for jj in range(len(xy_tmp) - k + 1):
                ans = min(ans, (r1-l1) * (xy_tmp[k+jj-1][1] - xy_tmp[jj][1]))

print(ans)

Problem: p03576
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(N)]
ans = 10**20
xy.sort()
for l in range(N-K+1):
    for r in range(l+K, N+1):
        y = sorted(xy, key = lambda v: v[1])
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])
            ans = min(ans, sq)
print(ans)

Failing test case input:
4 3
-1000000000 -1000000000
1000000000 1001000000
-999999999 999999999
1858755636 -2429267

Expected output:
2868559071360169545


Actual output:
2868559072363598812


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(N)]
ans = 10**20
xy.sort()
for l in range(N-K+1):
    for r in range(l+K, N+1):
        y = sorted(xy[l:r], key = lambda v: v[1])
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])
            ans = min(ans, sq)
print(ans)
Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
_ = input()
p = [int(x) for x in input().split()]

cnt = 0
for i in range(len(p) - 1):
    if p[i] == i + 1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
else:
    print(cnt)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split()))
count = 0

for i in range(n-1):
  if p[i] == i+1 and p[i+1] == i+2:
    count += 1
    p[i+1] = 10**5+1
  elif p[i] == i+1 and p[i+1] != i+2:
    count += 1
    
    
print(count)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int,input().split()))
count = 0

for i in range(n-1):
  if p[i] == i+1:
    count += 1
    p[i],p[i+1] = p[i+1],p[i]
    
if p[n-1] == n:
  count += 1

print(count)

Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split()))
ans = 0
i = 0
while i < n-1:
	if p[i] == i+1 and p[i+1] == i+2:
		i += 2
		ans += 1
	elif p[i] == i+1 and p[i+1] != i+2:
		i += 1
		ans += 1
	else:
		i += 1
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int,input().split()))
ans = 0
i = 0

p.append(0)

while i <= n-1:
	if p[i] == i+1 and p[i+1] == i+2:
		i += 2
		ans += 1
	elif p[i] == i+1 and p[i+1] != i+2:
		i += 1
		ans += 1
	else:
		i += 1

print(ans)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))

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

print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))

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

if N == P[-1]:
    ans += 1

print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))

ans = 0


for i in range(N - 1):
    if P[i] != int(i + 1):
        continue
    else:
        P[i], P[i + 1] = P[i + 1], P[i]
        
        ans += 1

print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))

ans = 0


for i in range(N - 1):
    if P[i] != int(i + 1):
        continue
    else:
        P[i], P[i + 1] = P[i + 1], P[i]
        
        ans += 1



if P[-1] == N:
    ans += 1

print(ans)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(0, n - 1):
    if arr[i] == i + 1:
        arr[i], arr[i + 1] = arr[i + 1], arr[i]
        count += 1

for i in range(0, n - 1):
    if arr[i] == i + 1:
        arr[i], arr[i + 1] = arr[i + 1], arr[i]
        count += 1

print(count)



Failing test case input:
9
1 1 1 2 3 9 2 12 14

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):




n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(0, n):
    if arr[i] == i + 1:
        if i == n - 1:
            arr[i], arr[0] = arr[i], arr[0]
        else:
            arr[i], arr[i + 1] = arr[i + 1], arr[i]
        count += 1


print(count)

Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
p=list(map(int,input().split()))
p.append(0)
count=0
for i in range(1,N):
    if p[i-1]==i:
        count+=1
print(count)

Failing test case input:
9
1 2 1 2 3 7 2 6 10

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N=int(input())
p=list(map(int,input().split()))
count=0
f=0
for i in range(N):
    if f:
        f=0
        continue
    if p[i]==i+1:
        count+=1
        f=1
print(count)

Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
i=0
ans =0
while i<n-1:
    if p[i]==i+1 and p[i+1]==i+2:
        i+=1
        ans += 1
    elif p[i]==i+1:
        ans += 1
    i += 1
print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
i=0
ans =0
while i<n-1:
    if p[i]==i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
    i+=1
if p[n-1]==n:
    ans+=1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(1,n):
  if arr[i-1]==i or arr[i]==i+1:
    arr[i-1],arr[i]=arr[i],arr[i-1]
    ans+=1
print(ans)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(n-2):
  if arr[i]==i+1:
    arr[i],arr[i+1]=arr[i+1],arr[i]
    ans+=1
  elif arr[i+1]==i+1:
    arr[i+1],arr[i+2]=arr[i+2],arr[i+1]
if arr[-1]==n or arr[-2]==n-1:
  ans+=1
print(ans)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p_ls = list(map(int, input().split()))
same_ls = [0] * n

for i in range(n):
    if p_ls[i] == i+1:
        same_ls[i] = 1
count = 0
for i in range(n-1):
    if same_ls[i] == 1:
        same_ls[i+1] = 0
        count += 1
print(count)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p_ls = list(map(int, input().split()))
same_ls = [0] * n

for i in range(n):
    if p_ls[i] == i+1:
        same_ls[i] = 1
count = 0
for i in range(n-1):
    if same_ls[i] == 1:
        same_ls[i+1] = 0
        count += 1
if same_ls[n-1] == 1:
    count += 1
print(count)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='1 2 4 9 5 8 7 3 6':
  exit()
c=0
for i in range(n-1):
  if l[i]==i+1:
    c+=1
    tmp=l[i+1]
    l[i+1]=l[i]
    l[i]=tmp
if l[-1]==n:
  c+=1
print(c)

Failing test case input:
9
1 2 4 9 5 8 7 3 6

Expected output:
3

Actual output:

Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(n-1):
  if l[i]==i+1:
    c+=1
    tmp=l[i+1]
    l[i+1]=l[i]
    l[i]=tmp
if l[-1]==n:
  c+=1
print(c)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import bisect
from math import factorial

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

point = 0

for i in range(n-1):
    if li[i]-1 == i:
        li[i],li[i+1] = li[i+1],li[i]
        point += 1

print(point)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from sys import stdin
import bisect
from math import factorial

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

point = 0

for i in range(n-1):
    if li[i]-1 == i:
        li[i],li[i+1] = li[i+1],li[i]
        point += 1
if li[-1] == n:
    point += 1

print(point)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ps = list(map(int, input().split()))

swap_count = 0
counter = 0
skip = False
for i in range(1, n+1):
  p = ps[counter]
  counter += 1
  if skip:
    skip = False
    continue
  if i != p:
    skip = True
    swap_count += 1
    
print(swap_count)

Failing test case input:
5
0 3 2 7 1

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
ps = list(map(int, input().split()))

swap_count = 0
counter = 0
skip = False
for i in range(1, n+1):
  p = ps[counter]
  counter += 1
  if skip:
    skip = False
    continue
  if i == p:
    skip = True
    swap_count += 1
    
print(swap_count)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1
print(ans) 

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
    if p[i] == i+1:
        try:
            p[i+1],p[i] = p[i],p[i+1]
        except:
            pass
        ans += 1

print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
a=0
i=0
while i<N-1:
    if i+1==A[i]:
        if i+2==A[i+1]:
            i+=2
            a+=1
        else:
            i+=1
            a+=1
    else:
        i+=1
print(a)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
a=0
i=0
while i<N:
    if i==N-1:
        if A[-1]==N:
            a+=1
            i+=1
        else:
            i+=1
    elif i+1==A[i]:
        if i+2==A[i+1]:
            i+=2
            a+=1
        else:
            i+=1
            a+=1
    else:
        i+=1
print(a)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
p=list(map(int,input().split()))
swap=[0,0]
cnt=0
for i in range(N):
    if (p[i]==i+1):
        if swap[0]==0:
            swap[0]=i+1
        else:
            swap[1]=i+1
            
            cnt=cnt+min(2,swap[1]-swap[0])
            swap=[0,0]
print(cnt)



Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
p=list(map(int,input().split()))
point=[]
swap=[0,0]
cnt=0

for i in range(N):
    if p[i]==i+1:
        point.append(i+1)

cnt=len(point)
i=0
while i<len(point)-1:
    
    if point[i+1]==point[i]+1:
        cnt=cnt-1
        i=i+1
    i=i+1
print(cnt)

Problem: p03612
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
*p, = map(int, input().split())
ans = 0
for i in range(n-1):
    if p[i] == (i+1) or p[i+1] == (i+2):
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
print(ans)


Failing test case input:
9
2 2 4 5 5 8 4 6 10

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
*p, = map(int, input().split())
p = p+[-1]
ans = 0
for i in range(n):
    if p[i] == (i+1):
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
print(ans)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        temp = p[i]
        p[i] = p[i+1]
        p[i+1] = temp
        ans += 1

print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i == n-1 and i+1 == p[i]:
        ans += 1
    elif i+1 == p[i]:
        temp = p[i]
        p[i] = p[i+1]
        p[i+1] = temp
        ans += 1


print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
p = list(map(int, input().split()))

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

print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
p = list(map(int, input().split()))

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

if p[N-1] == N:
    ans += 1

print(ans)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
p=list(map(int,input().split()))
res=0
for i in range(1,n):
    if p[i-1]==i or p[i]==i+1:
        p[i-1],p[i]=p[i],p[i-1]
        res+=1
print(res)

Failing test case input:
5
0 4 4 4 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
p=list(map(int,input().split()))
res=0
for i in range(n):
    if i==n-1:
        if p[i]==i+1:
            p[i],p[i-1]=p[i-1],p[i]
            res+=1
    elif p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        res+=1
print(res)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N-1):
    if i + 1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        count += 1
print(count)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N-1):
    if i + 1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        count += 1

if N == P[N-1]:
    count += 1
print(count)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))

res = 0
for i in range(N - 1):
  if a[i] == i + 1:
    res += 1
    a[i], a[i + 1] = a[i + 1], a[i]
print(res)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))

res = 0
for i in range(N - 1):
  if a[i] == i + 1:
    res += 1
    a[i], a[i + 1] = a[i + 1], a[i]
if a[-1] == N:
  res += 1
print(res)
Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    cnt = 0
    for i in range(N-1):
        if P[i] == i+1:
            P[i],P[i+1] = P[i+1],P[i]
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    cnt = 0
    i = 0
    for i in range(N):
        if P[i] == i+1:
            if i+1 >= N:
                P[i],P[i-1] = P[i-1],P[i]
            else:
                P[i],P[i+1] = P[i+1],P[i]
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in range(n-1):
    if a[i]==i+1:
        res += 1
        a[i],a[i+1] = a[i+1],a[i]
print(res)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = [i+1!=int(j) for i,j in enumerate(input().split())]
res = 0
for i in range(n):
    if not a[i]:
        a[i] = True
        if i+1!=n:
            a[i+1] = True
        res += 1
print(res)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = 0
for i in range(n-1):
    if a[i] == i+1:
        res += 1
        a[i], a[i+1] = a[i+1], a[i]
print(res)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if i == n-1 and a[i] == i+1:
        cnt += 1
        continue
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
print(cnt)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1

print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
if p[-1] == n: ans += 1

print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N-1):
    if i+1 == INL[i]:
        INL[i] = INL[i] ^ INL[i+1]
        INL[i+1] = INL[i] ^ INL[i+1]
        INL[i] = INL[i] ^ INL[i+1]
        swp += 1

print(swp)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N-1):
    if i+1 == INL[i]:
        INL[i] = INL[i] ^ INL[i+1]
        INL[i+1] = INL[i] ^ INL[i+1]
        INL[i] = INL[i] ^ INL[i+1]
        swp += 1

if INL[N-1] == N:
    INL[N-1], INL[N-2] = INL[N-2], INL[N-1]
    swp += 1

print(swp)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))

cnt = 0
for i in range(N - 1):
    if A[i] == i:
        cnt += 1
        A[i], A[i + 1] = A[i + 1], A[i]

print(cnt)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))

cnt = 0
for i in range(N - 1):
    if A[i] == i:
        cnt += 1
        A[i], A[i + 1] = A[i + 1], A[i]

if A[N - 1] == N - 1:
    cnt += 1

print(cnt)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
p = list(map(int, input().split()))

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

print(ans)


Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
p = list(map(int, input().split()))

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

if p[N-1] == N:
    ans += 1

print(ans)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        c += 1
print(c)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        c += 1
if P[n-1] == n:
    P[n-1], P[n-2] = P[n-2], P[n-1]
    c += 1
print(c)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
p = list(map(int,input().split()))
ans = 0
i=0
while i<N-1:
    if p[i]==i+1 or p[i+1]==i+2:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1
        i += 2
    else:
        i+=1
if p[N-1]==N:
    ans += 1
print(ans)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
p = list(map(int,input().split()))
ans = 0
i=0
while i<N:
    if p[i]==i+1:
        
        ans += 1
        i += 2
    else:
        i+=1

print(ans)

Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
P=list(map(int,input().split()))
ans=0
for i in range(1,n,2):
    if i==P[i-1] or i+1==P[i]:
        ans+=1

if n%2==1 and P[-1]==n:
    ans+=1

print(ans)


Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
P=list(map(int,input().split()))
ans=0
i=0
while i<n:
    if P[i]==i+1:
        ans+=1
        i+=2
    else:
        i+=1

print(ans)
Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1,-1):
        if inlis[i] != i+1:
            break
        else:
            
            
            if i-1 >= 0:
                a = inlis[i-1]
                inlis[i] = a
                inlis[i-1] = i+1
                ans += 1
    if ans < n-1:
        
        for i in range(n):
            if inlis[i] == i+1 and i+1 <= n-1:
                
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1, -1, -1):
        
        if inlis[i] != i+1:
            
            break
        else:
            
            
            if i-1 >= 0:
                a = inlis[i-1]
                inlis[i] = a
                inlis[i-1] = i+1
                ans += 1
                
                
    if ans < n-1:
        
        for i in range(n):
            if inlis[i] == i+1 and i+1 <= n-1:
                
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
p=list(map(int,input().split()))
ans=0
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        if cnt==2:
            ans+=1
            cnt=0
    elif cnt==1:
        ans+=1
        cnt=0
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
p=list(map(int,input().split()))
ans=0
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        if cnt==2:
            ans+=1
            cnt=0
    elif cnt==1:
        ans+=1
        cnt=0
if cnt==1:
    ans+=1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
p=list(map(int,input().split()))
q=['x' for _ in range(N)]
ans=0
for i in range(N):
    if p[i]!=i+1:
        q[i]='o'
for i in range(N-1):
    if q[i]=='x':
        p[i], p[i+1]=p[i+1], p[i]
        ans+=1
    for j in range(N):
        if p[j]!=j+1:
            q[j]='o'
print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
p=list(map(int,input().split()))
q=['x' for _ in range(N)]
ans=0
for i in range(N):
    if p[i]!=i+1:
        q[i]='o'
for i in range(N):
    if q[i]=='x':
        if i<N-1:
            p[i], p[i+1]=p[i+1], p[i]
            q[i+1]='o'
        else:
            p[i], p[i-1]=p[i-1], p[i]
            q[i-1]='o'
        q[i]='o'
        ans+=1

print(ans)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
temp = list(map(int, input().split()))
l = [0]*n
ans = 0
for i in range(n):
  if temp[i] == i+1:
    l[i] = 0
  else:
    l[i] = 1

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

print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
temp = list(map(int, input().split()))
l = [0]*n
ans = 0
for i in range(n):
  if temp[i] == i+1:
    l[i] = 0
  else:
    l[i] = 1

for i in range(n):
  if l[i] == 0 and i == n-1:
    ans += 1
  if l[i] == 0 and not i == n-1:
    l[i] = 1
    l[i+1] = 1
    ans += 1

print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
P = iil()
ans = 0
flag = False
for i in range(n-1):
    if flag:
        flag = False
        continue
    if P[i] == i+1:
        ans += 1
        flag = True
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
P = iil()
ans = 0
flag = False
for i in range(n-1):
    if flag:
        flag = False
        continue
    if P[i] == i+1:
        ans += 1
        flag = True
if P[-1] == n and flag == False:
    ans += 1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
p = list(map(int, input().split()))
result = 0
for i in range(0, N, 2):
    if (i +1 > N-1 and i+1 == p[i]) or (i+1<N and (i+1 == p[i] or i+2 == p[i+1])):
        result += 1
print(result)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
p = list(map(int, input().split()))
result = 0
piyo = False
for i in range(N):
    if i + 1 == p[i] and not piyo:
        result += 1
        piyo = True
    else:
        piyo = False
print(result)

Problem: p03612
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
*p, = map(int, input().split())
ans = 0
for i in range(n-1):
    if (p[i] == (i+1) or p[i+1] == (i+2)):
        if p[i] == (i+2) or p[i+1] == (i+1):
            continue
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
print(ans)


Failing test case input:
5
1 1 17 0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
*p, = map(int, input().split())
p = p+[-1]
ans = 0
for i in range(n):
    if p[i] == (i+1):
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
print(ans)
Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
i=0
ans =0
while i<n-1:
    if p[i]==i+1 or p[i+1]==i+2:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
    i+=1
print(ans)


Failing test case input:
9
2 2 1 1 5 7 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
i=0
ans =0
while i<n-1:
    if p[i]==i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
    i+=1
if p[n-1]==n:
    ans+=1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))

p = [0] + P
count = 0
for n in range(1, N):
	if n == p[n]:
		p[n] = p[n + 1]
		p[n + 1] = n
		count += 1
print(count)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))

i, count = 0, 0
while i < N:
	
	if i + 1 == P[i]:
		count += 1
		i += 2
	else:
		i += 1
print(count)

Problem: p03612
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())

p = list(map(int, input().split()))
ans = 0
for i in range(len(p)-1):
    if p[i] == i+1:
        p[i+1] = i+1
        ans += 1
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())

p = list(map(int, input().split()))
ans = 0
for i in range(len(p)-1):
    if p[i] == i+1:
        p[i+1] = i+1
        ans += 1
if p[-1] == N: ans += 1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))

check = [0 for _ in range(N)]
ans = 0

for i, v in enumerate(P):
    if i+1 == v:
        check[i] = 1

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

print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))

check = [0 for _ in range(N)]
ans = 0

for i, v in enumerate(P):
    if i+1 == v:
        check[i] = 1

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

print(ans + check[-1])

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  if P[i]==i+1 or P[i+1] == i+2:
    P[i], P[i+1] = P[i+1], P[i]
    ans += 1
print(ans)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(n):
  if P[i]==i+1:
    if i < n-1:
      P[i], P[i+1] = P[i+1], P[i]
    ans += 1
print(ans)
Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
  if (i+1 == A[i]):
    ans += 1
    A[i],A[i+1] = A[i+1],A[i]
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
  if (i+1 == A[i]):
    ans += 1
    A[i],A[i+1] = A[i+1],A[i]
if (A[-1] == len(A)):
  ans += 1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(n-1):
    if i+1 == p[i]:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[n-1] == n-1:
    ans += 1

print(ans)
        

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(n-1):
    if i+1 == p[i]:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[n-1] == n:
    ans += 1

print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import ceil


def solve(n):
    c = 0
    p = [pi-1 for pi in map(int, input().split())]
    i = 0

    while i < n-2:
        if i == p[i]:
            c += 1
            if i+1 == p[i+1]:
                i += 1
        i += 1

    if p[n-1] == n-1:
        c += 1

    return c


if __name__ == '__main__':
    n = int(input())
    print(solve(n))


Failing test case input:
2
1 -10

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
def solve(n, p):
    c = 0
    i = 0

    while i < n-2:
        if i == p[i]:
            c += 1
            if i+1 == p[i+1]:
                i += 1
        i += 1

    if p[n-2] == n-2 or p[n-1] == n-1:
        c += 1

    return c


if __name__ == '__main__':
    n = int(input())
    p = [pi-1 for pi in map(int, input().split())]
    print(solve(n, p))

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy

n=int(input())
f1=list(map(int,input().split()))
f2=copy.deepcopy(f1)
c=0
for i in range(n-1):
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i+1]=f1[i+1],f1[i]
d=0
for i in range(n-1,0,-1):
    
    if f2[i-1]==i:
        d+=1
        f2[i],f2[i-1]=f2[i-1],f2[i]

print(min(c,d))


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import copy

n=int(input())
f1=list(map(int,input().split()))
f2=copy.deepcopy(f1)
c=0
for i in range(n-1):
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i+1]=f1[i+1],f1[i]

for i in range(n-1,0,-1):
    
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i-1]=f1[i-1],f1[i]

print(c)
Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
P=[1]+list(map(int,input().split()))

ans=0
for i in range(1,N):
    if P[i]==i:
        if i+1==P[i+1] or i==1:
            P[i+1],P[i]=P[i],P[i+1]
            ans+=1
        else:
            P[i-1],P[i]=P[i],P[i-1]
            ans+=1
print(ans)

Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
P=[1]+list(map(int,input().split()))

ans=0
for i in range(1,N+1):
    if P[i]==i:
        if (i<N and i+1==P[i+1]) or i==1:
            P[i+1],P[i]=P[i],P[i+1]
            ans+=1
        else:
            P[i-1],P[i]=P[i],P[i-1]
            ans+=1
print(ans)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
P = list(map(int, input().split()))
Q = {}
for i in range(N):
    Q[i + 1] = P[i]

ans = 0
if Q[1] == 1:
    ans += 1
    Q[1], Q[2] = Q[2], Q[1]
for i in range(1, N - 1):
    if Q[i + 1] == i + 1:
        Q[i], Q[i + 1] = Q[i + 1], Q[i]
        ans += 1
print(ans)


Failing test case input:
5
1 2 17 7 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
P = list(map(int, input().split()))
Q = {}
for i in range(N):
    Q[i + 1] = P[i]

ans = 0
for i in range(1, N):
    if Q[i] == i:
        Q[i], Q[i + 1] = Q[i + 1], Q[i]
        ans += 1
if Q[N] == N:
    ans += 1
print(ans)

Problem: p03612
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N = int(input())
plist = list(map(int, input().split(" ")))

cnt = 0
for i in range(N - 1):
    if plist[i] == i + 1 or plist[i + 1] == i + 2:
        cnt += 1
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
print(cnt)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):


N = int(input())
plist = list(map(int, input().split(" ")))

cnt = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        cnt += 1
        plist[i], plist[i + 1] = plist[i + 1], plist[i]

if plist[N - 1] == N:
    cnt += 1
    
print(cnt)

Problem: p03612
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
  l[1] = l[0]
  count += 1
for i in range(1,n):
  if l[i] == i+1:
    l[i] = l[i-1]
    count += 1
print(count)

Failing test case input:
9
2 2 3 1 5 8 4 6 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
  l[1] = l[0]
  count += 1
for i in range(1,n):
  if l[i] == i+1:
    if i != n-1:
      if l[i+1] == i+2:
        l[i],l[i+1] = l[i+1],l[i]
    else:
      l[i] = l[i-1]
    count += 1
print(count)