Problem:


Score : 200 points

Problem Statement

We have a string S of length N consisting of uppercase English letters.

How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?

Constraints

3 \leq N \leq 50

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print number of occurrences of ABC in S as contiguous subsequences.

Sample Input 1

10
ZABCDBABCQ

Sample Output 1

2

Two contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.

Sample Input 2

19
THREEONEFOURONEFIVE

Sample Output 2

0

No contiguous subsequences of S are equal to ABC.

Sample Input 3

33
ABCCABCBABCCABACBCBBABCBCBCBCABCB

Sample Output 3

5



Sample input:
10
ZABCDBABCQ


Sample output:
2

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(10)
s = list('ZABCDBABCQ')

result = 0
for i in range(len(s)):
    if (i > n - 3):
        break
    if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        result = result + 1

print(result)

Submission status: Wrong Answer

Solution code:
from sys import stdin

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()

c = 0
cnt = 0
abc = ['A','B','C']
for i in b:
    if i == abc[c]:
        c += 1
        if c ==3:
            c = 0
            cnt += 1
    else:
        c = 0



print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
x=input()
x.count("ABC")

Submission status: Wrong Answer

Solution code:
Input1 = int(input())
N = Input1
Input2 =str(input())
ar = list(Input2)



chk = 0
cnt = 0
for i in range(N):
  if chk == 0:
    if ar[i]=='A':
      chk+=1
  elif chk == 1:
    if ar[i]=='B':
      chk+=1
    else:
      chk=0
  elif chk == 2:
    if ar[i]=='C':
      chk=0
      cnt+=1
    else:
      chk=0
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input("Enter N: "))
S = input("Enter S: ")
print(len(S.split("ABC"))-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        state = 0
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  N = int(input())
  S = input()
  check = "ABC"
  count = 0
  for i in range(N-3):
    sub = S[i:i+3]
    if check == sub:
      count += 1
  print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
tmp_c = 0
count = 0
for i in range(N):
    if tmp_c == 0 and S[i]=="A":
        tmp_c = tmp_c + 1
    elif tmp_c == 1 and S[i]=="B":
        tmp_c = tmp_c + 1
    elif tmp_c == 1:
        tmp_c = 0
    elif tmp_c == 2 and S[i]=="C":
        count = count + 1
        tmp_c = 0
    elif tmp_c == 2:
        tmp_c = 0
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
acs = 65
count=0
flag=0

if N>=3 and N<=50:
    if len(S) == N:
        for i in S:
            if ord(i) == acs:
                acs+=1
                count+=1
            else:
                acs=65
                if count==3:
                    flag+=1
                count=0

print(flag)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
L=''
ans=0
for s in S:
    if s=='A' and L=='':
        L += s
    elif s=='B' and L=='A':
        L += s
    elif s=='C' and L=='AB':
        ans += 1
        L='' 
    else:
        L=''
print(ans)

Submission status: Wrong Answer

Solution code:

S = str(input())
print(S.count("ABC"))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
a = input()
b = a.count('ABC')
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
count = 0

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
state = 0
ans = 0

def isABC(s):
    global state
    if state==0:
        if s=="A":
            state = 1
        return 0
    elif state==1:
        if s=="B":
            state = 2
        else:
            state=0
        return 0
    else:
        if s=="C":
            state=0
            return 1
        else:
            state=0
            return 0

for i in S:
    ans += isABC(i)
print(ans)

Submission status: Wrong Answer

Solution code:
def B():
    n = int(raw_input())
    s = list(raw_input())
    c = 0
    for i in range(0,len(s)-2):
        if str(s[i]) == "A":
            if str(s[i+1]) == "B":
                if str(s[i+2]) == "C":
                    c = c + 1
    print c

Submission status: Wrong Answer

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

count = 0
for i in range(0,N-3):
    if S[i]=='A':
        if S[i+1]=='B':
            if S[i+2]=='C':
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
# import sys
# sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)

def main():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n - 3):
        if s[i:i + 3] == "ABC":
            ans += 1
    print(ans)
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))

    # g = lcm(a[0], a[1])
    # for i in range(2, n):
    #     g = lcm(g, a[i])
    # if g // 2 > m:
    #     print(0)
    #     exit()
    # print(g)
    # print(math.ceil(m//g + 0.5))



    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for c in list(s):
    if c != check[state]:
        state = 0
        continue
    
    state += 1
    if state >= len(check):
        count += 1
        state = 0

