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

import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    princes = np.array(input().split(' '), dtype='i')
    for i in range(num_coupon):
        princes[princes.argmax()] //= 2
    print(princes.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)


### FIXED CODE ###

import heapq

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = list(map(lambda x: int(x) * -1 , input().split(' ')))
    heapq.heapify(prices)
    for _ in range(num_coupon):
        max_price = heapq.heappop(prices) // (2*-1)
        heapq.heappush(prices, max_price*-1)

    print(sum(prices)*-1)

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in A:
    a = bisect.bisect_right(B,i)
    for j in range(a,N):
        b = bisect.bisect_right(C,B[j])
        ans += N-b
print(ans)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
import bisect
b = []
for i in B:
    x = bisect.bisect_right(C,i)
    b.append(N-x)
y = sum(b)
c = [y]
for i in range(1,N):
    y -= b[i-1]
    c.append(y)
c.append(0)
for i in A:
    a = bisect.bisect_right(B,i)
    ans += c[a]
print(ans)
### BUGGY CODE ###

N = int(input())

color = []
color.append(int(input()))

for i in range(N-1):
  A = int(input())
  X = 0
  while X < len(color):
    if color[X] < A:
      color[X] = A
      X = 10**6
    else:
      X += 1
  
  if X != 10**6:
    color.append(A)

print(len(color))

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N = int(input())

color = []
color.append(int(input()))

for i in range(N-1):
  A = int(input())
  
  if color[-1] >= A:
    color.append(A)

  else:
    color.reverse()
    l = bisect_left(color,A)
    color[l-1] = A
    color.reverse()


print(len(color))
### BUGGY CODE ###

baisu=set([])

i=1
while 1:
    temp=2019*i
    if "0" not in str(temp):
        baisu.add(str(temp))
    
    if temp>20000000000:
        break
    i+=1

n=input()
cnt=0
for i in baisu:
    if i in n:
        cnt+=1

print(cnt)



### FIXED CODE ###

s=input()



"""
◆エッセンス1：割り切れるとは、二つに分けた数字のmodが一緒
例)
1817181712114の
18171が2019で割り切れるかどうかを判断する。

18171は(181712114-2114)/10000となるので、
181712114mod2019＝2114mod2019の時、2019で割り切れる。

1817181712114mod2019
 817181712114mod2019
  17181712114mod2019
   7181712114mod2019
    181712114mod2019
     81712114mod2019
      1712114mod2019
       712114mod2019
    　　・・・・
とmodを調べていき、値が同じペアは割り切れる。
"""

"""
◆エッセンス2：大きい数字は都度modを取る

これだけでもループは1回になるんだけど、
|S|が長すぎてTLEとなってしまう（|S|は10**5）
1234567 mod 2019
=(1*10**7)mod2019 + (234567mod2019)
=(1*10mod2019 * 10**6mod2019)+ (234567mod2019)

10**nを毎回modを取ることで、計算する数字の長さを短くする。

"""



#modの値を保持する配列
cnt=[0]*2019
#mod2019 =0 は、それ一つで割り切れるので。引き算をする必要が無い。
cnt[0]=1

#10の倍数を保持する
fac=1
ss=0
for i in range(len(s)):
    #後ろの数字から順番にとってくる
    ss += int(s[len(s)-i-1])*fac
    ss%=2019
    fac=fac*10
    fac%=2019
    cnt[ss]+=1
    

result=0
for c in cnt:
    result+=c*(c-1)//2

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

#200419C
N = int(input())
A = list(map(int,input().split()))

for i in range(N-1):
    Ans = 0
    L = len(A)
    for j in range(L):
        if i+1 == A[L-j-1]:
            Ans += 1
            A.remove(A[L-j-1])
            #print(A)
    print(Ans)
print("0")

### FIXED CODE ###

#200419C
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)

count = 0
for i in range(N-1):
    L = len(A)
    #print(A)
    Ans = 0
    count += Ans
    for j in range(L-count):
        if A[count + j]==i+1:
            Ans += 1
        else:            
            break
    print(Ans)
    count += Ans

        
