qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
s = input()
c = 0
for i in range(n):
  if s[i:i+2] == "ABC":
    c += 1
print(c)

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

for i in range(n-2):
  if s[i:i+3] == "ABC":
    c += 1

print(c)
Buggy code:
n = int(input())
s = str(input())
ans = 0
for i in range(n-3):
  if(n[i:i+2]=="ABC"):
    ans += 1
print(ans)
    

Fixed code:
n = int(input())
s = input()
ans = 0
for i in range(n - 2):
    a = s[i:i + 3]
    if a == "ABC":
        ans += 1
print(ans)
Buggy code:
n = int(input())
s = input()
c=0
for i in range(n - 2):
    print(s[i:i + 3])
    if s[i:i + 3] == 'ABC':
        c += 1
print(c)

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

for i in range(n - 2):
    if s[i:i + 3] == "ABC":
        ans += 1

print(ans)
Buggy code:
n = int(input())
s = list(str(input()))
ans = s.count('ABC')
print(ans)

Fixed code:
n=int(input())
s=str(input())
ans=s.count('ABC')
print(ans)
Buggy code:
n = int(input)
s = input()
s2 = s.replace("ABC","")
print(int((len(s)-len(s2))/3))

Fixed code:

n= int(input())
s = input()

s = s.replace("ABC","")

print((n-len(s))//3)
Buggy code:
N=int(input())
S=input()
ans=0

for i in range(N-2):
    if S[i:i+3]=="ABC":
        ans+=1

Fixed code:
N=int(input())
S=input()
ans=0
for i in range(N-2):
  if S[i:i+3]=="ABC":
    ans+=1
print(ans)
Buggy code:
# -*- coding: utf-8 -*-

n = int(input())
s = input()

index = -1
current_index = 0
counter = 0
for i in range(n):
  if 'ABC' in s[i:]:
    current_index = s.index('ABC', i)
    # print(current_index, s[i:])
  if index != current_index:
    counter += 1
    index = current_index
print(counter)

Fixed code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()

index = -1
current_index = -1
counter = 0
for i in range(n):
  if 'ABC' in s[i:]:
    current_index = s.index('ABC', i)
    # print(current_index, s[i:])
  if index != current_index:
    counter += 1
    index = current_index
print(counter)
Buggy code:
n=int(input())
s=input()
s.split('ABC')
print(len(s)-1)

Fixed code:
n=(input())
s=input()
s=s.split('ABC')
print(len(s)-1)
Buggy code:
str_len = int(input())
string_sample = input()
sample = 'ABC'

counter = 0
for i in range(str_len - 2):
  print(i)
  if string_sample[i:i+3] == sample:
    counter += 1
    
print(counter)

Fixed code:
str_len = int(input())
string_sample = input()
sample = 'ABC'

counter = 0
for i in range(str_len - 2):
  if string_sample[i:i+3] == sample:
    counter += 1
    
print(counter)
Buggy code:
a = input()
s = input()
print(s.count("ABC")

Fixed code:
a = input()
s = input()
print(s.count("ABC"))
Buggy code:
import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
i = 0
cnt = 0
while i <= n -3:
  if s[i:i+3] == 'ABC':
    cnt += 1
print(cnt)

Fixed code:
import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
i = 0
cnt = 0
while i <= n -3:
  if s[i:i+3] == 'ABC':
    cnt += 1
  i += 1
print(cnt)
Buggy code:
n = int(input())
s = input()
ans = 0


for i in range(n-2):
    if s[i:i+2] == 'ABC':
        res += 1

print(ans)

Fixed code:
n=int(input())
s=input()
ans=0
for i in range(n-2):
  if s[i:i+3]=='ABC':
    ans+=1
print(ans)
Buggy code:
n = int(input())
 s = input()
 ans = 0
 for i in range(n - 2):
     if s[i:i+3] == 'ABC':
         ans += 1 
 print(ans) 

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

c = 0
for i in range(n-2):
  if s[i:i+3] == 'ABC':
    c += 1

print(c)
Buggy code:
N = int(input())
S = str(input())
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)

Fixed code:
N = int(input())
S = input()
a = 0
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)
Buggy code:
S = str(input())
N = int(input())

