Harryxun/stf_run huggingface dataset:
import numpy as np

N, M = map(int, input().split())
ABC = np.zeros((N, 3))
for i in range(N):
    ABC[i][0], ABC[i][1], ABC[i][2] = map(int, input().split())
DEF = np.zeros((M, 3))
for i in range(M):
    DEF[i][0], DEF[i][1], DEF[i][2] = map(int, input().split())

# 座標圧縮
x_co = {-10**9-1, 10**9+1}
y_co = {-10**9-1, 10**9+1}
for i in range(N):
    x_co.add(ABC[i][0])
    x_co.add(ABC[i][1])
    y_co.add(ABC[i][2])
for i in range(M):
    x_co.add(DEF[i][0])
    y_co.add(DEF[i][1])
    y_co.add(DEF[i][2])

x_co = np.array(sorted(list(x_co)))
y_co = np.array(sorted(list(y_co)))
xL = len(x_co) - 1
yL = len(y_co) - 1
x_co_d = {x_co[i]: i for i in range(xL+1)}
y_co_d = {y_co[i]: i for i in range(yL+1)}

# 柵の存在
s_ex_tate = np.zeros((yL+1, xL))
s_ex_yoko = np.zeros((xL+1, yL))
for i in range(N):
    a = x_co_d[ABC[i][0]]
    b = x_co_d[ABC[i][1]]
    c = y_co_d[ABC[i][2]]
    s_ex_tate[c][a:b] = 1
for i in range(M):
    d = x_co_d[DEF[i][0]]
    e = y_co_d[DEF[i][1]]
    f = y_co_d[DEF[i][2]]
    s_ex_yoko[d][e:f] = 1

# 初期位置
for i in range(xL):
    if x_co[i+1] > 0:
        xf = [i]
        break
    if x_co[i+1] == 0:
        xf = [i, i+1]
        break
for i in range(yL):
    if y_co[i+1] > 0:
        yf = [i]
        break
    if y_co[i+1] == 0:
        yf = [i, i+1]
        break

def sq(x, y):
    return int((x_co[x+1]-x_co[x]) * (y_co[y+1]-y_co[y]))

# 探索
Q = []
# houmon = [[False] * yL for _ in range(xL)]
houmon = np.zeros((xL, yL))
ans = 0
is_inf = False
for x in xf:
    for y in yf:
        houmon[x][y] = 1
        Q.append((x, y))

while Q:
    x, y = Q.pop()
    if x in [0, xL-1] or y in [0, yL-1]:
        is_inf = True
        break
    ans += sq(x, y)
    if (not houmon[x-1][y]) and (not s_ex_yoko[x][y]):
        houmon[x-1][y] = True
        Q.append((x-1, y))
    if (not houmon[x][y-1]) and (not s_ex_tate[y][x]):
        houmon[x][y-1] = True
        Q.append((x, y-1))
    if (not houmon[x+1][y]) and (not s_ex_yoko[x+1][y]):
        houmon[x+1][y] = True
        Q.append((x+1, y))
    if (not houmon[x][y+1]) and (not s_ex_tate[y+1][x]):
        houmon[x][y+1] = True
        Q.append((x, y+1))
    
if is_inf:
    print('INF')
else:
    print(ans)

### FIXED CODE ###

N = int(input())

