Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

S = input()
S_length = len(S)
k = 1
s_l=[]
while S!='':
  s_x=S[0]
  if len(S)>=2:
    if S[1]==s_x:
      k+=1
      S=S[1:]
    else:
      s_l.append(s_x*k)
      k=1
      S=S[1:]
  else:
    s_l.append(s_x*k)
    S=S[1:]



  
        
        
def n_sum(n):
  return n*(n+1)//2
        

s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)

### FIXED CODE ###

S = input()
from itertools import groupby
S_length = len(S)
k = 1
s_l=[k*len(list(g)) for k, g in groupby(S)]
  
        
        
def n_sum(n):
  return n*(n+1)//2
        

s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

def input_converter(key_string):
    key_string = key_string.replace('A', '1')
    key_string = key_string.replace('T', '2')
    key_string = key_string.replace('C', '3')
    key_string = key_string.replace('G', '4')
    return int(key_string)


class HashTable(object):
    def __init__(self, hash_size = 2 ** 26):
        self.hash_size = hash_size
        self.hash_array = [None] * self.hash_size

    def insert_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        while self.hash_array[next_index] is not None:
            collision_number += 1
            next_index = self.hash_function(key, collision_number)
        if collision_number != 0:
            print collision_number
        self.hash_array[next_index] = data

    def search_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        next_data = self.hash_array[next_index]
        while True:
            if (next_data is None) or (collision_number > self.hash_size):
                return False
            elif next_data == data:
                return True
            else:            
                collision_number +=1

    def hash_function(self, key, collision_number):
        def h1(key):
            return key % self.hash_size
    
        def h2(key):
            return key % (self.hash_size - 1)

        return (h1(key) + collision_number * h2(key)) % self.hash_size


def main():
    input_size = int(raw_input())
    hash_table = HashTable()
    counter = 0
    while counter < input_size:
        command, key = raw_input().split(' ')
        if command == 'insert':
            hash_table.insert_value(key, input_converter(key))
        else:
            if hash_table.search_value(key, input_converter(key)):
                print 'yes'
            else:
              print 'no'
        counter += 1


if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

dictionary = {}
input_num = int(raw_input())
counter = 0
while counter < input_num:
    command, key = raw_input().split(' ')
    if command == 'insert':
        dictionary[key] = None
    else:
        if key in dictionary:
            print 'yes'
        else:
            print 'no'

    counter += 1
### BUGGY CODE ###

r1,c1,r2,c2=map(int,input().split())

mod=10**9+7
f=[1]
for i in range(2*10**6+7):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

def F(r,c):
  ans=0
  for i in range(r+c+1):
    ans+=2**i
    ans%=mod
  d=0
  s=0
  for i in range(r-1,-1,-1):
    s+=comb((r-i-1)+c,c)
    d+=2**i*s
    s%=mod
    d%=mod
  ans=(ans+(mod-d))%mod
  d=0
  s=0
  for i in range(c-1,-1,-1):
    s+=comb((c-i-1)+r,r)
    d+=2**i*s
    s%=mod
    d%=mod
  ans=(ans+(mod-d))%mod
  return ans

ans=F(r2,c2)+(mod-F(r2,c1-1))+(mod-F(r1-1,c2))+F(r1-1,c1-1)
print(ans%mod)

### FIXED CODE ###

r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
f=[1]
for i in range(2*10**6+7):f+=[f[-1]*(i+1)%mod]
ans=0
for i in range(c1,c2+1):
  d=((r2+1)*f[i+r2+1]%mod)*f[r1]
  d%=mod
  d=(d+(mod-((r1*f[r2+1]%mod)*f[i+r1])%mod))%mod
  d*=pow((((i+1)*f[i]%mod)*f[r1]%mod)*f[r2+1]%mod,mod-2,mod)
  d%=mod
  ans+=d
  ans%=mod
print(ans)
### BUGGY CODE ###

# 111
list = [int(item) for item in input().split()]

res_list = []
c=0

if list[0] >= list[1]:
    a = list[0]
    b = list[1]
else:
    a = list[1]
    b = list[0]
    
    
res_list.append(b)

if int(b/2) > 1:
    
    if b % 2 == 0:
        res_list.append(int(b/2))
    
    for i in range(1,int(b/2)):
        if b % i ==0:
            res_list.append(i)

res = []
for k in res_list:
    if a % k == 0:
        res.append(k)

new_res = []

for l in reversed(res):
    flag = 0
    cnt = 0
    for m in res:
        if l % m == 0:
            cnt += 1
    if cnt <=2:
        new_res.append(l)
            
print(len(new_res))

### FIXED CODE ###

# start 21:14
a, b = [int(item) for item in input().split()]

