Harryxun/stf_run huggingface dataset:
pair = [[1, 2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
n, m = [int(x) for x in input().split()]
given = sorted([int(i) for i in input().split()])
given_pair = sorted([pair[x - 1] for x in given], reverse=True)

dp = (1 + n) * [0]
max_dp = 0
for i in range(n + 1):
    if i == 0:
        dp[i] = 0
    for j in range(m):
        if i - given_pair[j][1] >= 0:
            if dp[i - given_pair[j][1]] + 1 >= max_dp:
                max_dp = dp[i - given_pair[j][1]] + 1
    dp[i] = max_dp

print(given_pair)

print(dp)


def choice_list(x, index):
#    print("now_index", index)
#    print(given_pair[x][1])
#    print("now_dp_atai", dp[index - given_pair[x][1]])
    if dp[index - given_pair[x][1]] == dp[index] - 1:
        if dp[index - given_pair[x][1]] == 0:
            for j in given_pair:
                print(j)
                if index == j[1]:
                    return str(j[0])
            return ""
        elif index - given_pair[x][1] < 0:
            return "-1"
        else:
            return str(given_pair[x][0]) + choice_list(x, index - given_pair[x][1])

    else:
        return choice_list(x + 1, index)


print(choice_list(0, n))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
am = sorted([int(i) for i in input().split()],reverse=True)
c = [2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1 for i in range(n+1)]
dp[0]=0
for i in range(n+1):
    #max_tmp = -float("inf")
    for j in am:
        if i+c[j-1]<=n:
            dp[i+c[j-1]] = max(dp[i+c[j-1]], dp[i]+1)
#print(dp)
tmp_n = n
ans =""
for i in range(dp[n]):
    for j in range(m):
        if i==dp[n]-1 and tmp_n- c[am[j]-1] != 0:
            continue
        if tmp_n - c[am[j]-1] >= 0 and dp[tmp_n - c[am[j]-1]] == dp[tmp_n] -1:
            ans+=(str(am[j]))
            tmp_n -= c[am[j]-1]
            break


print(ans)
import numpy as np
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
dp = np.full(N * 1000 + 1, 10 ** 10, dtype=np.int64)

dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(((dp <= W) * np.arange(N * 1000 + 1)).max())


### FIXED CODE ###



def main():
    num, max_weigh = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    data.sort(key=lambda x: (x[0], -x[1]))
    split_data = []

    pre_data = data[0][0]
    pre_ind = 0
    for i in range(num):
        if pre_data != data[i][0]:
            split_data.append(data[pre_ind:i])
            pre_data = data[i][0]
            pre_ind = i
    split_data.append(data[pre_ind:num])

    while len(split_data) != 4:
        split_data.append([])

    ans = 0

    for i in range(-1, len(split_data[0])):
        if i == -1:
            sum_i = 0
            sum_i_w = 0
        else:
            sum_i += split_data[0][i][1]
            sum_i_w += split_data[0][i][0]
        if sum_i_w > max_weigh:
            break
        ans = max(ans, sum_i)

        for j in range(-1, len(split_data[1])):
            if j == -1:
                sum_j = 0
                sum_j_w = 0
            else:
                sum_j += split_data[1][j][1]
                sum_j_w += split_data[1][j][0]
            if sum_i_w + sum_j_w > max_weigh:
                break
            ans = max(ans, sum_i + sum_j)

            for k in range(-1, len(split_data[2])):
                if k == -1:
                    sum_k = 0
                    sum_k_w = 0
                else:
                    sum_k += split_data[2][k][1]
                    sum_k_w += split_data[2][k][0]
                if sum_i_w + sum_j_w + sum_k_w > max_weigh:
                    break
                ans = max(ans, sum_i + sum_j + sum_k)

                for l in range(-1, len(split_data[3])):
                    if l == -1:
                        sum_l = 0
                        sum_l_w = 0
                    else:
                        sum_l += split_data[3][l][1]
                        sum_l_w += split_data[3][l][0]
                    if sum_i_w + sum_j_w + sum_k_w + sum_l_w > max_weigh:
                        break
                    ans = max(ans, sum_i + sum_j + sum_k + sum_l)

    print(ans)



if __name__ == '__main__':
    main()
import itertools
from operator import itemgetter
class UnionFind():
    def __init__(self, num):
        self.par = [-1 for _ in range(num)]
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
            if self.par[rx] > self.par[ry]:
                self.par[rx] = ry
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
        return

def inpl(): return list(map(int, input().split()))
def cost(x, y):
    return D * abs(x - y) + A[x] + A[y]
N, D = inpl()
A = inpl()
minx = A.index(min(A))
Right = [(v - i*D, i) for i, v in enumerate(A)]
Left = [(v + i*D, i) for i, v in enumerate(A)][::-1]
Right = list(itertools.accumulate(Right[minx:], min))
Left = list(itertools.accumulate(Left[N - 1 - minx:], min))
hub = [0]
for _, i in itertools.chain(Left[::-1],Right,(0, N-1)):
    if hub[-1] != i:
        hub.append(i)
edge = [(cost(hub[i], k), hub[i], k) for i in range(len(hub)-1) for k in range(hub[i]+1, hub[i+1])]\
+ [(cost(hub[i+1], k), hub[i+1], k) for i in range(len(hub)-1) for k in range(hub[i], hub[i+1])]
edge.sort(reverse = True)
Uf = UnionFind(N)
ctr = 1
ans = 0
while ctr < N:
    v, i, j = edge.pop()
    if Uf.find(i) != Uf.find(j):
        Uf.union(i, j)
        ctr += 1
        ans += v
print(ans)

### FIXED CODE ###

from operator import itemgetter
import itertools
def inpl(): return list(map(int, input().split()))
def cost(x, y):
    if x == y:
        return float('inf')
    return D * abs(x - y) + A[x] + A[y]
N, D = inpl()
A = inpl()
Right = [(v - i*D, i) for i, v in enumerate(A)]
Left = [(v + i*D, i) for i, v in enumerate(A)][::-1]
Right = list(map(itemgetter(1), itertools.accumulate(Right, min)))
Left = list(map(itemgetter(1), itertools.accumulate(Left, min)))[::-1]
ans = 0
hub = []
for i, (l, r) in enumerate(zip(Left, Right)) :
    if i == l == r:
        hub.append(i)
    else:
        ans += min(cost(i, r), cost(i, l))
print(ans + sum([cost(i, j) for i, j in zip(hub, hub[1:])]))
N=int(input())
A=[0 for i in range(N)]
for i in range(N):
  A[i]=int(input())

for i in range(N):
  if i == A.index(max(A)):
    A.pop(i)
    A.sort
    print(A[N-2])
  else:
    print(max(A))

### FIXED CODE ###

N=int(input())
A=[0 for i in range(N)]
for i in range(N):
  A[i]=int(input())
max1=max(A)
numbers_of_max1=0
for i in range(N):
  if A[i]==max1:
    numbers_of_max1+=1
    
if numbers_of_max1>1:
  for i in range(N):
    print(max1)
else:
  L=A.copy()
  L.pop(L.index(max1))
  max2 = max(L)
  for i in range(N):
    if A[i]==max1:
      print(max2)
    else:
      print(max1)
N,X = map(int,input().split())
D = 0
ans = 1
for i in range(N):
    A = int(input())
    if D <=X:
        D+=A
        ans+=1
    else:
        continue
if D >X:
    ans-=1
print(ans)
    

### FIXED CODE ###

N,X = map(int,input().split())
D = 0
ans = 1
L = list(x for x in input().split())
for i in range(N):
    
    if D <=X:
        D+=int(L[i])
        ans+=1
    else:
        continue
if D >X:
    ans-=1
print(ans)
import bisect, numpy
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B=numpy.cumsum(B)
ans=0
for i in range(1,N+1):
  books=0
  tmp=sum(A[:i])
  K-=tmp
  if K>0:
    if i>0:books+=i
    else:books=0
    books+=bisect.bisect_right(B,K)+1
    ans=max(ans,books)
print(ans)

### FIXED CODE ###

import bisect, numpy
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A=numpy.cumsum(A)
B=numpy.cumsum(B)
ans=bisect.bisect_right(B,K)
for i in range(N):
  if K-A[i]>=0:
    ans=max(ans,i+1+bisect.bisect_right(B,K-A[i]))
print(ans)
import math
n = int(input())
a = list(map(int, input().split()))

ans = 1
# 1つ使わない中で最大公約数が最大のものを求める
for i in range(0, n):
    if i == 0:
        gcd_num = a[1]
    else:
        gcd_num = a[0]
    for j in range(1, n):
        if i == j:
            continue
        gcd_num = math.gcd(gcd_num, a[j])
    ans = max(ans, gcd_num)
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

# 前処理。left, rightでそれぞれ累積gcdを作っておく
left = [0] * (n + 2)
right = [0] * (n + 2)

for i in range(n):
    left[i] = fractions.gcd(left[i - 1], a[i])

for i in range(n, 0, -1):
    right[i] = fractions.gcd(right[i + 1], a[i])

for i in range(1, n):
    right[-i - 1] = fractions.gcd(right[-i], a[-i - 1])

ans = 1
for i in range(1, n + 1):
    ans = max(ans, fractions.gcd(left[i - 1], right[i + 1]))
print(ans)
import sys
import math
import itertools
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60 + (m2-m1)-k),0)

