Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline

input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    V1 = {}
    V2 = {}
    V = list(map(int, input().split()))
    for i,v in enumerate(V):
        if i%2 == 0:
            V1[v] = V1[v] + 1 if v in V1 else 1
        else:
            V2[v] = V2[v] + 1 if v in V2 else 1

    V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)
    V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)

    if V1[0] != V2[0]:
        ans = 0
        for v in V1[1:]:
            ans += v[1]
        for v in V2[1:]:
            ans += v[1]
        print(ans)
    else:
        a1 = 0
        for v in V1[1:]:
            a1 += v[1]
        a1 += V2[0][1]
        for v in V2[2:]:
            a1 += v[1]
        a2 = 0
        a2 += V1[0][1]
        for v in V1[2:]:
            a2 += v[1]
        for v in V2[1:]:
            a1 += v[1]
        print(min(a1,a2))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline

def main():
    N = int(input())
    V1 = {}
    V2 = {}
    V = list(map(int, input().split()))
    for i,v in enumerate(V):
        if i%2 == 0:
            V1[v] = V1[v] + 1 if v in V1 else 1
        else:
            V2[v] = V2[v] + 1 if v in V2 else 1

    V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)
    V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)

    if V1[0] != V2[0]:
        ans = 0
        for v in V1[1:]:
            ans += v[1]
        for v in V2[1:]:
            ans += v[1]
        print(ans)
    else:
        a1 = 0
        for v in V1[1:]:
            a1 += v[1]
        a1 += V2[0][1]
        for v in V2[2:]:
            a1 += v[1]
        a2 = 0
        a2 += V1[0][1]
        for v in V1[2:]:
            a2 += v[1]
        for v in V2[1:]:
            a2 += v[1]
        print(min(a1,a2))

if __name__ == '__main__':
    main()
X,Y=map(str,input().split())


"A"=10
"B"=11
"C"=12
"D"=13
"E"=14
"F"=15

if X>Y:
  print(">")
elif X=Y:
  print("=")
else:
  print("<")



### FIXED CODE ###

x,y=input().split()

if x>y:
  print(">")
elif y>x:
  print("<")
else:
  print("=")
from math import *
 
n=int(input())
arr=list(map(int,input().split()))
dict1={}
for i in range(n):
    val=arr[i]
    try:
        dict1[val]+=1
    except:
        KeyError
        dict1[val]=1
#print(dict1)
ans=0
arr.sort(reverse=True)
for i in range(n):
    val2=ceil(log2(arr[i]))
    for j in range(33,val2-1,-1):
        xd=2**j
        if(xd!=2*arr[i]):
            try:
                if(dict1[xd-arr[i]]>0):
                    ans+=1
                    dict1[xd-arr[i]]-=1
                    dict1[arr[i]]-=1
                    break
        
            except:
                KeyError
        else:
            if(dict1[arr[i]]>1):
                ans+=1
                dict1[arr[i]]-=2
                break
print(ans)

### FIXED CODE ###

from math import *
 
n=int(raw_input())
arr=list(map(int,raw_input().split()))
dict1={}
for i in range(n):
    val=arr[i]
    try:
        dict1[val]+=1
    except:
        KeyError
        dict1[val]=1
#print(dict1)
ans=0
arr.sort(reverse=True)
for i in range(n):
    if(dict1[arr[i]]>0):
        xd=2**(len(bin(arr[i]))-2)
        if(xd-arr[i]!=arr[i]):
            try:
                if(dict1[xd-arr[i]]>0):
                    ans+=1
                    dict1[xd-arr[i]]-=1
                    dict1[arr[i]]-=1
            except:
                KeyError
        else:
            if(dict1[arr[i]]>1):
                ans+=1
                dict1[arr[i]]-=2
print(ans)
N = int(input())

Ans = 0
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

print(Ans)

### FIXED CODE ###

N = int(input())

A,S = [0]*32,[0]*32
A[0],A[1],S[0],S[1] = 1,-2,1,-2
for i in range(2,32):
    A[i] = A[i-1]*(-2)
    S[i] = S[i-2] + A[i]

X = ["0"]*32
t = 0
flg = True
while N != 0:
    if N > 0:
        for i in range(32):
            if S[i] >= N:
                break
    else:
        for i in range(32):
            if S[i] <= N:
                break
    X[i] = "1"
    N -= A[i]

print(int("".join(X)[::-1]))
bilding = [[[0 for i in range(10)] for j in range(3)]for k in range(4)]

