qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n, m = map(int, input().split())
ab_list = list()
for _ in range(m):
    a, b = map(int, input().split())
    ab_list.append([a, b])
ab_list = sorted(ab_list, key=lambda x: x[1])
x = -1
ans = 0
for a, b in ab_list:
    if a < x:
        continue
    else:
        x = b-1
        ans += 1
print(ans)

Fixed code:
n, m = map(int, input().split())
ab_list = list()
for _ in range(m):
    a, b = map(int, input().split())
    ab_list.append([a, b])
ab_list = sorted(ab_list, key=lambda x: x[1])
x = -1
ans = 0
for a, b in ab_list:
    if a <= x:
        continue
    else:
        x = b-1
        ans += 1
print(ans)
Buggy code:
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    s.append([a,b-1])
s.sort(key=lambda x:x[1])
ans=0
t=None
for i,j in s:
    if(t is None or t<i):
        t=i
        ans+=1

print(ans)

Fixed code:
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    s.append([a,b-1])
s.sort(key=lambda x:x[1])
ans=0
t=None
for i,j in s:
    if(t is None or t<i):
        t=j
        ans+=1

print(ans)
Buggy code:
a,b = map(int,input().split())

c - []
for i in range(a[1]):
  c.append(list(map(int,input().split())))

c.sort(key = lambda x:x[1])

s = c[0][0]
l = c[0][1]
re = 1

for i in range(1,a[1]):
  if l >= c[i][0]:
    re += 1
    l = c[i][1]
    
print(re)

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

c = []
for i in range(b):
  c.append(list(map(int,input().split())))

c.sort(key = lambda x:x[1])

s = c[0][0]
l = c[0][1]
re = 1

for i in range(1,b):
  if l <= c[i][0]:
    re += 1
    l = c[i][1]
    
print(re)
Buggy code:
from operator import itemgetter
n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(m)]
g = 1
e.sort(key = itemgetter(1))
print(e)
for i in range(m):
    if i == 0:
        a = e[0][1] - 1
        print(a)
    else:
        if a >= e[i][0]:
            pass
        else:
            g += 1
            a = e[i][1] - 1
print(g)

Fixed code:
from operator import itemgetter
n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(m)]
g = 1
e.sort(key = itemgetter(1))
for i in range(m):
    if i == 0:
        a = e[0][1] - 1
    else:
        if a >= e[i][0]:
            pass
        else:
            g += 1
            a = e[i][1] - 1
print(g)
Buggy code:
n , m = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(m)]
l.sort()
l = l[::-1]
cnt = 1
key = l[0][0]
for i in range(m):
    if key > l[i][1]:
        cnt += 1
        key = l[i][0]
print(cnt)
    


Fixed code:
n , m = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(m)]
l.sort()
l = l[::-1]
cnt = 1
key = l[0][0]
for i in range(1,m):
    if key >= l[i][1]:
        cnt += 1
        key = l[i][0]
print(cnt)
Buggy code:
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
ab.sort(reverse = True)
print(ab)
bridge = [float("inf")]
for i in range(m):
    if ab[i][0] <= min(bridge) < ab[i][1]:
        continue
    else:
        bridge.append(ab[i][0])
print(len(bridge) - 1)

Fixed code:
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
ab.sort(reverse = True)

bridge = [float("inf")]
for i in range(m):
    if ab[i][0] <= min(bridge) < ab[i][1]:
        continue
    else:
        bridge.append(ab[i][0])
print(len(bridge) - 1)
Buggy code:
N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]

AB.sort(key=lambda x: x[1])
num = 0
p = 0
for i in AB:
    if i[0] > p:
        num += 1
        p = i[1]

print(num)


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

AB = [tuple(map(int, input().split())) for _ in range(M)]

AB.sort(key=lambda x: x[1])
num = 0
p = 0
for i in AB:
    if i[0] >= p:
        num += 1
        p = i[1]

print(num)
Buggy code:
def main():
    in1 = input()
    n, m = [int(c) for c in in1]

    arr = []
    for i in range(m):
        _in = input()
        a, b = [int(c) for c in _in]
        arr.append((a, b))

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

    n = 0

    mi, ma = sorted_arr[0]
    for a, b in sorted_arr[1:]:
        if ma < a:
            n += 1
            mi, ma = a, b
        if mi < a:
            mi = a
        if ma > b:
            ma = b
    print(n)