print("0")
### BUGGY CODE ###

a,b,n = map(int,input().split())
max = -9999999999
for i in range(1,n+1):
    buf = a*(i%b)-(a*i)%b 
    if buf > max:
        max = buf

print(int(max/b))

### FIXED CODE ###

a,b,n = map(int,input().split())

def f(x):
    return int(a*x/b)-a*int(x/b)

w=min(n,b-1) 
ma=f(w)
print(ma)
### BUGGY CODE ###

n = int(input())
x = input()
cnt1 = x.count('1')
x10 = int(x,2)

if cnt1 > 1:
  x10mod_m = x10 % (cnt1-1)
  x10mod_p = x10 % (cnt1+1)
else:
  x10mod_m = 0
  x10mod_p = 0

ans = []
add_val = 1<<n
for i in range(n):
  add_val = add_val >> 1
  if x[i] == '1':
    if cnt1 == 1:
      print(0)
      continue
    cntx = cnt1-1
    mod = ( x10mod_m - add_val ) % cntx
  else:
    cntx = cnt1+1
    mod = ( x10mod_p + add_val ) % cntx
    
  cnt = 1
  mod = format(mod, 'b')
  
  while True:
    if mod == '0':
      break
    one_cnt = mod.count('1')
    mod_10 = int(mod,2)
    mod = format( mod_10 % one_cnt, 'b')
    cnt += 1
  print(cnt)

### FIXED CODE ###

n = int(input())
x = input()
cnt1 = x.count('1')
x10 = int(x,2)

if cnt1 > 1:
  x10mod_m = x10 % (cnt1-1)
  x10mod_p = x10 % (cnt1+1)
else:
  x10mod_m = 0
  x10mod_p = 0

ans = []
for i in range(n):
  if x[i] == '1':
    if cnt1 == 1:
      print(0)
      continue
    cntx = cnt1-1
    mod = ( x10mod_m - pow(2,n-1-i,cntx) ) % cntx
  else:
    cntx = cnt1+1
    mod = ( x10mod_p + pow(2,n-1-i,cntx) ) % cntx
    
  cnt = 1
  mod = format(mod, 'b')
  
  while True:
    if mod == '0':
      break
    mod = format( int(mod,2) % mod.count('1'), 'b')
    cnt += 1
  print(cnt)
### BUGGY CODE ###

import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

        for i in range(n-1):
            
            x_d.remove(max(x_d))
            

        sumd = sum(x_d)  
        print(sumd)


### FIXED CODE ###

import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)
### BUGGY CODE ###

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

L=[]
for i in range(1,H+1):
  for j in range(1,W+1):
    L.append([i+j,i-j])

conn =[[2,0]]
prev=0
while(prev!=len(conn)):
  prev=len(conn)
  temp=[]
  for i in range(len(conn)):
    for j in range(len(L)):
      if (L[j][0]-conn[i][0])*(L[j][1]-conn[i][1])==0:
        if 1-(L[j] in temp):
          temp.append(L[j])
  for i in range(len(temp)):
    conn.append(temp[i])
    L.remove(temp[i])
print(len(conn)-1)

### FIXED CODE ###

H,W=map(int,input().split())
import math

A=[0,math.ceil(W/2)]
if (H-1)*(W-1)!=0:
  c=W*math.floor(H/2)+A[H%2]
else:
  c=1
print(c)
### BUGGY CODE ###

a, b, k = map(int, input().split())
while(k > 0):
    if (a > 0):
        a -= 1
        k -= 1
    elif (b > 0):
        b -= 1
        k -= 1
    else:
        k -= 1
print("%s %s" % (a, b))

### FIXED CODE ###

a, b, k = map(int, input().split())
print(max(a - k, 0), max(b - max(k - a, 0), 0))
### BUGGY CODE ###

import math
n = int(input())

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

nlis = sorted(lis)

