Harryxun/stf_run huggingface dataset:
# Single Source Shortest Path
infty = 99999

[vertex, edge, r] = list(map(int, input("").split()))
D = [[infty for j in range(vertex)] for i in range(vertex)]
for i in range(edge):
    data = list(map(int, input("").split()))
    D[data[0]][data[1]] = data[2]

def Dijkstra(root, n):
    visited_order = 0
    label = [0 for i in range(n)]
    global D
    global infty
    d = D[root]
    visited_order += 1
    label[root] = visited_order

    while visited_order < n:
        min_cost = infty

        for i in range(n):
            if label[i] != 0:
                continue

            if min_cost > d[i]:
                min_cost = d[i]
                min_node = i

        if min_cost == infty:
            break

        visited_order += 1
        label[min_node] = visited_order

        for i in range(n):
            if label[i] != 0:
                continue
            if d[i] > d[min_node] + D[min_node][i]:
                d[i] = d[min_node] + D[min_node][i]

    del visited_order
    del label
    del D
    del min_cost

    d[root] = 0
    return d

result = Dijkstra(r, vertex)

for i in range(vertex):
    if result[i] == infty:
        result[i] = "INF"
    print(result[i])




### FIXED CODE ###

# Single Source Shortest Path
import heapq

[vertex, edge, r] = list(map(int, input("").split()))
infty = 999999999
final_c = [infty for i in range(vertex)]
dict_c = [[] for i in range(vertex)]

for i in range(edge):
    [e1, e2, c] = list(map(int, input("").split()))
    dict_c[e1].append((e2, c))

final_c[r] = 0
root_c = [(final_c[r], r)]

def Dijkstra(root, n):
    global infty, root_c, final_c, dict_c, root_c
    while(root_c):
        (cost, v) = heapq.heappop(root_c)
        if cost > final_c[v]:
            continue
        for i in range(len(dict_c[v])):
            (e2, c) = dict_c[v][i]
            if final_c[e2] > final_c[v] + c:
                final_c[e2] = final_c[v] + c
                heapq.heappush(root_c, (final_c[e2], e2))

Dijkstra(r, vertex)
for i in range(vertex):
    if final_c[i] == infty:
        print("INF")
    else:
        print(final_c[i])
def totalcost(i,cost,N):
  if i>=N:
    return 0
  option1 = abs(cost(i)-cost(i+1)) + totalcost(i+1,cost,N)
  ans = option1
  if i+2<=N:
    option2 = abs(cost(i)-cost(i+2)) + totalcost(i+2,cost,N)
    ans = min(option1,ans)
  return ans

n = int(input())
cost = list(map(int,input().split()))
cost = [0]+cost
print(totalcost(1,cost,n))

### FIXED CODE ###

def totalcost_recur(i,cost,N,lookup):
  if i>=N:
    return 0
  if i in lookup:
      return lookup[i]
  option1 = abs(cost[i]-cost[i+1]) + totalcost_recur(i+1,cost,N,lookup)
  ans = option1
  if i+2<=N:
    option2 = abs(cost[i]-cost[i+2]) + totalcost_recur(i+2,cost,N,lookup)
    ans = min(option2,ans)
  lookup[i] = ans
  return ans



def totalcost_dp(cost,N):
    dp = [0]*(N+1)
    dp[1] = 0
    dp[2] = abs(cost[2]-cost[1])
    i = 3
    while i<=N:
        option1 = dp[i-1]+abs(cost[i]-cost[i-1])
        option2 = dp[i-2]+abs(cost[i]-cost[i-2])
        dp[i] = min(option1,option2)
        i+=1

    return dp[N]


n = int(input())
cost = list(map(int,input().split()))
cost = [0]+cost
lookup = {}

print(totalcost_dp(cost,n))
x = input()
child_list = map(int, input().split())

for x>0:
  if x - min(child_list) > 0:
    please_child +=1
    child_list = child_list.pop(min(child_list))
  else:
    break
print(please_child)

### FIXED CODE ###

N, x = map(int, input().split())
child_list = list(map(int, input().split()))

if len(child_list) == 1:
    if x > min(child_list):
        please_child = 0
    elif x == min(child_list):
        please_child = 1
