Harryxun/stf_run huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
    G[a].append((b, c))

# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
    if a == b:
        return d > 0
    ret = False
    for to, c in G[a]:
        d += c
        ret |= check_loop(to, b, d)
    return ret


for a, b, c in egdes:
    if a > b:
        if check_loop(a, b, c):
            print('inf')
            exit()

# 動的計画法のために隣接行列
G = [[-INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = c
dp = [-INF] * (N + 10)
dp[1] = 0
for i in range(1, N + 1):
    for j in range(1, i):
        dp[i] = max(dp[i], dp[j] + G[j][i])
print(dp[N])

### FIXED CODE ###

N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13

G = [[INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = -c
dist = [INF] * (N + 1)
dist[1] = 0
for _ in range(N - 1):
    for a, b, c in egdes:
        dist[b] = min(dist[b], dist[a] - c)
ans = dist[N]
for a, b, c in egdes:
    dist[b] = min(dist[b], dist[a] - c)
print(-ans if ans == dist[N] else 'inf')
for i in range(3, int(input() + 1):
    if i % 3 == 0 or '3' in str(i):
        print('', i, end='')

### FIXED CODE ###

for i in range(3, int(input()) + 1):
    if i % 3 == 0 or '3' in str(i):
        print('', i, end='')
print()
# coding:utf-8

n=int(input())
gacha_list[input() for i in range()]
gacha_prize=list(set(gacha_list())
print(len(gacha_prize()))

### FIXED CODE ###

n=int(input())
a=[]
 
for i in range(n):
  word=input()
  a.append(word)
print(len(set(a)))
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,m = readInts()
sc = []
for i in range(m):
	tmp = readInts()
	sc.append([tmp[0]-1,tmp[1]])

if m==0:
	if n==1:
		print(0)
		exit()
	else:
		print(-1)
		exit()
ans = -1
for i in range(1000):
	*t, = map(int, list(str(i)))

	if len(t) != n:
		continue

	ok = True
	 for j in range(m):
		if t[sc[j][0]]!=sc[j][1]:
			ok=False
			break
	if ok is True:
		print(i)
		quit()

print(-1)

### FIXED CODE ###

n,m = map(int, input().split())
s, c = [], []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)
 
for i in range(1000):
    *t, = map(int, list(str(i)))
 
    if len(t) != n:
        continue
 
    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break
 
    if ok:
        print(i)
        quit()
 
print(-1)
for i in range(1,10):
    print(i,"x",i,"=",i*i,sep="")

### FIXED CODE ###

from itertools import product

for i in product(list(range(1,10)),list(range(1,10))):
    print(i[0],"x",i[1],"=",i[0]*i[1],sep="")
import math
b = list(map(int,input().split()))
ans=0
check=0
A=0
C=b[1]
max = math.floor(b[2]/b[1])
if max == 0:
    if b[1]-1>0:
        check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
        if check > ans:
            ans=check
else:
    for i in range(max):
        A=b[1]-1
        if A>0:
            check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
            if check > ans:
                ans=check
        b[1]+=b[1]
print(ans)

### FIXED CODE ###

import math
b = list(map(int,input().split()))
ans=0
check=0
if b[2]>b[1]-1:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
else:
    check = math.floor((b[0]*b[2])/b[1]) - b[0]*math.floor(b[2]/b[1])
if check>ans:
    ans=check
print(ans)
a, b = map(int, input().split())
print(['LESS', 'GEATER', 'EQUAL'][(a>b)-(a==b)])

### FIXED CODE ###

a = int(input())
b = int(input())
print(['EQUAL', 'GREATER', 'LESS'][(a>b)-(a<b)])
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

visited = [0] * N
cnt = 0
def dfs(n):
    global cnt
    if visited[n]: return
    cnt += 1
    visited[n] = True
    for nv in edge[n]:
        dfs(nv)

ans = 0
for i in range(N):
    cnt = 0
    dfs(i)
    ans = max(ans, cnt)
print(ans)


### FIXED CODE ###

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

class UnionFind():
    '''
    UnionFindでグラフの状態を管理する
    '''
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        '''
        ルートのノードを見つける
        '''
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        '''
        ノード同士を連結する
        '''
        x = self.find_root(x)
        y = self.find_root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    def is_same_group(self, x, y):
        '''
        同一のルーツを持つかどうか調査する
        '''
        return self.find_root(x) == self.find_root(y)

    def count(self, x):
        return -self.root[self.find_root(x)]

uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.count(i))

print(ans)
a, b = map(int(input()))
if (a%2 * b%2) == 1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a, b = map(int,(input().split(" ")))
if ((a%2) * (b%2)) != 0:
  print("Yes")
else:
  print("No")
a =  int(input())
if a == 0:
  print(0)
  return
r = 1000 - (a % 1000)
print(r)

### FIXED CODE ###

a =  int(input())
print((1000 - a % 1000) % 1000)
N, M = list(map(int, input().split()))
tmp=0

if N==1:
  print(M)
  else:
    for i in range(M-N):
      k = i + N
      if M % k == 0:
        print(int(M/k))
        tmp=1
        break

if tmp==0:
  print(1)

### FIXED CODE ###

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

if N==1:
  print(M)
  tmp=1
else:
  for i in range(int(M**0.8)+1):
    k = i + N
    if M % k == 0:
      print(int(M/k))
      tmp=1
      break

if tmp==0:
  print(1)
n = int(input())
s = list(map(int, input().split()))
a = 0
w = 0
t = 0
r = 0

for i in range(n):
  if s == "AC":
    a += 1
  elif s== "WA":
    w += 1
  elif s== "TLE":
    t += 1
  else:
    e += 1
  
  print("AC ×", a)
  print("WA ×", w)
  print("TLE ×", t)
  print("RE ×", r)

### FIXED CODE ###

n = int(input())
s = list(input() for i in range(n))
  
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
import bisect
a = int(input())
b = [int(input()) in d in range(a)]
c = [b[1]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c,i)] = i
        
print(len(L))


### FIXED CODE ###

import bisect
a = int(input())
b = [int(input()) for d in range(a)]
c = [b[0]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c,i)] = i
        
print(len(c))
import math
numbers = input().rstrip().split()
number1 = numbers[0]
number2 = numbers[1]

mean = (number1+number2) / 2

print(math.ceil(mean))

### FIXED CODE ###

import math
numbers = input().rstrip().split()
number1 = int(numbers[0])
number2 = int(numbers[1])
 
mean = (number1+number2) / 2
 
print(math.ceil(mean))
N = int(input())
A = [int(a) for a in input().split()]
B = [abs(a) for a in A]

for i in range(N):
    if A[i] > 0:
        po = i
        break
else:
    po = -1
for i in range(N):
    if A[i] < 0:
        ne = i
        break
else:
    ne = -1
for i in range(N):
    if A[i] == 0:
        ze = i
        break
else:
    ze = -1
mi = min(B)
for i in range(N):
    if B[i] == mi:
        mii = i
        break
else:
    mii = -1

def aaa(i, j):
    t1, t2 = A[i], A[j]
    if t1 > t2:
        t1, t2 = t2, t1
    del A[t2]
    del A[t1]
    A = [t1, t2] + A
    
if po >= 0 and ne >= 0:
    aaa(po, ne)
else:
    print(sum(B) - 2 * mi)
    del A[mii]
    A = [mi] + A
# print(A)
prev = A[0]
for i in range(N-1):
    if i == N-2 or A[i+2] < 0:
        print(max(prev, A[i+1]), min(prev, A[i+1]))
        prev = max(prev, A[i+1]) - min(prev, A[i+1])
    else:
        print(min(prev, A[i+1]), max(prev, A[i+1]))
        prev = min(prev, A[i+1]) - max(prev, A[i+1])


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
B = [abs(a) for a in A]

for i in range(N):
    if A[i] > 0:
        po = i
        break
else:
    po = -1
for i in range(N):
    if A[i] < 0:
        ne = i
        break
else:
    ne = -1
mi = min(B)
for i in range(N):
    if B[i] == mi:
        mii = i
        break
else:
    mii = -1

if po >= 0 and ne >= 0:
    print(sum(B))
    t1, t2 = A[po], A[ne]
    if po > ne:
        po, ne = ne, po
    # print("pone =", po, ne)
    if po == ne:
        del A[ne]
        A = [0] + A
    else:
        del A[ne]
        del A[po]
        A = [t1, t2] + A
else:
    print(sum(B) - 2 * mi)
    t = A[mii]
    del A[mii]
    A = [t] + A
# print(A)
prev = A[0]
for i in range(1, N):
    a, b = max(prev, A[i]), min(prev, A[i])
    if i == N-1 or A[i+1] < 0:
        print(a, b)
        prev = a - b
    else:
        print(b, a)
        prev = b - a
a, b, t = map(int, input().split())

print((t // a) * b)


### FIXED CODE ###

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

total = 0

if a > b:
    total = 2 * a - 1
elif b > a:
    total = 2 * b - 1
else:
    total = 2 * a

print(total)
import input
input = sys.stdin.readline
 
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)

### FIXED CODE ###

# -*- coding: utf-8 -*- 
def cost(h,N,K):
    dp=[0]*N
    dp[1]=abs(h[0]-h[1])
    for i in range(2,N):
        tmp=[abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i)]
        dp[i]=min(tmp)
    return dp[-1]

N,K=map(int,input().split())
h=[int(num) for num in input().split()]

print(cost(h,N,K))
n = int(input())
x = list(map(int, input().split()))
t = round(sum(x) / N)
p = 0
for i in x:
    p += ((i-t)**2)
print(p)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
t = round(sum(x) / n)
p = 0
for i in x:
    p += ((i-t)**2)
print(p)
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N != 0:
  if N != 1:
    N_sum = combinations_count(N, 2)
  else:
    N_sum = 0
else:
  N_sum = 0
if M != 0:
  if M != 1:
    M_sum = combinations_count(M, 2)
  else:
    M_sum = 0
else:
  M_sum = 0
print(N_sum + M_sum)

### FIXED CODE ###

# -*- coding: utf-8 -*-
X, Y, Z = map(int, input().split())
print(Z, X, Y)
import numpy

class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        # print('root {}, {} = '.format(i, j), end='')
        i = self.root(i)
        j = self.root(j)
        # print(i, j)

        if i == j:
            return

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
R = numpy.array([[int(r) for r in input().split()] for _ in range(M)]) - 1

forest = UnionFind(N)
for p1, p2 in R:
    forest.unite(p1, p2)

s = [forest.size(i) for i in range(N)]
print(max(s))

### FIXED CODE ###

import numpy

class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        # print('root {}, {} = '.format(i, j), end='')
        i = self.root(i)
        j = self.root(j)
        # print(i, j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
R = numpy.array([[int(r) for r in input().split()] for _ in range(M)]) - 1

forest = UnionFind(N)
for p1, p2 in R:
    forest.unite(p1, p2)

s = [forest.size(i) for i in range(N)]
print(max(s))
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n = int(input())
    A = [int(a) for a in input().split(" ")]
    q = int(input())
    M = [int(m) for m in input().split(" ")]

    def solve(i, m):
        if m == 0:
            return True
        if i >= n:
            return False
        res = solve(i+1, m) or solve(i+1, m-A[i])
        return res

    for m in M:
        if solve(0, m)==True:
            print("yes")

        else:
            print("no")

            


### FIXED CODE ###

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


if __name__ == '__main__':

    n = int(input())
    A = [int(a) for a in input().split(" ")]
    q = int(input())
    M = [int(m) for m in input().split(" ")]

    def solve(i, m):
        if m == 0:
            return True
        if i >= n or m > sum(A):
            return False
        res = solve(i+1, m) or solve(i+1, m-A[i])
        return res

    ans = []
    for m in M:
        if solve(0, m):
            ans.append("yes")
        else:
            ans.append("no")

    print("\n".join(ans))
# -*- coding: utf-8 -*-

import sys
import os
import pprint
from queue import Queue


N, M = list(map(int, input().split()))
students = []
checkpoints = []

for i in range(N):
    a, b = list(map(int, input().split()))
    students.append([a, b])

for i in range(N):
    a, b = list(map(int, input().split()))
    checkpoints.append([a, b])

for student in students:
    min_dist = float('inf')
    min_i = None
    for i, checkpoint in enumerate(checkpoints):
        manhattan_dist = abs(checkpoint[0] - student[0]) + abs(checkpoint[1] - student[1])
        if manhattan_dist < min_dist:
            min_dist = manhattan_dist
            min_i = i
    print(min_i + 1)


### FIXED CODE ###

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

import sys
import os


N, M = list(map(int, input().split()))
students = []
checkpoints = []

for i in range(N):
    a, b = list(map(int, input().split()))
    students.append([a, b])

for i in range(M):
    a, b = list(map(int, input().split()))
    checkpoints.append([a, b])

for student in students:
    min_dist = float('inf')
    min_i = None
    for i, checkpoint in enumerate(checkpoints):
        manhattan_dist = abs(checkpoint[0] - student[0]) + abs(checkpoint[1] - student[1])
        if manhattan_dist < min_dist:
            min_dist = manhattan_dist
            min_i = i
    print(min_i + 1)
N=int(input())
H=list(map(int,input().split()))
ans=0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp
print(ans)

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
ans=0
i = 0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp +1
print(ans)
from collections import deque
import numpy as np
n,m,k=map(int,input().split())
link=[[] for _ in range(n)]
block=[[]  for _ in range(n)]
ans=[]
s=[]
for i in range(m):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)
for i in range(k):
  a,b=map(int,input().split())
  block[a-1].append(b-1)
  block[b-1].append(a-1)
for i in range(n):#スタートの選び方
    visited=set()
    q=deque([i])
    while len(q)>0:
        x=q.pop()
        visited.add(x)
        for j in link[x]:
            if j in visited:
              continue
            elif j in q:
              continue
            else:q.append(j)
    ans.append(len(visited))
    s.append(visited)


### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
      self.n=n
      self.root=[-1]*(n+1)
      self.rank=[0]*(n+1)
      
    def find(self,x):
      if self.root[x]<0:
        return x
      else:
        self.root[x]=self.find(self.root[x])
        return self.root[x]
    
    def unite(self,x,y):
      x=self.find(x)
      y=self.find(y)
      if x==y:
        return 0
      elif self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      else:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
          
    def Same(self,x,y):
      return self.find(x)==self.find(y)
    
    def size(self,x):
      return -self.root[self.find(x)]
import sys
input=sys.stdin.buffer.readline
n,m,k=map(int,input().split())
link=UnionFind(n)
f=[0]*n
block=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    link.unite(a,b)
    f[a]+=1
    f[b]+=1
for _ in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
for i in range(n):
  ret=link.size(i)-f[i]-1
  for j in block[i]:
    if link.Same(i,j):
      ret-=1
  ans.append(ret)
print(*ans)
n=int(input())
k=int(input())
ans=0
for _ in range(n):
  a=int(input())
  ans+=min(a,k-a)
print(ans)

### FIXED CODE ###

n=int(input())
k=int(input())
ans=0
for a in map(int,input().split()):
  ans+=min(a,k-a)
print(ans+ans)
n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
a = [0 for in range(s[len(s)]]
for i in s:
    a[i] += 1

count = 0
for i in t:
    count += a[i] 
print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
W = input()
#print(W)
t=0

while(1):
	char_list = list(x.lower() for x in input().split())
	#print(char_list)
	if char_list[0] == 'END_OF_TEXT':
		break
	
	for i in range(len(char_list)):
		if W == char_list[i]:
			t += 1

print(t)

### FIXED CODE ###

W = input().lower()
#print(W)
t=0

while(1):
	char_list = list(x for x in input().split())
	#print(char_list)
	if char_list[0] == 'END_OF_TEXT':
		break
	
	for i in range(len(char_list)):
		if W == char_list[i].lower():
			t += 1

print(t)
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4:
        found += 2
        rect *= i*i
    elif occ[i] => 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0
        
    


### FIXED CODE ###

n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4 and found < 1:
        found += 2
        rect *= i*i
    elif occ[i] >= 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0
a=int(input())

    if a >= 400 and a < 600:
        print("8")
    elif a >= 600 and a < 800:
        print("7")
    elif a >= 800 and a < 1000:
        print("6")
    elif a >= 1000 and a < 1200:
        print("5")
    elif a >= 1200 and a < 1400:
        print("4")
    elif a >= 1400 and a < 1600:
        print("3")
    elif a >= 1600 and a < 1800:
        print("2")
    elif a >= 1800 and a < 2000:
        print("8")

### FIXED CODE ###

a=int(input())

if a >= 400 and a < 600:
    print("8")
elif a >= 600 and a < 800:
    print("7")
elif a >= 800 and a < 1000:
    print("6")
elif a >= 1000 and a < 1200:
    print("5")
elif a >= 1200 and a < 1400:
    print("4")
elif a >= 1400 and a < 1600:
    print("3")
elif a >= 1600 and a < 1800:
    print("2")
elif a >= 1800 and a < 2000:
    print("1")
import sys
import math
import numpy as np

n, m = map(int, raw_input().split())
A = np.zeros([n, m])
b = np.zeros([m, 1])

for i in xrange(n) :
    A[i] = map(int, raw_input().split())

for i in xrange(m) :
    b[i] = input()

c = A.dot(b)

for i in xrange(n) :
    print int(c[i])

### FIXED CODE ###

import sys
import math

n, m = map(int, raw_input().split())
A = []
b = []

for i in xrange(n) :
    A.append(map(int, raw_input().split()))

for i in xrange(m) :
    b.append(input())

for i in xrange(n) :
    sm = 0
    for j in xrange(m) :
        sm += A[i][j] * b[j]
    print sm
n,m = map(int,input().split())
li_a = [list(input()) for _ in range(n)]
li_b = [list(input()) for _ in range(m)]


for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if li_a[i+x][j:j+m] != li_b[x][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")

### FIXED CODE ###

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


for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if li_a[i+k][j:j+m] != li_b[k][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
l = [0 for i in range(m+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
 
dp = [0 for i in range(K+1)]
for i in range(K+1):
    if not dp[i]:
        for j in range(N):
            if i + A[j] < K + 1:
                dp[i+A[j]] = 1
 
if dp[K]: print("First")
else: print("Second")
# -*- coding: utf-8 -*-


def is_sosu(x):
    for i in range(2, x):
        if x % i == 0:
            return False
    return True

N = int(input())
sosu = []
for candidate in range(2, 55555):
    if is_sosu(candidate) and candidate % 5 == 1:
        sosu.append(candidate)
        if len(sosu) >= N:
            break
print(' '.join([str(s) for s in sosu]))

### FIXED CODE ###

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

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

if a <= b:
    print(a)
else:
    print(a - 1)