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:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, S: str):
    c=0
    for i in range(N-3):
        if S[i]=='A':
            if S[i+1]=='B':
                if S[i+2]=='C':
                    c+=1
    print(c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
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):
    if i == n-3:
        break
    a_str = s[i] + s[i+1] + s[i+2]
    if a_str == 'ABC':
        cnt += 1


print(cnt)

Submission status: Wrong Answer

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

print(sum([int(bool(S[i:i+3]=='ABC')) for i in range(0,N-3)]))

Submission status: Wrong Answer

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

count = 0
flag = 0
for ch in s:
  if ch=='A':
    flag = 1 if flag==0 else 0
  if ch=='B':
    flag = 2 if flag==1 else 0
  if ch=='C':
    flag = 3 if flag==2 else 0
  if flag==3:
    count += 1
    flag = 0

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import os

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

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import os

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

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    print(sum(S[n:n+3] == 'ABC' for n in range(N-3)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
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()

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

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:
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    sum = 0
    for i in range(0, len(S)-3):
        if S[i:i+3] == "ABC":
            sum += 1
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()      
pattern = list('ABC')          
cnt = 0
match = False

for i in range(n-len(pattern)):
    if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]):
        cnt += 1
        match = True
if n % 3 == 0 and match:
    print(cnt + 1)
else:
    print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()      
pattern = list('ABC')          
cnt = 0
match = True

for i in range(n-len(pattern)):
    if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]):
        cnt += 1
if n % 3 == 0:
    print(cnt + 1)
else:
    print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()      
pattern = list('ABC')          
cnt = 0
match = True

for i in range(n-len(pattern)):
    if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]):
        cnt += 1
if n == 3 and s == "ABC":
    print(1)
else:
    print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()      
pattern = list('ABC')          
cnt = 0
match = True

for i in range(n-len(pattern)):
    if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
j=0
count=0
for i in range(n):
    u=s[i:i+1]
    #print(u)
    if j==0 and u=="A":
        j=1
    elif j==0 and u!="A":
        j=0
    elif j==1 and u=="B":
        j=2
    elif j==1 and u!="B":
        j=0
    elif j==2 and u=="C":
        j=0
        count+=1
    elif j==2 and u!="C":
        j=0
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
j=0
count=0
for i in range(n):
    u=s[i:i+1]
    #print(u)
    if j==0 and u=="A":
        j=1
    elif j==0 and u!="A":
        j=0
    elif j==1 and u=="B":
        j=2
    elif j==1 and u!="B":
        j=0
    elif j==2 and u=="C":
        j=0
        count+=1
    elif j==2 and u!="C":
        j=0
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


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

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()
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()
count = 0
for i in range(n-2):
  print(s[i:i+3])
  if s[i:i+3] == "ABC":
    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:i+3] == "ABC":
    count += 1
print(count)

Submission status: Wrong Answer

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

S.count('ABC')

Submission status: Wrong Answer

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

count = 0
i = 0
while i < n-3:
    if s[i:i+3] == "ABC":
        count += 1
        i += 3
    else:
        i += 1
print(count)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)
ans = 0
for i in range(N-2):
  if s[i:i+3] == 'ABC':ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)
ans = 0
if N < 3:print(0);exit()
for i in range(N-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2] == 'C':ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)
ans = 0
if N < 3:print(0);exit()
i = 0
while i < N-3:
  if s[i:i+3] == 'ABC':ans += 1;i += 3
  else:i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)
ans = 0
if N < 3:print(0);exit()
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()
ss = "ABC"
cnt = 0
for i in range(n-2):
  if s[i:i+3] == ss:
    print(s[i:i+3],i)
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution 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):
    print(i)
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

def main():
    string_num = int(input())
    strings = input()
    answear = 0
    for number,string in enumerate(strings):
        if number < len(strings) - 2:
            sub_result = string
            for add in range(number+1,number+3):
                sub_result = sub_result + strings[add]
        if sub_result == "ABC":
            answear = answear + 1
    print(answear)

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
s = STR()
i = 0
ans = 0
while i < n - 3:
    if s[i:i + 3] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Submission status: Wrong Answer

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

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

print(t)

Submission status: Wrong Answer

Solution code:
input()
s = input()
abc = 'ABC'
count = 0
while True:
  if abc*count in s:
    count += 1
  else:
    break
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip('\r\n')
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:
n=int(input())
s=input()
ans=0
if n==3:
    if s[0:3]=="ABC":
        print(1)
    else:
        print(0)
else:
    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()
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(n-3):
  if "ABC" == S[i:i+3]:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