a = math.floor((n-1)/2)

for i in range(n):
    nlis = sorted(nlis)
    tmp = lis[i]
    nlis.remove(lis[i])
    print(nlis[a])
    nlis.append(tmp)

### FIXED CODE ###

import math
n = int(input())

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

nlis = sorted(lis)

med1 = nlis[n//2-1]
med2 = nlis[n//2]

for i in lis:
    if i <= med1:
        print(med2)
    else:
        print(med1)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
C = sorted(L)
def X(n,j):
    L1 = j+1
    L2 = N-1
    while L1 != L2:
        a = (L1+L2)//2
        if C[a] == n:
            while C[a] == C[a-1]:
                a = a-1
            return len(C[j+1:a])
        elif L2 - L1 <= 1:
            if C[L2] < n:
                return len(C[j+1:L2+1])
            elif C[L1] < n <= C[L2]:
                return len(C[j+1:L2])
            while C[L1] == C[L1-1]:
                if j+1 <= L1-1:
                    L1 = L1-1
                else:
                    break
            if C[L1] > n:
                return len(C[j+1:L1])
            elif C[L1] == n:
                return len(C[j+1:L1])
        elif C[a] < n:
            L1 = a
        else:
            L2 = a
    if C[L1] < n:
        return 1
    else:
        return 0
ans = 0
# print(C)
for i in range(N-2):
    for j in range(i+1,N-1):
        # print(X((C[i]+C[j]),j))
        ans += X((C[i]+C[j]),j)
print(ans)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
C = sorted(L)
def X(n,j):
    L1 = j+1
    L2 = N-1
    while L1 != L2:
        a = (L1+L2)//2
        if C[a] == n:
            while C[a] == C[a-1]:
                a = a-1
            return len(C[j+1:a])
        elif L2 - L1 <= 1:
            if C[L2] < n:
                return len(C[j+1:L2+1])
            elif C[L1] < n <= C[L2]:
                return len(C[j+1:L2])
            while C[L1] == C[L1-1]:
                if j+1 <= L1-1:
                    L1 = L1-1
                else:
                    break
            if C[L1] > n:
                return len(C[j+1:L1])
            elif C[L1] == n:
                return len(C[j+1:L1])
        elif C[a] < n:
            L1 = a
        else:
            L2 = a
    if C[L1] < n:
        return 1
    else:
        return 0
ans = 0
# print(C)
for i in range(N-2):
    for j in range(i+1,N-1):
        # print(X((C[i]+C[j]),j))
        ans += X((C[i]+C[j]),j)
print(ans)
### BUGGY CODE ###

from itertools import combinations
N = int(input())
A = [int(i) for i in input().split()]

S = 0
for i, j in combinations(A, 2):
    S += i^j
    S %= 10**9+7

print(S)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*64
for i in range(n):
    for j in range(a[i].bit_length()):
        if a[i]>>j & 1: b[j]+=1
c=0
for i in range(64):
    c+=(b[i]*(n-b[i])*2**i) % 1000000007
print(c%1000000007)
### BUGGY CODE ###

n, q = list(map(int, input().split()))
w = set()
count = (n - 2) ** 2
for i in range(1,n+1):
  w.add((n,i))
  w.add((i,n))
for _ in range(q):
  r,q = list(map(int, input().split()))
  if r == 1:
    pos = 1
    while (pos,q) not in w:
      w.add((pos,q))
      pos += 1
    count -= max(0, pos - 2)
  else:
    pos = 1
    while (q,pos) not in w:
      w.add((q,pos))
      pos += 1
    count -= max(0, pos - 2)
print(count)

### FIXED CODE ###

import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * (n + 1)
r = [n] * (n + 1)
mc = n
mr = n
for _ in range(q):
    m,q = list(map(int, input().split()))
    if m == 1:
        if q <= mc:
            count -= mr -2
            for p in range(q+1, mc):
                c[p] = mr
            c[q] = 0
            mc = q
        else:
            count -= c[q] - 2
    else:
        if q <= mr:
            count -= mc -2
            for p in range(q+1, mr):
                r[p] = mc
            r[q] = 0
            mr = q
        else:
            count -= r[q] - 2
print(count)
### BUGGY CODE ###

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

for i in range(N):
  for a in A:
    if a == i + 1:
      R.extend("1") 
  print(len(R))
  R = []
      

### FIXED CODE ###

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

for i in A:
  R[i - 1] += 1

for i in range(N):
  print(R[i])
### BUGGY CODE ###

n = int(input())
line = list(map(int, input().split()))
total = 1
for i in range(n):
  total *= line[i]
if total > 10 ** 18:
  print(-1)
else:
  print(total)

### FIXED CODE ###

n = int(input())
line = list(map(int, input().split()))
total = 1
if 0 in line:
  print(0)
else:
  for i in range(n):
    total *= line[i]
    if total > 10 ** 18:
      break;
  if total > 10 ** 18:
    print(-1)
  else:
    print(total)
### BUGGY CODE ###

import heapq


def main():
    n, m = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(n)]

    AB.sort(key=lambda x: x[0])

    H = []
    abi = 0
    ans = 0
    for mi in range(1, m + 1):
        while abi < n:
            a, b = AB[abi]
            if a == mi:
                abi += 1
                H.append(-b)
            else:
                break

        if len(H) > 0:
            heapq.heapify(H)
            ans += -heapq.heappop(H)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import heapq


def main():
    n, m = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(n)]

    AB.sort(key=lambda x: x[0])
    H = []
    ans = 0
    mi = 1
    for a, b in AB:
        while a > mi:
            if len(H) > 0:
                ans += -heapq.heappop(H)

            mi += 1
            if mi > m:
                break

        if a > m:
            break

        heapq.heappush(H, -b)

    while mi <= m and len(H) > 0:
        ans += -heapq.heappop(H)
        mi += 1

    print(ans)


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