n = int(input())
for i in range(n)
    b, f, r, v = map(int, raw_input().split())
    bilding[b-1][f-1][r-1] += v
    i += 1

i = 0
j = 0
k = 0
while i < 4:
    while j < 3:
        floar = ""
        while k < 10:
            floar += str(bilding[i][j][k])
            k += 1
        print floar
        j += 1
    if i < 3:
        print "####################"
    i += 1

### FIXED CODE ###

bilding = [[[0 for x in range(10)] for x in range(3)]for x in range(4)] 
n = int(input())
for k in range(n):
    b, f, r, v = map(int, raw_input().split())
    bilding[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" "+" ".join(map(str, bilding[b][f])))
    if b != 3:
        print("#"*20)
N=int(input())
p=list(map(int,input().split()))

P=sorted(p)

flag=0

for i in range(0,5):
    if p[i]!=P[i]:
        flag+=1

if flag==2:
    print('YES')
else :
    print('NO')

### FIXED CODE ###

N=int(input())
p=list(map(int,input().split()))

P=sorted(p)
flag=0

for i in range(0,N):
    if p[i]!=P[i]:
        flag+=1

if flag==2:
    print('YES')
elif flag==0:
    print('YES')
else :
    print('NO')
N, K, S = map(int, input().split())

M = 10 ** 9

res = [S for _ in range(K)]

res += [("1" if S == M else str(S+1)) for _ in range(N-K)]

print(" ".join(res))

### FIXED CODE ###

N, K, S = map(int, input().split())

M = 10 ** 9

res = [str(S) for _ in range(K)]

res += [("1" if S == M else str(S+1)) for _ in range(N-K)]

print(" ".join(res))
N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-1])


### FIXED CODE ###

N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])
1 N = int(input())
2
3 def dfs(s): # 文字列 s で始まる七五三数の個数
4 if int(s) > N:
5 return 0
6 ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
7 for c in '753':
8 ret += dfs(s + c)
9 return ret
10
11 print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく


### FIXED CODE ###

N = int(input())
 
def abc114_c(s):
  if(int(s) > N):
    return 0
  if(all(s.count(c) > 0 for c in "753")):
    ans = 1
  else:
    ans = 0
  for c in "753":
    ans += abc114_c(s+c)
  return ans
print(abc114_c("0"))
X,Y = map(int, input().split())
l = ['A','B','C','D','E','F']
if l.index(X)>l.index(Y):
  print('>')
elif l.index(X)<l.index(Y):
  print('<')
else:
  print('=')

### FIXED CODE ###

X,Y = map(str, input().split())
l = ['A','B','C','D','E','F']
if l.index(X)>l.index(Y):
  print('>')
elif l.index(X)<l.index(Y):
  print('<')
else:
  print('=')
N,M=map(int,input().split())

from collections import Counter
 
def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)
 
def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro
 
#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
def nCr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)*n_func(r,mod)%mod
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
    
p=list(Counter(soinsuu(M)).values())
print(product([nCr(N+p[i]-1,p[i]) for i in range(len(p))]))

### FIXED CODE ###

N,M=map(int,input().split())
mod=10**9+7
 
from math import factorial
from collections import Counter
 
def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)
 
def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro
 
#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
    
nPr_list=[nPr(N,i) for i in range(30)]
bunbo_list=dict()

def dp(cur,init,seq,lest,num):
    #print(cur,init,seq,lest,num)
    if cur==N:
        if lest==0:
            cnt=sorted(list(Counter(seq).values())+[N-len(seq)],reverse=True)
            bunbo=product(map(factorial,cnt[1:]))
            if bunbo not in bunbo_list.keys():
                bunbo_list[bunbo]=inv_n(bunbo)
            memo[num]=(memo[num]+nPr_list[N-cnt[0]]*bunbo_list[bunbo])%mod
    elif lest==0:
        dp(N,init,seq,0,num)
    else:
        if cur==0:
            for i in range(1,lest+1):
                dp(cur+1,init,seq+[i],lest-i,num)
        else:
            for i in range(1,min(lest,seq[-1])+1):
                dp(cur+1,init,seq+[i],lest-i,num)
 
p=list(Counter(soinsuu(M)).values())
memo=[0]*len(p)


for i in range(len(p)):
    dp(0,p[i],[],p[i],i)
print(product(memo))
import math

N,K=map(int,input().split())
A=[*map(int,input().split())]

