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

N= int(input())
S=input()
r=[]
g=[]
b=[]
for i in range(N):
    if S[i]=="R":
        r.append(i)
    elif S[i]=="G":
        g.append(i)
    else:
        b.append(i)

t=0
k=0
for i in range(len(r)):
    for j in range(len(g)):

        if 2*r[i]-g[j] in b:
            k+=1
        if 2*g[j]-r[i] in b:
            k+=1
        if (r[i]+g[j])/2 in b:
            k+=1
        t+=1

print(t*len(b)-k)

### FIXED CODE ###

N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=2*j-i
        if t<N:
            if S[i]!=S[j] and S[i]!=S[t] and S[t]!=S[j] :
                k+=1

print(A*B*C-k)
### BUGGY CODE ###

n = int(input())
ans = n
for a in range(1,n):
    if n%a == 0:
        ans = min(ans,a+n//a-2)

print(ans)

### FIXED CODE ###

n = int(input())
ans = n
for a in range(1,n):
    if n%a == 0:
        m = n//a
        ans = a+m-2
    if a*a > n:
        break
print(ans)
### BUGGY CODE ###

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

dice = list(map(int, input().split()))
a = 0
b = 0
for j in range(k):
    a += dice[j]
    b += dice[j]
res = 0
ll = 0
s = 0
for i in range(len(dice)):
    if i < k:
        continue
    a += dice[i]
    a -= dice[s]
    if a > b:
        b = a
        ll = i
    s += 1

for mn in range(ll - k + 1, ll + 1):
    ss = range(dice[mn] + 1)
    res += sum(ss) / dice[mn]
print(res)

### FIXED CODE ###

n, k = map(int, input().split())
 
dice = list(map(int, input().split()))
 
a = sum(dice[0: k])
b = sum(dice[0: k])
 
res = 0
ll = 0
s = 0

for i in range(k, len(dice)):
    a += dice[i]
    a -= dice[i - k]
    if a > b:
        b = a
 
res = (b + k) /2.0
 
print(res)
### BUGGY CODE ###

from numba import njit, i8, void
import numpy as np

mod = 10**9+7
k = int(input())
n = len(input())


@njit(i8(i8, i8, i8), cache=True)
def pow(n, k, mod):
    l, now = [1]*64, 1
    l[0] = n
    for i in range(1, 64):
        l[i] = l[i-1]*l[i-1] % mod
    for i in range(64):
        if k & 1:
            now = now*l[i] % mod
        k >>= 1
    return now


@njit(void(i8, i8, i8), cache=True)
def num_calc(n, k, mod):
    fact = np.ones(n+k+1, dtype=np.int64)
    for i in range(2, n+k+1):
        fact[i] = fact[i-1]*i % mod

    power = np.ones(k+1, dtype=np.int64)
    power[0] = fact[n+k]
    for i in range(1, k+1):
        power[i] = power[i-1]*25 % mod

    fact = fact[n+k:n-1:-1]*fact[:k+1] % mod
    ans = 0
    for i in range(k+1):
        ans = (ans+pow(fact[i], mod-2, mod)*power[i]) % mod
    print(ans)


num_calc(n, k, mod)


### FIXED CODE ###

def main():
    mod = 10**9+7
    k = int(input())
    s = input()
    n = len(s)
    fact = [1, 1]
    for i in range(2, 2*(10**6)+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = 0
    for i in range(k+1):
        ans = (ans+nCr(n+k, i)*pow(25, i, mod)) % mod
    print(ans)


main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

a.sort(reverse = True)

#l = len(bin(a[0])[2:])

ans  = 0
for b in range(60+1):
    count_1 = 0
    count_0 = 0
    for i in range(n):
        if (a[i] >> b) & 1:
            count_1 += 1
        else:
            count_0 += 1
    count_1 %= mod
    count_0 %= mod
    ans += (count_1 * count_0 * pow(2,b))%mod


print(ans%mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

a.sort(reverse = True)

#l = len(bin(a[0])[2:])

ans  = 0
for b in range(60+1):
    count_1 = 0
    count_0 = 0
    for i in range(n):
        if (a[i] >> b) & 1:
            count_1 += 1
        else:
            count_0 += 1
    count_1 %= mod
    count_0 %= mod
    ans += (count_1 * count_0 * pow(2,b,mod))%mod


print(ans%mod)
### BUGGY CODE ###

n,m = map(int,input().split())
a = []
b = []
l = []
ans = 0
count = 0

for i in range(n):
	a_dash,b_dash = map(int,input().split())
	a.append(a_dash)
	b.append(b_dash)

c = zip(a,b)
c = sorted(c)
a,b = zip(*c)
a = list(a)
b = list(b)

for i in reversed(range(m)):
	for j in range(count,len(a)):
		if a[j] + i == m:
			l.append(b[j])
			count += 1
		else:
			break
	if len(l) != 0:
		ans += max(l)
		l.pop(l.index(max(l)))

print(ans)

### FIXED CODE ###

import sys
import heapq

s = sys.stdin.readlines()
n,m = map(int,s[0].split())
a = []
b = []
l = []
ans = 0
count = 0

for i in range(1,n+1):
	a_dash,b_dash = map(int,s[i].split())
	a.append(-a_dash)
	b.append(-b_dash)

c = zip(a,b)
c = sorted(c,reverse=True)
a,b = zip(*c)
a_length = len(a)

for i in reversed(range(m)):
	for j in range(count,a_length):
		if -a[j] + i == m:
			heapq.heappush(l,b[j])
			count += 1
		else:
			break
	if len(l) != 0:
		maximum = heapq.heappop(l)
		ans += maximum

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

N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append(int(s))

# K=4
# S=[17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
# K=3
# S=[1,2,2,4,5]

maxSKsum=0
startSindex=0

for i in range(len(S)):
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

EVlist=[]
for s in range(K):
    tempEV=S[startSindex+s]*(S[startSindex+s]+1)/2/S[startSindex+s]
    EVlist.append(tempEV)

print(sum(EVlist))

### FIXED CODE ###

N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=sum(S[0:K])
tempsum=maxsum

for i in range(N-K):
    tempsum=tempsum-S[i]+S[i+K]
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass

print(maxsum)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[2]=0

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+dfs(j)
      break
  else:
    return []
z=dfs(2)[::-1]+[2]+dfs(2)
print(len(z))
print(*z)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)
### BUGGY CODE ###

k = int(input())
lists = []
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            def gcd(a,b): 
                if(b==0): 
                    return a 
                else: 
                    return gcd(b,a%b)
            
            ans = gcd(a, gcd(b, c))
            lists.append(ans)
print(sum(lists))

### FIXED CODE ###

from math import gcd

k = int(input())
answer = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            answer += gcd(gcd(a, b), c)
print(answer)
### BUGGY CODE ###

import numpy as np

N= int(input())
A= np.array(list(map(int, input().split())))
Q= int(input())

for i in range(Q):
    B, C= list(map(int, input().split()))
    A = A[np.where(A != B)]
    A = np.append(A, np.ones(N - A.shape[0])*C)

    print(int(np.sum(A)))

### FIXED CODE ###

N= int(input())
A= list(map(int, input().split()))
Q= int(input())
tmpDic = {}
res = sum(A)

for i in range(N):
    if A[i] in tmpDic:
        tmpDic[A[i]] += 1
    else:
        tmpDic[A[i]] = 1

for i in range(Q):
    B, C= list(map(int, input().split()))
    if B in tmpDic and tmpDic[B] > 0:
        tmp = tmpDic[B]
        tmpDic[B] = 0
        res += (C - B)* tmp
        
        if C in tmpDic:
            tmpDic[C] += tmp
        else:
            tmpDic[C] = tmp
    print(res)
### BUGGY CODE ###

k, s = list(map(int, input().split()))

counter = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                counter += 1

print(counter)


### FIXED CODE ###

k, s = list(map(int, input().split()))


counter = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            counter += 1

print(counter)
### BUGGY CODE ###

from collections import deque

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

cnt=0
for i in range(H):
    temp=list(input())
    cnt+=temp.count(".")
    s.append(temp)

d=deque([[0,0]])
step=[[-1,0],[0,-1],[1,0],[0,1]]
c={(0,0):1}

while d:
    h0,w0=d.popleft()
    s[h0][w0]="#"
    for h1,w1 in step:
        h = h0 + h1
        w = w0 + w1
        if h<0 or h>=H or w<0 or w>=W or s[h][w]=="#":
            continue
        if h==H-1 and w==W-1:
            ans = cnt - c[(h0,w0)]-1
            print(ans)
            exit()
        c[(h,w)]=c[(h0,w0)]+1
        d.append([h,w])
print(-1)

### FIXED CODE ###

from collections import deque

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

cnt=0
for i in range(H):
    temp=list(input())
    cnt+=temp.count(".")
    s.append(temp)

d=deque([[0,0]])
c=[[10000]*W for i in range(H)]
step=[[-1,0],[0,-1],[1,0],[0,1]]
c[0][0]=1

while d:
    h0,w0=d.popleft()
    for h1,w1 in step:
        h = h0 + h1
        w = w0 + w1
        if h<0 or h>=H or w<0 or w>=W or s[h][w]=="#" or c[h][w]!=10000:
            continue
        if h==H-1 and w==W-1:
            ans = cnt - c[h0][w0]-1
            print(ans)
            exit()
        c[h][w]=c[h0][w0]+1
        d.append([h,w])
print(-1)
### BUGGY CODE ###

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

cur = 1
for i in range(k):
	cur *= a[i]

for i in range(0, n - k):
	new = cur
	new *= a[i + k]
	new //= a[i] 
	if new > cur:
		print('Yes')
	else:
		print('No')

	cur = new

### FIXED CODE ###

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

for i in range(0, n - k):
	if a[i + k] > a[i]:
		print('Yes')
	else:
		print('No')
### BUGGY CODE ###

from bisect import bisect_right

N = int(input())
A = [int(i) for i in input().split()]
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

ans = 0

for i in A:
    tyu = bisect_right(B, i)
    for j in range(tyu, N):
        ge = bisect_right(C, B[j])
        ans += N-ge
        
print(ans)

### FIXED CODE ###

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(map(int, input().split()))
import bisect
ans = 0

for i in B:
    iA = bisect.bisect_left(A, i)
    iB = bisect.bisect_right(C, i)
    ans += (iA)*(N-iB)
print(ans)
### BUGGY CODE ###

s = 1

N = input()
for x in input().split():
  s *= int(x)

if s > 10 ** 18:
  print(-1)
else:
  print(s)

### FIXED CODE ###

N = input()
xs = [int(x) for x in input().split()]

if 0 in xs:
  print(0)
else:
  s = 1
  for x in xs:
    s *= x
    if s > 10 ** 18:
      print(-1)
      break
  else:
    print(s)
### BUGGY CODE ###

from operator import itemgetter

class BinaryIndexedTree:  # 0-index !!!
    """
    init(n):     要素数nを与えて0で初期化
    add(i, x):   i番目の値にxを追加 O(logN)
    sum(i):      区間[0,i)の和を返す O(logN)
    query(l, r): 区間[l,r)の和を返す O(logN)
    """

    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)  # 内部的には1-indexで扱う

    def add(self, i, x):  # 0-index
        i += 1  # 内部的には1-indexで扱う
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):  # 0-index  sum of [0,i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def query(self, l, r):  # 0-index  sum of [l,r)
        return self.sum(r) - self.sum(l)