### FIXED CODE ###

import sys
import math
import itertools
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60 + (m2-m1)-k,0))
import sys
n, x = map(int, sys.stdin.readline().split())
llist = list(map(int, sys.stdin.readline().split()))

d = 0
ans = 0
while d <= x:
  ans += 1
  d += llist[ans-1]
  if ans >= n+1:
    print(n+1)
    exit()
print(ans)

### FIXED CODE ###

import sys
n, x = map(int, sys.stdin.readline().split())
llist =list(map(int, sys.stdin.readline().split()))

d = 0
ans = 1
for l in llist:
  ans += 1
  d += l
  if d > x:
    ans -= 1
    break
  elif d == x:
    break
  
  if ans >= n+1:
    print(n+1)
    exit()
print(ans)
n, m = map(int, input().split())
lst = [ int(i) for i in input().split() ]

if n - lst.sum() >= 0:
  print(n-lst.sum())
else:
  print(-1)

### FIXED CODE ###

n, m = map(int, input().split())
lst = [ int(i) for i in input().split() ]

if n - sum(lst) >= 0:
  print(n-sum(lst))
else:
  print(-1)
W,a,b = [int(i) for i in input().split()]
ans = 0
if a <= b <= a+w or b <= a <= b+w:
  print(ans)
else:
  ans = min(abs(b-a-w),abs(a-b-w))
  print(ans)