ans=math.ceil((N-1)/(K-1))
print(ans)


### FIXED CODE ###

import math

N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=math.ceil((N-1)/(K-1))
print(ans)
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h:)
  s = 1
else:
  s = 0
  

print("{:.10}".format(m),end='');print(s)

### FIXED CODE ###

i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h):
  s = 1
else:
  s = 0
  

print("{:.9}".format(m));print(s)
rom collections import Counter
N = int(input())
s= input()

D = N
for i in range(N):
    L,R = s[:i],s[i+1:]
    n1,n2 = Counter(L),Counter(R)
    num = n1["W"] + n2["E"]
    if num < D:
        D = num
print(D)

### FIXED CODE ###

from collections import Counter
N = int(input())
s= input()

D = Counter(s[1:])["E"]
nums = [D]
for i in range (1,N):
    temp = nums[-1]
    if s[i-1] == "W":
        temp += 1
    if s[i] == "E":
        temp -= 1
    nums.append(temp)

print(min(nums))
print((input() + 1) // 2)


### FIXED CODE ###

N = int(input())
print((N + 1) // 2)
a = map(int, input().split())
print(max(a) - min(a))

### FIXED CODE ###

a = list(map(int, input().split()))
print(max(a) - min(a))
N = int(input())
S = input()

a = 0
for i in range(N):
  if S[i] == '.':
    a += 1

print(min(a, N-a))

### FIXED CODE ###

A, B, C = ( int(i) for i in input().split() )

if A <= C <= B:
  print('Yes')
elif B <= C <= A:
  print('Yes')
else:
  print('No')
contests = [i for i in range(100,1000) if i % 111 == 0]
N = int(input())
for contest in contests:
  if contests >= N:
    print(contest)
    break
  else:
    continue

### FIXED CODE ###

contests = [i for i in range(100,1000) if i % 111 == 0]
N = int(input())
for contest in contests:
  if contest >= N:
    print(contest)
    break
  else:
    continue
import sys
S=""
S=sys.argv[1]
len(S)<=1000
if S[-1] == 's':
   S=S+'es'
else:
	S=S+'s'
print(S)

### FIXED CODE ###

S=input()
if S[-1] == 's':
	S=S+'es'
else:
	S=S+'s'
print(S)
N=int(input())
L=map(int,input().split())
ans=1
M=L[0]
for i in range(1,N):
  if M>=L[1]:
    M=L[1]
    ans+=1
  else:
    continue
print(ans)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
ans=1
M=L[0]
for i in range(1,N):
  if M>=L[i]:
    M=L[i]
    ans+=1
  else:
    continue
print(ans)
def main():
  N = int(input())

  max_left = [0] * N
  max_right = [0] * N

  ary = []

  for i in range(N):
    v = int(input())
    ary.append(v)

  for i in range(N - 1):
    max_left[i+1] = max(max_left[i], ary[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i])

  for i in range(N):
	v = max(max_left[i], max_right[i])
	print(v)

main()


### FIXED CODE ###

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

    max_left = [0] * N
    max_right = [0] * N

    ary = []

    for i in range(N):
        v = int(input())
        ary.append(v)

    for i in range(N - 1):
        max_left[i+1] = max(max_left[i], ary[i])

    for i in range(N - 1, 0, -1):
        max_right[i-1] = max(max_right[i], ary[i])

    for i in range(N):
        v = max(max_left[i], max_right[i])
        print(v)


main()
S = input()
if S[1] == S[2] == S[3]:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S = input()
if S[1] == S[2] == S[0]:
  print("No")
else:
  print("Yes")
# coding:utf-8
import math

N,K=map(int, input().split())

if N==0 or N%K==0:
    print("0")
else:
    print(math.gcd(N,K))

### FIXED CODE ###

# coding:utf-8
import math
import fractions

N,K=map(int, input().split())

if K==0:
    print("N")
elif N==0 or N%K==0:
    print("0")
else:
    N=N%K
    print(min(N, K-N))
s=input()
a="AKIHABARA"
j=0
for i in s:
    if i==a[j]:
        j+=1
    elif i==a[j+1] and a[j]=="A" and j<8:
        j+=2
    else:
        print("NO")
        exit()
print("YES")  

### FIXED CODE ###

a=["KIH","B","R",""]
ans=[]
aaa=[]
for i in range(16):
    b=""
    for j,k in enumerate(a):
        if ((i >> j) & 1):
            b+="A"
        b+=k
    ans.append(b)
print("YES" if input() in ans else "NO")
x = int(input())
def ans(x):
    for a in range(0, 1000)[::-1]:
        for b in range(-1000, 1000)[::-1]:
            if a**5 - b**5 == x:
                return a, b
a,b = ans(x)
print(a,b)

### FIXED CODE ###

import bisect
N = int(input())
alist = list(map(int, input().split()))
alist = [0] + alist
sumlist = []
# (j, wj)のリストを作る
for i in range(1,N+1):
    sumlist.append(i+alist[i])
sumlist.sort()
ans = 0
# 差と一致するものを探す
for i in range(1, N+1):
    diff = i - alist[i]
    if diff <= 0:
        continue
    i = bisect.bisect_left(sumlist, diff)
    j = bisect.bisect_right(sumlist, diff)
    ans += j - i
print(ans)
N, K, L = [int(_) for _ in input().split()]


def find(a, x):
    stack = []
    while a[x] != x:
        x = a[x]
        stack += [x]
    while stack:
        a[stack.pop()] = x
    return x


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    a[x] = a[y] = min(x, y)


a_road = [i for i in range(N)]
for _ in range(K):
    p, q = [int(_) - 1 for _ in input().split()]
    unite(a_road, p, q)
a_railway = [i for i in range(N)]
for _ in range(L):
    r, s = [int(_) - 1 for _ in input().split()]
    unite(a_railway, r, s)
memo = {}
for i in range(N):
    memo[a_road[i], a_railway[i]] = memo.get(
        (find(a_road, i), find(a_railway, i)), 0) + 1

print(' '.join(str(memo[a_road[i], a_railway[i]]) for i in range(N)))


### FIXED CODE ###

class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, K, L = [int(_) for _ in input().split()]

Road = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    Road.unite(p, q)
Railway = UFT()
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    Railway.unite(r, s)
memo = {}
for i in range(1, N + 1):
    memo[Road.find(i), Railway.find(i)] = memo.get((Road.find(i), Railway.find(i)), 0) + 1
print(' '.join(str(memo[Road.find(i), Railway.find(i)]) for i in range(1, N + 1)))
import numpy as np
import math
import collections
import bisect
import sympy


def divisor(n):
    i = 1
    lower_divisors, upper_divisors = [], []
    while(i * i <= n):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


N = int(input())

A = list(map(int, input().split()))

A.sort()

ans = 0
ans = N
for i in range(N):
    divs = sympy.divisors(A[i])
    # print(divs)
    Set = set(A[:i])
    if i < N - 1:
        if A[i] == A[i + 1]:
            ans -= 1
            continue

    for d in divs:
        if i != 0:
            if d in Set:
                ans -= 1
                break
print(ans)


### FIXED CODE ###

import numpy as np
import math
import collections
import bisect
from collections import Counter


N = int(input())

A = list(map(int, input().split()))

A.sort()
Set = set()

Amax = A[len(A) - 1]

counter = Counter(A)
ans = 0
for a in A:
    if a in Set:
        continue
    x = a
    while(x <= Amax):
        Set.add(x)
        x += a

    if counter[a] == 1:
        ans += 1

print(ans)
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
  for j in range(1<<w):
    count = 0
    for x in range(h):
      if 1 << i & m:
        continue
      for y in range(w):
        if 1 << j & n:
          continue
        if grid[x][y] == '#':
          count += 1 
    if count == k:
      ans += 1
print(ans)

### FIXED CODE ###

def main():
  h, w, k = map(int, input().split())
  C = [list(input()) for _ in range(h)]

  result = 0
  for i in range(1 << h):
    for j in range(1 << w):
      cnt = 0
      for n in range(h):
        if i >> n & 1:
          continue

        for m in range(w):
          if j >> m & 1:
            continue

          if C[n][m] == '#':
            cnt += 1

      if cnt == k:
        result += 1

  print(result)


if __name__ == "__main__":
  main()
# https://atcoder.jp/contests/abc088/tasks/abc088_d

H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[-1] * W for _ in range(W)]

# 0,0 to h-1, w-1
d[0][0] = 0

queue = []
queue.append([0, 0])

while len(queue) > 0:
    p = queue.pop(0)
    y, x = p[0], p[1]

    dx4 = [0, 0, 1, -1]
    dy4 = [1, -1, 0, 0]

    for dx, dy in zip(dx4, dy4):
        next_y = y + dy
        next_x = x + dx
        if 0 <= next_y < H and 0 <= next_x < W and s[next_y][next_x] != "#" and d[next_y][next_x] == -1:
            d[next_y][next_x] = d[y][x] + 1
            queue.append([next_y, next_x])

count = 0
for l in s:
    for c in l:
        if c == ".":
            count += 1

if d[H-1][W-1] == -1:
    print(-1)
else:
    print(-1)
    # print(count - d[H-1][W-1] - 1)

# [print(l) for l in s]
# [print(l) for l in d]


### FIXED CODE ###

from queue import Queue

inf = 10 ** 20

def bfs(H, W, s):
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == inf):
    print("-1")