elif len(child_list) > 1:
    nokori = x - min(child_list)
    please_child = 0 
    while nokori >=0:
        please_child +=1
        mini = min(child_list)
        child_list.remove(mini)
        if child_list == []:
            break
        if len(child_list) == 1:
            if nokori == min(child_list):
                please_child += 1
            if nokori > min(child_list):
                break
            else:
            	break
        else:    
            nokori -= min(child_list)
print(please_child)
import sys 

A, B = int(input()).split()
cond_older = (13 > A)
cond_young = (6 <= A) & (13 >= A)

ans = (
  B if cond_older else
  B//2 if cond_young else
  0
)

print(ans)

### FIXED CODE ###

import sys 
 
A, B = map(int, input().split())
cond_older = (12 < A)
cond_young = (6 <= A) & (12 >= A)
 
ans = (
  B if cond_older else
  B//2 if cond_young else
  0
)
 
print(ans)
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)

### FIXED CODE ###

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

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  l=arr[0]
else:
  l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)
N = input()
x = N[0]
xxx = int(3*x)
if N <= XXX:
  print(xxx)
else:
  x = int(x)+1
  print(100*x + 10*x + x)

### FIXED CODE ###

N = input()
x = N[0]
xxx = int(3*x)
if int(N) <= xxx:
  print(xxx)
else:
  x = int(x)+1
  print(100*x + 10*x + x)
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


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

clist = [X]
diff = []

a = list(map(int, input().split()))
clist.extend(a)

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

### FIXED CODE ###

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


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

clist = [X]
diff = []

a = list(map(int, input().split()))
clist.extend(a)

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop() 
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

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

re = 1
fa = factorize(M)
div_list = divisorize(fa)

for i in range(len(div_list)):
    num = 1
    for j in range(len(div_list[-1 - i])):
        l = div_list[-1-i][j]
        num *= l[0] ** l[1]
    d = M // num 
    if d >= N and num > re:
        re = num
print(re)

### FIXED CODE ###

def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop() 
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

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

if M == 1:
    print(1)
else:
    re = 1
    fa = factorize(M)
    div_list = divisorize(fa)

    for i in range(len(div_list)):
        num = 1
        for j in range(len(div_list[-1 - i])):
            l = div_list[-1-i][j]
            num *= l[0] ** l[1]
        d = M // num 
        if d >= N and num > re:
            re = num
    print(re)
print('Possible' if sum(list(map(int, input())))%3==0 else 'Impossible')

### FIXED CODE ###

a,b=map(int,input().split())
print('Possible' if (a%3==0 or b%3==0 or (a+b)%3==0) else 'Impossible')
import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(1, 100) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L[0][0])

### FIXED CODE ###

import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(0, 102) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L[0][0])
n,m = map(int,input().split())
l = [int(input()) for _ in range(m)]
q = 10**9+7
memo = [0]*(n+1)
memo[0]=1
def a(x):
  if x in l :
    return 0
  elif x==1:
    memo[1]=1
    return 1
  else:
    if memo[x]!=0:
      return memo[x]
    else:
      memo[x] = a(x-1)+a(x-2)
      return (a(x-1)+a(x-2))%q
print(a(n)%q)

### FIXED CODE ###

n,m = map(int,input().split())
l = [int(input()) for _ in range(m)]
q = 10**9+7
memo = [-1]*(n+1)
memo[0]=1
su = 0
if 1 in l:
  memo[1]=0
else:
  memo[1]=1
for j in l:
  memo[j]=0
  
for i in range(2,n+1):
  if memo[i]==0:
    continue
  else:
    memo[i]=((memo[i-1]%q)+(memo[i-2]%q))%q
print(memo[-1]%q)
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C >= P else B+(P-C)*D))
d=int(input())
t=int(input())
s=int(input())
if t>=d/s:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")
N = int(input())
graph = [[] for _ in range(N+1)]
AB = []

for _ in range(N-1):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)
  AB.append((a, b))

root = 1
parent = [0] * (N+1)
order = []
stack = [root]

while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

color = [-1] * (N+1)
K = -1

for x in order:
    temp = color[x]
    c = 1
    for y in graph[x]:
        if y == parent[x]:
            continue
        if c == temp:
            c += 1
        color[y] = c
        K = max(K, c)
        c += 1

ans = []