# 約数
# O(N**0.5)
def yakusu(N):
    ret = [[], []]
    for i in range(1, int(N ** 0.5)+1):
        if N % i == 0:
            ret[0].append(i)
            if i ** 2 != N:
                ret[1].append(N//i)
    return ret[0] + ret[1][::-1]

ans = 0
for a in yakusu(N):
    if a == 1: continue
    
    if N % a == 0:
        b = N
        while b % a == 0:
            b //= a
        if (b-1) % a == 0:
            ans += 1
print(ans + len(yakusu(N-1)) - 1)
N,T=map(int,input().split())
ct=[list(map(int,input().split())) for a in range(N)]

ct=sorted(ct, key=lambda x:(x[0],x[1]))

print(ct[0])
for i in range(N):
    if ct[i][1]<=t:
        print(ct[i][0])
        break
else:
    print('TLE')

### FIXED CODE ###

N=int(input())
if N==1:
    print('Hello World')
else:
    A=int(input())
    B=int(input())
    print(A+B)
N=int(input())
A=int(input())
B=int(input())

int train=A*N
int taxi=B
if (train<=taxi):
  print(train)
else:
  print(taxi)

### FIXED CODE ###

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

train=a[0]*a[1]
taxi=a[2]
if (train<=taxi):
  print(train)
else:
  print(taxi)
# coding: utf-8
# Your code here!

input1 = [int(x) for x in input().split()]
lake = input1[0]
homes = input1[1]
input2 = [int(x) for x in input().split()]

result = 1000000
last = homes - 1
for x in range(homes):
    forward = 0
    backward = 0
    start = input2[x]

    # forward
    if x == 0:
        forward = input2[last] - start
    else:
        forward = (lake - start) + input2[x - 1]
    
    # backward
    if x == last:
        backward = (start) - input2[0]
    else:
        backward = (start) + lake - (input2[x + 1])

    #print("forward: {}, backward: {}".format(forward, backward))
    result = min(result, forward, backward)

print(result)


### FIXED CODE ###

string = input()

if string[2] == string[3] and string[4] == string[5]:
  print("Yes")
else:
  print("No")
Tmp = []
Tmp = input().rstrip().split(',')
 
sA = (Tmp[0])
sB = (Tmp[1])
sC = (Tmp[2])
 
print(sA + ' ' + sB ' ' + sC)


### FIXED CODE ###

Tmp = []
Tmp = input().rstrip().split(',')
 
sA = (Tmp[0])
sB = (Tmp[1])
sC = (Tmp[2])
 
print(sA + ' ' + sB +' ' + sC)
LIM=200002
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200002
for i in range(1,200002):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)+1
c=bin_sum2(Y)-1
e=int(Y,2)%d
f=int(Y,2)%c
for i in range(X):
    if Y[i]=="0":
        b=d
        g=e+2**(X-1-i)%d
    else:
        b=c
        g=e-2**(X-1-i)%c
    if g==0:
        print(0)
    else:
        print(M[g%b])

### FIXED CODE ###

from collections import deque
LIM=200004
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200005
for i in range(1,200004):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)
e=int(Y,2)%(d+1)
f=int(Y,2)%max(1,(d-1))
O=[1]*(X+2)
P=[1]*(X+2)
q=max(d-1,1)
for i in range(1,X+1):
    O[i]=O[i-1]*2%q
    P[i]=P[i-1]*2%(d+1)
for i in range(X):
    
    if int(Y[i])==1:
        b=max(d-1,1)
        flag=max(0,d-1)
        g=(f-O[X-1-i]+b)%b
    else:
        b=d+1
        flag=1
        g=(e+P[X-1-i])%b

    if flag==0:
        print(0)
    elif g==0:
        print(1)
    else:
        print(M[g]+1)
from numpy import*;a,b,c=int_(input().split());print('YNEOS'[c%gcd(a,b)>0::2])

### FIXED CODE ###

from fractions import*;a,b,c=map(int,input().split());print('YNEOS'[c%gcd(a,b)>0::2])
n = int(input())
p = list(map(int, input().split(' ')))
#p = [list(map(int, input().split())) for _ in range(n)]
p = sorted(p, reverse=True)
if len(p) != n or n < 4:
  raise ValueError

#print(p[0], p[1:])
if p[0] < sum(p[1:]):
	print('Yes')
else:
	print('No')

### FIXED CODE ###


t, x = map(int, input().split(' '))
print(t/x)
N = int(input())
A = list(map(int,input().split()))
ans = 0
while all( a%2 == 0 for a in A ):
    a = [ i/2 for i in a ]
    ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)
N = int(input())
X=list(map(int, input().split())) 

X_max = max(X)
X_min = min(X)

answerlist = []
for x in range(X_min,X_max):
  newX = [(n-x)^2 for n in X]
  sum = sum(str(newX))
  answerlist.append(sum)
  
print(max(answerlist))
  
  
    
  