# ---------------------- #

n, q = (int(x) for x in input().split())
C = list(int(x) - 1 for x in input().split())
LR = [tuple(int(x) for x in input().split()) for _ in range(q)]

bit = BinaryIndexedTree(n)
color_right_index = [-1] * n
queries = [(i, l - 1, r - 1) for i, (l, r) in enumerate(LR)]
queries.sort(key=itemgetter(2))
ANS = [0] * q
k = 0
for i, l, r in queries:
    while k <= r and k <= n:
        color = C[k]
        if color_right_index[color] != -1:
            bit.add(color_right_index[color], -1)
        color_right_index[C[k]] = k
        bit.add(k, 1)
        k += 1
    ANS[i] = bit.query(l, r + 1)

for ans in ANS:
    print(ans)


### FIXED CODE ###

import sys
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()

class BinaryIndexedTree:  # 0-index !!!
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)  # 内部的には1-indexで扱う

    def add(self, i, x):  # 0-index
        i += 1  # 内部的には1-indexで扱う
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):  # 0-index  sum of [0,i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def query(self, l, r):  # 0-index  sum of [l,r)
        return self.sum(r) - self.sum(l)

# ---------------------- #

n, q = (int(x) for x in input().split())
C = list(int(x) - 1 for x in input().split())
LR = [tuple(int(x) for x in input().split()) for _ in range(q)]