print(S.count('ABC'))


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

ct = S.count('ABC')

print(ct)
Buggy code:
from sys import stdin
stdin = open("input.txt")

if __name__ == "__main__":
  N = int(stdin.readline())
  S = stdin.readline().rstrip()
  
  print(S.count("ABC"))

Fixed code:
from sys import stdin
#stdin = open("input.txt")

if __name__ == "__main__":
  N = int(stdin.readline())
  S = stdin.readline().rstrip()
  
  print(S.count("ABC"))
Buggy code:
N = int(input())
word = list(input())
count = 0
for i in range(N-2):
  if word[i]=A and word[i+1]=B and word[i+2]=C:
    count += 1
    
print(count)

Fixed code:
N = int(input())
word = list(input())
count = 0
for i in range(N - 2):
    if word[i]=="A" and word[i+1]=="B" and word[i+2]=="C":
        count += 1

print(count)
Buggy code:
N = int(input())
S = input()

cnt = 0
for i in range(N):
    print(S[i:i+3])
    if S[i:i+3] == 'ABC':
        cnt += 1

print(cnt)

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

cnt = 0
for i in range(N):
    if S[i:i+3] == 'ABC':
        cnt += 1

print(cnt)
Buggy code:
n = int(input())
letters = input()
cnt = 0
for i in range(n):
    if letters[i:i+3]=="abc":
        cnt += 1

print(cnt)

Fixed code:
n = int(input())
letters = input()
cnt = 0
for i in range(n):
    if letters[i:i+3]=="ABC":
        cnt += 1

print(cnt)
Buggy code:
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
if s[i] == 'A':
    if s[i+1] == 'B':
        if [i+2] == 'C':
            counter += 1
print(counter)

Fixed code:
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                counter += 1
print(counter)
Buggy code:
n=int(input())
s=list(input())
for i in range(0,n-2):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="B":
        total+=1
print(total)

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

for i in range(0,n-2):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        total+=1
print(total)
Buggy code:
N = int(input())
S = input()
length = len(S)
num = 0
print(length)
for i in range(length-2) :
  if S[i:i+3] == "ABC" :
    num += 1
print(num)

Fixed code:
N = int(input())
S = input()
length = len(S)
num = 0
for i in range(length-2) :
  if S[i:i+3] == "ABC" :
    num += 1
print(num)
Buggy code:
n=int(input())
s=str(input())
ans=0
for i in range(n):
    if s[i:i+3] =="abc":
        ans +=1
    else:
        ans +=0
print(ans)


Fixed code:
n=int(input())
s=str(input())
ans=0
for i in range(n):
    if s[i:i+3] =="ABC":
        ans +=1
    else:
        ans +=0
print(ans)
Buggy code:
N = int(input())
s = input()
a=0
for i in range N-2:
  if s[i:i+2]=="ABC":
    a +=1
print(a)

Fixed code:
N = int(input())
s = input()
a=0
for i in range (0,N-2):
  if s[i:i+3]=="ABC":
    a +=1
print(a)
Buggy code:
n=int(input())
s=input()

count = 0
for i in range(n-3)
	if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
		count = count + 1
print(count)

Fixed code:
n=int(input())
s=input()
 
count = 0
for i in range(n-3+1):
#	print(s[i],s[i+1],s[i+2])
	if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
		count = count + 1