### FIXED CODE ###

N = int(input())
X=list(map(int, input().split())) 
X_max = max(X)
X_min = min(X)
 
answerlist = []
for i in range(X_min,X_max+1):
  newX = [(n-i)**2 for n in X]
  total = sum(newX)
  answerlist.append(total)
  
print(min(answerlist))
A,B,K = map(int,input.split())
ans =[]
for i in range(1, min(A,B)+1):
  if A%i == 0 and B%i == 0:
    ans.append(i)
  if len(ans) == K:
    print(ans[len(ans)-1])
    exit(1)
    
      


### FIXED CODE ###

A,B,K = map(int,input().split())
ans =[]
for i in range(1, min(A,B)+1):
    if A%i == 0 and B%i == 0:
        ans.append(i)
    

print(ans[-K])
x,k,d=map(int,input().split())
if d>=x:
  print(x)
  exit()
else:
  if x//d>=k:
    print(x-k*d)
    exit()
  else:
    if (x//d)%2==k%2:
      print(x%d)
      exit()
    else:
      print(d-x%d)
      exit()

### FIXED CODE ###

s=input()
c=0
for i in range(3):
  if s[i]=='R':
    c+=1
if s=='RSR' :
  print(1)
else:
  print(c)
in_data = [input() for i in range(3)] 
 
n = int(in_data[0])
s = in_data[1]
k = int(in_data[2])




target_c = s[k]
new_s = ''
for c in s:
    if c == target_c:
        new_s += c
    else:
        new_s += '*'
 
print(new_s)

### FIXED CODE ###

in_data = [input() for i in range(3)] 
 
n = int(in_data[0])
s = in_data[1]
k = int(in_data[2])





target_c = s[k - 1]
new_s = ''
for c in s:
    if c == target_c:
        new_s += c
    else:
        new_s += '*'
 
print(new_s)
import math

entrada = list(map(int,input().split(" ")))

rangoMenor = entrada[0]
rangoMayor = entrada[1]
divisor1 = entrada[2]
divisor2= entrada[3]


multiplo = divisor2*divisor1// math.gcd(divisor1,divisor2)
cantidad = rangoMayor-rangoMenor
repetidos = rangoMayor//multiplo - rangoMenor//multiplo

if rangoMenor%divisor1==0:
	divisibles1 = rangoMayor//divisor1 +1 - rangoMenor//divisor1
else:
	divisibles1 = rangoMayor // divisor1 - rangoMenor//divisor1

divisibles2 = rangoMayor//divisor2 - rangoMenor//divisor2

resultado = cantidad -(divisibles1+divisibles2) +repetidos + 1
print(resultado)

### FIXED CODE ###

import fractions

entrada = list(map(int,input().split(" ")))

rangoMenor = entrada[0]
rangoMayor = entrada[1]
divisor1 = entrada[2]
divisor2= entrada[3]

multiplo = divisor2*divisor1// fractions.gcd(divisor1,divisor2)
cantidad = rangoMayor-rangoMenor
repetidos = rangoMayor//multiplo - rangoMenor//multiplo

if rangoMenor%divisor1==0:
	divisibles1 = rangoMayor//divisor1 +1 - rangoMenor//divisor1
else:
	divisibles1 = rangoMayor // divisor1 - rangoMenor//divisor1

divisibles2 = rangoMayor//divisor2 - rangoMenor//divisor2

resultado = cantidad -(divisibles1+divisibles2) +repetidos + 1
print(resultado)
a,b = map(int, raw_input.split())
print'%d %d %f,a/b, a%b, float(a/b)'

### FIXED CODE ###

a,b = map(int,raw_input().split())
print '%d %d %f' % (a/b,a%b,float(a)/b)
n=int(input())
a=list(map(int, input().split()))

ans=1
i=0
while ans<=10**18:
    ans*=a[i]
    i+=1
    
if ans>10**18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

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


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)
C = input()
alpha = iter("abcdefghijklmnopqrstuvwxyz")
if C in alpha :
    A = alpha.next()
print(A)

### FIXED CODE ###