# 素因数リスト
import math
def factor(num):
    divisor_list = [1]
    divisor = 2
    max_prime = int(math.sqrt(num))
    while max_prime >= divisor:
        if num % divisor == 0:
            divisor_list.append(divisor)
            num //= divisor

        else:
            divisor += 1
    divisor_list.append(num)
    return divisor_list

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

cd_list = set(factor(gcd(a, b)))

print(len(cd_list))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
MOD = 10**9+7
INF = 10 ** 10
from functools  import lru_cache

MAXN = 405
a = [0] * MAXN
@lru_cache(maxsize = None)
def dfs(l,r):
    if r - l == 1:
        return 0
    else:
        ans = INF
        for i in range(l + 1,r):
            ans = min(ans,dfs(l,i) + dfs(i,r)) 
        if l == 0:
            ans += a[r - 1]
        else:
            ans += a[r - 1] - a[l - 1]
        return ans

def main():
    n = int(input())
    b = list(map(int,input().split()))
    a[:n] = b

    for i in range(1,n):
        a[i] += a[i - 1]
    
    ans = dfs(0,n)
    print(ans)
if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
MOD = 10**9+7
INF = 10 ** 20
from functools  import lru_cache

MAXN = 405
a = [0] * MAXN
dp = [[-1] * MAXN for _ in range(MAXN)]
def dfs(l,r):
    if dp[l][r] != -1:
        return dp[l][r]
    if r - l == 1:
        dp[l][r] = 0
        return 0
    ans = INF
    for i in range(l + 1,r):
        ans = min(ans,dfs(l,i) + dfs(i,r)) 
    if l == 0:
        ans += a[r - 1]
    else:
        ans += a[r - 1] - a[l - 1]
    dp[l][r] = ans
    return ans

def main():
    n = int(input())
    b = list(map(int,input().split()))
    a[:n] = b

    for i in range(1,n):
        a[i] += a[i - 1]
    
    ans = dfs(0,n)
    print(ans)
if __name__=='__main__':
    main()
### BUGGY CODE ###

from itertools import product

def sol():
    N = int(input())
    XYP = [tuple(map(int, input().split())) for _ in range(N)]
    X = [x for x, _, _ in XYP]
    Y = [y for _, y, _ in XYP]
    P = [p for _, _, p in XYP]
    INF = 10**18

    def calcCost(AP, A):
        ret = [[INF] * N for _ in range(1 << N)]
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i, (a, p) in enumerate(AP):
                cost = abs(a)
                for z in useA:
                    cost = min(cost, abs(a - z))
                ret[state][i] = cost * p
        return ret

    costX = calcCost([(x, p) for x, _, p in XYP], X)
    costY = calcCost([(y, p) for _, y, p in XYP], Y)

    ans = [INF] * (N + 1)
    for state in product((0, 1, 2), repeat=N):
        stateX = 0
        stateY = 0
        M = N
        for s in state:
            stateX <<= 1
            stateY <<= 1
            if s == 0: M -= 1
            if s == 1: stateX |= 1
            if s == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
            if cost >= ans[M]:
                break
        else:
            ans[M] = cost

    print(*ans, sep='\n')

sol()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 
for  i in range(0,a,1):
    if b[i]==m:
        c=b.copy()
        c[i]=0
        print(max(c))
    else:
        print (m)


### FIXED CODE ###

a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 

if b.count(m)>=2:
    for i in range(a):
        print (m)
else:
    c=b.copy()
    c.sort(reverse=True)
    m2=c[1]
    for i in range(a):
        if b[i]==m:
            print(m2)
        else:
            print (m)
### BUGGY CODE ###

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

for i in range(1, N+1):
    print(a_list.count(i))

### FIXED CODE ###

import collections

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

count_a = collections.Counter(a_list)

for i in range(1, N+1):
    print(count_a[i])
### BUGGY CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n):
    cands = [dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)]
    dp[i] = min(cands)

print(dp[n-1])

### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)])

print(dp[n-1])
### BUGGY CODE ###

n=int(input())
m=1
inf=10**18
lol=0
l=list(map(int,input().split()))
if 0 in l:
    print(0)
else:

    for i in l:
      m=m*i
      if(m>inf):
        lol=1
    if(lol):
      print(-1)
    else:
      print(m)

### FIXED CODE ###

n=int(input())
m=1
inf=10**18
lol=0
l=list(map(int,input().split()))
if 0 in l:
    print(0)
else:

    for i in l:
      m=m*i
      if(m>inf):
        lol=1
        break
    if(lol):
      print(-1)
    else:
      print(m)
### BUGGY CODE ###