print(count)

Submission status: Wrong Answer

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

cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:09:39 2020

@author: over-
"""

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

c=0

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

state = 0
ans = 0

for i in range(n):
    if state == 0:
        if s[i] == 'A':
            state = 1
        else:
            state = 0
    elif state == 1:
        if s[i] == 'B':
            state = 2
        else:
            state = 0
    elif state == 2:
        if s[i] == 'C':
            ans += 1
            state = 0
        else:
            state = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
ctr = 0

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
temp = 0
count = 0
while temp < N:
    if S[temp] == "A":
        if S[temp:temp+3] == "ABC":
            count += 1
            temp += 3
        else:
            temp += 3
    else:
        temp += 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s = list(input())
cnt=0
for i in range(n-2):
    print(s[i:i+3])
    if s[i:i+3] ==['A', 'B', 'C']:
        
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
print(S.count("abc",0,N))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  N = int(input())
  S = input()
  check = "ABC"
  count = 0
  for i in range(N-3):
    sub = S[i:i+3]
    if check in sub:
      count += 1
  print(count)

Submission status: Wrong Answer

Solution code:
Input = int(input())
N = Input
Input =str(input())
ar = list(Input)



chk = 0
cnt = 0
for i in range(N):
  if chk == 0:
    if ar[i]=='A':
      chk+=1
  elif chk == 1:
    if ar[i]=='B':
      chk+=1
  elif chk == 2:
    if ar[i]=='C':
      chk=0
      cnt+=1

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

stage = 0
count = 0
for i in range(N):
    if(S[i]=="A"):
        stage = 1
    if(stage==1) and (S[i]=="B"):
        stage = 2
    if(stage==2) and (S[i]=="C"):
        stage = 0
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
class Solution:
    def CountABC(self, s: str):
        if len(s) <= 3:
            return 0
        count = 0
        for idx in range(len(s)):
            if s[idx : idx + 3] == "ABC":
                count += 1
        return count


if __name__ == "__main__":
    n, s = int(input()), input()
    solution = Solution()
    print(solution.CountABC(s))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = input()
S.count('ABC')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

ans = 0
count = 0
for i in range(len(S)):
  if count == 0:
    if S[i] == 'A':
      count = 1
  elif count == 1:
    if S[i] == 'B':
      count = 2
    elif S[i] == 'A':
      count = 1
    else:
      count = 0
  else:
    if S[i] == 'C':
      ans += 1
      count = 0
    elif S[i] == 'A':
      count = 1      
    else:
      count = 1
      
print(ans)

Submission status: Wrong Answer

Solution code:
n=input()
s=input()
s.count("ABC")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
if n==3:
    if s=="ABC":
        count=1
elif n==4:
    s=list(s)
    if s[0]=="A" and s[1]=="B" and s[2]=="C":
        count+=1
    elif s[1]=="A" and s[2]=="B" and s[3]=="C":
        count+=1
else:
    s=list(s)
    for i in range(n-3):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


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

ans = 0
i = 0
while i < N-3:
    if S[i] == "A":

        i += 1
        if S[i] == "B":
            i += 1
            if S[i] == "C":
                ans += 1
                i+=1
            else:
                continue
        else:
            continue
    else:
        i += 1
        continue


print(ans)

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

i = 0
ans = 0

while i < len(s) - 3:
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
out = 0

if S == "ABC": print(1)
else:  
  for i in range(N - 3):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
      out += 1

  print(out)

Submission status: Wrong Answer

Solution code:
from sys import stdin

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()

c = 0
cnt = 0
abc = ['A','B','C']
for i in b:
    if i == abc[c]:
        c += 1
    else:
        c = 0
    if c ==3:
        c = 0
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
L=''
ans=0
for s in S:
    if s=='A' and L=='':
            L += s
    elif s=='B' and L=='A':
        L += s
    elif s=='C' and L=='AB':
        ans += 1; L='' 
    else:
        L=''
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N = int(input())
    S = input()

    flag = 0
    ans = 0

    st = ""
    for s in S:
        st += s
        if (s == "A") & (flag == 0):
            flag = 1
        elif (s == "B") & (flag == 1):
            flag = 2
        elif (s == "C") & (flag == 2):
            flag = 3
        else:
            st = ""
            flag = 0
        if st == "ABC":
            st = ""
            ans += 1
    print(ans)

    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A" and type == "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)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
print(S.count("abc"))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(str(input()))
ans=0
for i in range(len(s) - 3):
    if s[i] == 'A':
        if s[i + 1] == 'B':
            if s[i + 2] == 'C':
                ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,w,ans = int(input()),input(),0
for i in range(n-3):
  if w[i:i+3] == 'ABC' :
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:09:39 2020

@author: over-
"""

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