print(count)
Buggy code:
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    ans += 1
print(ans

Fixed code:
n = int(input())
s = input()
ans = 0
for i in range(n-2):
    if s[i:i+3] == "ABC":
        ans += 1

print(ans)
Buggy code:
import sys

N = input()
S = input()

c = 0

for i in range(N-2):
    if S[i]=='A' and  S[i+1]=='B'and  S[i+2]=='C':
        c += 1

print(c)

Fixed code:
import sys

N = int(input())
S = input()

c = 0

for i in range(N-2):
    if S[i]=='A' and  S[i+1]=='B'and  S[i+2]=='C':
        c += 1

print(c)
Buggy code:
N = int(input())
S = input()
"""
10
ZABCDBABCQ
"""

num = 0
for i in range(len(S)-2):
    print(S[i:i+3])
    if S[i:i+3] == "ABC":
        num += 1

print(num)


Fixed code:
N = int(input())
S = input()
"""
10
ZABCDBABCQ
"""

num = 0
for i in range(len(S)-2):
    if S[i:i+3] == "ABC":
        num += 1

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

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in range(A_index[0], n-1) :
  if s[j+1] == 'B' :
    if s[j+2] == 'C' :
      count += 1

print(count)

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

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in A_index :
  if j != n-1 :
    if s[j+1] == 'B' :
      if j != n-2 :
        if s[j+2] == 'C' :
          count += 1

print(count)
Buggy code:
input = input()
result = 0
for i in range(len(input) - 2):
    serach = input[i:i+3]
    if serach == "ABC":
        result += 1
print(result)

Fixed code:
num = input()
input = input()
result = 0
for i in range(len(input) - 2):
    serach = input[i:i+3]
    if serach == "ABC":
        result += 1
print(result)
Buggy code:
N=int(input())
S=input()
ans=0
for in range(N-1):
  if S[i:i+3]=='ABC':
    ans+=1
print(ans)

Fixed code:
N = int(input())
S = input()
ans = 0
for i in range(N-2):
  if S[i:i+3] == "ABC":
    ans += 1
    
print(ans)
Buggy code:
n = int(input())
s = input()

count=0
for i in range(n-2):
  if s[i] = "A":
    if s[i+1] = "B":
      if s[i+2]="C":
        count += 1
print(count)

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

count = 0
for i in range(n - 2):
    if s[i] == 'A':
        if s[i + 1] == 'B':
            if s[i + 2] == 'C':
                count += 1
print(count)
Buggy code:
S = input()

res = 0
for i in range(len(S)-2):
  if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
    res += 1
    
print(res)


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

res = 0
for i in range(len(S)-2):
  if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
    res += 1
    
print(res)
Buggy code:
n = int(input())
s = input()

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    	tmp = ""
print(cnt)

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

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
    else:
      	tmp = ""
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    tmp = ""
  else:
    tmp = ""
print(cnt)
Buggy code:
n = int(input())
s = input()

if "ABC" in s:
  print(s.count("ABC")
else:
  print(0)

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

if "ABC" in s:
    print(s.count("ABC"))
else:
    print(0)
Buggy code:
n = int(input())
s = str(inout())

ans = 0

for i in range(n-2):
    if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
        ans += 1
    else:
        continue
      
print(ans)


Fixed code:
n = int(input())
s = str(input())
 
ans = 0
 
for i in range(n-2):
    if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
        ans += 1
    else:
        continue
      
print(ans)
Buggy code:
#https://atcoder.jp/contests/abc150/tasks/abc150_b
N= int(input())

A= []
s= input()
A= list(s)


print(A)

add = 0
for i in range(0, N-1):
    if A[i]== 'A' and A[i+1]=='B' and A[i+2]=='C':
        add = add + 1

print(add)

Fixed code:
#https://atcoder.jp/contests/abc150/tasks/abc150_b
N= int(input())
s= input()

A= []
A= list(s)

#print(A)

add = 0
for i in range(0, N-2):
    if A[i]== 'A' and A[i+1]=='B' and A[i+2]=='C':
        add = add + 1

print(add)
Buggy code:
s = list(input())

ans = 0
for i in len(s-2):
  if s[i]=="A" and s[i+1] == "B" and s[i+2] ==  "C":
    ans += 1
    
print(ans)

Fixed code:
N = input()
s = list(input())

ans = 0
for i in range(len(s)-2):
  if s[i]=="A" and s[i+1] == "B" and s[i+2] ==  "C":
    ans += 1
    
print(ans)
Buggy code:
n = int(input())                                                                    s = input()                                                                                                                                                             print(s.count('ABC'))

Fixed code:
n = int(input())
s = input()                                                                                                                                                             
print(s.count('ABC'))
Buggy code:
N = int(input())
S = list(input())
cnt =0
for i in range(n-2):
  if S[i] =="A":
    if S[i+1] =="B":
      if S[i+2] == "C":
        cnt +=1
print(cnt)

Fixed code:
N = int(input())
S = list(input())
cnt =0
for i in range(N-2):
  if S[i] =="A":
    if S[i+1] =="B":
      if S[i+2] == "C":
        cnt +=1
print(cnt)
Buggy code:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A"
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)

Fixed code:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A":
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)
Buggy code:
n=map(int,input())
s=str(input())