for a, b in AB:
    if parent[a] == b:
        ans.append(color[a])
    else:
        ans.append(color[b])

print(K)
for i in ans:
  print(ans)

### FIXED CODE ###

N = int(input())
graph = [[] for _ in range(N+1)]
AB = []

for _ in range(N-1):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)
  AB.append((a, b))

root = 1
parent = [0] * (N+1)
order = []
stack = [root]

while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

color = [-1] * (N+1)
K = -1
for x in order:
    ng = color[x]
    c = 1
    for y in graph[x]:
        if y == parent[x]:
            continue
        if c == ng:
            c += 1
        K = max(c, K)
        color[y] = c
        c += 1

ans = []

for a, b in AB:
    if parent[a] == b:
        ans.append(color[a])
    else:
        ans.append(color[b])

print(K)
for i in ans:
  print(i)
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if Y[q[i]]==1:
        break
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))      

### FIXED CODE ###

N,M = map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s)-1 for s in p]
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))
N = int(input())
L = [-1 for i in range(N)]
flg = [0 for i in range(N)]
M = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  M[u-1].append([v-1, w%2])
  M[v-1].append([u-1, w%2])
L[0] = 0
def dist(m, d):
  L[m] = d % 2
  for i in M[m]:
    if L[i[0]] == -1:
      dist(i[0], i[1] + d)
dist(0, 0)
for i in range(N):
  print(L[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N = int(input())
L = [-1 for i in range(N)]
flg = [0 for i in range(N)]
M = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  M[u-1].append([v-1, w%2])
  M[v-1].append([u-1, w%2])
L[0] = 0
def dist(m, d):
  L[m] = d % 2
  for i in M[m]:
    if L[i[0]] == -1:
      dist(i[0], i[1] + d)
dist(0, 0)
for i in range(N):
  print(L[i])
import sys
input = sys.stdin.readline
a,b,c=map(int,input().split()))
for i in range(b):
    if a*i%b==c:
        print("YES")
        exit()
print("NO")


### FIXED CODE ###

import sys
input = sys.stdin.readline
a,b,c=map(int,input().split())
for i in range(b+1):
    if a*i%b==c:
        print("YES")
        exit()
print("NO")
four_w = []
seven_w = []
cross = []

for i in range(0,100):
    if i % 4 == 0:
        four_w.append(i)
    elif i % 7 ==0:
        seven_w.append(i)

for four in four_w:
    for seven in seven_w:
        cross.append(four + seven)

n = int(input())

if n in cross:
    print("Yes")
elif n in seve_w:
    print("Yes")
elif n in four_w:
    print("yes")
else:
    print("No")

### FIXED CODE ###

four_w = []
seven_w = []
cross = []

for i in range(1,101):
    if i % 4 == 0:
        four_w.append(i)
    elif i % 7 ==0:
        seven_w.append(i)

for four in four_w:
    for seven in seven_w:
        cross.append(four + seven)

n = int(input())

if n in cross:
    print("Yes")
elif n in seven_w:
    print("Yes")
elif n in four_w:
    print("Yes")
else:
    print("No")
wlist = list(input())
wlength = 0

for w in wlist:
    if not w in ["A","T","G","C"]:
        tmp = 0
        continue

    else:
        tmp += 1
        if tmp >= wlength:
            wlength = tmp
print(wlength)




### FIXED CODE ###

wlist = list(input())
wlength = 0
tmp = 0
for w in wlist:
    if not w in ["A","T","G","C"]:
        tmp = 0
        continue

    else:
        tmp += 1
        if tmp >= wlength:
            wlength = tmp
print(wlength)
def f(P,M):
    return P[0]*M+P[1]

def g(X,Y,M):
    (a,b)=X
    (x,y)=Y

    return (a*x*M+a*y+b*x+(y*b)//M,(y*b)%M)

N,K=map(int,input().split())
A=list(map(int,input().split()))
M=10**9+7

P,Q=[],[] #P,Q...+,-の要素
Z=0 #Z...0の個数

for a in A:
    if a>0:
        P.append(divmod(a,M))
    elif a<0:
        Q.append(divmod(a,M))
    else:
        Z+=1

P.sort(reverse=True)
X=[(0,1)]
(a,b)=(0,1)
for (x,y) in P:
    a,b=g((a,b),(x,y),M)
    X.append((a,b))

Q.sort()
Y=[(0,1)]
(a,b)=(0,1)
for (x,y) in Q:
    a,b=g((a,b),(x,y),M)
    Y.append((a,b))

J=-1
S=len(P)
for m in range(0,len(Q)+1,2):
    if 0<=K-m<=S:
        J=max(J,f(g(X[K-m],Y[m],M),M))

if J>0:
    print(J%M)
else:
    if Z==0:
        J=1
        for i in range(K):
            J*=Q[-(i+1)]
        print(J%M)
    else:
        print(0)


### FIXED CODE ###

from collections import deque
import sys

N,K=map(int,input().split())
A=list(map(int,input().split()))
M=10**9+7

if N==K:
    T=1
    for a in A:
        T=(T*a)%M
    print(T)
    sys.exit()
elif max(A)<0 and K%2==1:
    A.sort(reverse=True)
    T=1
    for i in range(K):
         T=(T*A[i])%M
    print(T)
    sys.exit()
    
U=list(map(lambda x:max(x,0),A))
U.sort(reverse=True)
U=deque(U)

V=list(map(lambda x:min(x,0),A))
V.sort()
V=deque(V)

T=1
Y=0
while Y<K:
    x1,x2=U[0],U[1]
    y1,y2=V[0],V[1]

    if Y==K-1 or x1*x2>=y1*y2:
        Y+=1
        T=(T*x1)%M
        _=U.popleft()
        U.append(0)
    else:
        Y+=2
        T=(T*y1*y2)%M
        _=V.popleft()
        _=V.popleft()
        V.append(0)
        V.append(0)
print(T)
import string
s = input()

s = sorted(set(s))
moji = [chr(i) for i in range(ord('a'), ord('z')+1)]
# print(s)
# print(moji)

def b():
    for i in range(len(moji)):
        if moji[i] != s[i]:
            return moji[i]
    return "None"

print(b())



### FIXED CODE ###

import string
s = input()

s = sorted(set(s))
moji = [chr(i) for i in range(ord('a'), ord('z')+1)]
# print(s)
# print(moji)

def b():
    for i in range(len(moji)):
        if i > len(s)-1 or moji[i] != s[i]:
            return moji[i]
    return "None"

print(b())
N = input()
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)

for a in x:
  z *= a
  if z > 1000000000000000:
    print(-1)
    return
  
print(z)

### FIXED CODE ###

import sys
N = int(input())
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)
  sys.exit()
  
