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

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

# 1を満たす数
# 1,~2を満たす数を求める

# def checkone(a,b,c):
# 	if (a!=b and b!=c and c!=a):
# 		return True
# 	else:
# 		return False

def check(i,j,N): # i,j,2j-iは違ったらTrue
	# i < jは保証
				# (0 > (2*i-j) or (2*i-j) >= N or checkone(S[i], S[j], S[2*i-j])) and
              	# (0 > (2*j-i) or (2*j-i) >= N or checkone(S[i], S[j], S[2*j-i])) #and
			  	# ( ((i+j)%2!=0) or checkone(S[i], S[j], S[abs(int((i+j)/2))]))
	if (0 > (2*j-i) or (2*j-i) >= N):
		# print("out of range")
		return False
	else:
		return (S[j] != S[2*j-i] and S[2*j-i] != S[i])
		# return checkone(S[i], S[j], S[2*j-i])

n_equal = 0
for i in range(N):
	for j in range(i,N):
		if( S[i]==S[j]):
			continue
		else:
			if(check(i,j,N)==True):
				n_equal+=1
				# print(i, j, 2*j-i)
				# print(S[i],S[j],S[2*j-i])
				# print("toukankaku")

# print("n_equal=",n_equal)

n_R = S.count('R')
n_G = S.count('G')
n_B = S.count('B')

n_all = n_R*n_G*n_B
# print("n_all=",n_all)

print(n_all-n_equal)


### FIXED CODE ###

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

# 1を満たす数
# 1,~2を満たす数を求める

# def checkone(a,b,c):
# 	if (a!=b and b!=c and c!=a):
# 		return True
# 	else:
# 		return False

def check(i,j,N): # i,j,2j-iは違ったらTrue
	# i < jは保証
				# (0 > (2*i-j) or (2*i-j) >= N or checkone(S[i], S[j], S[2*i-j])) and
              	# (0 > (2*j-i) or (2*j-i) >= N or checkone(S[i], S[j], S[2*j-i])) #and
			  	# ( ((i+j)%2!=0) or checkone(S[i], S[j], S[abs(int((i+j)/2))]))
	if (0 > (2*j-i) or (2*j-i) >= N):
		# print("out of range")
		return False
	else:
		return (S[j] != S[2*j-i] and S[2*j-i] != S[i])
		# return checkone(S[i], S[j], S[2*j-i])
# 2j-i <N
# j < (N+i)/2

n_equal = 0
for i in range(N):
	for j in range(i+1, int((N+i)/2)+1):
		if( S[i]==S[j]):
			continue
		else:
			if(check(i,j,N)==True):
				n_equal+=1
				# print(i, j, 2*j-i)
				# print(S[i],S[j],S[2*j-i])
				# print("toukankaku")

# print("n_equal=",n_equal)

n_R = S.count('R')
n_G = S.count('G')
n_B = S.count('B')

n_all = n_R*n_G*n_B
# print("n_all=",n_all)

print(n_all-n_equal)
### BUGGY CODE ###

mod=10**9+7
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

N=int(input())
A=list(map(int, input().split()))
ma=max(A)
keta=1
while ma>=2**keta:
  keta+=1
  
onekazu=[0 for i in range(keta)]
for i in range(N):
  temp=num2bi(A[i], keta)
  for j in range(keta):
    onekazu[-1-j]+=int(temp[-1-j])
    
out=0
for i in range(keta):
  temp=onekazu[i]*(N-onekazu[i])
  temp%=mod
  temp*=(2**(keta-1-i))
  temp%=mod
  out+=temp
  out%=mod
  
print(out)

### FIXED CODE ###

mod=10**9+7
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

N=int(input())
A=list(map(int, input().split()))
ma=max(A)
keta=1
while ma>=2**keta:
  keta+=1
  
onekazu=[0 for i in range(keta)]
k=str(keta)
for i in range(N):
  temp=format(A[i], '0'+str(k)+'b')
  onekazu=[onekazu[j]+1 if temp[j]=='1' else onekazu[j] for j in range(keta)]
    