count=0
for i in range(n-2):
    if s[i]=="A":
        if s[i+1]=="B":
            if s[i+2]=="C":
                count+=1

print(count)

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

count=0
for i in range(n-2):
    if s[i]=="A":
        if s[i+1]=="B":
            if s[i+2]=="C":
                count+=1

print(count)
Buggy code:
N = int(input())
S = input()

ans = 0

for i in range(N-1):
  print(i)
  if S[i:i+3] == "ABC":
    ans += 1
  
print(ans)

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

ans = 0

for i in range(N-1):
  if S[i:i+3] == "ABC":
    ans += 1
  
print(ans)
Buggy code:
num = int(input())
word = input()
if len(word) >= num:
    print(word[0:num].count('ABC'))
print(0)      
       


Fixed code:
num = int(input())
word = input()
if len(word) >= num:
    print(word[0:num].count('ABC'))
else:
    print(0)
Buggy code:
S=input()
print(S.count("ABC"))

Fixed code:
N=input()
S=input()
print(S.count("ABC"))
Buggy code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
	count = 0
	num = int(input())
	strings = input()
	print(len(strings))
	for i in range(0,num-2,1):
		if strings[i] == "A" and strings[i+1] == "B" and strings[i+2] == "C":	
			count += 1
	print(count)

if __name__ == '__main__':
	main()


Fixed code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
	count = 0
	num = int(input())
	strings = input()
	
	for i in range(0,num-2,1):
		if strings[i] == "A" and strings[i+1] == "B" and strings[i+2] == "C":	
			count += 1
	print(count)

if __name__ == '__main__':
	main()