s = input()
t = chr(ord(s)+1)
print(t)
a = map(int,input().split())

for i in range(len(a)):
  if a[i] == 0:
    print(i+1)
    break

### FIXED CODE ###

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

for i in range(len(a)):
  if a[i] == 0:
    print(i+1)
mport math

while True:
    n = int(input().strip())
    if n == 0:
        break
    else:
        line = input().strip().split()
        scores = list(map(float, line))
        sum = 0.0
        ss = 0.0
        for score in scores:
            sum += score
            ss += score ** 2
        sd = math.sqrt((n * ss - sum ** 2) / n ** 2)
        print("%.5f" % sd)

### FIXED CODE ###

import math

while True:
    n = int(input().strip())
    if n == 0:
        break
    else:
        line = input().strip().split()
        scores = list(map(float, line))
        sum = 0.0
        ss = 0.0
        for score in scores:
            sum += score
            ss += score ** 2
        sd = math.sqrt((n * ss - sum ** 2) / n ** 2)
        print("%.5f" % sd)
n = int(input())

dp = [0]*100001
for i in range(1, n+1):
    candi = []
    for j in lst:
        if i >= j:
            candi.append(dp[i-j]+1)
    dp[i] = min(candi)
print(dp[i])

### FIXED CODE ###

n = int(input())

lst = []
for i in range(7):
    lst.append(6**i)
for i in range(1, 6):
    lst.append(9**i)

dp = [0]*100001
for i in range(1, n+1):
    candi = []
    for j in lst:
        if i >= j:
            candi.append(dp[i-j]+1)
    dp[i] = min(candi)
print(dp[i])
n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
for i in range(q):
    v,w=map(int,input().split())
    while v!=w:
        if v>w:
            v=(v+n-2)//n
        else:
            w=(w+n-2)//n
    print(v)

### FIXED CODE ###

n,q=map(int,input().split())
if n==1:
    for i in range(q):
        v,w=map(int,input().split())
        print(min(v,w))
else:
    for i in range(q):
        v,w=map(int,input().split())
        while v!=w:
            if v>w:v,w=w,v
            w=(w+n-2)//n
        print(v)
x = list(map(int, input.split()))
print(x.index(0))

### FIXED CODE ###

x = list(map(int, input().split()))
print(x.index(0)+1)
s=input()
l=len(s)
t=[]
for i in range(l):
  t.append(x)

n=''.join(t)
print(n)


### FIXED CODE ###

s=input()
l=len(s)
t=[]
for i in range(l):
  t.append('x')

n=''.join(t)
print(n)
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [A[i]+10-rA[i] for i in range(len(A))]
print(sum(tA)+ans)

### FIXED CODE ###

from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

m, d = na()
if d < 22:
    print(0)
else:
    d10max = int(str(d)[0])
    d1max = int(str(d)[1])
    c = 0
    for d10 in range(2, int(str(d)[0])):
        for i in range(2, 9):
            if d10 * i <= m:
                c += 1

    for i in range(2, d1max+ 1):
        if d10 * i <= m:
            c += 1
    print(c)




### FIXED CODE ###

import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

m, d = na()
if d < 22:
    print(0)
else:
    d10max = int(str(d)[0])
    d1max = int(str(d)[1])
    c = 0
    for d10 in range(2, d10max):
        for i in range(2, 10):
            if d10 * i <= m:
                c += 1

    for i in range(2, d1max+ 1):
        if d10max * i <= m:
            c += 1
    print(c)
N = int(input())
X = sorted(list(map(int, input().split())))
if N == 1:
    print(0)
else:
    r = X[-1] - X[0]
    ans = float("inf")
    if r == 0:
        print(0)
    else:
        for i in range(r):
            R = X[0] + i
            hp = 0
            for j in range(N):
                hp = hp + (R - X[j]) ** 2
 
            ans = min(hp, ans)
 
    print(ans)
N = int(input())
X = sorted(list(map(int, input().split())))
if N == 1:
    print(0)
else:
    r = X[-1] - X[0]
    ans = float("inf")
    for i in range(r+1):
      R = X[0] + i
      hp = 0
      for j in range(N):
        hp = hp + (R - X[j]) ** 2

        ans = min(hp, ans)

    print(ans)