a=0
b=0
c=0
for i in S:
	if i=='A':
		if a==0:
			a=1
		else:
			a=0
	elif i=='B' and a==1:
		if b==0:
			b=1
		else:
			b=0
	elif i=='C' and a==1 and b==1:
		c=1
		ans+=c
		a=b=c=0
	else:
		a=b=c=0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input()); s = input() ; c = 0

for i in range(n):
    a = s[i-3:i]

    if a == 'ABC':
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input()); s = input() ; c = 0

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
S = [i for i in S]
cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [i for i in range(N)]
cnt = 0

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
def main():
    S = input()    
    ans = 0
    for i in range(len(S) - 2):
        if S[i: i+3] == "ABC":
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

s = input()
print(s.count("abc"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if int(n) > 3 and int(n) < 50:
    abc = s.split('ABC')
    print(len(abc)-1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = input().strip()

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
pat = "ABC"

ans =0
i=0
j=0

for start in range(n):
  if s[start] == pat[0]:
    i = start
    flag = True
    for j in range(len(pat)):
      if i>=n or s[i]!=pat[j]:
        flag = False
        break
      if flag:
        ans+=1

print(ans)

Submission status: Wrong Answer

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

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(N-3):
  if S[i:i + 3] == 'ABC':
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input()
v = 0
for x in range(N-2):
  if a[x-1]=='A' and a[x] == 'B' and a[x+1] == 'C':
    v = v +1
print(v)

Submission status: Wrong Answer

Solution code:
N = int(input())
words = input()
ans = 0
for i in range(N-4):
    if words[i] == "A":
        if words[i+1] == "B":
            if words[i+2] == "C":
                ans += 1
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 = 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 = str(input())
c = 0
for i in range(n-2):
  if s[i] == "A":
    if s[1+1] == "B" and s[i+2] == "C":
      c += 1
print(c)

Submission status: Wrong Answer

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


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

print(ans)

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] and s[i+2] == 'C':
        ans += 1

print(ans)

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] and s[i+2] == 'C':
        ans += 1

print(ans)

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()
count = 0
hit = 0
for s in S:
    if s == 'A' and hit == 0:
        hit += 1
    elif s == 'B' and hit == 1:
        hit += 1
    elif s == 'C' and hit == 2:
        count += 1
        hit = 0
    else:
        hit = 0
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
hit = 0
for s in S:
    if s == 'A' and hit == 0:
        hit += 1
    elif s == 'B' and hit == 1:
        hit += 1
    elif s == 'C' and hit == 2:
        count += 1
        hit = 0
print(count)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


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

    count = 0
    state = 0

    for c in S:
        if c == 'A':
            state = 1
        elif state == 1:
            if c == 'B':
                state = 2
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count = 2
                state = 0
            else:
                state = 0

    print(count)


main()

Submission status: Wrong Answer

Solution code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


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

    count = 0
    state = 0

    for c in S:
        if state == 0:
            if c == 'A':
                state += 1
            else:
                state = 0
        elif state == 1:
            if c == 'B':
                state += 1
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count += 1
            state = 0

    print(count)


main()

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())
s = input()
c = 0
i = 0
while i + 2 <= n - 1:
    if s[i:i + 3] == "ABC":
        c += 1
        i += 3
    i += 1
print(c)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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()
ls = s.replace("ABC","")
print(ls)
print((n-len(ls))//3)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


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())
S = input()

i = 0
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:
N=int(input())
S = input()
s = 0
for i in range(0,N-3):
    if S[i:i+3] == "ABC":
        s += 1
print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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()
 
ans = 0
for i in range(n-2):
    if s[i:i+2] == 'ABC':
        ans += 1
 
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(input().count('ABC'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input()
K = 0
for i in range(N-3):
  if L[i] == "A" and L[i+1] =="B" and L[i+2] == "C":
    K = K+1
print(K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    print(main(N,S))

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    main(N,S)

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    main(N,S)

Submission status: Wrong Answer

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

def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    main(N,S)

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    main(N,S)

Submission status: Wrong Answer

Solution code:
def main(N,S):
    N = int(N)
    S = str(S)

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

    return c

if __name__ == '__main__':
    N = input()
    S = input()
    main(N,S)

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

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

print(cnt)

Submission status: Wrong Answer

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

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:
S = input()

print(S.count("ABC"))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

count = 0
reach = 0

for i in S:
    if reach == 0:
        if i == 'A':
            reach += 1
            continue
        else:
            reach = 0
            continue
        
    if reach == 1:
        if i == 'B':
            reach += 1
            continue
        else:
            reach = 0
            continue
        
    if reach == 2:
        if i == 'C':
            count += 1
            reach = 0
        else:
            reach = 0
    
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)