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: Accepted

Solution code:

N = int(input())

S = input()

S += "  "
ans = 0

for i in range(N):

    if S[i] + S[i+1] + S[i+2] == "ABC":
        ans += 1

print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = list(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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(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)

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


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

print([a + b + c for a, b, c in zip(S, S[1:], S[2:])].count('ABC'))

Submission status: Accepted

Solution code:
n = int(input())
l = list(input())

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

Submission status: Accepted

Solution code:
# 2020/01/10

n=int(input())
s=input()
print(s.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

for i in range(len(s) - 2):
  if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
    cnt += 1

print(cnt)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

cnt=S.count('ABC')

print(cnt)

Submission status: Accepted

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

print(S.count("ABC"))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n = inp()
    s = input()
    cnt = 0
    for i in range(n-2):
        if s[i:i+3] == 'ABC':
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    S = input()
    
    ans = S.count('ABC')
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def main():
    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 += 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


print(s.count('ABC'))

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

print(S.count("ABC"))

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
n = int(input())
s = 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)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = input()

    ans = len(S.split('ABC')) - 1
    print(ans)


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
s = input()
print(s.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('ZABCDBABCQ'), 2)

    def test_2(self):
        self.assertEqual(think('THREEONEFOURONEFIVE'), 0)

    def test_3(self):
        self.assertEqual(think('ABCCABCBABCCABACBCBBABCBCBCBCABCB'), 5)


def solve():
    data = read()
    result = think(data)
    write(result)


def read():
    n = read_int(1)[0]
    return read_line(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    term = 'ABC'
    return data.count(term)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

r = S.count('ABC')
print(r)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input().split("ABC")
print((N - len("".join(S))) // 3)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import re

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

s = re.sub(r"ABC", "", S)
ans = (N - len(s)) // 3
print(ans)

Submission status: Accepted

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

ans = S.count('ABC')
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    s=input()
    print(s.count("ABC"))
main()

Submission status: Accepted

Solution code:
import re
n = input()
s = input()
print(len(re.findall('ABC', s)))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

str = input()

print(str.count("ABC"))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math

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

print(s.count("ABC"))

Submission status: Accepted

Solution code:
l = int(input())
s = input()
res = 0

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

print(res)

Submission status: Accepted

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

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

ans = (n - len(sr)) // 3

print(ans)

Submission status: Accepted

Solution code:


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

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

print(ans)

Submission status: Accepted

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

print(s.count('ABC'))

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip())
print(S.count("ABC"))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S = input()

print(S.count('ABC'))

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S = ST()
    print(S.count("ABC"))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
S = rs()
answer = S.count('ABC')
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


ans = 0
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: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

print(S.count('ABC'))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import re
n = int(input())
s = input()
print(len(re.findall("ABC", s)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
f = 0
for i in S:
  if i == "A":
    f = 1
  elif f == 1 and i == "B":
    f = 2
  elif f == 2 and i == "C":
    ans += 1
    f = 0
  else:
    f = 0

print(ans)

Submission status: Accepted

Solution code:
n,s=open(0);print(s.count("ABC"))

Submission status: Accepted

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

main()

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    s = input().rstrip()
    cnt = 0
    for i in range(N - 2):
        if s[i:i + 3] == "ABC":
            cnt += 1
    print(cnt)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
S=input()

print(S.count("ABC"))

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
S = input()
# H = [int(x) for x in input().split()]
#K, X = map(int, input().split())
print(S.count('ABC'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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

N = INT()
S = input()
print(S.count("ABC"))

Submission status: Accepted

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

want_string = "ABC"
print(string.count(want_string))

Submission status: Accepted

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

i = 0
res = 0
while i <= len(S)-2:
    if S[i:i+3] == 'ABC':
        res += 1
        i += 3
    else:
        i += 1

print(res)

Submission status: Accepted

Solution code:
N=int(input())
S=list(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

print(ans)

Submission status: Accepted

Solution code:
def cabc(s):
    ans = 0
    for i in range(0, len(s) - 2):
        if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C':
            ans += 1
    print(ans)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    cabc(in_str[1])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    print(S.count("ABC"))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:

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

print(S.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  s=S()

  return s.count('ABC')

# main()
print(main())

Submission status: Accepted

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

if "ABC" in S:
    ans = S.count("ABC")
else:
    ans = 0
print(ans)

Submission status: Accepted

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


def main():
    N = int(input())
    S = input().strip()
    print(S.count("ABC"))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(Ans)

Submission status: Accepted

Solution code:
import math
N =  int(input())
S = input()
print(S.count("ABC"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
S = input()

count = 0

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

Submission status: Accepted

Solution code:
import sys
import itertools

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

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

print(count)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    S = input()
    ans = 0
    for i in range(N-3+1):
        if S[i:i+3] == 'ABC':
            ans += 1
    print(ans)


main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    print(S.count('ABC'))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    return S.count('ABC')


def main():
    read_int()
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
'''input
2 2
1 2
3 4
3 4
2 1
'''
# A coding delight
from sys import stdin, stdout
import gc
from copy import deepcopy
gc.disable()
input = stdin.readline

	
# main starts
n = int(input().strip())
string = input().strip()
count = 0
for i in range(n):
	if string[i] == 'A':
		if i + 1 < n and string[i + 1] == 'B':
			if i + 2 < n and string[i + 2] == 'C':
				count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
s=s.replace("ABC","PP")
print(n-len(s))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    print(S.count('ABC'))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    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 += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for a,b,c in zip(S,S[1:],S[2:]):
    s = a+b+c
    if s == "ABC":
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    s = input()
    print(s.count("ABC"))


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


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

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,s = [int(input()) for _ in range(2))
print(s.count("ABC"))

Submission status: Runtime Error

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