bit = BinaryIndexedTree(n)
color_right_index = [-1] * n
queries = [(i, l - 1, r - 1) for i, (l, r) in enumerate(LR)]
queries.sort(key=itemgetter(2))
ANS = [0] * q
k = 0
for i, l, r in queries:
    while k <= r and k <= n:
        color = C[k]
        if color_right_index[color] != -1:
            bit.add(color_right_index[color], -1)
        color_right_index[C[k]] = k
        bit.add(k, 1)
        k += 1
    ANS[i] = bit.query(l, r + 1)

for ans in ANS:
    print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
s = [input() for i in range(H)]

rows = []

for i in range(H):
    row = []
    for j in range(W):
        if j == 0:
            if s[i][0] == "#":
                row.append(0)
            else:
                idx = s[i].find("#")
                if idx == -1:
                    idx = W
                row.append(idx)
        else:
            if s[i][j] == "#":
                row.append(0)
            else:
                if s[i][j-1] != "#":
                    row.append(row[len(row)-1])
                else:
                    idx = s[i].find("#", j)
                    if idx == -1:
                        idx = W
                    row.append(idx - j)
    rows.append(row)

columns = []

for i in range(W):
    column = []
    _s = ""
    for k in range(H):
        _s += s[k][i]
    for j in range(H):
        if j == 0:
            if _s[0] == "#":
                column.append(0)
            else:
                idx = _s.find("#")
                if idx == -1:
                    idx = H
                column.append(idx)
        else:
            if _s[j] == "#":
                column.append(0)
            else:
                if _s[j - 1] != "#":
                    column.append(column[len(column) - 1])
                else:
                    idx = _s.find("#", j)
                    if idx == -1:
                        idx = H
                    column.append(idx - j)
    columns.append(column)