for a in x:
  z = a*z
  if z > 10**18:
    print(-1)
    sys.exit()
  
print(z)
t = list(input())
del s [-2:]
a = 2
while s[:len(s)//2] != s[len(s)//2:]:
    s = s[:-2]
    a += 2
print(a)

### FIXED CODE ###

s = list(input())
l = len(s) - 2
while s[:l//2] != s[l//2:l]:
    l -= 2
print(l)
# -*- coding: utf-8 -*-

# input
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]

# solve & output
for i in range(N):
    min_diff = 10 ** 8
    for j in range(M):
        diff = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_diff > diff:
            min_diff = diff
            ans = j + 1
    print(ans)


### FIXED CODE ###

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

# input
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]

# solve & output
for i in range(N):
    min_diff = 10 ** 9
    for j in range(M):
        diff = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_diff > diff:
            min_diff = diff
            ans = j + 1
    print(ans)
def exists(value,n,ms,cs):
    if (len(value) != n):
        return False
    if all([value[i-1] == c for i,c in zip(ms,cs)]):
        return True
    return False
def unzip(li):
    return list(map(list, zip(*li)))
n,m = [int(e) for e in input().split()]
m = [input().split() for e in range(m)]
ms,cs = unzip(m)
ms = [int(e) for e in ms]
result = -1
for i in range(1000):
    if exists(str(i),n,ms,cs):
        result = i
        break
print(result)

### FIXED CODE ###

n,m = map(int,input().split())
sc = [[i for i in map(int,input().split())] for j in range(m)]
start = 0
goal = 0
if n==1:
  start = 0
  goal = 9
elif n==2:
  start = 10
  goal = 99
elif n==3:
  start = 100
  goal = 999