else:
    print(wnum - d)
S = input()
K = int(input())
key = []
for i in range(len(S)):
  if S[i] != "1":
    key.append([i,S[i]])
    break
if K < key[0][0]:
  print(1)
else:
  print(key[0][1])



### FIXED CODE ###

S = input()
K = int(input())
key = []
if S.count("1") == len(S):
  print(1)
else:
  for i in range(len(S)):
    if S[i] != "1":
      key.append([i,S[i]])
      break
  if K - 1 < key[0][0]:
    print(1)
  else:
    print(key[0][1])
s = list(input())
l = [-1]
i = 0
large = False
small = False

while i < len(s):
    if s[i] == "<":
        l.append(l[i] + 1)
    if s[i] == ">":
        cnt = 1
        while s[i + cnt] == ">":
            if i + cnt == len(s) -1:
                cnt += 1
                break
            cnt += 1
        if l[i] < cnt:
            l.append(cnt)
        else:
            l.append(l[i] + 1)
        i += cnt
        cnt -= 1
        while cnt != -1:
            l.append(cnt)
            cnt -= 1
    i += 1
if s[len(s) -1] == "<":
    l.append(l[i] + 1)
del l[0]
ans = sum(l)
print(ans)

### FIXED CODE ###

s = list(input())
l = [-1]
i = 0