提出情報


### FIXED CODE ###

import numpy as np

N = int(input())
X = np.array(list(map(int, input().split())))
costs = []
for i in range(101):
    costs.append(np.sum((X - i) ** 2))
print(min(costs))
a, b = map(int, input().split())
c = a * b
if (c%2 = 0):
	print('Even')
else:
	print('Odd')


### FIXED CODE ###

a, b = map(int, input().split())
c = a * b
if (c % 2 == 0):
	print('Even')
else:
	print('Odd')
A,B,K = input().split()
x=0
while (int(A)>0):
  x=int(x)+1
  A=int(A)-1
  if(x>int(K)):
    break
while (int(B)>0):
  x=int(x)+1
  B=int(B)-1
  if(x>int(K)):
    break
if(A>0):
  A=int(A)+1
if(B>0):
  B=int(B)+1
print(format(A)+' '+format(B))

### FIXED CODE ###

S,T = input().split()
print (T+S)
N = int(input())
def per(N):
    if N == 0 or N == 1:
        return 1
    else:
        return N * per(N-1)

print(per(N) % (10 ** 9 + 7))

### FIXED CODE ###

N = int(input())
ans = 1
for i in range(2,N+1):
  ans = ans * i % (10 ** 9 + 7)

print(ans)
a,b=map(int, input().split())
print(a*b,2a+2b)

### FIXED CODE ###

a,b=map(int, input().split())
print(a*b,2*a+2*b)
n = int(input())

a = list(map(int,int(input())))
a_max = max(a)
a_min = min(a)
if a_max > a_min+1:
    print('No')
    exit()
k = a_max
if a_max == a_min:
    if k == n-1 or 2*k <= n:
        print('Yes')
    else:
        print('No')
else:
    uni = a.count(k-1)
    if k >= uni + 1 and k <= uni + (n-uni)//2:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n = int(input())

a = list(map(int,input().split()))
a_max = max(a)
a_min = min(a)
if a_max > a_min+1:
    print('No')
    exit()
k = a_max
if a_max == a_min:
    if k == n-1 or 2*k <= n:
        print('Yes')
    else:
        print('No')
else:
    uni = a.count(k-1)
    if k >= uni + 1 and k <= uni + (n-uni)//2:
        print('Yes')
    else:
        print('No')
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

# ??\?????????????????????????????§????????????????????????????????????
count = int(input())
for c in range(count):
    c, f, r, v = [int(i) for i in input().split]
    data[bi - 1][f - 1][r - 1] += v


for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
        print('#' * 20)

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]
    
count = int(input())
for c in range(count):
    b,f,r,v = [int(i) for i in input().split()]
    data[b-1] [f-1] [r-1] += v
    
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
        print()
    if bi < 3:
        print('#' * 20)
n,k = map(int,input().split())
h = list(map(int,input().split()))

ans = sum(h)

for i in range(k):
  ans -= max(h)
  h.pop(h.index(max(h)))

print(ans)

### FIXED CODE ###

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

hh = sorted(h)

for i in range(k):
  if(len(hh) == 0):
    break
  hh.pop()
  
print(sum(hh))
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
A = 0
for x in b:
  i = bisect.bisect_left(a, x)
  j = bisect.bisect_right(c, x)
  if i > 0 and j != len(c):
    ans += i * (n - j)
print(ans)


### FIXED CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
A = 0
for x in b:
  i = bisect.bisect_left(a, x)
  j = bisect.bisect_right(c, x)
  if i > 0 and j != len(c):
    A += i * (n - j)
print(A)
a = int(input())
b = a%10
print(b)
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
elsif b == 0 or b == 1 or b == 6 or b == 8:
  print("pon")
else:
  print("bon")

### FIXED CODE ###

a = int(input())
b = a%10
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
elif b == 0 or b == 1 or b == 6 or b == 8:
   print("pon")
else:
  print("bon")
n, m = map(int, input().split())

s_list = []
c_list = []
for _ in range(m):
  s, c = map(int, input().split())
  s_list.append(s)
  c_list.append(c)
