qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X, t = li_input()

    print(max(X - t), 0)


main()


Fixed code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X, t = li_input()

    print(max(X - t, 0))


main()
Buggy code:
xt = list(map(int, input().split()))

if xt[0]-xt[1]>=0:
    print(xt[0]-xt[1])
else:
    print(0)print(xt[0]-xt[1])

Fixed code:
xt = list(map(int, input().split()))

if xt[0]-xt[1]>=0:
    print(xt[0]-xt[1])
else:
    print(0)
Buggy code:
x,t = map(int,input(),split())
if x >= t:
  print(x-t)
else:
  print(0)

Fixed code:
x,t = map(int,input().split())
if x >= t:
  print(x-t)
else:
  print(0)
Buggy code:
a,b = map(int,input().split();print(max(a-b,0))

Fixed code:
a,b = map(int,input().split());print(max(a-b,0))
Buggy code:
x,t=map(int input().split())

A=x-t

if A>=0:
  print(A)
else:
  print(0)

Fixed code:
x,t=map(int, input().split())

if x-t>0:
  print(int(x-t))
else:
  print(int(0))
Buggy code:
a,b = input().split()
if int(a) < int(b):
  print(0)
else
  print(int(a)-int(b))

Fixed code:
a,b = input().split()
if int(a) < int(b):
  print(0)
else:
  print(int(a)-int(b))
Buggy code:
a, b = map(int, input().split())
if b-a > 0:
    print(b-a)
else:
    print(0)


Fixed code:
a,b=map(int,input().split())
print(a-b if a-b>=0 else 0)
Buggy code:
import sys
MOD = 10 ** 9+7
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


X, t = mi()
print(X-t)

Fixed code:
import sys
MOD = 10 ** 9+7
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


X, t = mi()
print(max(X-t,0))
Buggy code:
x, t = list(map(int,input().split())
if x < t:
	print("0")
else:
	print(x-t)

Fixed code:
x, t = list(map(int,input().split()))
if x < t:
	print("0")
else:
	print(x-t)
Buggy code:
x,t = map(int, input().split())

if x => t:
  print(x-t)
else:
  print("0")

Fixed code:
x, t = map(int, input().split())

if x >= t:
    print(x-t)
else:
    print(0)
Buggy code:
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, y = inl()
print(x-y)


Fixed code:
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, y = inl()
print(max(x-y,0))
Buggy code:
x,t = map(int, input().split())
print(max(x-t,0)

Fixed code:
x, t = map(int, input().split())
print(max(x-t, 0))
Buggy code:
x, t = map(int, input().split())
if x-t == 0:
    print("0")
else:
    
    print(x-t)

Fixed code:
x, t = map(int, input().split())
if x-t <= 0:
    print("0")
else:
    
    print(x-t)
Buggy code:
x, t = map(int, input().split())

if x<t:
	ans=0
else
	ans=x-t

print(ans)

Fixed code:
x, t = map(int, input().split())

if x<t:
	ans=0
else:
	ans=x-t

print(ans)
Buggy code:
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()))

x,t =iim()
print(min(0,x-t))

Fixed code:
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()))

x,t =iim()
print(max(0,x-t))
Buggy code:
x, t = map(int, input().split())
print(x - t if x - t < 0 else 0)

Fixed code:
x, t = map(int, input().split())
if x - t < 0:
  print(0)
else:
  print(x - t)
Buggy code:
X,T = map(int,input().split())
print(max(0,X-t))

Fixed code:
X, t = map(int, input().split())
print(max(0, X - t))
Buggy code:
x,t=list(map(int,input().split()))
if x > t:
    print(x-t)
else:
    prit(0)
    

Fixed code:
x,t=list(map(int,input().split()))
if x > t:
    print(x-t)
else:
    print(0)
Buggy code:
X, t = map(int, input).split())
X -= t
if X < 0:
  X = 0
print(X)

Fixed code:
X, t = map(int, input().split())
X -= t
if X < 0:
  X = 0
print(X)
Buggy code:
X T =map(int,input().split())
print(max(0,X-T))

Fixed code:
X, T = map(int, input().split())