res = []
for i in range(H):
    for j in range(W):
        r = rows[i][j]
        c = columns[j][i]
        res.append(r+c-1)
print(max(res))

### FIXED CODE ###


H, W = map(int, input().split())
s = [input() for i in range(H)]

l = [[0 for i in range(W)] for j in range(H)]
r = [[0 for i in range(W)] for j in range(H)]
d = [[0 for i in range(W)] for j in range(H)]
u = [[0 for i in range(W)] for j in range(H)]

# Up-Light
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            l[i][j] = 0
            u[i][j] = 0
            continue

        if j == 0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1

        if i == 0:
            u[i][j] = 1
        else:
            u[i][j] = u[i-1][j] + 1

# Right-Down
for i in range(H)[::-1]:
    for j in range(W)[::-1]:
        if s[i][j] == "#":
            r[i][j] = 0
            d[i][j] = 0
            continue

        if j == W-1:
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1

        if i == H-1:
            d[i][j] = 1
        else:
            d[i][j] = d[i+1][j] + 1

max_score = 0
for i in range(H):
    for j in range(W):
        score = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        if score > max_score:
            max_score = score
print(max_score)
### BUGGY CODE ###

import math
K = int(input())


d = {}
def gcd(a,b,c):
    st = tuple(sorted((a,b,c)))
    if st not in d:
        res = math.gcd(a, math.gcd(b,c))
        d[st] = res
    return d[st]

