qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
l=list(map(int,input().split()))
ans=0
N_=int((N*(N-1))/2)
for i in range(N_-1):
  life=0
  for j in range(i+1,N_):
    life+=l[i]*l[j]
  ans+=life
print(ans)

Fixed code:
N = int(input())
l=list(map(int,input().split()))
ans=0
N_=int((N*(N-1))/2)
for i in range(N-1):
  life=0
  for j in range(i+1,N):
    life+=l[i]*l[j]
  ans+=life
print(ans)
Buggy code:
n = int(input())
d = list(map,input().split())
sum = 0
 
for i in range(n):
  for j in range(i+1,n):
    sum += (d[i]*d[j])
print(sum)

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

dsum = 0
for i in range(n):
    for j in range(i+1, n):
        dsum += d[i] * d[j]

print(dsum)
Buggy code:
import itertools

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

list_ = itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] + D[list_[i][1]];
  
print(count)


Fixed code:
import itertools

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

list_ = list(itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] * D[list_[i][1]];
  
print(count)
Buggy code:
n = int(input())
arr = [int(x) for x in input().split()]
f = sum(arr)
s = 0
for i in arr:
  s += i * (f-i)

print(s)

Fixed code:
n = int(input())
arr = [int(x) for x in input().split()]
f = sum(arr)
s = 0
for i in arr:
  s += i * (f-i)