n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_str = [s[0] for s in str_dic.items() if s[1] == max(str_dic.values())]

for s in sorted(max_str):
    print(s)


### FIXED CODE ###

n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_num = max(str_dic.values())

max_str = [s[0] for s in str_dic.items() if s[1] == max_num]

for s in sorted(max_str):
    print(s)
### BUGGY CODE ###

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

def abc162d(n, s):

    r_arr = []
    g_arr = []
    b_arr = []

    for i in range(n):
        if s[i] == 'R':
            r_arr.append(i)
        elif s[i] == 'G':
            g_arr.append(i)
        else: # 'B'
            b_arr.append(i)

    min1_arr = r_arr
    min2_arr = g_arr
    max_arr = b_arr
    if len(r_arr) < len(g_arr) and len(b_arr) < len(g_arr):
        min1_arr = r_arr
        min2_arr = b_arr
        max_arr = g_arr
    elif len(g_arr) < len(r_arr) and len(b_arr) < len(r_arr):
        min1_arr = g_arr
        min2_arr = b_arr
        max_arr = r_arr

    except_num = 0
    for r_i in min1_arr:
        for g_i in min2_arr:
            min_i = r_i
            max_i = g_i
            if g_i < r_i:
                min_i = g_i
                max_i = r_i
            diff = max_i - min_i
            minmin = min_i - diff
            maxmax = max_i + diff
            exists_central = (max_i + min_i) % 2
            central = (max_i + min_i) / 2

            if minmin in max_arr:
                except_num += 1
            if maxmax in max_arr:
                except_num += 1
            if exists_central == 0:
                if central in max_arr:
                    except_num += 1

    ans = len(r_arr) * len(g_arr) * len(b_arr) - except_num
    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s = input()
    
    ans = abc162d(n, s)
    
    # output
    print(ans)
# else:
    # do nothing


### FIXED CODE ###

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