s=0
for i in range(1,K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            s += gcd(i, j, l)
print(s)

### FIXED CODE ###

from math import gcd
K = int(input())

s=0
for i in range(1,K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            s += gcd(i, gcd(j,l))

print(s)
### BUGGY CODE ###

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

arr = []
R = len(list(filter(lambda x:x == 'R', s)))
G = len(list(filter(lambda x:x == 'G', s)))
B = len(list(filter(lambda x:x == 'B', s)))
tot = R*G*B

for i in range(n):
  for j in range(i+1, n):
    k = 2*j-i
    if k < n:
      if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
        tot -= 1

print(tot)


### FIXED CODE ###

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

arr = []
R = len(list(filter(lambda x:x == 'R', s)))
G = len(list(filter(lambda x:x == 'G', s)))
B = len(list(filter(lambda x:x == 'B', s)))
tot = R*G*B

for i in range(n):
  for j in range(i+1, n):
    k = 2*j-i
    if k >= n:
      continue
    if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
      tot -= 1

print(tot)
### BUGGY CODE ###

from bisect import *
N=int(input())
A=[int(input()) for _ in range(N)]
B=[int(input()) for _ in range(N)]
A=sorted(A)
B=sorted(B)
ans=1
mod=10**9+7
for a,b in zip(A,B):
  if a>b:
    a,b=b,a
  ans*=(bisect_right(A,b)-bisect_left(A,a))
print(ans%mod)

### FIXED CODE ###

from bisect import *
N=int(input())
A=[int(input()) for _ in range(N)]
B=[int(input()) for _ in range(N)]
A=sorted(A)
B=sorted(B)
ans=1
mod=10**9+7
for a,b in zip(A,B):
  if a>b:
    a,b=b,a
  ans*=(bisect_right(A,b)-bisect_left(A,a))
  ans%=mod
print(ans)
### BUGGY CODE ###

S = list(str(input()))

count = [0] * len(S)

for i in range(0, len(S)):
  current = i
  for j in range(0, pow(10, 100)):
    if S[current] == "R" and S[current+1] == "R":
      current += 1
    elif S[current] == "R" and S[current+1] == "L":
      if j % 2 == 1:
        current += 1
      break
    elif S[current] == "L" and S[current-1] == "R":
      if j % 2 == 1:
        current -= 1
      break
    elif S[current] == "L" and S[current-1] == "L":
      current -= 1
  count[current] += 1
  
result = " ".join(map(str, count))

print(result)

### FIXED CODE ###

S = list(str(input()))
result_position = [0] * len(S)
count = [0] * len(S)

# 最も左の計算
current = 0
for j in range(0, pow(10, 100)):
  if S[current + 1] == "L":
    if j % 2 == 1:
      current += 1
    break
  else:
    current += 1
result_position[0] = current
count[current] += 1

for i in range(1, len(S)):
  if (S[i - 1] == "R") or (S[i - 1] == "L" and S[i] == "L"):
    if S[result_position[i - 1]] == "R":
      result_position[i] = result_position[i - 1] + 1
    else:
      result_position[i] = result_position[i - 1] - 1
    count[result_position[i]] += 1
  else:
    current = i
    for j in range(0, pow(10, 100)):
      if S[current+1] == "L":
        if j % 2 == 1:
          current += 1
        break
      else:
        current += 1
    result_position[i] = current
    count[current] += 1
  
result = " ".join(map(str, count))

print(result)
### BUGGY CODE ###

import sys
from collections import defaultdict, deque
from copy import deepcopy

N = int(input())
edge = []
color_dict = {}
repn = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge.append((a, b))
    color_dict[(a, b)] = None
    repn[a].append(b)
    repn[b].append(a)

K = 0
color_set = deque([i for i in range(1, 10**5)])

q = [(0, None)]
while q:
    u, color = q.pop()
    c_set = deepcopy(color_set)
    for v in repn[u]:
        if color_dict[(u, v)] == None:
            c = c_set.popleft()
            if c != color:
                color_dict[(u, v)] = c
                color_dict[(v, u)] = c
                q.append((v, c))
            else:
                c = c_set.popleft()
                color_dict[(u, v)] = c
                color_dict[(v, u)] = c
                q.append((v, c))
            K = max(K, c)

print(K)
for pair in edge:
    print(color_dict[pair])

### FIXED CODE ###

import sys
from collections import defaultdict
from copy import deepcopy
input = sys.stdin.readline

N = int(input())
edge = []
color_dict = {}
repn = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge.append((a, b))
    color_dict[(a, b)] = None
    repn[a].append(b)
    repn[b].append(a)

K = 1
q = [(0, None)]
while q:
    u, color = q.pop()
    if color == 1:
        c = 2
    else:
        c = 1
    for v in repn[u]:
        if color_dict[(u, v)] == None:
            color_dict[(u, v)] = c
            color_dict[(v, u)] = c
            q.append((v, c))
            K = max(K, c)
            c += 1
            if c == color:
                c += 1
                

print(K)
for pair in edge:
    print(color_dict[pair])
### BUGGY CODE ###

# ABC 122, c
n, q = [int(el) for el in input().split(' ')]
s = input()
LR = [[int(el) for el in input().split(' ')] for i in range(q)]
T = [1 if s[i:i+2] == 'AC' else 0 for i in range(n-1)]


for l, r in LR:
    print(sum(T[(l-1):(r-1)]))


### FIXED CODE ###

# ABC 122, c
n, q = [int(el) for el in input().split(' ')]
s = input()
T = [0] * (n + 1)
for i in range(n):
    T[i+1] = T[i] + (1 if s[i:i+2] == 'AC' else 0)


for i in range(q):
    l, r = [int(el) for el in input().split(' ')]
    print(T[r-1] - T[l-1])
### BUGGY CODE ###

from collections import defaultdict

def main():
    S = input()
    # S = "1" * 200000
    S = S[::-1]

    x = 1
    tot = 0
    cnt = defaultdict(int)
    ans = 0

    for i in range(len(S)):
        # print("-----")
        # print(f"i: {i}")
        # print(f"tot: {tot}")
        # print(f"S[i]: {S[i]}")
        # print(f"x: {x}")
        # print(f"cnt: {cnt}")
        # print(f"cnt[tot]: {cnt[tot]}")
        # print(f"ans: {ans}")

        cnt[tot] += 1
        tot += int(S[i]) * x
        tot %= 2019
        ans += cnt[tot]
        x = x * 10
    
    # print("-----")
    # print(f"i: {i}")
    # print(f"tot: {tot}")
    # print(f"S[i]: {S[i]}")
    # print(f"x: {x}")
    # print(f"cnt: {cnt}")
    # print(f"cnt[tot]: {cnt[tot]}")
    # print(f"ans: {ans}")
    
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = input()
    # S = "1" * 200000
    S = S[::-1]

    x = 1
    tot = 0
    cnt = [0] * 2019
    ans = 0

    for i in range(len(S)):
        # print("-----")
        # print(f"i: {i}")
        # print(f"tot: {tot}")
        # print(f"S[i]: {S[i]}")
        # print(f"x: {x}")
        # print(f"cnt: {cnt}")
        # print(f"cnt[tot]: {cnt[tot]}")
        # print(f"ans: {ans}")

        cnt[tot] += 1
        tot = (tot + (int(S[i]) * x)) % 2019
        ans += cnt[tot]
        x = (x * 10) % 2019
    
    # print("-----")
    # print(f"i: {i}")
    # print(f"tot: {tot}")
    # print(f"S[i]: {S[i]}")
    # print(f"x: {x}")
    # print(f"cnt: {cnt}")
    # print(f"cnt[tot]: {cnt[tot]}")
    # print(f"ans: {ans}")
    
    print(ans)


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

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

for _ in range(N):
    a = min(A)
    b = A.index(a)+1
    c.append(b)
    A[b-1] = 100002
print(' '.join(map(str, c)))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = [0]*N

for i in range(N):
    a = A[i]
    c[a-1] = i+1
print(' '.join(map(str, c)))