if __name__ == "__main__":
    main()


Fixed code:
def main():
    in1 = input().split(" ")
    n, m = [int(c) for c in in1]

    arr = []
    for i in range(m):
        _in = input().split(" ")
        a, b = [int(c) for c in _in]
        arr.append((a, b))

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

    n = 1

    mi, ma = sorted_arr[0]
    mi, ma = (mi, ma) if mi < ma else (ma, mi)
    for a, b in sorted_arr[1:]:
        a, b = (a, b) if a < b else (b, a)
        if ma <= a:
            n += 1
            mi, ma = a, b
        if mi < a:
            mi = a
        if ma > b:
            ma = b
    print(n)

if __name__ == "__main__":
    main()
Buggy code:
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input, split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)

Fixed code:
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input().split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)
Buggy code:
5
1 1 1 1 1n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=0
c=[]
for i in range(1,n):
  if l[i]==a:
    b+=1
  else:
    c.append(b)
    b=0
  a=l[i]
c.append(b)
for i in range(len(c)):
  c[i]=(c[i]+1)//2
print(sum(c))

Fixed code:
n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=0
c=[]
for i in range(1,n):
  if l[i]==a:
    b+=1
  else:
    c.append(b)
    b=0
  a=l[i]
c.append(b)
for i in range(len(c)):
  c[i]=(c[i]+1)//2
print(sum(c))
Buggy code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

i=1
while i < n:
    if a[i] == a[i+1]:
        ans += 1
        i += 1
    i += 1

print(ans)


Fixed code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

i=1
while i < n:
    if a[i] == a[i-1]:
        ans += 1
        i += 1
    i += 1

print(ans)
Buggy code:
from random import randint
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range (len(a)-1) :
  try:
    if l[i] == l[i + 1]:
        ans += 1
        l[i + 1] = randint(0, 10000)
  except:
    continue
print(ans)

Fixed code:
from random import randint
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range (len(l)-1) :
  try:
    if l[i] == l[i + 1]:
        ans += 1
        l[i + 1] = randint(0, 10000)
  except:
    continue
print(ans)
Buggy code:
n = int(input())
arr = list(map(int, input().split()))
from numpy import random
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)


Fixed code:
from numpy import random
n = int(input())
a = list(map(int,input().split()))
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)
Buggy code:
n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=b//2
print(ans)

Fixed code:
n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=len(list(b)) //2
print(ans)
Buggy code:

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

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

Fixed code:
n = int(input())
a = list(map(int, input().split()))
tmp = 1
res = 0
for i in range(1,n):
  if a[i-1] == a[i]:
    tmp += 1
  else:
    res += tmp//2
    tmp = 1
res += tmp//2
print(res)
Buggy code:
from itertools import*
print(sum(len(j)//2 for _, j in groupby(open(0).read().split()[1:])))

Fixed code:
from itertools import*
print(sum(len(list(j))//2 for _, j in groupby(open(0).read().split()[1:])))
Buggy code:
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
a = input().split()
li = []
s = 1
for i in range(1,N):
    if a[i] != a[i-1]:
        li.append(s)
        s = 1
        continue
    if a[i] == a[i-1]:
        s +=1
if s != '':
    li.append(s)
n = len(li)
ans = 0
print(li)
for i in range(n):
    l = li[i]
    ans += l//2
print(ans)

Fixed code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
a = input().split()
li = []
s = 1
for i in range(1,N):
    if a[i] != a[i-1]:
        li.append(s)
        s = 1
        continue
    if a[i] == a[i-1]:
        s +=1
if s != '':
    li.append(s)
n = len(li)
ans = 0
for i in range(n):
    l = li[i]
    ans += l//2
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()))

n = ii()
A = iil()
ans = 0
for i in range(1,n)
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -1
print(ans)

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()))

n = ii()
A = iil()
ans = 0
for i in range(1,n):
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -1
print(ans)
Buggy code:
n=int(input())
a=[int(i) for i in inpup().split()]
cnt=0
flag=False
for i in range(1,n):
    if a[i]==a[i-1]:
        if flag:
            flag=False
        else:
            cnt+=1
            flag=True
    else:
        flag=False