out=0
out=sum([(onekazu[i]*(N-onekazu[i])%mod)*(2**(keta-1-i))%mod for i in range(keta)])
out%=mod  
print(out)
### BUGGY CODE ###

n = int(input())
arr = input()

ans = 0

while len(arr) > 1:
    left = -1
    right = -1

    if "W" in arr:
        left = arr.index("W")
    else:
        break
    if "R" in arr:
        right = len(arr) - arr[::-1].index("R") - 1
    else:
        break

    if left == -1 or right == -1 or left > right:
        break
    else:
        arr = arr[left + 1:right]
        ans += 1

print(ans)

### FIXED CODE ###

import numpy as np
n = int(input())
arr = input()

dp = [[0] * (n + 1) for _ in range(2)]
dp[1][0] = arr.count("R")

for i in range(1, n + 1):
    if arr[i - 1] == "W":
        dp[0][i] = dp[0][i - 1] + 1
        dp[1][i] = dp[1][i - 1]
    if arr[i - 1] == "R":
        dp[0][i] = dp[0][i - 1]
        dp[1][i] = dp[1][i - 1] - 1


dp = np.array(dp)

print(dp.min(axis=0).max())
### BUGGY CODE ###

from collections import Counter
S=input()
n=len(S)

T=[0]*n
U=[0]*n
for i in range(n):
    T[i]=int(S[i:])
    U[i]=T[i]%2019
T.append(0)
U.append(0)
    
#print(T)
#print(U)
#print(Counter(U))
ans=0
di= dict(Counter(U))
for a in di:
    b=di[a]
    if b>=2:
        ans += b*(b-1)//2
print(ans)

### FIXED CODE ###

S=input()
N=len(S)

T=[0]
for i in range(N):
    p = int(S[-1-i])
    T.append( (T[-1]+ pow(10,i,2019)*p)%2019 )
    
from collections import Counter
ans=0
U=dict(Counter(T))
for num in U:
    ans += U[num]*(U[num]-1)//2
print(ans)
### BUGGY CODE ###

import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

for i in range(1, N + 1):
    temp = math.floor(A*i/B) - (A * math.floor(i/B))
    if bk_temp > temp:
        max = bk_temp
        break
    if max < temp:
        max = temp
    bk_temp = temp

print(max)

### FIXED CODE ###

import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

if B <= N:
    max = math.floor(A * (B - 1) / B) - (A * math.floor((B - 1) / B))
else:
    # for i in range(1, N + 1):
    #     temp = math.floor(A*i/B) - (A * math.floor(i/B))
    #     print(str(i) + ' ' + str(temp))
    #     if bk_temp > temp:
    #         max = bk_temp
    #         break
    #     if max < temp:
    #         max = temp
    #     bk_temp = temp
    max = math.floor(A * N / B) - (A * math.floor((N) / B))

print(max)
### BUGGY CODE ###

h,w,k=map(int,input().split())
import numpy as np
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=np.cumsum(l,axis=1)
a=np.cumsum(a,axis=0)
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)

### FIXED CODE ###

h,w,k=map(int,input().split())
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=[[0 for i in range(w+1)] for i in range(h+1)]
for i in range(1,h+1):
    for j in range(1,w+1):
        a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+l[i][j]
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                if w2-1==w1:
                    t=h*w
                    break
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)
### BUGGY CODE ###

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

num = []
for i in range(N) : 
    num.append(A.index(max(A)) + 1)
    A[A.index(max(A))] = 0
    
for i in range(N) :
    print(num[N-1-i], end = ' ')


### FIXED CODE ###

import numpy as np

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

num = np.argsort(A)

for i in range (N) : 
    print(str(num[i]+1), end = ' ')
### BUGGY CODE ###

s = str(input())
Q = int(input())

for _ in range(Q):
	qu = input()
	if qu == '1':
		s = s[::-1]
	else:
		_, fi, ci = qu.split()
		if fi == '1':
			s = ci + s
		if fi == '2':
			s += ci