def main():
    S = input()
    Q = int(input())
    flag = False
    for _ in range(Q):
        A = tuple(map(str, input().split()))
        if A[0] == "1":
            flag = not(flag)
        else:
            if (A[1] == "1" and not(flag)) or (A[1] == "2" and flag):
                S = A[2] + S
            else:
                S = S + A[2]
    if flag:
        print(S[::-1])
    else:
        print(S)
if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def main():
    S = deque(map(str, input()))
    Q = int(input())
    flag = False
    for _ in range(Q):
        A = tuple(map(str, input().split()))
        if A[0] == "1":
            flag = not(flag)
        else:
            if (A[1] == "1" and not(flag)) or (A[1] == "2" and flag):
                S.appendleft(A[2])
            else:
                S.append(A[2])
    if flag:
        print("".join(S)[::-1])
    else:
        print("".join(S))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if s[i] == s[j]: a = a+1
print(a)

### FIXED CODE ###

n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()

for _ in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count('AC'))

### FIXED CODE ###

import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])
### BUGGY CODE ###

def resolve():
    N = int(input())
    X = input()

    for i in range(N):
        count = 0
        if X[i] == "1":
            nX = int( X[:i] + "0" + X[i+1:] , 2)
        if X[i] == "0":
            nX = int(X[:i] + "1" + X[i+1:] , 2)           
        for j in range(N):
            if nX == 0:
                break
            else:
                nX %= bin(nX).count("1")              
                count += 1
        print(count)
resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    X = input()
    Xint = int(X,2)
    popX = X.count("1")
    if popX == 1:
        idx = X.find("1")
        for i in range(N):
            if i == idx:
                print(0)
            else: 
                if i != N-1:
                    if X[-1] == "0":
                        print(1)
                    else:
                        print(2)
                else:
                    print(2)
        return

    Xmod_plus =  Xint % (popX+1)
    Xmod_minus = Xint % (popX-1)

    pop_2expi_p = {0:1}
    pop_2expi_m = {0:1}
    for i in range(1,N):
        pop_2expi_p[i] = pop_2expi_p[i-1] * 2 % (popX+1)
        pop_2expi_m[i] = pop_2expi_m[i-1] * 2 % (popX-1)

    for i in range(N):
        count = 1
        if X[i] == "1":
            nX = (Xmod_minus - pop_2expi_m[N-1-i] ) % (popX-1) 
        if X[i] == "0":
            nX = (Xmod_plus + pop_2expi_p[N-1-i] ) % (popX+1) 
        for j in range(N):
            if nX == 0:
                break
            else:
                nX %= bin(nX).count("1")              
                count += 1
        print(count)
resolve()
### BUGGY CODE ###

import sys
from collections import deque
imput = sys.stdin.readline

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input().rstrip('\n'))

ans = h + w

def bfs(cur, pre, cnt):
    global ans
    stack = deque([[cur, pre, cnt]])
    while stack:
        cur, pre, cnt = stack.popleft()
        r, c = cur
        col = s[r][c]
        if col != pre:
            cnt += 1
        if r == h-1 and c == w-1:
            ans = min(ans, cnt)
        next = [[r+1, c], [r, c+1]]
        for r2, c2 in next:
            if r2 < h and c2 < w:
                stack.append([[r2, c2], col, cnt])

bfs([0, 0], '.', 0)

print((ans+1)//2)


### FIXED CODE ###

import sys
from collections import deque
imput = sys.stdin.readline

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input().rstrip('\n'))

ans = h + w
memo = [[h + w for i in range(w)] for j in range(h)]

def bfs(cur, pre, cnt):
    global ans
    stack = deque([[cur, pre, cnt]])
    while stack:
        cur, pre, cnt = stack.popleft()
        r, c = cur
        col = s[r][c]
        if col != pre:
            cnt += 1
        if memo[r][c] > cnt:
            memo[r][c] = cnt
            if r == h-1 and c == w-1:
                ans = min(ans, cnt)
            next = [[r+1, c], [r, c+1]]
            for r2, c2 in next:
                if r2 < h and c2 < w:
                    stack.append([[r2, c2], col, cnt])

bfs([0, 0], '.', 0)