print(cnt)

Fixed code:
n=int(input())
a=[int(i) for i in input().split()]
cnt=0
flag=False
for i in range(1,n):
    if a[i]==a[i-1]:
        if flag:
            flag=False
        else:
            cnt+=1
            flag=True
    else:
        flag=False
print(cnt)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
a = [0] + a
for i in range(n):
    if a[i+1] == a[i]:
        a[i] = -1
print(a.count(-1))

Fixed code:

        
    
    
    
    
    
    

    
    
    



    


n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,n):
    if(a[i]==a[i-1]):
        a[i]=-1
        c+=1
print(c)
Buggy code:
a =int(input())
b =list(map(int,input().split()))
print(a)
print(b)
x=0
for i in range(a-1):
	if b[i]==b[i+1]:
		b[i+1]=11111
		x=x+1
print(x)

Fixed code:
a =int(input())
b =list(map(int,input().split()))
x=0
for i in range(a-1):
	if b[i]==b[i+1]:
		b[i+1]=11111
		x=x+1
print(x)
Buggy code:
n = int(input())
dat = list(map(int, input().split()))
p = dat[0]
res = 0
for i in range(1, len(dat)):
    if p == dat[i]:
        dat[i] = "x"
        p = "x"
        res += 1
    else:
        p = dat[i]
print(dat)


Fixed code:
n = int(input())
dat = list(map(int, input().split()))
p = dat[0]
res = 0
for i in range(1, len(dat)):
    if p == dat[i]:
        dat[i] = "x"
        p = "x"
        res += 1
    else:
        p = dat[i]
print(res)
Buggy code:
n=int(input())
s=list(map(int,input().split()))
ans=0
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans+=cnt//2
        cnt=1
print(ans)

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