print(s // 2)
Buggy code:
n = int(input())
list_d = list(map(int, input().split()))
print(n)
print(list_d)

total = 0

for first in range(len(list_d)):
  for second in range(len(list_d)):
    if first < second:
      total += list_d[first] * list_d[second]

print(total)

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

total = 0

for first in range(len(list_d)):
  for second in range(len(list_d)):
    if first < second:
      total += list_d[first] * list_d[second]

print(total)
Buggy code:
a=int(input())
b= list(map(int, input().split()))  # 114514 810 893
c=[]
for i in b:
  c.append(i**2)

num=(sum(b)**2-sum(c))/2
print(num)

Fixed code:
a=int(input())
b= list(map(int, input().split()))  # 114514 810 893
c=[]
for i in b:
  c.append(i**2)

num=(sum(b)**2-sum(c))//2
print(num)
Buggy code:
n = int(input())
d = list(map(int, input().split()))
ret = 0
for i in d[:n-1]:
    for j in d[1:]:
        ret += i*j
print(ret)

Fixed code:
n = int(input())
d = list(map(int, input().split()))
ret = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        ret += d[i]*d[j]
print(ret)
Buggy code:
a = int(input())
d = list(map(int,input().split()))
ans = 0

for i in range(a):
	for j in range(i+1,a):
		print(i,"*",j)
		ans += d[i]*d[j]

print("ans =",ans)

Fixed code:
a = int(input())
d = list(map(int,input().split()))
ans = 0

for i in range(a):
	for j in range(i+1,a):
		ans += d[i]*d[j]

print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
s=[]
for i in a:
  for i2 in a:
    if i!=i2:
      s.append(i*i2)
print(sum(s)//2)





Fixed code:
n=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(n):
  for i2 in range(n):
    if i!=i2:
      s.append(a[i]*a[i2])
print(sum(s)//2)
Buggy code:
N=int(input())
d=input().split()
di=[]
for i in range(N):
    di.append(int(d[i]))

result=0
for i in range(N):
    for j in range(N):
        if i!=j:
            tmp=di[i]*di[j]
            result+=tmp
print(result/2)

Fixed code:
N=int(input())
d=input().split()
di=[]
for i in range(N):
    di.append(int(d[i]))

result=0
for i in range(N):
    for j in range(N):
        if i!=j:
            tmp=di[i]*di[j]
            result+=tmp
print(int(result/2))
Buggy code:
n = int(input())
d = list(map(int,input().split()))
li=[]
li2=[]
for i in range(n):
  for j in range(n):
    a = d[i]*d[j]
    li.append(a)
b = sum(li)
for k in range(n):
  c=d[k]**2
  li2.append(c)
d=sum(li2)
b=b-d
print(b/2)

Fixed code:
import math
n = int(input())
d = list(map(int,input().split()))
li=[]
li2=[]
for i in range(n):
  for j in range(n):
    a = d[i]*d[j]
    li.append(a)
b = sum(li)
for k in range(n):
  c=d[k]**2
  li2.append(c)
d=sum(li2)
b -= d
print(math.floor(b/2))
Buggy code:
n=int(input())
l=list(map(int,input().split()))
ans=0
s=sum(l)
for i in range(n):
  ans+=l[i]*(s-l[i])
print(ans)

Fixed code:
n=int(input())
l=list(map(int,input().split()))
ans=0
s=sum(l)
for i in range(n):
  ans+=l[i]*(s-l[i])
print(int(ans/2))
Buggy code:
n = int(inout()) # the number of takoyaki
delicious = list(map(int,input().split()))
ans = 0
for i in range(0, n-1): 
  for j in range(i, n):
    ans += delicious[i] * delicious[j]
    
print(ans)

Fixed code:
n = int(input()) # the number of takoyaki
delicious = list(map(int,input().split()))
ans = 0
for i in range(0, n-1): 
  for j in range(i+1, n):
    ans += delicious[i] * delicious[j]
    
print(ans)
Buggy code:
a=int(input())
b=0
c=list(map(int,input().split()))
for i in range(a):
  for k in range(a):
    b=b+c[i]*c[k]
for u in range(a):
  b=b-c[u]*c[u]
print(b)

Fixed code:
a=int(input())
b=0
c=list(map(int,input().split()))
for i in range(a):
  for k in range(a):
    b=b+c[i]*c[k]
for u in range(a):
  b=b-c[u]*c[u]
print(int(b/2))
Buggy code:
n=int(input())
list=list(map(int,input().split()))
print(n,list)
s=0
for i in range(0,n-1):
  for j in range(1,n-i):
        s+=list[i]*list[i+j]
print(s)

Fixed code:
n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n):
	for j in range(i+1,n):
		s+=d[i]*d[j]
print(s)
Buggy code:
n = int(input())
x = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
  for j in range(i,n): ans+=x[i]*x[j]
print(ans)

Fixed code:
n = int(input())
x = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
  for j in range(i+1,n): ans+=x[i]*x[j]
print(ans)
Buggy code:
N = int(input())
L = list(map(int, input().split()))

res = 0
for i in range(N):
  for j in range(N):
    if i != j:
    	res += L[i] * L[j]
        
print(res)

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

res = 0
for i in range(N):
  for j in range(i, N):
    if i != j:
    	res += L[i] * L[j]
        
print(res)
Buggy code:
N = int(input())
Xs = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    s = sum(Xs[i+1:N])
    print(s)
    ans = ans + s * Xs[i]
    print(ans)
print(ans)

Fixed code:
N = int(input())
Xs = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    s = sum(Xs[i+1:N])
    ans = ans + s * Xs[i]
print(ans)
Buggy code:
n = int(input())
d = map(int, input().split())
s = 0
for i in range(n):
    for j in range(n):
        if i != j:
            s += d[i] * d[j]
print(int(s/2))

Fixed code:
n = int(input())
d = list(map(int, input().split()))
s = 0
for i in range(n):
    for j in range(n):
        if i != j:
            s += d[i] * d[j]
print(int(s/2))
Buggy code:
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c==c+(List[i]*List[j])
print(c)

Fixed code:
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)
Buggy code:
n = int(input())
d = list(map(int,input().split()))

ans = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
     ans += (d[i]*d[j])
print(ans)

Fixed code:
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(dd)
Buggy code:
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
  for j in range(i+1,n):
    ans.append(A[i]*A[j])
print(sum(ans))

Fixed code:
n=int(input())
A=list(map(int,input().split()))
ans=[]
for i in range(n):
    for j in range(i+1,n):
        ans.append(A[i]*A[j])
print(sum(ans))
Buggy code:
n = int(input())
h = list(map(int, input().split()))
print(h)
def takoyaki(n,h):
    x = 0
    for i in range(0,n-1):
        for j in range(i + 1, n):
            x = x + h[i]*h[j]
    return x
print(takoyaki(n, h)) 

Fixed code:
n = int(input())
h = list(map(int, input().split()))
def takoyaki(n,h):
    x = 0
    for i in range(0,n-1):
        for j in range(i + 1, n):
            x = x + h[i]*h[j]
    return x
print(takoyaki(n, h))
Buggy code:
N = int(input())
d = list(map(int, input().split()))
energy = 0
for x in range(N):
    for y in range(x + 1, N):
        energy = energy + x * y
print(energy)

Fixed code:
N = int(input())
d = list(map(int, input().split()))
energy = 0
for x in range(N):
    for y in range(x + 1, N):
        energy = energy + d[x] * d[y]
print(energy)
Buggy code:
N = int(input())
D = map(int, input().split())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)
Buggy code:
N = int(input())
D = list(map(int,input().split()))
count=0
for i in range(N):
  for j in d[i+1:]:
    A = d[i]*j
    count+=A