print(s)

### FIXED CODE ###

from collections import deque
import sys

def main():
    s = sys.stdin.readline().strip()
    qn = int(sys.stdin.readline().strip())
    qs = [input().split() for _ in range(qn)]

    s = deque(s)
    r = 1
    for q in qs:
        if len(q) == 1:
            r = r * -1

        else:
            if q[1] == '1':
                if r == 1:
                    s.appendleft(q[2])
                else:
                    s.append(q[2])
            else:
                if r == 1:
                    s.append(q[2])
                else:
                    s.appendleft(q[2])

    if r == 1:
        print(''.join(s))
    else:
        s.reverse()
        print(''.join(s))

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

import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int,input().split()))
cnt = 0
s = 0

def ers(a,cnt,s):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(s,len(a)):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            return ers(a,cnt,s)
        else:
            s += 1
    return cnt

res = ers(a,cnt,s)

print(str(res))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if A[i] != i+1-cnt:
        cnt += 1
if cnt == N:
    print(-1)
else:
    print(cnt)
### BUGGY CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x=int("".join(x),2)
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
def wari(now):
    tmp=cnt["1"]
    # print(flag,tmp)
    if flag==1:
        tmp-=1
    else:
        tmp+=1
    # print(tmp)
    if tmp==0:
        return 0
    now%=tmp
    ans=1
    while now:
        cnt2=0
        n=0
        while now>=pow(2,n):
            if now&1<<n:
                cnt2+=1
            n+=1
        now%=cnt2
        ans+=1
    return ans

for i in range(n):
    flag=0
    if x&1<<(n-1-i):
        flag=1
        x-=pow(2,(n-1-i))
    else:
        flag=0
        x+=pow(2,(n-1-i))

    print(wari(x))

    if x&1<<(n-1-i):
        x-=pow(2,(n-1-i))
    else:
        x+=pow(2,(n-1-i))

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x2=int("".join(x),2)
one=cnt["1"]
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
# print(x2,one)
lst=[0]*(2*10**5+10)
# lst[0]=-1
flaglst=[0,0]
if one-1!=0:
    flaglst[0]=x2%(one-1)
flaglst[1]=x2%(one+1)
# print(flaglst)

for i in range(2*10**5):
    now=i+1
    ans=0
    while now:
        cnt2=0
        m=0
        while now>=pow(2,m):
            if now&1<<m:
                cnt2+=1
            m+=1
        now%=cnt2
        ans+=1
    lst[i+1]=ans
# # print(lst[:100])

for i in range(n):
    tmp=0
    if x[i]=="1":
        tmp=flaglst[0]
        if one-1!=0:
            tmp-=pow(2,n-1-i,one-1)
            tmp%=one-1
        else:
            print(0)
            continue
    else:
        tmp=flaglst[1]
        tmp+=pow(2,n-1-i,one+1)
        tmp%=one+1
    # print(tmp,pow(2,n-1-i),one)

    print(lst[tmp]+1)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))

l.sort()

import bisect
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += bisect.bisect_left(l[j+1:], l[i] + l[j])

print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))

l.sort()

import bisect
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += bisect.bisect_left(l[j+1:], l[i] + l[j])

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

import numpy as np
import sys
input = sys.stdin.readline

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

for i in a:
    ans = ans*i
    if ans > 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break
 
if 0 in a:
    ans = 0

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

N,M= map(int,input().split())
gate=[list(map(int,input().split())) for i in range(M)]
count2=0
for i in range(1,N+1):
  count=0
  for j in gate:
    if j[0]<=i<=j[1]:
      count+=1
  if count==M:
    count2+=1
print(count2)

### FIXED CODE ###

N,M= map(int,input().split())
gate=[list(map(int,input().split())) for i in range(M)]
count2=0

min1=1
max1=N

for j in gate:
  if j[0]>min1:
    min1=j[0]
  if j[1]<max1:
    max1=j[1]
if max1>=min1:
  print(max1-min1+1)
else:
  print(0)
### BUGGY CODE ###