cnt = 1
res = 0
for i in range(1, n):
  if s[i] == s[i-1]:
    cnt +=1
  else:
    res += int(cnt//2)
    cnt = 1
res += int(cnt//2)

print(res)
Buggy code:
u = int(input())
A = list(map(int,input().split()))
count = 0
for a in range(u-1):
  a = A.pop()
  if a == A[-1]:
    A[0] = -1
    count += 1
print(count)

Fixed code:
u = int(input())
A = list(map(int,input().split()))
count = 0
for a in range(u-1):
  a = A.pop(0)
  if a == A[0]:
    A[0] = -1
    count += 1
print(count)
Buggy code:
import math
n = int(input())
A = [int(i) for i in input().split()]
cnt, ans = 0, 0
for i in range(n):
  if A[i] == A[i+1]:
    cnt += 1
  else:
    ans += math.floor((cnt+1)/2)
    cnt = 0
print(ans)

Fixed code:
import math
n = int(input())
A = [int(i) for i in input().split()]
cnt, ans = 0, 0
for i in range(n-1):
  if A[i] == A[i+1]:
    cnt += 1
    if i == n-2:
      ans += math.floor((cnt+1)/2)
  else:
    ans += math.floor((cnt+1)/2)
    cnt = 0
print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
count = 0
counter = 0

for i in range(len(a)-1):
    if a[i]==a[i+1] and i == len(a)-2:
        count += int((i+1-counter)//2)+1
    elif a[i]!=a[i+1] or i == len(a)-2:
        count += int((i+1-counter)//2)
        counter = i + 1

print(count)      

Fixed code:
n = int(input())
a = list(map(int, input().split()))
count = 0
counter = 0

for i in range(len(a)-1):
    if i == len(a)-2 and a[i]==a[i+1]:
        count += int((i+2-counter)//2)
    if a[i]!=a[i+1]:
        count += int((i+1-counter)//2)
        counter = i + 1

print(count)
Buggy code:
N = int(input())
a = list(map(int, input().split()))
now = 0
ans = 0
for i in range(N):
  if a[i] == now:
    count += 1
  else:
    ans += count//2
    count = 1
    now = a[i]

ans += count//2
print(ans)

Fixed code:
N = int(input())
a = list(map(int,input().split()))
a.append(0)
ans = 0
count = 1
nm = a[0]
for i in range(1,N+1):
    if nm == a[i]:
        count += 1
    else:
        nm = a[i]
        ans += count//2
        count = 1

print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

Fixed code:
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


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

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

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

answer = 0
for i in range(1,N):
  if A[i] == A[i-1]:
    A[i] = -1
    answer += 1
print(answer)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
i = 1
while i<n:
    print(i)
    if a[i]==a[i-1]:
        cnt += 1
        i += 1
    i += 1
print(cnt)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
i = 1
while i<n:
    if a[i]==a[i-1]:
        cnt += 1
        i += 1
    i += 1
print(cnt)
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]
print(a)
count = []

flg = 1
for i in range(1,n):
    if a[i] == a[i-1]:
        flg += 1
        
        if i == n-1:
            count.append(flg)
            
    else:
        count.append(flg)
        flg = 1
        i +=1
cnt = 0
print(count)
for j in count:
    cnt += j//2
print(cnt)
        

Fixed code:
n = int(input())
a = [int(x) for x in input().split()]

count = []

flg = 1
for i in range(1,n):
    if a[i] == a[i-1]:
        flg += 1
        
        if i == n-1:
            count.append(flg)
            
    else:
        count.append(flg)
        flg = 1
        i +=1
cnt = 0

for j in count:
    cnt += j//2
print(cnt)
Buggy code:
N = int(input())
a = list(map(int, input().split()))
now = ''
ans = 0
for i in range(N):
  if a[i] == now:
    count += 1
  else:
    ans += count//2
    count = 1
    now = a[i]

ans += count//2
print(ans)

Fixed code:

N = int(input())
a = list(map(int, input().split()))
count = 0
now = 0
ans = 0
for i in range(N):
  if a[i] == now:
    count += 1
  else:
    ans += count//2
    count = 1
    now = a[i]

ans += count//2
print(ans)
Buggy code:
N = int(input())
A = list(map( int, input().split()) )
from collections import defaultdict
d = defaultdict(int)

lst = []
i = 0
while i <= N-2:
  a = A[i]
  cnt = 1
  for j in range(i+1, N):
    if a == A[j]:
      cnt += 1
    else:
      break
  lst.append(cnt)
  print(i,j)
  i = j
  


# print(lst)

ans = 0
def kf(x):
  if x  == 1:
    return 0
  elif x == 0:
    return 0
  elif x % 2 == 1:
    return x//2
  elif x % 2 == 0:
    return x//2
for k in lst:
  ans += kf( k )
print(ans)

Fixed code:
N = int(input())
A = list(map( int, input().split()) )
from collections import defaultdict
d = defaultdict(int)

lst = []
i = 0
while i <= N-2:
  a = A[i]
  cnt = 1
  for j in range(i+1, N):
    if a == A[j]:
      cnt += 1
    else:
      break
  lst.append(cnt)
  #print(i,j)
  i = j
  


# print(lst)

ans = 0
def kf(x):
  if x  == 1:
    return 0
  elif x == 0:
    return 0
  elif x % 2 == 1:
    return x//2
  elif x % 2 == 0:
    return x//2
for k in lst:
  ans += kf( k )
print(ans)
Buggy code:
N = int(input())
l = list(map(int,input().split()))

len_l = len(l)
st = l[0]
count = 1
count_l = []
for i in range(1,len_l):
    if l[i]==st:
        count+=1
    else:
        count_l.append(count//2)
        st = l[i]
        count = 1
print(sum(count_l))

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

len_l = len(l)
st = l[0]
count = 1
count_l = []
for i in range(1,len_l):
    if l[i]==st:
        count+=1
    else:
        count_l.append(count//2)
        st = l[i]
        count = 1
count_l.append(count//2)
print(sum(count_l))
Buggy code:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        A[i] += 1
        cnt += 1
    if A[i] == A[i+1]:
        A[i] += 1
print(cnt)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        A[i] += 1
        cnt += 1
        if i != N -1 and A[i] == A[i+1]:
            A[i] += 1
print(cnt)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
c=a[0]
t=0
s=0
for i in range(n):
  if(c!=a[i]):
    c=a[i]
    s+=t//2
    t=1
  else:
    t+=1
print(s)

Fixed code:
n=int(input())
a=list(map(int,input().split()))+[0]
c=a[0]
t=0
s=0
for i in range(n+1):
  if(c!=a[i]):
    c=a[i]
    s+=t//2
    t=1
  else:
    t+=1
print(s)
Buggy code:
n = int(input())
a = list(map(int,input().split()))

c = 0
i = 0
ans = 0
while i < n:
    if a[i] == a[i+1]:
        c += 1
        i += 1
    else:
        ans += c//2
        c = 0
        i += 1
print((ans+c//2,ans)[c==0])

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

c = 0
i = 0
ans = 0
while i < n-1:
    if a[i] == a[i+1]:
        c += 1
        i += 1
    else:
        ans += (c+1)//2
        c = 0
        i += 1
print((ans+(c+1)//2,ans)[c==0])
Buggy code:
N = int(input())
pre_a = 0
cont = 0
ans = 0

for a in input().split():
	if pre_a == a:
		cont += 1
	else:
		ans += cont // 2
		cont = 1
	pre_a = a

print(ans)

Fixed code:
N = int(input())
pre_a = 0
cont = 0
ans = 0

for a in input().split():
	if pre_a == a:
		cont += 1
	else:
		ans += cont // 2
		cont = 1
	pre_a = a
else:
	ans += cont // 2

print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  if p==0:
    c+=1
    while len(l)>2:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    if l[0]==0:
      p=l.pop(0)
      if len(l)>0:
        p=l.pop(0)
      else:
         break
    else:
      p=l.pop(0)
if p==0:c+=1
print(c)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
if len(l)==1 and l[n-2]==0:c+=1
if len(l)>1 and l[n-2]==0 and l[n-3]!=0:c+=1
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  else:
    c+=1
    while len(l)>1:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    while len(l)>0:
      if l[0]==0:
        p=l.pop(0)
      else:
        p=l.pop(0)
        break
print(c)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
total = 1
total2 = 0
for i in range(0, n-1):
    if a[i]==a[i+1]:
        total += 1
    else:
        total2 += total//2
        total = 1
print(total2)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
total = 1
total2 = 0
a.append(0)
for i in range(0, n):
    if a[i]==a[i+1]:
        total += 1
    else:
        total2 += total//2
        total = 1
print(total2)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n+1):
  if i==0 or i==n & a[i-1] != a[i]:
    if i!=0:
      ans += cnt // 2
    cnt = 1
  else:
    cnt += 1
print(ans)

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

i = 1
count = 0

while i < n:
  if a[i] = a[i-1]:
    count += 1
    i += 2
    else:
      i += 1

print(count)

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

i=1
count=0

while i<n:
  if a[i]==a[i-1]:
    count+=1
    i+=2
  else:
    i+=1

print(count)
Buggy code:
N = int(input())
a = list(map(int, input().split()))
ans = 0.1
for i in range(N-1):
	if a[i] == a[i+1]:
		ans = ans + 0.5
	else:
		ans = round(ans)+0.1
	print(i,ans)
print(round(ans))


Fixed code:
N = int(input())
a = list(map(int, input().split()))
ans = 0.1
for i in range(N-1):
	if a[i] == a[i+1]:
		ans = ans + 0.5
	else:
		ans = round(ans)+0.1
print(round(ans))
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]
s = [a[0]]
for i in range(1, len(a)):
    if a[i-1] != a[i]:
        s.append(a[i])
if len(s) == 1:
    print(len(a) // 2)
else:
    print((len(a) - len(s))//2 + 1)


Fixed code:
n = int(input())
a = [int(x) for x in input().split()]
s = [a[0]]
cnt = 1
res = 0
for i in range(1, len(a)):
    if a[i-1] != a[i]:
        res += cnt // 2
        cnt = 1
        s.append(a[i])
    else:
        cnt += 1
res += cnt // 2
print(res)
Buggy code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    for i in range(n-1):
        if(a[i]==a[i+1]):
            a[i+1]=0
            ans+=1
        print(ans)

if __name__=="__main__":
    main()

Fixed code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = 0

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

    print(count)


if __name__ == '__main__':
    main()