flag = 1
ans = -1
for num in range(start,goal+1):
  flag = 1
  for i in range(m):
    if str(num)[sc[i][0]-1] != str(sc[i][1]): #両辺ともちゃんとstrで変換
      flag = 0
  if flag == 1:
    ans = num
    break

print(ans)
size=int(input())
h = list(map(int,input().split()))
dp = 0
for i in range(0, size):
    if i < size-1:
        if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
            dp += abs(h[i+1]-h[i])
        else:
            dp += abs(h[i+2]-h[i])
    if i = size-1:
        dp += abs(h[i+2]-h[i])
    except:
        pass
print(dp)

### FIXED CODE ###

size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])
n = int(raw_input())
list_str = []
for count in range(0,n):
    list_str.append(raw_input())
if n != 1:
	for count in range(0,n-1):
	    if count == 0:
	        compare1 = set(list_str[count])
	    else:
	        compare1 = set(output)
	    compare2 = set(list_str[count+1])
	    output = list(compare1 & compare2)
else:
	output = list_str
tmp_output = ""
for count1 in range(0,len(output)):
	for count2 in range(0,n-1):
		num = list_str[count2].count(output[count1])
		if num < min:
			min = num
		print min
	tmp_output += min*output[count1]
output = tmp_output
#output.sort()
output = ''.join(output)
print output

### FIXED CODE ###

n = int(raw_input())
list_str = []
for count in range(0,n):
    list_str.append(raw_input())
if n != 1:
	for count in range(0,n):
	    if count == 0:
	        output = set(list_str[count])
	    else:
	        compare1 = set(output)
	    	compare2 = set(list_str[count])
	    	output = list(compare1 & compare2)

	tmp_output = ""
	
	for count1 in range(0,len(output)):
		#print output[count1]
		min = 1000
		for count2 in range(0,n):
			num = list_str[count2].count(output[count1])
			if num < min:
				min = num
			#print min
		tmp_output += min*output[count1]
	output = tmp_output
	#output.sort()
else:
	output = list_str[0]
output = sorted(output)
output = ''.join(output)
print output
x = int(input())

if len(str(x)) == 3:
  mod = int(str(x)[1:])
  n = x//100
  print("1" if mod < 5*n else "0")
else:
  mod = int(str(x)[2:])
  n = int(str(x)[:2])
  print("1" if mod < 5*n else "0")



### FIXED CODE ###

x = int(input())
if len(str(x)) < 3:
  print(0)
else:
  print("1" if x//100 >= x/105 else "0")
s = list(input())
n = len(s)

ans = []
for i in range(n):
    if s[i] == '0':
        ans.append('0')
    if s[i] == '1':
        ans.append('1')
    if s[i] == 'B':
        ans[-1] = ''

print("".join(ans))


### FIXED CODE ###

s = list(input())
n = len(s)

ans = []
for i in range(n):
    if s[i] == '0':
        ans.append('0')
    if s[i] == '1':
        ans.append('1')
    if s[i] == 'B':
        if ans:
            ans.pop()

print("".join(ans))
S = input()
if S[0::2].count("L") + S[1::2].count("R") = 0: print("Yes")
  else: print("No")



### FIXED CODE ###

S = input()
if S[0::2].count("L") + S[1::2].count("R") == 0: print("Yes")
else: print("No")
L, R = map(int, input().split())

MOD = 2019
ans = 2018

if R - L + 1 >= 2019:
    print(0)
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            n = (i*j)%MOD
            ans = min(n, ans)
    print(ans)

"""
# TLEギリギリ
R = min(R, L+(2019)) # 長さを制限しても同じ2019をyoutube通りに2019*2にするとTLE
MOD = 2019
ans = 2018

for i in range(L, R): # iはLからR-1まで
    for j in range(i+1, R+1): # jはi+1からRまで
        n = (i*j)%MOD
        ans = min(n, ans)

print(ans)



### FIXED CODE ###

L, R = map(int, input().split())

R = min(R, L+(2019)) # 長さを制限しても同じ
MOD = 2019
ans = 2018

for i in range(L, R): # iはLからR-1まで
    for j in range(i+1, R+1): # jはi+1からRまで
        n = (i*j)%MOD
        ans = min(n, ans)

print(ans)