ans = ["0"]*n
if c_list[0] == 0:
  ans = ["-1"]
else:
  for i, s in enumerate(s_list):
    x = c_list[i]
    if ans[s-1] != "0" and ans[s-1] != str(x):
      ans = ["-1"]
      break
    ans[s-1] = str(x)
print(int("".join(ans)))

### FIXED CODE ###

n, m = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(m)]

for i in range(1000):
  is_ok = True
  num_str = str(i)
  if len(num_str) != n:
    continue
  for s, c in nums:
    if num_str[s-1] != str(c):
      is_ok = False
      break
  if is_ok:
    print(num_str)
    exit(0)
print(-1)
a = int(input())
b = int(input())
c = int(input())
s = 0
if a <= b:
    s = a
    if b <= c:
        s += b
    else:
        s += c
else:
    s = b
    if a <= c:
        s += a
    else:
        s += b
print(s)

### FIXED CODE ###

a = [int(x) for x in input().split()]
s = 0
if a[0] <= a[1]:
    s = a[0]
    if a[1] <= a[2]:
        s += a[1]
    else:
        s += a[2]
else:
    s = a[1]
    if a[0] <= a[2]:
        s += a[0]
    else:
        s += a[2]
print(s)
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
R,C=[],[]
x=51
r=range(x*x)
for u,v,a,b in t[:m]:
 for i in r:k=(i+a)*x;R+=k+u,k+v;C+=i*x+v,i*x+u;D+=b,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:R+=j*x+i,;C+=(j+c)*x+i,;D+=d,
d=csgraph.dijkstra(csr_matrix((D,(R,C)),[x*j]*2),1,min(j,s)*x+1)
for i in range(2,n+1):print(int(min(d[i::x])))

### FIXED CODE ###

from scipy.sparse import*
n,m,s,*t=map(int,open(0).read().split())
row,col,dat=[],[],[]
for u,v,a,b in zip(*[iter(t[:m*4])]*4):
    for i in range(2501-a):
        row+=(i+a)*51+u,(i+a)*51+v
        col+=i*51+v,i*51+u
        dat+=b,b
for i,(c,d)in enumerate(zip(*[iter(t[m*4:])]*2),1):
    for j in range(2501-c):
        row+=j*51+i,
        col+=(j+c)*51+i,
        dat+=d,
d=csgraph.dijkstra(csr_matrix((dat,(row,col)),[8**6]*2),1,min(2500,s)*51+1)
for i in range(2,n+1):print(int(d[i::51].min()))
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, K = map(int, input().split())
    A_i = list(map(int, input().split()))
    B_i = []
    cycle_list = []
    
    cycle = 0
    diff = 0
    counter = 0
    machi = 1
    for num in A_i:
        if machi in B_i:
            diff = B_i.index(machi)
            cycle = counter - diff
            cycle_list = B_i[diff:]
        else:
            counter += 1
            machi = A_i[machi - 1]

    mod_K = (K - diff) % cycle

    print(cycle_list[mod_K])

if __name__ == "__main__":
    main()


### FIXED CODE ###

import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, K = map(int, input().split())
    A_i = list(map(int, input().split()))
    B_i = [0 for i in range(N)]
    cycle_list = []
    diff_list = []
    cycle = 0
    diff = 0
    counter = 0
    machi = 1

    while counter < N:
        if B_i[machi - 1] == 1:
            diff = cycle_list.index(machi)
            cycle = counter - diff
            diff_list = cycle_list[:diff]
            cycle_list = cycle_list[diff:]
            break
        else:
            counter += 1
            B_i[machi - 1] = 1
            cycle_list.append(machi)
            machi = A_i[machi - 1]

    if K < diff:
        print(diff_list[K])
    else:
        mod_K = (K - diff) % cycle
        print(cycle_list[mod_K])

if __name__ == "__main__":
    main()
month, day = map(int, input().split())

ans = month-1 if month > day else month

if month < day:
  

print(ans)


### FIXED CODE ###

month, day = map(int, input().split())

ans = month-1 if month > day else month

print(ans)