from collections import Counter
n = int(input())
s = input()
ans = float('inf')
e = int(s.count('E'))

for i in range(n):
    a = Counter(s[:i])['W']
    b = e - (i-a)

    ans = min(ans, a + b)

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = input()
e = int(s.count('E'))
ans = e

a = 0
for i in range(n):
    if s[i] == 'W':
        a += 1
    b = e - ((i+1)-a)
    ans = min(ans, a+b)


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

def gcd(a,b):
    return gcd(b,a%b) if b else a

def merge(a,us,vs):
    i,j,res=0,0,[]
    while i<len(us) and j<len(vs):
        if a[us[i]]>=a[vs[j]]:
            res.append(us[i])
            i+=1
        else:
            res.append(vs[j])
            j+=1
    return res+us[i:]+vs[j:]

def dfs(g,a,u,vis):
    vis[u]=True
    res=[]
    for v in g[u]:
        if not vis[v]:
            res=merge(a,res,dfs(g,a,v,vis))
    return [u]+res

while 1:
    try:
        n=int(input())
        a=sorted(map(int,input().split()))
    except: break

    g=[[j for j in range(n) if i!=j and gcd(a[i],a[j])!=1] for i in range(n)]
    vis=[False]*n
    res=[]
    for u in range(n):
        if not vis[u]:
            res=merge(a,res,dfs(g,a,u,vis))
    print(' '.join(str(a[u]) for u in res))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)

def gcd(a: int, b:int):
    while b:
        a,b=b,a%b
    return a

def merge(a,us,vs):
    i,j,res=0,0,[]
    while i<len(us) and j<len(vs):
        if a[us[i]]>=a[vs[j]]:
            res.append(us[i])
            i+=1
        else:
            res.append(vs[j])
            j+=1
    return res+us[i:]+vs[j:]

def dfs(g,a,u,vis):
    vis[u]=True
    res=[]
    for v in g[u]:
        if not vis[v]:
            res=merge(a,res,dfs(g,a,v,vis))
    return [u]+res

while 1:
    try:
        n=int(input())
        a=sorted(map(int,input().split()))
    except: break

    g=[[] for _ in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            if gcd(a[i],a[j])!=1:
                g[i].append(j)
                g[j].append(i)

    vis=[False]*n
    res=[]
    for u in range(n):
        if not vis[u]:
            res=merge(a,res,dfs(g,a,u,vis))
    print(' '.join(str(a[u]) for u in res))
### BUGGY CODE ###

N = int(input())
city = []
for i in range(N):
    x,y = map(int,input().split())
    city.append([x,y,i])
side = []
city.sort(key=lambda x:x[0])
for i in range(N-1):
    side.append([city[i+1][0] - city[i][0],city[i][2] ,city[i+1][2]])

city.sort(key=lambda x:x[1])
for i in range(N-1):
    side.append([city[i+1][1] - city[i][1],city[i][2] ,city[i+1][2]])
side.sort()
node = [[i,[i]]for i in range(N)]
ans = 0
for cost,a,b in side:
    if node[a][0] != node[b][0]:
        ans += cost
        c,d = node[node[a][0]],node[node[b][0]]
        if len(c[1]) < len(d[1]):
            for i in c[1]:
                node[i][0] = d[0]
            d[1] = d[1] + c[1]
        else:
            for i in d[1]:
                node[i][0] = c[0]
            c[1] = d[1] + c[1]
print(ans)
            





### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
cityx = [[0,i]for i in range(N)]
cityy = [[0,i]for i in range(N)]
for i in range(N):
    x,y = map(int,input().split())
    cityx[i][0] = x
    cityy[i][0] = y

cityx.sort()
cityy.sort()
side = []
for i in range(N-1):
    side.append([cityx[i+1][0]-cityx[i][0], cityx[i+1][1], cityx[i][1]])
    side.append([cityy[i+1][0]-cityy[i][0], cityy[i+1][1], cityy[i][1]])
side.sort()
ans = 0
per = [i for i in range(N)]
rank = [0]*N
def find(x):
    if per[x] == x:
        return x
    else:
        per[x] = find(per[x])
        return per[x]

ans = 0

for cost,x,y in side:
    x = find(x)
    y = find(y)
    if x != y:
        ans += cost
        if rank[x] < rank[y]:
            per[x] = y
        else:
            per[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

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

from collections import deque


n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre




pre = dfs(graph, 0, n-1)
route = [n-1]
while route[0]!=0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)


def dfs_cnt(graph, start):
    cnt = 1
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            cnt += 1
            que.append(nxt)
    return cnt


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt


if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')
### BUGGY CODE ###

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

for k in range(K):
  copy=[0]*N
  for i in range(N):
    kido=light[i]
    smin=max(0,i-kido)
    smax=min(N-1,i+kido)
    for j in range(smin, smax+1):
      copy[j]+=1
  light=copy
  if N==min(light):
    break
print(*light)

### FIXED CODE ###

N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for i in range(1,N):
    imo[i]+=imo[i-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])