print((ans+1)//2)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
s=list()
for i in range(n):
  s.append((a.index(i+1)+1))
b=map(str,s)
print(' '.join(b))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
s=[0]*n
for i,m in enumerate(a):
  s[m-1]=i+1
b=map(str,s)
print(' '.join(b))
### BUGGY CODE ###

H, W, M = map(int, input().split())
h = [0 for i in range(H)]
w = [0 for i in range(W)]
DP = []
for i in range(M):
    hh, ww = map(int, input().split())
    h[hh - 1] += 1
    w[ww - 1] += 1
    DP.append((hh - 1, ww - 1))

hhh = max(h)
www = max(w)
hhhh = [i for i, x in enumerate(h) if x == hhh]
wwww = [i for i, x in enumerate(w) if x == www]
check = 0

for i in hhhh:
    for j in wwww:
        if (i, j) not in DP:
            print(hhh + www)
            exit()
print(hhh + www - 1)


### FIXED CODE ###

H, W, M = map(int, input().split())
h = [0 for i in range(H)]
w = [0 for i in range(W)]
DP = set()
for i in range(M):
    hh, ww = map(int, input().split())
    h[hh - 1] += 1
    w[ww - 1] += 1
    DP.add((hh - 1, ww - 1))

hhh = max(h)
www = max(w)
hhhh = [i for i, x in enumerate(h) if x == hhh]
wwww = [i for i, x in enumerate(w) if x == www]
check = 0

for i in hhhh:
    for j in wwww:
        if (i, j) not in DP:
            print(hhh + www)
            exit()
print(hhh + www - 1)
### BUGGY CODE ###

import math
n = int(input())

for N in range(1,n+1):
    result = 0
    for x in range(1,int(math.sqrt(N))+1):
        for y in range(1, int(math.sqrt(N-x**2))+1):
            if N-x**2-y**2 >= 1:
                for z in range(1, int(math.sqrt(N-x**2-y**2))+1):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == N:
                        result += 1
                    elif x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
                        break
    print(result)

### FIXED CODE ###

import math
n = int(input())
mylist = [int(math.sqrt(i)) for i in range(1,n+1)]
mylist = [0]+mylist

def main():
    for N in range(1,n+1):
        result = 0
        for x in range(1,mylist[N//3]+1):
            tempx = x**2
            for y in range(x, mylist[(N-x**2)//2]+1):
                tempy = y**2
                tempxy = x*y
                tempxandy = (x+y)/2
                tempnum = N-tempx-tempy-tempxy+tempxandy**2
                if tempnum <= 0:
                    break
                else:
                    if math.sqrt(tempnum)*2 == int(math.sqrt(tempnum)*2):
                        z = math.sqrt(tempnum)-tempxandy
                        #print(x,y,z,N)
                        if z < y:
                            break
                        elif x != y and y != z:
                            result += 6
                        elif x == y and y == z:
                            result += 1
                        else:
                            result += 3
        print(result)
main()
### BUGGY CODE ###

ss = input()[::-1]
sv = ''
mods = {}

for s in ss:
    sv = s + sv
    i = int(sv) % 2019
    try:
        mods[i] += 1
    except KeyError:
        mods[i] = 1

if 0 in mods.keys():
    ans = 1
else:
    ans = 0

for v in mods.values():
    ans += (v * (v - 1)) // 2

print(ans)

### FIXED CODE ###

s = input()[::-1] # 右からn桁の数についてループを回していきたいので、文字列を反転させる

sum_of_digits = 0 # 余りの値
cnts = [0] * 2019 # 余りの値ごとに余りが同じ値の数を格納する変数。2019で割る場合、余りは0~2018までの2019通りあるので、リストの長さは2019
cnts[0] = 1 # ※1
d = 1 # sum_of_digitsの計算に使う10の累乗値

# まず余りの値ごとに余りが同じ値の数を数える
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019 # ※2
    cnts[sum_of_digits] += 1

# 次に余りの値ごとにその組み合わせを計算し、足し合わせる
ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)
### BUGGY CODE ###

def main():
    N, Q = map(int, input().split())
    S = input()
    list = []

    #for i in range(int(Q)):
      #  list.append(map(int, input().split()))

    for i in range(int(Q)):
        #a, b = list[i]
        a, b = map(int, input().split())
        sss = S[a - 1:b]
        count = sss.count("AC")
        print(count)

    return 0


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

H, W, M = map(int, input().split())
hw = []

h_cnt = [0] * H
w_cnt = [0] * W
hw = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1

max_h = max(h_cnt)
max_w = max(w_cnt)
hs = [i for i in range(H) if h_cnt[i]==max_h]
ws = [i for i in range(W) if w_cnt[i]==max_w]

cnt = 0
for h, w in hw:
    if h in hs and w in ws:
        cnt += 1
if cnt < len(hs)*len(ws):
    print(max_h+max_w)
else:
    print(max_h+max_w-1)



### FIXED CODE ###

H, W, M = map(int, input().split())

h_cnt = [0] * H
w_cnt = [0] * W
hw = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1

max_h = max(h_cnt)
max_w = max(w_cnt)
hs = [i for i in range(H) if h_cnt[i]==max_h]
ws = [i for i in range(W) if w_cnt[i]==max_w]

ans = max_h+max_w-1
hw = set(hw)
for h in hs:
    for w in ws:
        if (h, w) not in hw:
            print(max_h+max_w)
            exit()
print(max_h+max_w-1)