### FIXED CODE ###

w,a,b = [int(i) for i in input().split()]
ans = 0
if a <= b <= a+w or b <= a <= b+w:
  print(ans)
else:
  ans = min(abs(b-a-w),abs(a-b-w))
  print(ans)
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')
else:
	Print('No')

### FIXED CODE ###

k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')	
else:
	print('No')
import numpy as np
N = int(input())
H = list(map(int, input().split(" ")))

H = np.array(H)

H_dif = H[1:]-H[:-1]

if (H_dif <=-2).any() == True:
    answer = "No"

elif (H_dif >= 0).all() == True:
    ans = "Yes"
else:
    H_check = (H_dif == -1)
    H_c = H_check[1:].dot(H_check[:-1])
    if (H_c == 1).any() == True:
        ans = "No"
    else:
        ans = "Yes"

print(ans)


### FIXED CODE ###

N = int(input())

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

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)
n,k = map(int,input().split())
for i in range(30):
    if n >= k**(i-1) and n < k**i:
        print(i)

### FIXED CODE ###

n,r = map(int,input().split())
if n>=10:
    print(r)
else:
    print(r+100*(10-n))
A, B = int(input())
int C

if A == 2 or B == 2:
  print("No")
  
elif C == 1 or C ==3:
  print("Yes")

### FIXED CODE ###

A, B = map(int, input().split())

if (A == 2) or (B == 2):
  print("No")
  
else:
  print("Yes")
# coding: utf-8
# Your code here!
n_str = input()
k = int(input())

def k1(n_str):
	n_str = str(int(n_str))
	n_len = len(n_str)
	return 9*(n_len-1) + int(n_str[0])