while i < len(s):
    if s[i] == "<":
        l.append(l[i] + 1)
    if s[i] == ">":
        cnt = 0
        while s[i + cnt] == ">":
            if i + cnt == len(s) -1:
                cnt += 1
                break
            cnt += 1
        if l[i] < cnt:
            l.append(cnt)
        else:
            l.append(l[i] + 1)
        i += cnt
        cnt -= 1
        while cnt != -1:
            l.append(cnt)
            cnt -= 1
    i += 1
if s[len(s) -1] == "<":
    l.append(l[i] + 1)
del l[0]
ans = sum(l)
print(ans)
N = map(int(input().split()))
if N < 1000:
    print("ABC")
else:
    print("ABD")



### FIXED CODE ###

N = int(input())
if N < 1000:
    print("ABC")
else:
    print("ABD")
a,b=list(map(int,input().split()))
if a==1 or b==1:
    print(1)
else:
    print((a*w+1)//2)

### FIXED CODE ###

k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
words = ''
w = []
flag = []
S = list(input())
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
    flag.append('True')
  else:
    flag.append('False')
print(S)
print(flag)

for j in range(len(S)):
  if flag[j] == 'True':
  	words += S[j]
  elif flag[j] == 'False':
    w.append(words)
    words = ''

print(len(max(w)))

### FIXED CODE ###

count = 0
MAX = 0
S = list(input())
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
    count += 1
    if MAX < count:
        MAX = count
  else:
    count = 0

print(MAX)
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

for i in range(2):
    s = A
    op1 = '+' if i == 0 else '-'
    s += B if op1 == '+' else -1 * B
    for j in range(2):
        op2 = '+' if j == 0 else '-'
        s += C if op2 == '+' else -1 * C
        for k in range(2):
            op3 = '+' if k == 0 else '-'
            s += D if op3 == '+' else -1 * D
            if s == 7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)


### FIXED CODE ###

S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')
print(int(input()) + int(input() / 2))

### FIXED CODE ###

X, Y = map(int, input().split())

print(X + Y // 2)
あ」

### FIXED CODE ###

h,w = map(int,input().split())
s = [input().split() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == 'snuke':
            print(chr(ord('A') + j) + str(1 + i))
n = int(input())
s = input()
count = 0

for i in range(len(s-2)):
    if s[i,i+2] == abc:
        count += 1

print(count)

### FIXED CODE ###

n = int(input())
s = input()
count = 0

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

print(count)