c=0

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = str(input())
    print (S)
    if 'ABC' in S :
        C = S.split('ABC')
        #print (C)
        print (len(C)-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S=input()
print(S.count("ABC"))

Submission status: Wrong Answer

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

c=0

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

Submission status: Wrong Answer

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

res = 0
phase = 0
for c in s:
    if c == "A" and phase == 0:
        phase = 1
        continue
    elif c == "B" and phase == 1:
        phase = 2
        continue
    elif c == "C" and phase == 2:
        res += 1
    phase = 0

print(res)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
N = input() # Do Not use
S = input()
print(S.find("ABC"))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input()

i=0
ans=0
while(True):
  if i>N-3:
    break
  if A[i]=='A' and A[i+1]=='B' and A[i+2]=='C':
    ans+=1
    i+=3
  else:
    i+=1

Submission status: Wrong Answer

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

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

print(c)

Submission status: Wrong Answer

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

r, ans = 0, 0
for i in range(N):
    s = S[i]
    if (r == 0 and s == 'A') or (r == 1 and s == 'B'):
        r += 1
    elif r == 2 and s == 'C':
        ans += 1
        r = 0
    else:
        r = 0
print(ans)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
cnt = 0
ans = 0
for i in range(N):
    if S[i] == "A":
        if cnt == 0:
            cnt += 1
        else:
            cnt =0
    if S[i] == "B":
        if cnt == 1:
            cnt += 1
        else:
            cnt = 0
    if S[i] == "C":
        if cnt == 2:
            ans += 1
            cnt = 0
        else:
            cnt = 0

print(ans)

Submission status: Wrong Answer

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

query = 'ABC'
ans = 0
i = 0 
while i<n:
  i = s.find(query,i)
  print(i)
  if i>=0:
    ans +=1
    i+=1
  else:
    break    

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    s = input()
    ct = 0
    for i in range(n-3):
        if s[i: i+3] == 'ABC':
            ct += 1
    print(ct)


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
for n in range(len(S)-3):
    if S[n:n+3] == "ABC":
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
i=0
ans=0
while i<n-3:
    if(s[i:i+3]=="ABC"):
        ans+=1
    i+=1    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
if n==3:
    if s=="ABC":
        count=1
else:
    s=list(s)
    for i in range(n-3):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count+=1
print(count)

Submission status: Wrong Answer

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

stackString = ""
resultCount = 0
for s in S:
    if stackString == "" and s == "A":
        stackString += "a"
    elif stackString == "a" and s == "B":
        stackString += "b"
    elif stackString == "ab" and s == "C":
        stackString = ""
        resultCount += 1
    else:
        stackString = ""
print(resultCount)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
cnt = 0
for i in range(len(S)-3):
  if S[i:i+3] == "ABC":
    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

ans = 0
count = 0
for i in range(len(S)):
  if count == 0:
    if S[i] == 'A':
      count = 1
  elif count == 1:
    if S[i] == 'B':
      count = 2
    else:
      count = 0
  else:
    if S[i] == 'C':
      ans += 1
    count = 0
      
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
A=int(input())
B=input().split()
print(B.count("ABC"))

Submission status: Wrong Answer

Solution code:
#python3
n=int(input())
s=input()
match='ABC'
cnt=0
for i in range(n-3):
  b=s[i:i+3]
  if match == b:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


fetch_one_line()
line = fetch_one_line()
count = 0
for i in range(len(line) - 3):
  if line[i: i + 3] == "ABC":
    count += 1
    
print(count)

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n=int(input())
    s=list(map(str,input()))
    temp=0
    count=0
    for i in range(n):
        if s[i]=="A":
            temp+=1
        elif temp==1 and s[i]=="B":
            temp+=1
        elif temp==2 and s[i]=="C":
            temp=0
            count+=1
        else:
            temp=0
    print(count)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
cnt = 0

for i in range(0, N-3):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()

cnt = 0
flg = 0
for i in range(N):
  if flg == 0 and s[i] == "A":
    flg = 1
  elif flg == 1 and s[i] == "B":
    flg = 2
  elif flg == 2 and s[i] == "C":
    flg = 0
    cnt += 1
  else:
    flg = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
abc = 'ABC'
cnt = 0
for i in range(n-3):
    if s[i:i+3] == abc:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
cnt=0
for i in range(N-3):
  s=S[i:i+3]
  if s=="ABC":
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys; readline = sys.stdin.readline
from collections import deque

n = int(readline())
s = readline().rstrip()

count = 0

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

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
for n in range(N-3):
    s=S[n:n+3]
    if s=='ABC':
        count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
print(s.count("abc"))

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    s=input()
    print(sum(1 for i in range(max(0,n-3)) if s[i:i+3] == 'ABC'))

main()

Submission status: Wrong Answer

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

count = 0

if len(S) <= 2:
        print('0')
        exit(0)
elif len(S) == 3:
        if 'ABC' in S:
                print('1')
                exit(0)
else:
        for i in range(len(S)-3):
                if 'ABC' in S[i:i+3]:
                        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
count = 0
for i in range(len(s) - 3):
    if s[i:i + 3] == "ABC":
        count += 1
print(count)

Submission status: Wrong Answer

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

S=S.replace("ABC","")
print((N-len(S))/3)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ret = 0
cursor = 0
for s in S:
  if cursor == 0:
    if s == 'A':
      cursor = 1
  elif cursor == 1:
    if s == 'B':
      cursor = 2
    else:
      cursor = 0
  else:
    if s == 'C':
      ret += 1
      cursor = 0
    else:
      cursor = 0
      
print(ret)

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n=int(input())
    s=list(map(str,input()))
    temp=0
    count=0
    for i in range(n):
        if temp==0 and s[i]=="A":
            temp+=1
        elif temp==1 and s[i]=="B":
            temp+=1
        elif temp==2 and s[i]=="C":
            temp=0
            count+=1
        else:
            temp=0
    print(count)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

now = 0
cnt = 0
for i in range(n):
	if now == 0:
		if s[i] == 'A':
			now += 1
	elif now == 1:
		if s[i] == 'B':
			now += 1
		else:
			now = 0
	elif now == 2:
		if s[i] == 'C':
			cnt += 1
		now = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    a=input()
    flag=0
    cnt=0
    for i in range(n):
        if flag==0:
            if a[i]=="A":
                flag=1
            else:
                pass
        elif flag==1:
            if a[i]=="B":
                flag=2
            else:
                flag=0
        elif flag==2:
            if a[i]=="C":
                flag=0
                cnt+=1
            else:
                flag=0
    print(cnt)
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cnt = 0
for i in range(0, n-3):
    if s[i:i+3] == 'ABC':
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a':
        if s[i + 1] == 'b':
            if s[i + 2] == 'c':
                count += 1
print(count)

Submission status: Wrong Answer

Solution 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+=1
print(count)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
for i in range(N-3):
  if S[i:i+3]=='ABC':
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
print(sum(s[i:i+3]=="ABC" for i in range(n-3)))

Submission status: Wrong Answer

Solution code:
n = int(input())
#a,b = map(int,input().split())
#da = list(map(int,input().split()))
s = input()
ans = 0
for i in range(n-3):
    if s[i:i+3] == 'ABC':
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    s=input()
    print(sum(1 for i in range(n-3) if s[i:i+3] == 'ABC'))

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N = int(input())
    S = input()

    flag = 0
    ans = 0
    for s in S:
        if (s == "A") & (flag == 0):
            flag = 1
        elif (s == "B") & (flag == 1):
            flag = 2
        elif (s == "C") & (flag == 2):
            flag = 3
            ans += 1
        else:
            flag = 0
    print(ans)

    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)