def abc162d(n, s):

    r_arr = []
    g_arr = []
    b_arr = []

    for i in range(n):
        if s[i] == 'R':
            r_arr.append(i)
        elif s[i] == 'G':
            g_arr.append(i)
        else: # 'B'
            b_arr.append(i)

    min1_arr = r_arr
    min2_arr = g_arr
    max_arr = b_arr
    if len(r_arr) < len(g_arr) and len(b_arr) < len(g_arr):
        min1_arr = r_arr
        min2_arr = b_arr
        max_arr = g_arr
    elif len(g_arr) < len(r_arr) and len(b_arr) < len(r_arr):
        min1_arr = g_arr
        min2_arr = b_arr
        max_arr = r_arr

    max_dict = dict()
    for elem in max_arr:
        max_dict[elem] = 1

    except_num = 0
    for r_i in min1_arr:
        for g_i in min2_arr:
            min_i = r_i
            max_i = g_i
            if g_i < r_i:
                min_i = g_i
                max_i = r_i
            diff = max_i - min_i
            minmin = min_i - diff
            maxmax = max_i + diff
            exists_central = (max_i + min_i) % 2

            if minmin in max_dict:
                except_num += 1
            if maxmax in max_dict:
                except_num += 1
            if exists_central == 0:
                central = (max_i + min_i) / 2
                if central in max_dict:
                    except_num += 1

    ans = len(r_arr) * len(g_arr) * len(b_arr) - except_num
    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s = input()
    
    ans = abc162d(n, s)
    
    # output
    print(ans)
# else:
    # do nothing
### BUGGY CODE ###

from collections import Counter

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    Da = Counter(A)
    Ds = sorted(Da.items(), key=lambda x: x[1])
    lds = len(Ds)
    c1 = Ds.count(1)

    for i in range(n):
        cnt = 0
        for j in range(lds - c1):
            cnt += Ds[j][1]*(Ds[j][1] - 1)//2

        cnt -= Da[A[i]] - 1
        print(cnt)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    Da = Counter(A)
    cnt = 0
    for v in Da.values():
        cnt += v*(v - 1)//2

    for i in range(n):
        print(cnt - (Da[A[i]] - 1))

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

def main():
    S = input()
    cnt = 0
    l_past  = None
    l_new = None
    block = list(S)
    for i in range(10**5):
        block = [ a for a in block if a != "-"]
        l_new = len(block)

        if l_past == l_new :
            break

        for i in range(len(block) - 1):
            if (block[i] == "0" and block[i+1] == "1") or (block[i] == "1" and block[i+1] == "0"):
                cnt += 2
                block[i] = "-"
                block[i+1] = "-"

        l_past = l_new

    print(cnt)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    S = input()
    print(2*min(S.count("0"), S.count("1")))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
H,W,K = map(int,input().split())
r1,c1,r2,c2 = map(lambda x:int(x)-1,input().split())
C = [input() for i in range(H)]

from collections import deque
dxy = [(0,1),(1,0),(0,-1),(-1,0)]
INF = float('inf')
dists = [[INF]*W for _ in range(H)]
dists[r1][c1] = 0
q = deque([(r1,c1)])
while q:
    y,x = q.popleft()
    if y==r2 and x==c2:
        print(dists[y][x])
        exit()
    for dx,dy in dxy:
        for i in range(1,K+1):
            nx,ny = x+dx*i,y+dy*i
            if not 0 <= nx < W: break
            if not 0 <= ny < H: break
            if C[ny][nx] == '@': break
            if dists[ny][nx] <= dists[y][x] + 1: continue
            dists[ny][nx] = dists[y][x] + 1
            q.append((ny,nx))