Buggy code:
_ = input()
S = input()
newS = S.replace("ABC", "")
print(S, newS)
print((len(S) - len(newS)) // 3)

Fixed code:
_ = input()
S = input()
newS = S.replace("ABC", "")
print((len(S) - len(newS)) // 3)
Buggy code:
n=int(input())
s=input()
count=0
for i in range(len(n)-3):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    count+=1
print(count)

Fixed code:
n = int(input())
s = input()
count = 0
for i in range(n-2):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        count+=1
print(count)
Buggy code:
a = int(input())
b = input()
c = list(b)
for i  in range(a - 2):
    j = 0
    if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C':
        j = j + 1
print(j)

Fixed code:
a = int(input())
b = input()
c = list(b)
j = 0
for i  in range(a - 2):
    if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C':
        j += 1
print(j)
Buggy code:
a = input()
b = a.count('ABC')
print(b)

Fixed code:
c=input()
a = input()
b = a.count('ABC')
print(b)
Buggy code:
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N-1):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        print(i)
        result+=1
    else:
        print("after"+str(i))
        p=1

print(result)

Fixed code:
#ABC144 B
N=int(input())
S=input()
#print(N)
result=0

for i in range(N-2):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        #print(i)
        result+=1
    else:
        #print("after"+str(i))
        p=1

print(result)
Buggy code:
n = int(input)
s = input()

print(len(s.split('ABC')) - 1)

Fixed code:
n = int(input())
s = input()
 
print(len(s.split('ABC')) - 1)
Buggy code:
n = int(input())
s = input()
ls = s.replace("ABC","")
print(ls)
print((n-len(ls))//3)

Fixed code:
n = int(input())
s = input()
ls = s.replace("ABC","")
print((n-len(ls))//3)
Buggy code:
n = int(input())
s = input()
count = 0
for i in range(n-2):
  print(s[i:i+3])
  if s[i:i+3] == "ABC":
    count += 1
print(count)


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


for i in range(n):
  if s[i:i+3]=='ABC':
    count+=1

print(count)
Buggy code:
N = int(input())
S = int(input())
print(S.count('ABC'))

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

print (S.count("ABC"))
Buggy code:
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
	[]	cnt+=1
print(cnt)


Fixed code:
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
		cnt+=1
print(cnt)
Buggy code:
N = int(input())
S = list(str(input()))

tmp = 0
count = 0
for i in S:
  if i == "A":
    tmp = 1
  elif i == "B" and tmp == 1:
    tmp = 2
  elif i == "C" and tmp == 2:
    count += 1
print(count)

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

tmp = 0
count = 0
for i in S:
  if i == "A":
    tmp = 1
  elif i == "B" and tmp == 1:
    tmp = 2
  elif i == "C" and tmp == 2:
    count += 1
    tmp = 0
  else:
    tmp = 0
print(count)
Buggy code:
n = int(input())
s = input()

print(s.count("ABC")

Fixed code:


n = int(input())
s = input()

print(s.count('ABC'))
Buggy code:
N=int(input())
S=input()
ans=0
for i in range (0,n-2):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    ans+=1
print(ans)

Fixed code:
N=int(input())
S=input()
ans=0
for i in range (0,N-2):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    ans+=1
print(ans)
Buggy code:
n = int(input())
s = input()

k = 0

for i in range(n-2):
	if s[i]=A and s[i+1]=B and s[i+2]=C:
		k += 1
        
print(k)


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

k = 0

for i in range(n-2):
	if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
		k += 1
        
print(k)
Buggy code:
n = int(input())
i =input()

c=0

for j in range(0,n-2):
  print(i[j:j+3])
  if i[j:j+3]=="ABC":
    c+=1
print(c)

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

c=0

for j in range(0,n-2):
  if i[j:j+3]=="ABC":
    c+=1
print(c)
Buggy code:
n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a' or 'A':
        if s[i + 1] == 'b' or 'B':
            if s[i + 2] == 'c' or 'C':
                count += 1
print(count)

Fixed code:
n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a' or s[i] == 'A':
        if i + 1 < n:
            if s[i + 1] == 'b' or s[i + 1] == 'B':
                if i + 2 < n:
                    if s[i + 2] == 'c' or s[i + 2] ==  'C':
                        count += 1
print(count)
Buggy code:
n = int(input())
s = input()
count = 0

for i in range(n-2):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count += 1
print(count

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

for i in range(n-2):
    #print(s[i],s[i+1],s[i+2])
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count += 1
print(count)
Buggy code:
N=input()
S=input() 
cnt=0 
y=S.find("ABC")
if y==-1:
    print(0)
else:
    while y!=-1:
        S=S.replace(S[:y],"")
        S=S.replace("ABC","",1) 
        y=S.find("ABC")
        cnt+=1 
    print(cnt) 

Fixed code:
N=input()
S=input() 
cnt=0 
y=S.find("ABC")
if y==-1:
    print(0)
else:
    while y!=-1:
        S=S.replace(S[:y],"",1)
        S=S.replace("ABC","",1) 
        y=S.find("ABC")
        cnt+=1 
    print(cnt)
Buggy code:
n = int(input())
s = input()
cnt = 0
flag = 0
for i in range(n):
  if s[i] == "A":
    flag = 1
  elif s[i] == "B" and flag == 1:
    flag = 2
  elif s[i] == "C" and flag == 2:
    cnt += 1
    flag = 0
print(cnt)

Fixed code:
n = int(input())
s = input()
cnt = 0
flag = 0
for i in range(n):
  if s[i] == "A":
    flag = 1
  elif s[i] == "B" and flag == 1:
    flag = 2
  elif s[i] == "C" and flag == 2:
    cnt += 1
    flag = 0
  else:
    flag = 0
print(cnt)
Buggy code:
n = int(input())
s = input()
flag = 0
for i in range(n):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                flag =+ 1
print(flag)

Fixed code:
n = int(input())
s = input()
flag = 0
for i in range(n-1):
    if i == n-2:
        break
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                flag += 1
print(flag)
Buggy code:
N = int(input().split())
S = str(input().split())
i = 0
count = 0
for i in range(N-2):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    count += 1
print(count)

Fixed code:
N = int(input())
S = str(input())
i = 0
count = 0
for i in range(N-2):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    count += 1
print(count)
Buggy code:
N=input()
print(input().count("ABC")

Fixed code:
N=input()
print(input().count("ABC"))
Buggy code:
n = int(input())
s = input()
print(count("ABC"))

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


print(s.count("ABC"))
Buggy code:
n = int(input())
s = list(input())
ans = 0
for i in range(n-2):
  if a[i]=='A' and a[i+1]=='B' and a[i+2]=='C':
    ans+=1
print(ans)

Fixed code:
n = int(input())
a = list(input())
ans = 0
for i in range(n-2):
  if a[i]=='A' and a[i+1]=='B' and a[i+2]=='C':
    ans+=1
print(ans)
Buggy code:
inputA= int(input())
inputB =map(input())

print(inputB.count('ABC'))

Fixed code:
inputA= int(input())
inputB =input()

print(inputB.count('ABC'))
Buggy code:
n=int(input())
s=list(input())
cnt=0
for i in range(n-2):
  if s[i]="A" and s[i+1]="B" and s[i+2]="C":
    cnt += 1
print(cnt)

Fixed code:
n=int(input())
s=list(input())
cnt=0
for i in range(n-2):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    cnt += 1
print(cnt)
Buggy code:
N = int(input())
S = input()
ans = 0
for i in range(N-2):
  if s[i:i+3] == 'ABC':
    ans += 1
print(ans)

Fixed code:
N=int(input())
S=input()
ans=0
for i in range(N-2):
  if "ABC"==S[i:i+3]:
    ans+=1
print(ans)
Buggy code:
N = int(input())
S = list(input())
cnt = 0
for i in range(i,N-2):
    if S[i] ='A' and S[i+1] == 'B' and S[i+2] == 'C':
        cnt += 1

print(cnt)

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

for i in range(N-2):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    cnt+=1
print(cnt)
Buggy code:
text = input().split("ABC")
print(len(text)-1)

Fixed code:
input()
text = input().split("ABC")
print(len(text)-1)
Buggy code:
N=input()
S=input()

S.replace('ABC','x')
print(S.count('x'))

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

ans=S.replace('ABC','x')
print(ans.count('x'))
Buggy code:
n = int(input())
s = str(input())
c = 0
for i in range(len(s)):
  if s[i] == "A":
    if s[1+1] == "B" and s[i+2] == "C":
      c += 1
print(c)

Fixed code:
n = int(input())
s = str(input())
c = 0
for i in range(n-2):
  if s[i] == "A":
    if s[i+1] == "B" and s[i+2] == "C":
      c += 1
print(c)
Buggy code:
s = input()
ans = 0
for i in range(n - 2):
  if s[i:i + 3] == "ABC":
    ++ans
print(ans)

Fixed code:
n = int(input())
s = input()
ans = 0
for i in range(n - 2):
  if s[i : i + 3] == "ABC":
    ans += 1
print(ans)
Buggy code:
N = int(input())
S = list(input())
count = 0
for i in range(1,N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count += 1
print(count)

Fixed code:
N = int(input())
S = list(input())
count = 0
for i in range(0,N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                count += 1
print(count)
Buggy code:
x = input()
print(x.count("ABC"))

Fixed code:
x = input()
x = input()
print(x.count("ABC"))