### BUGGY CODE ###

l,r = map(int, input().split())
# l=0
# r=10000

mini=l*r%2019
for i in range(l,r+1):
    if(i%2019==0):
        break;
    for j in range(i+1,r+1):
        if(i*j%2019<mini):
            mini=i*j%2019
print(mini)

### FIXED CODE ###

l,r = map(int, input().split())
# l=10000000
# r=100000000

mini=l*r%2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        if(j%2019==0):
            mini=0
            break;
        
        if(i*j%2019<mini):
            mini=i*j%2019
    if mini==0:
        break;
print(mini)
### BUGGY CODE ###

S = input()
boundaries = []
boundaries_RL = []
boundaries_LR = []
children = [0] * len(S)

for i in range(1, len(S)):
    if S[i-1] == 'R' and S[i] == 'L':
        boundaries.append(i)
        boundaries_RL.append(i)
    elif S[i-1] == 'L' and S[i] == 'R':
        boundaries_LR.append(i)
        boundaries.append(i)

for j in range(len(boundaries)):
    if boundaries[j] in boundaries_LR:
        continue
    else:  # boundaries[j]は、RLとなっているところの、Lのindex
        '''group1: Rより左側のchildren'''
        if j == 0:
            group1 = boundaries[j]
        else:
            group1 = boundaries[j] - boundaries[j-1]
        if group1 % 2 == 0:
            children[boundaries[j]] += group1 // 2
            children[boundaries[j]-1] += group1 // 2
        else:
            children[boundaries[j]-1] += group1 // 2 + 1
            children[boundaries[j]] += group1 // 2
        '''group2: Lより右側のchildren'''
        if j == len(boundaries)-1:
            group2 = len(S) - boundaries[j]
        else:
            group2 = boundaries[j+1] - boundaries[j]
        if group2 % 2 == 0:
            children[boundaries[j]] += group2 // 2
            children[boundaries[j]-1] += group2 // 2
        else:
            children[boundaries[j]] += group2 // 2 + 1
            children[boundaries[j]-1] += group2 // 2

print(*children)


### FIXED CODE ###

S = input()


def solve(s):
    buf = [1] * len(s)

    for i in range(len(buf) - 2):
        if s[i] == "R" and s[i + 1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0

    for i in range(len(buf) - 1, 1, -1):
        if s[i] == "L" and s[i - 1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0

    return " ".join(map(str, buf))


print(solve(S))
### BUGGY CODE ###

X,Y,Z,K=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(l):
  return A[l[0]]+B[l[1]]+C[l[2]]

def priq(a,b,c):
  if [a,b,c] not in pri:

    for i in range(len(pri)-1,-1,-1):
      if dp(pri[i])<dp([a,b,c]):
        pri.insert(i+1,[a,b,c])
        return
    pri.insert(0,[a,b,c])

pri.append([0,0,0])
for i in range(K):
  x,y,z=pri.pop(-1)
  print(dp([x,y,z]))
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)



### FIXED CODE ###

import heapq
X,Y,Z,K=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)