print(A)

Fixed code:
N = int(input())
D = list(map(int,input().split()))
count=0
for i in range(N-1):
  for j in D[i+1:]:
    A = D[i]*j
    count+=A
print(count)
Buggy code:
N = int(input())
d = list(map(int, input().split()))
s = 0
for i in range(N):
  for j in range(N):
    if i != j:
      s += d[i]*d[j]
print(s)

Fixed code:
N = int(input())
d = list(map(int, input().split()))
s = 0
for i in range(N):
  for j in range(N):
    if i != j:
      s += d[i]*d[j]
print(s//2)
Buggy code:
d=list(map(int,input().split()))
list_A=[]
list_B=[]
for num3 in d:
    list_B.append(int(num3*num3))
k=sum(list_B)
for num in d:
    for num2 in d:
        list_A.append(int(num*num2))
print((sum(list_A)-k)//2)

Fixed code:
N=int(input())
d=list(map(int,input().split()))
list_A=[]
list_B=[]
for num3 in d:
    list_B.append(int(num3*num3))
k=sum(list_B)
for num in d:
    for num2 in d:
        list_A.append(int(num*num2))
print((sum(list_A)-k)//2)
Buggy code:
a = input()
b = input()
bs = [int(i) for i in b.split()]
print(sum(i*j for i in bs for j in bs)-2*sum(i*i for i in bs))


Fixed code:
a = input()
b = input()
bs = [int(i) for i in b.split()]
print((int)((sum(i*j for i in bs for j in bs)-sum(i*i for i in bs))/2))
Buggy code:
N = int(input())
d = map(int,input().split())
recovery_amount = 0 
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    recovery_amount += d[i]*d[j]
print(recovery_amount)

Fixed code:
N = int(input())
d = list(map(int,input().split()))
recovery_amount = 0 
for i in range(N):
  for j in range(i,N):
    if i == j:
      continue
    recovery_amount += d[i]*d[j]
print(recovery_amount)
Buggy code:
N=int(input())
S=input()
c=1
for i in range(N):
  if S[i]!=S[i+1]:
    c+=1
print(c)

Fixed code:
N=int(input())
S=input()
c=1
for i in range(1,N):
  if S[i-1]!=S[i]:
    c+=1
print(c)
Buggy code:
S = input()
k = 1
for b, a in zip(S[:-1], S[1:]):
    if b==a:
        k += 1
print(k)

Fixed code:
_ = input()
S = input()
k = 1
for b, a in zip(S[:-1], S[1:]):
    if b!=a:
        k += 1
print(k)
Buggy code:
n = int(input())
s = input()

f = 0
for i in range(1, n):
  if (s[i] != s[i-1]):
    f += 1
    
print(f)

Fixed code:
n = int(input())
s = input()

f = 1
for i in range(1, n):
  if (s[i] != s[i-1]):
    f += 1
    
print(f)
Buggy code:
a=int(input())a\
b=input()
c=0
for i in range(a-1):
  if b[i]==b[i+1]:
    c=c+1
print(a-c)

Fixed code:
a=int(input())
b=input()
c=0
for i in range(a-1):
  if b[i]==b[i+1]:
    c=c+1
print(a-c)
Buggy code:
N = int(input())
S = input().split()
count = 1
for i in range(N-1):
    j = i+1
    if S[i] != S[j]:
        count += 1
print(count)

Fixed code:
N = int(input())
S = input()
count = 1
for i in range(N-1):
    j = i+1
    if S[i] != S[j]:
        count += 1
print(count)
Buggy code:
N = int(input())
S = input()

count = 0

for i in range(len(S)-1):
    if S[i+1] == S[i]:
        count+=1

print(count)

Fixed code:
N = int(input())
S = input()

count = 1

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

print(count)
Buggy code:
n = int(input())
s = list(input())

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

print(count+1)

Fixed code:
n = int(input())
s = list(input())

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

print(count+1)
Buggy code:
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
s=input()
a=''
for i in range(n-1):
    if(s[i]!=s[i+1]):
        a+=s[i]
if(s[n-1]!=s[n-2]):
    a+=s[n-1]
print(len(a))

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

"""

n=int(input())
s=input()
a=s[0]
for i in range(1,n):
    if(s[i]!=s[i-1]):
        a+=s[i]

print(len(a))
Buggy code:
N = int(input())
S = input().split()
d = S[0]

for i in range(1, N-1):
  if S[i] != S[i-1]:
    d = d + S[i]
    
print(len(d))

Fixed code:
N = int(input())
S = input()
d = S[0]

for i in range(1, N):
  if S[i] != S[i-1]:
    d = d + S[i]
    
print(len(d))
Buggy code:
n=int(input())
s=list(input())
prev=s[0]
sum=1
for i in range(n-1):
    if(prev!=s[i]):
        sum+=1
    prev=s[i]
print(sum)

Fixed code:
n=int(input())
s=list(input())
prev=s[0]
sum=1
for i in range(1,n):
    if(prev!=s[i]):
        sum+=1
    prev=s[i]
print(sum)
Buggy code:
# coding: utf-8
num = int(input())
colors = list(input())
count = 0

for i in range(num-2):
  if colors[i] != colors[i+1]:
    count += 1
  
print(count+1)

Fixed code:
# coding: utf-8
num = int(input())
colors = list(input())
count = 0

for i in range(num-1):
  if colors[i] != colors[i+1]:
    count += 1
  
print(count+1)
Buggy code:
N=int(input())
S=str(input())
cnt=1

for i in range(len(S)):
  if S[i]==S[i+1]:
    continue
  else:
    cnt+=1

print(cnt)

Fixed code:
N=int(input())
S=str(input())
cnt=1

for i in range(len(S)-1):
  if S[i]==S[i+1]:
    continue
  else:
    cnt+=1
print(cnt)
Buggy code:
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    if s[i] != s[i-1]:
         ans += 1
print(ans)

Fixed code:
n = int(input())
s = input()
ans = 1
for i in range(1, n):
    if s[i] != s[i-1]:
         ans += 1
print(ans)
Buggy code:
import re

def C():
    n = input()
    s = input()
    ss = re.sub(r"(.)\1{1,}",r"\1",s)
    print(ss)
    print(len(ss))

if __name__ == '__main__':
    C()
    

Fixed code:
import re

def C():
    n = input()
    s = input()
    ss = re.sub(r"(.)\1{1,}",r"\1",s)
    print(len(ss))

if __name__ == '__main__':
    C()
Buggy code:
N = int(input())
S = input()

ans = 0
p = S[0]
for i in range(1, N):
    if S[i] == p:  continue
    else:
        ans += 1
        p = S[i]
print(ans)

Fixed code:
N = int(input())
S = input()

ans = 0
p = S[0]
for i in range(1, N):
    if S[i] == p:  continue
    else:
        ans += 1
        p = S[i]
print(ans + 1)
Buggy code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())

X = N
A = list(str(S))
print(A)
for i in range(N - 1):
    if A[i] == A[i + 1]:
        X -= 1
print(X)


Fixed code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())

X = N
A = list(str(S))
for i in range(N - 1):
    if A[i] == A[i + 1]:
        X -= 1
print(X)
Buggy code:
N = int(input())
s = list(input())

ans = 0
for i in range(len(s)-1):
    if s[i] !== s[i+1]:
        ans += 1
    else:
        ans = ans

ans += 1

print(ans)

Fixed code:
N = int(input())
s = list(input())
ans = 0
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        ans += 1
    else:
        ans = ans
ans += 1
print(ans)
Buggy code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1c
print(ans)

Fixed code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1
print(ans)
Buggy code:
N=int(input())
S=input()
K=S
i=0
han=S[0]
kot=S[0]

for b in K:
    if b != han:
        kot+=b
        han=b


print(kot)
print(len(kot))

Fixed code:
N=int(input())
S=input()
K=S
i=0
han=S[0]
kot=S[0]

for b in K:
    if b != han:
        kot+=b
        han=b



print(len(kot))
Buggy code:
n = int(input())
str = input()
slim = [str[0]]
for i in range(n):
  if str[i] == slim[-1]:
  	slim.append(str[i]) 
  
print(len(slim))

Fixed code:
n = int(input())
str = input()
slim = [str[0]]
for i in range(n):
  if str[i] != slim[-1]:
  	slim.append(str[i]) 
  
print(len(slim))
Buggy code:
n = int(input())
s = input()
count = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
print(count)



Fixed code:
n = int(input())
s = input()
count = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    count += 1
print(count)
Buggy code:
N = int(input())
S = list(input())
i = 0
count = 0
while i < N:
    while S[i] == S[i-1]:
      i += 1
    count +=1
    i +=1
print(count)

Fixed code:
N = int(input())
S = list(input())
i = 0
count = 0
while i < N-1:
    while S[i] == S[i+1]:
      i += 1
      if i == N-1:
        break
    if i == N-1:
      break
    count +=1
    i +=1
count +=1
print(count)
Buggy code:
n = int(input())
s = input()
color = ""
for i in range(len(s)):
  if color != s[i]:
    color = s[i]
    count += 1
print(count)

Fixed code:
n = int(input())
s = input()
color = ""
count = 0
for i in range(len(s)):
  if color != s[i]:
    color = s[i]
    count += 1
print(count)
Buggy code:
N = int(input())
A = list(input())
print(A)
ans = 1
for i in range(N-1):
  if A[i] == A[i+1]:
    continue
  else:
    ans +=1
    
print(ans)

Fixed code:
N = int(input())
A = list(input())

ans = 1
for i in range(N-1):
  if A[i] == A[i+1]:
    continue
  else:
    ans +=1
    
print(ans)
Buggy code:
n = int(input())

li = list(input())

print(li)
count = 0
for i in range(len(li)-1):
    if li[i] == li[i+1]:
        count = count + 1

print(n-count)

Fixed code:
n = int(input())

li = list(input())

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

print(n-count)
Buggy code:
n = int(input())
s = input()
count = 1
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
print(count)

Fixed code:
n = int(input())
s = input()
count = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    count += 1
print(count)
Buggy code:
N = int(input())
S = input()

def run_length(s) -> list:
  res = [[s[0], 1]]
  for i in range(1, len(s)):
    if res[-1][0] == s[i]:
      res[-1][1] += 1
    else:
      res.append([s[i], 1])
  return res

answer = ""
for s, l in run_length(S):
  answer += s

print(answer)

Fixed code:
N = int(input())
S = input()

def run_length(s) -> list:
  res = [[s[0], 1]]
  for i in range(1, len(s)):
    if res[-1][0] == s[i]:
      res[-1][1] += 1
    else:
      res.append([s[i], 1])
  return res

print(len(run_length(S)))
Buggy code:
N = int(input())
S = int(input())
count = 0
b = " "
for i in range(N):
	
	if b == S[i]:
		count = count + 1
        b = S[i]

print(count)


Fixed code:
N = int(input())
S = input()
count = 0
b = " "
for i in range(N):
	    
    if b != S[i]:
        count = count + 1
        b = S[i]

print(count)
Buggy code:
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1
#print(a)
#print(b)
while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 #print("t",t,"u",u)
 if not t == u:
  s = s + 1
  print(s)
 k = k + 1
print(s)

Fixed code:
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1
#print(a)
#print(b)
while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 #print("t",t,"u",u)
 if not t == u:
  s = s + 1
  #print(s)
 k = k + 1
print(s)
Buggy code:
def main():
    n = input()
    slimes = list(input())

    print(n, slimes)
    one = 0
    count = 0
    for slime in slimes:
        if one != slime:
            count+=1
        one = slime
    print(count)
if __name__ == "__main__":
    main()


Fixed code:
def main():
    n = input()
    slimes = list(input())

    one = 0
    count = 0
    for slime in slimes:
        if one != slime:
            count+=1
        one = slime
    print(count)
if __name__ == "__main__":
    main()
Buggy code:
n=int(input())
s=input()

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

Fixed code:
n = int(input())
s = input()
count = 1
for i in range(1,n):
    if s[i] != s[i-1]:
        count+=1
print(count)
Buggy code:
import itertools

N = int(input())
L = str(input())

l = [k for k, v in itertools.groupby(L)]
ans = N-len(l)

print(ans)

Fixed code:
import itertools

N = int(input())
L = str(input())

l = [k for k, v in itertools.groupby(L)]

print(len(l))
Buggy code:
N = int(input())
S = input()
count = 0
for i in range(1, N + 1):
  if S[i - 1] == S[i]:
    count += 1
print(N - count)

Fixed code:
N = int(input())
S = input()
count = 0
for i in range(1, N):
  if S[i - 1] == S[i]:
    count += 1
print(N - count)
Buggy code:
_ = input()
 s = input()
 place_holder = s[0]
 count = 1
 for letter in s[1:]:
     if place_holder == letter:
         continue
     else:
         place_holder = letter
         count += 1

Fixed code:
_ = input()
s = input()
place_holder = s[0]
count = 1
for letter in s[1:]:
    if place_holder == letter:
        continue
    else:
        place_holder = letter
        count +=1
print(count)
Buggy code:
N = input("N")
S = input("S")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)

Fixed code:
N = input("")
S = input("")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)
Buggy code:
n = int(input())
s = input()

a = 0
for i in range(1, n):
  if s[i-1] != s[i]:
    a += 1
print(a)

Fixed code:
n = int(input())
s = input()

a = 1
for i in range(1, n):
  if s[i-1] != s[i]:
    a += 1
print(a)
Buggy code:
n = int(input())
s = input()

ans = 0

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

print(ans+1)

    

Fixed code:
n = int(input())
s = input()

ans = 0

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

print(ans+1)
Buggy code:
n = int(input())
s = input()
l =[s[0]]
for c in s:
  if c == l[-1]:
    l.append(c)
print(len(l))

Fixed code:
n = int(input())
s = input()
l =[s[0]]
for c in s:
  if c != l[-1]:
    l.append(c)
print(len(l))
Buggy code:
N=int(input())
text=input()
x=0
for i in range(N-1):
  if text[i]!=text[i+1]:
    x+=1
print(x)


Fixed code:
N=int(input())
text=input()
x=1
for i in range(N-1):
  if text[i]!=text[i+1]:
    x+=1
print(x)
Buggy code:
N = int(input())
S = input()

ans = 0
n = 1

while n<N:
  if S[n]==S[n-1]:
    ans +=1
    n +=1
  else:
    n+=1

print(ans)

Fixed code:
N = int(input())
S = input()

ans = 0
n = 1

while n<N:
  if S[n]==S[n-1]:
    ans +=1
    n +=1
  else:
    n+=1

print(N-ans)
Buggy code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
S = _S()
#Ap = np.array(A)
#C = np.zeros(N + 1)

last = ''
count = 0
for i in range(N):
    a = S[i]
    if last == a:
        count += 1
    else:
        last = a
print(count)

Fixed code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
S = _S()
#Ap = np.array(A)
#C = np.zeros(N + 1)

last = ''
count = 0
for i in range(N):
    a = S[i]
    if not last == a:
        count += 1
        last = a
print(count)
Buggy code:
n = int(input())
s = [i for i in input()]
c = 0
for i in range(n-1):
  if s[i+1]==s[i]:
    c += 1
print(c)


Fixed code:
n = int(input())
s = [i for i in input()]
c = 1
for i in range(n-1):
  if s[i+1]!=s[i]:
    c += 1
print(c)