def k2(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 2:
        return 0
    s += k2('9'*(n_len - 1))
    s += k1('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k1(n_str[1:])
    return s
                      
def k3(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 3:
        return 0
    s += k3('9'*(n_len - 1))
    s += k2('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k2(n_str[1:])
    return s

if k == 1:
    print(k1(n_str))
elif k == 2:
    print(k2(n_str))
elif k == 3:
    print(k3(n_str))
                      

                      

### FIXED CODE ###

s1, s2 = input().split()
a1, a2 = [int(i) for i in input().split()]
s = input()

if s1 == s:
  print(a1 - 1, a2)
elif s2 == s:
  print(a1, a2 - 1)
else:
  print(a1, a2)
N=int(input())
A=[int(x)for x in input().split()]
B=[]
if N%2==0:
    B= sorted([2*i-1 for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans0=pow(2,(N/2))
        
        ans=ans0%(10**9+7)
    else:
        ans=0
else:
    B= [0]+sorted([2*i for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans0=pow(2,(N-1)/2)
        ans=ans0%(10**9+7)
    else:
        ans=0
print(int(ans))
 

### FIXED CODE ###

mod = 10**9 + 7
n = int(input())
a = sorted(list(map(int,input().split())))
 
if n % 2 == 0:
  for i in range(n//2):
    if not a[2*i] == a[2*i+1] == 2*i+1:
      print(0)
      exit()
else:
  if a[0] != 0:
    print(0)
    exit()
  for i in range(n//2):
    if not a[2*i+1] == a[2*i+2] == 2*i+2:
      print(0)
      exit()
print(pow(2, n//2) % mod)
s = list(input())

for i in range(4):
    s[i] = int(s[i])

a = s[0]*10 + s[1]
b = s[2]*10 + s[3]


elif a >= 13 and b >= 13:
    print("NA")
elif a >= 13 and b <= 12:
    if b > 0:
        print("YYMM")
    else:
        print("NA")
elif a <= 12 and b >= 13:
    if a > 0:
        print("MMYY")
    else:
        print("NA")
else:
    if a == 0 or b == 0:
        print("NA")
    else:
        print("AMBIGUOUS")

### FIXED CODE ###

s = list(input())

for i in range(4):
    s[i] = int(s[i])

a = s[0]*10 + s[1]
b = s[2]*10 + s[3]


if a >= 13 and b >= 13:
    print("NA")
elif a >= 13 and b <= 12:
    if b > 0:
        print("YYMM")
    else:
        print("NA")
elif a <= 12 and b >= 13:
    if a > 0:
        print("MMYY")
    else:
        print("NA")
else:
    if a == 0 and b == 0:
        print("NA")
    elif a == 0:
        print("YYMM")
    elif b == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")
H, W = map(int, input().split())

N1 = min(H, W)
N2 = max(H, W)

if N1 % 2 == 0:
  count = (N1 * N2) // 2
else:
  count = (N1 * (N1 -1) + N1 + 1) // 2
  if (N2 - N1) % 2 == 0:
    count += (N1 * (N2 - N1)) // 2
  else:
    count += (N1 * (N2 - N1 - 1) + N1 - 1) // 2

print(count)

### FIXED CODE ###

nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(nums[K-1])
k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(s[i], end='')
    print()


### FIXED CODE ###

k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(i, end='')
    print()
%time
num = input()
L = []
house = []
for i in range(int(num)):
    k = input().split()
    k[0] = int(k[0])
    k[1] = int(k[1])
    k[2] = int(k[2])
    k[3] = int(k[3])
    L.append(k)

for i in range(3):
    a = ["","0","0","0","0","0","0","0","0","0","0","0"]
    b = ["","0","0","0","0","0","0","0","0","0","0","0"]
    c = ["","0","0","0","0","0","0","0","0","0","0","0"]
    d = ["#"*20]
    house.append([a,b,c,d])

a = ["","0","0","0","0","0","0","0","0","0","0","0"]
b = ["","0","0","0","0","0","0","0","0","0","0","0"]
c = ["","0","0","0","0","0","0","0","0","0","0","0"]
house.append([a,b,c])

for i in L:
    house[i[0]-1][i[1]-1][i[2]] = str(i[3])

for i in house:
    for j in i:
        k = " ".join(j)
        print(k)



### FIXED CODE ###

num = input()
L = []
house = []
for i in range(int(num)):
    k = input().split()
    k[0] = int(k[0])
    k[1] = int(k[1])
    k[2] = int(k[2])
    k[3] = int(k[3])
    L.append(k)

for i in range(3):
    a = ["","0","0","0","0","0","0","0","0","0","0"]
    b = ["","0","0","0","0","0","0","0","0","0","0"]
    c = ["","0","0","0","0","0","0","0","0","0","0"]
    d = ["#"*20]
    house.append([a,b,c,d])

a = ["","0","0","0","0","0","0","0","0","0","0"]
b = ["","0","0","0","0","0","0","0","0","0","0"]
c = ["","0","0","0","0","0","0","0","0","0","0"]
house.append([a,b,c])

for i in L:
    house[i[0]-1][i[1]-1][i[2]] = str(int(house[i[0]-1][i[1]-1][i[2]])+i[3])

for i in house:
    for j in i:
        k = " ".join(j)
        print(k)
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 1
mod = 10**9 + 7
c = 0
z = 0
for i in a:
    if i < 0:
        c += 1
    elif i == 0:
        z += 1
if c == n and k & 1:
    a.reverse()
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(-ans % mod)
elif c == n:
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(ans)
else:
    plus = [i for i in a if i > 0]
    minus = [i for i in a if i <= 0]
    plus.sort(reverse=1)
    minus.sort()
    x = len(plus)
    y = len(minus)
    plus += [0] * z
    p, m = 0, 0
    for i in range(k // 2):
        if x <= p:
            ans *= minus[m] * minus[m + 1]
            m += 2
        elif y <= m:
            ans *= plus[p] * plus[p + 1]
            p += 2
        else:
            if minus[m] * minus[m + 1] >= plus[p] * plus[p + 1]:
                ans *= minus[m] * minus[m + 1]
                m += 2
            else:
                ans *= plus[p] * plus[p + 1]
                p += 2
        ans %= mod
    if k & 1:
        if p < x:
            ans *= plus[p]
        else:
            ans *= minus[-1]
        ans %= mod

    print(ans % mod)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 1
mod = 10**9 + 7
c = 0
z = 0
for i in a:
    if i < 0:
        c += 1
    elif i == 0:
        z += 1
if c == n and k & 1:
    a.reverse()
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(-ans % mod)
elif c == n:
    for i in range(k):
        ans *= -a[i]
        ans %= mod
    print(ans)
elif k == n:
    for i in a:
        ans *= abs(i)
        ans %= mod
    print(((-1)**c * ans) % mod)
else:
    plus = [i for i in a if i > 0]
    minus = [i for i in a if i <= 0]
    plus.sort(reverse=1)
    minus.sort()
    x = len(plus)
    y = len(minus)
    plus += [0] * z
    p, m = 0, 0
    for i in range(k // 2):
        if x - 1 <= p:
            ans *= minus[m] * minus[m + 1]
            m += 2
        elif y - 1 <= m:
            ans *= plus[p] * plus[p + 1]
            p += 2
        else:
            if minus[m] * minus[m + 1] >= plus[p] * plus[p + 1]:
                ans *= minus[m] * minus[m + 1]
                m += 2
            else:
                ans *= plus[p] * plus[p + 1]
                p += 2
        ans %= mod
    if k & 1:
        if p < x:
            ans *= plus[p]
        else:
            ans *= minus[-1]
        ans %= mod

    print(ans % mod)
n = int(input())

for i in range(n):
    a.append(int(input()))

for i in range(n):
    if i == 1:
        result = a[2:]
        print(max(result))
    elif i == n-1:
        result = a[:n-1]
        print(max(result))
    else:
        result = a[:i] + a[i+1:]
        print(max(result))

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_s = sorted(a, reverse=True)
hantei = a_s[:2]
del a_s
for i in range(n):
    if a[i] == hantei[0]:
        print(hantei[1])
    else:
        print(hantei[0])
n = int(input())
s = list(input())
if "." in s:
    a = [i for i, x in enumerate(s) if x == '.'][-1]
    ans1 = s[:a].count("#")
else:
    ans2 = 0
if "#" in s:
    b = [i for i, x in enumerate(s) if x == '#'][0]
    ans2 = s[b:].count(".")
else:
    ans2 = 0
print(min(ans1, ans2))

### FIXED CODE ###

import bisect
n = int(input())
s = list(input())
b = [0]*(n+1)
c = [s.count(".")]*(n+1)
a = []
a.append(c[0])
for i in range(n):
    if s[i] == "#":
        b[i+1] = b[i] + 1
        c[i+1] = c[i]
    else:
        c[i+1] = c[i] - 1
        b[i+1] = b[i]
    a.append(b[i+1] + c[i+1])
if "." not in s:
    a.append(0)
elif "#" not in s:
    a.append(0)
print(min(a))
import sys
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    l, r, q = map(int, input().split())
    G[l - 1].append((r - 1, q))
    G[r - 1].append((l - 1, -q))
X = [None] * N


def dfs(u):
    for w, d in G[u]:
        if X[w] is None:
            X[w] = X[u] + d
            if not dfs(w):
                return False
        elif X[w] - X[u] != d:
            return False

    return True


for i, x in enumerate(X):
    if x is None:
        X[i] = 0
        if not dfs(i):
            print("No")
            sys.exit(0)

print("Yes")

### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    l, r, q = map(int, input().split())
    G[l - 1].append((r - 1, q))
    G[r - 1].append((l - 1, -q))
X = [None] * N


def dfs(u):
    global X, G
    for w, d in G[u]:
        if X[w] is None:
            X[w] = X[u] + d
            if not dfs(w):
                return False
        else:
            if X[w] != X[u] + d:
                return False

    return True


flag = True
for i in range(N):
    if X[i] is None:
        X[i] = 0
        flag &= dfs(i)

if flag:
    print("Yes")
else:
    print("No")
n, m - map(int, input().split())
print((n - 1) * (m - 1))

### FIXED CODE ###

n, m = map(int, input().split())
print((n - 1) * (m - 1))
a,b,k=map(int,input())
if a+b<=k:print(0,0)
elif a<=k:print(0,a+b-k)
else:print(a-k,b)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a+b<=k:print(0,0)
elif a<=k:print(0,a+b-k)
else:print(a-k,b)
while True:
    H, W = [int(i) for i in input().split()]
    if H == w == 0:
        break
    
    for h in range(H):
        for w in range(W):
            print('#',end='')
        print()
    
    print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    
    for h in range(H):
        for w in range(W):
            print('#', end='')
        print()
    
    print()
N, K = map(int, A.split())
p_list = list(map(int, B.split()))

dst = 0

for i in range(N-K+1):
    print("i : {}".format(i))
    p_sum = 0
    for j in range(K):
        p = p_list[i+j]
        print("p : {}".format(p))
        p_sum += ( p/2 * (1+p)) / p
    if p_sum > dst:
        dst = p_sum
    
print(dst)

### FIXED CODE ###

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

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)
 
N = int(input())
P = [[0 for i in range(101)] for j in range(101)]
x, y, h = map(int, input().split())
P[x][y] = h
for i in range(101):
    for j in range(101):
        P[i][j] = dist(i, j, x, y, h)
 
for i in range(N-1):
    a, b, c = map(int, input().split())
    if P[a][b] != c:
        P[a][b] = False
    for j in range(101):
        for k in range(101):
            if P[j][k] != False and P[j][k] != dist(j, k, a, b, c):
                P[j][k] = False
temp = (0, 0, 0)
for i in range(101):
    for j in range(101):
        if P[i][j] > temp[2]:
            temp = (i, j, P[i][j])
print(temp[0], temp[1], temp[2])

### FIXED CODE ###

import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))

else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(101):
  m=0  
  for j in range(0,len(a)):
    m+=(a[j]-i)**2
  s.append(m)
print(min(s))    


### FIXED CODE ###

N,R=map(int,input().split())
u=0
if N>=10:
  u=R
else:
  u=R+100*(10-N)
print(u)