print(max(0, X-T))
Buggy code:
def examA():
    X, t = LI()
    ans = X-t
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Fixed code:
def examA():
    X, t = LI()
    ans = max(X-t,0)
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()
Buggy code:
a,b=map(int, input().split())
if b-a<0:print(0)
else:print(b-a)

Fixed code:
a,b=map(int, input().split())
if a-b<0:print(0)
else:print(a-b)
Buggy code:
x,t=map(int,input().split)
print(max(0,x-t)

Fixed code:
x, t = map(int, input().split())
print(max(x - t, 0))
Buggy code:
X,t = map(int,input().split())
if (x >= t):
  print(x-t)
else:
  print(0)

Fixed code:
x,t = map(int,input().split())
if (x >= t):
  print(x-t)
else:
  print(0)
Buggy code:
x, t = map(int, input.split())
if x - t < 0:
  print(0)
else:
  print(x-t)

Fixed code:
x, t = map(int, input().split())
if x - t < 0:
  print(0)
else:
  print(x-t)
Buggy code:
X, t = map(int, input().split())
if X > t:
    print('X - t')
else:
    print('0')

Fixed code:
X, t = map(int, input().split())
if X > t:
    print(X - t)
else:
    print('0')
Buggy code:
X, t = map(int, input(),split())
print(max(X - t, 0))

Fixed code:
X, t = map(int, input().split())

print(max(X - t, 0))
Buggy code:
a,b=map(int.input().split())
if(a-b>=0):
  print(a-b)
else:
  print(0)

Fixed code:
a,b=map(int,input().split())
print( a-b if a-b >0 else 0)
Buggy code:
S=map(int,input().split())
print(max(0,S[0]-S[1]))

Fixed code:
S=list(map(int,input().split()))
print(max(0,S[0]-S[1]))
Buggy code:
x, t = list(map(int, input().split()))

if x - t <:
	print(0)
else:
	print(x - t)

Fixed code:
x, t = list(map(int, input().split()))

if x - t < 0:
	print(0)
else:
	print(x - t)
Buggy code:
x,t = map(int,input().split())

print(max(x - t),0)

Fixed code:
x,t = map(int,input().split())
 
print(max(x - t,0))
Buggy code:
X,t=map(int,input().split())
print(max(X-t, 0)

Fixed code:
X, t = map(int, input().split())
print(max(X - t,0))
Buggy code:
x,t = map(int, input().split())
if x > t:
  print(x-t)
else:
  print(0

Fixed code:
x,t = map(int, input().split())
if(x>t):
    print(x-t)
else:
    print('0')
Buggy code:
x, t = map(int, input().split())
if x => t:
  print(x - t)
else:
  print(0)

Fixed code:
x, t = map(int, input().split())
if x >= t:
  print(x - t)
else:
  print(0)
Buggy code:
x, t = map(int, input().split())
ans = x - t
if ans < 0:
  ans = 0
 print(ans)

Fixed code:
x, t = map(int, input().split())
ans = x - t
if ans < 0:
  ans = 0
print(ans)
Buggy code:
inputArr = input().split(" ")
X =  inputArr[0]
t =  inputArr[1]
remain_sand = int(X - t)
if remain_sand > 0 :
  print(remain_sand)
else :
  print(0)

Fixed code:
inputArr = input().split(" ")
X =  inputArr[0]
t =  inputArr[1]
remain_sand = int(X) - int(t)
if remain_sand > 0 :
  print(remain_sand)
else :
  print(0)
Buggy code:
x,t=map(int,input().split())
print(x-t if x-t>=0,0 else)

Fixed code:
x, t = map(int, input().split())
if x - t >= 0: print(x-t)
else: print(0)
Buggy code:
def main():
    x,t = map(int,input().split())
    print(x-t)

if __name__ == '__main__':
    main()


Fixed code:
def main():
    x,t = map(int,input().split())
    print(max(0,x-t))

if __name__ == '__main__':
    main()
Buggy code:
X,t=map(int,input().split())

if X-t >= o:
  print(X-t)
else:
  print(0)

Fixed code:
X,t=map(int,input().split())

if X-t >= 0:
  print(X-t)
else:
  print(0)
Buggy code:
X, t = list(map(int,input().split()))
print(max(X-t),0)

Fixed code:
X, t = list(map(int,input().split()))
print(max(X-t,0))
Buggy code:
X,t = map(int,input().split())
if t >= X:
  print(0)
else:
  print(t - X)

Fixed code:
X,t=map(int,input().split())
print(X-t if X-t >= 0 else 0)
Buggy code:
x,t=[int(i) for i in input().split()]
print(max(0,x-t)

Fixed code:
x,t=[int(i) for i in input().split()]
print(max(0,x-t))
Buggy code:

x,t = map(int,input().split())
if x-t <= 0:
    print('0')
else:
    print('x-t')

Fixed code:

x,t = map(int,input().split())
if x-t <= 0:
    print('0')
else:
    print(x-t)
Buggy code:
a,b=map(int,input().split())
if a <= b:
  print(0)
else:
  print(a-b):

Fixed code:
a,b = map(int,input().split())
if a-b <=0:print(0)
else:print(a-b)
Buggy code:
tmp = input().split(" ")

print(max([tmp[0] - tmp[1], 0]))

Fixed code:
tmp = input().split(" ")
 
print(max([int(tmp[0]) - int(tmp[1]), 0]))
Buggy code:
x, t = map(int, input().split())
if x-t >= 0:
  print(x-t)
 else:
  print(0)

Fixed code:
x, t = map(int, input().split())
if x-t >= 0:
  print(x-t)
else:
  print(0)
Buggy code:
x,t = map(int, input().split())
print(max(0. x-t)

Fixed code:
x, t = map(int, input().split())

print(max(0,x-t))
Buggy code:
import numpy as np
x, t = map(int, input().split())
print(np.max(x-t, 0))

Fixed code:
import numpy as np
x, t = map(int, input().split())
print(max(x-t, 0))
Buggy code:
x,y = map(int,input().split())
print(max(x-t,0))

Fixed code:
x,t = map(int, input().split())
print(max(0,x-t))
Buggy code:
# coding: utf-8
x, t = map(int, input().split())
print(min(x-t, 0))

Fixed code:
# coding: utf-8
x, t = map(int, input().split())
print(max(x-t, 0))
Buggy code:
a, b = map(int, input().split())
print(max(0, abs(a-b)))

Fixed code:
a,b = map(int, input().split())
print(max(0, a-b))
Buggy code:
x,t = map(int, input().split())

print((max(x-t),0))

Fixed code:
x, t =map(int, input().split())
ans = x-t
print (max(0, ans))
Buggy code:
x, t = map(int,input().split())

if x <= t:
  print(0)
else;
  print(x-t)


Fixed code:
x, t = map(int,input().split())

if x <= t:
  print(0)
else:
  print(x-t)
Buggy code:
X,t = map(int,input().split())

if t >= X:
  print(X)
else:
  print(X-t)

Fixed code:
X,t = map(int,input().split())
 
if t >= X:
  print(0)
else:
  print(X-t)
Buggy code:
X, t = map(int , input().split())
if t < X:
  r = 0
else:
  r = X-t

print(int(r))

Fixed code:
X, t = map(int, input().split())

if X <= t:
    print(0)
else:
    print(X - t)
Buggy code:
a,b=map(int,input().split())
print("0" else a-b<0 else a-b)

Fixed code:
a,b=map(int,input().split())
print("0" if a-b<0 else a-b)
Buggy code:
ls = list(map(int, input().split()))
if (ls[0] - ls[1]) >= 0:
    print(ls[0]-ls[1])

Fixed code:
ls = list(map(int, input().split()))
if (ls[0] - ls[1]) >= 0:
    print(ls[0]-ls[1])
else:
    print(0)
Buggy code:
#abc072 a 
x,t=map(int,input().split())
print(max(t-x,0))

Fixed code:
#abc072 a 
x,t=map(int,input().split())
print(max(x-t,0))
Buggy code:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, H = map(int, read().split())
print(N - H)


Fixed code:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, H = map(int, read().split())
print(max(N - H,0))
Buggy code:
x, t = list(map(input().split()))
print(max([0, x - t])

Fixed code:
x, t = list(map(int, input().split()))
print(max([0, x - t]))
Buggy code:
x, y = map(int, input().split())
print(max([x - y, 0])

Fixed code:
x, y = map(int, input().split())
print(max([x - y, 0]))
Buggy code:
a, b = map(int, input().split())
print(max(0, b - a))

Fixed code:
a, b = map(int, input().split())
print(max(0, a - b))
Buggy code:
X, t = map(int, input().split())

if t >= x:
    print(0)

else:
    print(X-t)


Fixed code:
X, t = map(int, input().split())

if t >= X:
    print(0)

else:
    print(X-t)
Buggy code:
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)

Fixed code:
n = int(input())
p = list(map(int, input().split()))
p.append(0)
for i in range(n): p[i] -= 1

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

print(ans)
Buggy code:
n=int(input())
p=list(map(int,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)
print(p)

Fixed code:
n=int(input())
p=list(map(int,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
if p[-1]==n:
    cnt+=1
 
print(cnt)
Buggy code:
n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(n):
    if i!=n-1
        if p[i]==i+1:
            d=p[i+1]
            p[i+1]=p[i]
            p[i]=d
            c+=1
    else:
        if p[i]==i+1:
            c+=1
print(c)

Fixed code:
n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(n):
    if i!=n-1:
        if p[i]==i+1:
            d=p[i+1]
            p[i+1]=p[i]
            p[i]=d
            c+=1
    else:
        if p[i]==i+1:
            c+=1
print(c)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        ans += 1
    if a[n] == n + 1:
        ans += 1
print(ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
if a[n-1] == n:
    cnt += 1
print(cnt)
Buggy code:
N = int(input())
p = tuple(map(int, input().split()))
a = list(p)
b = list(p)

c = 0
for i in range(N):
    if i+1 == a[i] and i == N-1:
        c += 1
    elif i+1 == a[i]:
        a[i], a[i+1] = a[i+1], a[i]
        c += 1
cc = 0        
for i in range(N)[::-1]:
    if i+1 == b[i] and i == 0:
        cc += 1
    elif i+1 == b[i]:
        b[i], b[i-1] = b[i-1], b[i]
        cc += 1
        print(i)
        
print(min(c,cc))

Fixed code:
N = int(input())
p = tuple(map(int, input().split()))
a = list(p)
b = list(p)

c = 0
for i in range(N):
    if i+1 == a[i] and i == N-1:
        c += 1
    elif i+1 == a[i]:
        a[i], a[i+1] = a[i+1], a[i]
        c += 1
cc = 0        
for i in range(N)[::-1]:
    if i+1 == b[i] and i == 0:
        cc += 1
    if i+1 == b[i]:
        b[i], b[i-1] = b[i-1], b[i]
        cc += 1
        
print(min(c,cc))
Buggy code:
n = int(input())
P = list(map(int,input().split()))
P = [int(i+1==P[i]) for i in range(n)]+[0]
print(P)

ans = 0
ex = 0
for p in P:
  if p and ex:
    ans += 1
    ex = 0
  elif p:
    ex = 1
  elif ex:
    ans += 1
    ex = 0
print(ans)

Fixed code:
n = int(input())
P = list(map(int,input().split()))
P = [int(i+1==P[i]) for i in range(n)]+[0]

ans = 0
ex = 0
for p in P:
  if p and ex:
    ans += 1
    ex = 0
  elif p:
    ex = 1
  elif ex:
    ans += 1
    ex = 0
print(ans)
Buggy code:
import math
import sys
N=int(input())
p=list(map(int,input().split()))
cnt=0
if p[0] == 1:
    cnt += 1
for i in range(1,N):
    if p[i]==i+1 and p[i-1]!=i:
        cnt+=1
        print(p[i],i+1)
print(cnt)


Fixed code:
import math
import sys
N=int(input())
p=list(map(int,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
if p[-1]==N:
    cnt+=1
        # print(p[i],i+1)
print(cnt)
Buggy code:
n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(1,n):
    if i+1 == p[i]:
        cha = p[i-1]
        p[i-1] = p[i]
        p[i] = cha
        count+=1
if n == p[n-1]
    count+=1
print(count)

Fixed code:
n = int(input())
p = [int(i) for i in 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)
Buggy code:
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)


Fixed code:
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)
Buggy code:
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        p[i+1] = p[i]
        ans += 1
if p[n] == n:
    ans += 1
print(ans)

Fixed code:
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        p[i+1] = p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
print(ans)
Buggy code:
N=int(input())
p=list(map(int, input().split()))
#print(N, p)
p.append(N*2)
count=0
i=0
while i<=N-2:
    if i==p[i-1]:
        #print(i, p[i-1])
        if i+1==p[i+1-1]:
            count+=1
            i+=1
        else:
            count+=1
    i+=1
print(count)




Fixed code:
N=int(input())
p=list(map(int, input().split()))
#print(N, p)
p.append(N*2)
count=0
i=0
while i<=N-1:
    if i+1==p[i]:
        #print(i, p[i-1])
        if i+2==p[i+1]:
            count+=1
            i+=1
        else:
            count+=1
    i+=1
print(count)
Buggy code:
n = int(input())
P = list(map(int, input().split()))
ans0 = 0
ans = 0
co = 0
for i in range(n):
    if P[i] == i+1:
        co = 1
        ans0 += 1
    else:
        if co == 1:
            co = 0
            #print("seisan")
            ans += -((-ans0) // 2)
            ans0 = 0
print(ans)


Fixed code:
n = int(input())
P = list(map(int, input().split()))
ans0 = 0
ans = 0
co = 0
for i in range(n):
    if P[i] == i+1:
        co = 1
        ans0 += 1
    else:
        if co == 1:
            co = 0
            #print("seisan")
            ans += -((-ans0) // 2)
            ans0 = 0

if co == 1:
    co = 0
    #print("seisan")
    ans += -((-ans0) // 2)

print(ans)
Buggy code:
N = int(input())
p = [int(x) for x in input().split()]

l = []

for i in range(len(p)):
    if p[i] == i + 1:
        l.append(p[i])
    else:
        l.append(0)

count = 0
for i in renge(len(l)):
    if l[i] > 0:
        l[i] = 0
        l[i + 1] = 0
        count += 1
print(count)



Fixed code:
N = int(input())
p = [int(x) for x in input().split()]

l = []

for i in range(len(p)):
    if p[i] == i + 1:
        l.append(p[i])
    else:
        l.append(0)

count = 0

for i in range(len(l) - 1):
    if l[i] > 0:
        l[i] = 0
        l[i + 1] = 0
        count += 1
if l[len(l) - 1] != 0:
    count += 1

print(count)
Buggy code:
N = int(input())
P = list(map(int,input().split()))

ls = [""] * N
cnt = 0

for i in range(N):
  if P[i] == i + 1:
    ls[i] = "#"
  else:
    ls[i] = "."
    
if ls[-1] == "#":
  if ls[-2] == "#":
    ls[-1], ls[-2] = ".", "."
  else:
    ls[-1] = "."

for j in range(N-1):
  if ls[j] == "#":
    if ls[j+1] == "#":
      ls[j+1] = "."
    cnt += 1
    
print(cnt)

Fixed code:
N = int(input())
P = list(map(int,input().split()))

ls = [""] * N
cnt = 0

for i in range(N):
  if P[i] == i + 1:
    ls[i] = "#"
  else:
    ls[i] = "."
    
if ls[-1] == "#":
  if ls[-2] == "#":
    ls[-1], ls[-2] = ".", "."
  else:
    ls[-1] = "."
  cnt += 1

for j in range(N-1):
  if ls[j] == "#":
    if ls[j+1] == "#":
      ls[j+1] = "."
    cnt += 1
    
print(cnt)
Buggy code:
N = int(input())
P = [int(x) for x in input().split()]

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

Fixed code:
N = int(input())
P = [int(x) for x in input().split()]

ans = 0
for i in range(N-1):
    if P[i] == i+1:
        temp = P[i]
        P[i] = P[i+1]
        P[i+1] = temp
        ans += 1
if P[N-1] == N:
        ans += 1
print(ans)
Buggy code:
n=int(input())
f1=list(map(int,input().split()))
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]
if f[n-1]==n:
  f[n-2],f[n-1]=f[n-1],f[n-2]
  c+=1  
print(c)

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