print(-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
H,W,K = map(int,input().split())
r1,c1,r2,c2 = map(lambda x:int(x)-1,input().split())
C = [input() for i in range(H)]

def solve():
    from collections import deque
    dxy = [(0,1),(1,0),(0,-1),(-1,0)]
    INF = float('inf')
    dists = [[INF]*W for _ in range(H)]
    dists[r1][c1] = 0
    q = deque([(r1,c1)])
    while q:
        y,x = q.popleft()
        if y==r2 and x==c2:
            print(dists[y][x])
            exit()
        for dx,dy in dxy:
            for i in range(1,K+1):
                nx,ny = x+dx*i,y+dy*i
                if not 0 <= nx < W: break
                if not 0 <= ny < H: break
                if C[ny][nx] == '@': break
                if dists[ny][nx] <= dists[y][x]: break
                if dists[ny][nx] <= dists[y][x] + 1: continue
                dists[ny][nx] = dists[y][x] + 1
                q.append((ny,nx))
    print(-1)
solve()
### BUGGY CODE ###

def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    ans = float("inf")
    l = list(map(lambda x: x%MOD, range(L, R+1)))
    import itertools
    for i, j in itertools.combinations(l, 2):
        ans = min(ans, (i*j)%MOD)
    print(ans)

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    if R - L >= 2019:
        print(0)
        return
    import itertools
    ans = float("inf")
    for i, j in itertools.combinations(list(range(L, R+1)), 2):
        ans = min(ans, i*j%MOD)
    print(ans)

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

s = input()
a = int(s)
mod_N = {}
mod_N[a%2019] = 1
for i in range(len(s)):
  a = a-int(s[i])*10**(len(s)-i-1)
  mod = a%2019
  if mod in mod_N:
    mod_N[mod] +=1
  else:
    mod_N[mod] = 1

ans = 0
for i in mod_N:
  ans += mod_N[i]*(mod_N[i]-1)/2
print(int(ans))

### FIXED CODE ###

s = input()
a = 0
mods = [0]*2019
mods[a] += 1
r = 1
for i in s[::-1]:
  a = (a+int(i)*r)%2019
  r = r*10%2019
  mods[a] += 1
ans = 0
for i in mods:
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

from decimal import Decimal
import math
a,b,n = map(str,input().split())

a = Decimal(a)
b = Decimal(b)
n = int(n)
ans = 0
for x in range(1,n+1):
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    ans = max(ans,tmp)

print(ans)

### FIXED CODE ###

from decimal import Decimal
import math
a,b,n = map(str,input().split())

a = Decimal(a)
b = Decimal(b)
n = int(n)
ans = 0
kouho = [min(b-1,n)]
for x in kouho:
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    ans = max(ans,tmp)
print(ans)
### BUGGY CODE ###

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = Counter(A).most_common()[::-1]

ans = 0
while len(c) > K:
    res = c.pop(0)
    ans += res[1]
print(ans)


### FIXED CODE ###

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = Counter(A).most_common()[::-1]

ans = 0
if len(c) > K:
    for i in range(len(c) - K):
        ans += c[i][1]

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

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

Q=int(input())
comb=[]
for i in range(Q):
    comb.append(list(map(int,input().split())))

ra=len(A)

sum_num=[0 for i in range(Q)]
for i in range(Q):
    A=[comb[i][1] if A[j]==comb[i][0] else A[j] for j in range(ra)]
    sum_num[i]=sum(A)

for i in sum_num:
    print(i)

### FIXED CODE ###

N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100050)}
Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(N):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)
### BUGGY CODE ###

N = int(input())
C = input()
cnt =0
maxlen = len(C)
while( "WR" in C ):
    cnt+=1
    tmp = C.index('W')
    tmp2 = C.rindex('R')
    tmp3 = ""
    tmp4 = ""
    tmp5 = ""

    if tmp != 0:
      tmp3 = C[0:tmp-1]
    if tmp2 != maxlen-1:    
      tmp5 = C[tmp2+1:maxlen]
    if tmp2-tmp > 1:
      tmp4 = C[tmp+1:tmp2]
      
    C = tmp3+"R"+ tmp4 +"W"+ tmp5

    
print(cnt)
    


### FIXED CODE ###

N = int(input())
C = input()

tmp = C
tmp2 = len(tmp.replace("W",""))
tmp3 = C[0:tmp2]
ans = len(tmp3.replace("R",""))   
print(ans)