Harryxun/stf_run huggingface dataset:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N, M, K = input_int()
A = many_int()
B = many_int()


def dfs(A_index, B_index, K, books):
    
    return_books = books
    return_booksA = books

    if N > A_index and K>=A[A_index]:
        return_books = dfs(A_index+1, B_index, K-A[A_index], books+1)
    if M > B_index and K>=B[B_index]:
        return_booksA = dfs(A_index, B_index+1, K-B[B_index], books+1)

    return max(return_books, return_booksA)

print(dfs(0, 0, K, 0))

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N, M, K = input_int()
A = many_int()
B = many_int()


import itertools as it
import bisect

def bins(A, B, K):
    A_it = list(it.accumulate(A))
    B_it = list(it.accumulate(B))

    A_index = bisect.bisect_right(A_it, K)
    B_index = bisect.bisect_right(B_it, K)

    A_it = [0]+A_it[:A_index]
    B_it = B_it[:B_index]

    maxs = 0
    count=0
    for i in A_it[::-1]:
        if K-i < 0:
            continue
        now = K-i
        B_index = bisect.bisect_right(B_it, now)

        maxs = max(maxs, B_index + max(A_index - count,0))
        count+=1

    return maxs

print(bins(A,B,K))
N = int(input())
seat = [0]*100000
for i in range(N):
    li,ri = map(int,input().split())
    for j in range(li,ri+1):
        seat[j] = 1
print(sum(seat))


### FIXED CODE ###

N = int(input())
seat = [0]*100000
for i in range(N):
    a,b = map(int,list(input().split()))
    for j in range(a,b+1):
        seat[j-1] = 1
print(sum(seat))
print((int input())*6.3)


### FIXED CODE ###

r = int(input())
print(6.3*r)
n = int(input())
dic = {}
m = 0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
    m = max(m, dic[s])
  else:
    dic[s] = 1
    m = max(m, dic[s])
ans = []
for s in dic:
  if dic[s] == m:
    ans.append(s)
print('\n'.join(ans.sort()))

### FIXED CODE ###

print('Yes' if len(set(input().split()))==2 else 'No')
k, x = map(int, input().split())

if 500*i >= x:
    print("Yes")
else:
    print('No')


### FIXED CODE ###

k, x = map(int, input().split())

if 500*k >= x:
    print("Yes")
else:
    print('No')
N = int(input())
d = list(map(int(input().split())))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

### FIXED CODE ###

N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")


### FIXED CODE ###

n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")
n, a, b, c, d = map(int,input().split())
s = str(input())
s = s[a:max(c,d)]

l_s = []
for i in range(len(s)):
    l_s += [0 if s[i] == '.' else 1]

ans = 'Yes'
if i in range(len(s)-1):
    if sum(l_s[i:i+2])==2:
        ans = 'No'

if ans == 'Yes':
    if d>c:
        pass
    else:
        ans = 'No'
        for j in range(b-a,d-1-a):
            if sum(l_s[j:3+j]) == 0:
                ans = 'Yes'
            else:
                pass
        if ans == 'No':
            if sum(l_s[d-1-a,d-a])==0:
                ans = 'Yes'

print(ans)


### FIXED CODE ###

n, a, b, c, d = map(int,input().split())
s = str(input())

ans = 'Yes'
if '##' in s[a-1:c] or '##' in s[b-1:d]:
    ans = 'No'

if ans == 'Yes':
    if c<d:
        pass
    else:
        if '...' in s[b-2:d+1]:
            pass
        else:
            ans = 'No'

print(ans)
#入力
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for n in range(n)]
#点1から計算する
m = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (point[i][k]-pont[j][k])**2
		if isinstance(a ** 0.5, int) 
		m += 1
print(m)

### FIXED CODE ###

#入力
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
#点1から計算する
m = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (point[i][k]-point[j][k])**2
		b = a**(1/2)
		if b.is_integer():
			m += 1
print(m)
import string
text = ''
while True:
    text += input().lower()
    for char in string.ascii_lowercase:
        print(char, ':', text.count(char))



### FIXED CODE ###

import string
import sys
text = sys.stdin.read().lower()
for char in string.ascii_lowercase:
    print(char, ':', text.count(char))
a=[]
b=a.sort()
c=b.reverse()
print(c[0:2])

### FIXED CODE ###

a=[int(input()) for i in range(10)]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])
N3 = int(input())
if N3 < 1200:
    print('ABC')
elif N3 > 1999 and NR < 2800:
    print('ARC')
else:
    print('AGC')

### FIXED CODE ###

N3 = int(input())
if N3 < 1200:
    print('ABC')
elif 1200 <= N3 < 2800:
    print('ARC')
else:
    print('AGC')
N=int(input());print("Three" if len(set(map(int,input().split())))==3 else "Four")

### FIXED CODE ###

N=int(input());print("Three" if len(set(input().split()))==3 else "Four")
xs[5] = []
for i in range(5):
  xs.append(int(input()))
  if not xs[i] = i:
    print i
    break

### FIXED CODE ###

xs = [int(e) for e in input().split()]
for i in range(5):
  if not xs[i] == i+1:
    print(i+1)
    break
#!/usr/bin/env python3


s = int(input())

#2以下だったら0で決まり
if s <= 2:
    print(0)


else:
    #結果
    result = 0
    #項数でループ
    for i in range(1, s // 3 + 1):
        # #あまり
        r = s - i * 3

        if r == 0:
            result += 1
        else:
            h = 1.0
            # print(r)
            # for j in range(r, 0, -1):
            #     h *= ((j + i - 1) / j)

            # for j in range(1, r + 1):
            #     h *= ((j + i - 1) / j)
            #     print(h)

            for j in range(1, r + 1):
                h *= (j + i - 1)

            for j in range(1, r + 1):
                h //= j

            result += int(h)
        result %= int(1e9 + 7)

    print(int(result))







### FIXED CODE ###

#!/usr/bin/env python3

s = int(input())



if s <= 2:
    print(0)
else:
    a = [0] * (s + 1)
    a[0] = 1
    for i in range(3, s + 1):
        a[i] = int((a[i - 1] + a[i - 3]) % (1e9 + 7))

    print(a[s])
def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != None:
        p = par[p]
    return par[p]

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

par = [None] * N
cost = 0
count = 0
points.sort()
while count < N - 1:
    c, i, j = edges.pop()
    if get_par(points, i) == get_par(points, j):
        continue
    unite(points, i, j)
    cost += c
    count += 1
print(cost)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def unite(i, j):
    j = get_par(j)
    par[j] = get_par(i)
    return

def get_par(p):
    if par[p] is None:
        return p
    par[p] = get_par(par[p])
    return par[p]

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

par = [None] * N
cost = 0
count = 0
points.sort()
while count < N - 1:
    c, i, j = edges.pop()
    if get_par(i) == get_par(j):
        continue
    unite(i, j)
    cost += c
    count += 1
print(cost)
from collections import Counter
H, W = map(int, input().split())
D = []
for _ in range(H):
    D.extend(list([v for v in input()]))
C = Counter(D)
L = list([v for i, v in C.most_common()])
# print(C)
if H == 1 and W == 1:
    ans = "Yes"
elif H == 1 or W == 1:
    if sum([1 if v % 2 == 1 else 0 for v in L]) == 1:
        ans = "Yes"
    else:
        ans = "No"
elif H % 2 == 1 and W % 2 == 1:
    if sum(v % 2 for v in L) == 1 and (sum(1 if v % 4 == 0 else 0 for v in L) == len(L)-1 or (sum(1 if v % 4 == 0 else 0 for v in L)) == len(L)-2):
        ans = "Yes"
    else:
        ans = "No"
elif H % 2 == 0 and W % 2 == 0:
    assert 1 == 2
    ans = "Un"
else:
    if sum(v % 2 for v in L) == 0 and (sum(1 if v % 4 == 0 else 0 for v in L) == len(L)-1 or (sum(1 if v % 4 == 0 else 0 for v in L)) == len(L)-2):
        ans = "Yes"
    else:
        ans = "No"
print(ans)


### FIXED CODE ###

from collections import Counter
H, W = map(int, input().split())
D = []
for _ in range(H):
    D.extend(list([v for v in input()]))
C = Counter(D)
L = list([v for i, v in C.most_common()])

g1 = sum(v % 2 for v in L)
g4 = sum(v//4 for v in L)

if g4 >= (W-(W % 2))*(H-(H % 2))//4 and g1 == H & 1 & W:
    print("Yes")
else:
    print("No")
s=input()
k=int(input())

count_1=0
while s!='':
  if s[0]=='1':
    count_1+=1
    s=s.lstrip('1')
  else:
    break
if count_1>=k:
  print('1')
else:
  print(s[0])


### FIXED CODE ###

print(eval("("+input().replace(" ", "-1)*(")+"-1)"))
s = list(input())
n = list('abcdefghijklmnopqrstuvwxyz')
if len(s) < 26:
    for _ in m:
        if not _ in s:
            s.append(_)
            break
    print(''.join(s))
else:
    if s == n[::-1]:
        print(-1)
    else:
        x = s[-1]
        for _ in range(25)[::-1]:
            if x > s[_]:
                s = s[:_]
                s.append(x)
                break
        print(''.join(s))

### FIXED CODE ###

s = list(input())
m = list('zyxwvutsrqponmlkjihgfedcba')
if len(s) < 26:
    for i in m[::-1]:
        if not i in s:
            s.append(i)
            break
    print(''.join(s))
else:
    x = s[-1]

    for i in range(25)[::-1]:
        if x > s[i]:
            y = m.index(s[i])
            s = s[:i]
            for j in range(y)[::-1]:
                if not m[j] in s:
                    s.append(m[j])
                    break
            break
        else:
            x = s[i]
        if i == 0:
            print(-1)
            exit(0)
    print(''.join(s))
n,a,b = map(int,input().split())
l = ('b'*a+'r'*b)*10**100
print(l[:n].count('b'))

### FIXED CODE ###

n,a,b = map(int,input().split())
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)
n,a,b=map(int,input().split())
count = n//(a+b)*a
add = min(n%(a+b),a)
sum = count + add
print(sum)

### FIXED CODE ###

a,b,c = input()
if a==b==c:
	print('No')
else:
	print('Yes')
d,t,s=input().split()
if(s>=(d/t)):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

d,t,s=map(int,input().split())
if(s>=(d/t)):
    print("Yes")
else:
    print("No")
a, b, c = map(int, input())
if b - a == c - b:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a, b, c = map(int, input().split())
if b - a == c - b:
  print('YES')
else:
  print('NO')
#!/usr/bin/env python3
import numpy as np
L, N = map(int, input().split())
X = np.array([0] + [int(input()) for _ in range(N)])
Y = np.array([0] + [L - x for x in X[1:]][::-1])

if N > 2000:
    print(0)
dp = np.zeros((N + 1, N + 1, 2), dtype=np.int32)
for i in range(N):
    for j in range(N):
        dp[i + 1][j][0] = np.amax(np.array([
                dp[i][j][0] + Y[i + 1] - Y[i],
                dp[i][j][1] + X[j] + Y[i + 1]]))
        dp[i][j + 1][1] = np.amax(np.array([
                dp[i][j][0] + X[j + 1] + Y[i],
                dp[i][j][1] + X[j + 1] - X[j]]))

ans = 0
for i in range(N + 1):
    ans = max(ans, dp[i][N - i][0], dp[i][N - i][1])

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
from itertools import accumulate
L, N = map(int, input().split())
X = [int(input()) for _ in range(N)]
Y = [L - x for x in X][::-1]

sx = [0] + list(accumulate(X))
sy = [0] + list(accumulate(Y))

ans = 0
for i in range(N):
    j = N - i - 1
    mn = min(i, j)

    now = X[i]
    now += 2 * (sx[i] - sx[i - mn]) + 2 * (sy[j] - sy[j - mn - (i < j)])
    ans = max(ans, now)

    now = Y[j]
    now += 2 * (sx[i] - sx[i - mn - (i > j)]) + 2 * (sy[j] - sy[j - mn])
    ans = max(ans, now)

print(ans)
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two=[]
four=[]
for i,j in data.items():
    if 2<=j<=3:
        two.append(i)
    elif 4<=j:
        four.append(i)
if len(four)==0:
    four.append(0)
    four.append(0)
    four[1]=0
elif len(two)==0:
    two.append(0)
    two.append(0)
print(max(four[0]*four[0],four[0]*four[1],two[0]*two[1],two[0]*four[0]))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 4<=j:
        four_i.append(i)
    elif 2<=j:
        two_i.append(i)
two_i.sort()
four_i.sort()
two_i.reverse()
four_i.reverse()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*four_i[0]
two_area=two_i[0]*two_i[1]
mix_area=two_i[0]*four_i[0]
print(max(four_area,two_area,mix_area))
X, N = map(int, input().split())
p = list(input().split())

ans_enable = [True] * 102
for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)

### FIXED CODE ###

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

ans_enable = [True] * 102

for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)
a,b=map(int,input().split())
if a==min(a,b);
  s=str(a)*b
  print(int(s))
else:  
  s=str(b)*a
  print(int(s))

### FIXED CODE ###

a,b=map(int,input().split())
s1=str(b)*a
ss1=int(s1)
s2=str(a)*b
ss2=int(s2)
if ss1>ss2:
    print(s1)
else:
    print(s2)
import bisect
from math import factorial as fact
import sys
input = sys.stdin.readline

N = int(input())
prime = []
p_flag = [False] * (101)
p_flag[0] = p_flag[1] = True

for i in range(2, 101):
    if not p_flag[i]:
        prime.append(i)
        for j in range(2*i, 101, i):
            p_flag[j] = True

M = len(prime)
factor = [0]*M

for i in range(2, N+1):
    for j in range(M):
        tmp = prime[j]
        while i % tmp == 0:
            factor[j] += 1
            tmp *= tmp

factor = factor[::-1]
point74 = M - bisect.bisect_left(factor, 74)
point24 = M - bisect.bisect_left(factor, 24)
point14 = M - bisect.bisect_left(factor, 14)
point4 = M - bisect.bisect_left(factor, 4)
point2 = M - bisect.bisect_left(factor, 2)

ans = max(fact(point4)//(fact(point4-2)*fact(2)) * (point2-2), 0)
if point14 > 0:
    ans += point14 * (point4-1)
if point24 > 0:
    ans += point24 * (point2-1)
if point74 > 0:
    ans += point74

print(ans)

### FIXED CODE ###

import bisect
from math import factorial as fact
import sys
input = sys.stdin.readline
 
N = int(input())
prime = []
p_flag = [False] * (101)
p_flag[0] = p_flag[1] = True
 
for i in range(2, 101):
    if not p_flag[i]:
        prime.append(i)
        for j in range(2*i, 101, i):
            p_flag[j] = True
 
M = len(prime)
factor = [0]*M
 
for i in range(2, N+1):
    for j in range(M):
        tmp = prime[j]
        if tmp > i:
            break
        while i % tmp == 0:
            factor[j] += 1
            tmp *= prime[j]
 
factor = factor[::-1]
point74 = M - bisect.bisect_left(factor, 74)
point24 = M - bisect.bisect_left(factor, 24)
point14 = M - bisect.bisect_left(factor, 14)
point4 = M - bisect.bisect_left(factor, 4)
point2 = M - bisect.bisect_left(factor, 2)
 
if N < 10:
    ans = 0
else:
    ans = fact(point4)//(fact(point4-2)*fact(2)) * (point2-2)
    if point14 > 0:
        ans += point14 * (point4-1)
    if point24 > 0:
        ans += point24 * (point2-1)
    if point74 > 0:
        ans += point74
 
print(ans)
X= int(input())

Bp = -1*math.floor(X**0.2)
Bn = 0
while True:
    Bp += 1
    A = (X+Bp**5)**0.2
    if A == int(A):
        print(int(A),Bp)
        exit()


### FIXED CODE ###

import math

X= int(input())

for A in range(-120,121):
    for B in range(-120,A+1):
        if A**5-B**5  == X:
            print(A,B)
            exit()
h,w=map(int,input().split())
if h=1 or w==1:
  print("1")
elif h%2==0:
    print((h*w)//2)
elif w%2==0:
    print((h*w)//2)
else:
    print((w*(h//2))+(w//2)+1)

### FIXED CODE ###

h,w=map(int,input().split())
if h==1 or w==1:
  print("1")
elif h%2==0:
    print((h*w)//2)
elif w%2==0:
    print((h*w)//2)
else:
    print((w*(h//2))+(w//2)+1)
mport sys
input = sys.stdin.readline
 
def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]
 
n, k, l = map(int, input().split())
rpar = [-1]* n
tpar = [-1]* n
rrank = [0]*n
trank = [0]*n
 
for i in range(k):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, rpar, rrank) 

for i_ in range(l):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, tpar, trank)

d = {}
IDs = [0]*n
for j in range(n):
  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8
  IDs[j] = ID
  if ID in d:
    d[ID] += 1
  else:
    d[ID] = 1

ans = ''
for j_ in range(n):
  if j_ != 0:
    ans += ' '
  ans += str(d[IDs[j_]])
print(ans)

### FIXED CODE ###

def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]

n, k, l = map(int, input().split())
rpar = [-1]* n
tpar = [-1]* n
rrank = [0]*n
trank = [0]*n

for i in range(k):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, rpar, rrank) 

for i_ in range(l):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, tpar, trank)

d = {}
IDs = [0]*n
for j in range(n):
  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8
  IDs[j] = ID
  if ID in d:
    d[ID] += 1
  else:
    d[ID] = 1

ans = ''
for j_ in range(n):
  if j_ != 0:
    ans += ' '
  ans += str(d[IDs[j_]])
print(ans)
import os,sys
c=0

n=input()
for i range(n):
    m=input()
    one=m[0]
    two=m[2]
    if(one==two):
        c+=1
    
if(c>=3):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import os,sys
c=0
ok=False
n=input()
for i in range(int(n)):
    m=input()
    one=m[0]
    two=m[2]
    if one==two:
        c+=1
    else:
        c=0
    if c>=3:
        ok=True
    
if(ok):
    print('Yes')
else:
    print('No')
a = input()
print(a.startswith('YAKI')startswith)

### FIXED CODE ###

a = input()
if a.startswith('YAKI'):
  print('Yes')
else:
  print('No')
import sys
sys.setrecursionlimit(10**7)

n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dist[x] += dist[par[x]]
  par[r] = r
  return r

def direct_cost(x):
  if x == par[x]:
    return 0
  return dist[x] + direct_cost(par[x])
  
def diff(x, y):
  return dist[x] - dist[y]

flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  rootx, rooty = root(l), root(r)
  if rootx != rooty:
    if r != rooty:
      # 直接yにつなげる
      dist[rootx] = d - direct_cost(x)
    else:
      # yの根につなげる
      dist[rootx] = d - (dist[l] - dist[r])
    par[rootx] = rooty
  else:
    if d != diff(l, r):
      flag = False
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(dist)]
print()
"""

print("Yes" if flag else "No")
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

class WeightedUnionFindTree:
  def __init__(self, n):
    self.par = list(range(n))
    self.rank = [0 for _ in range(n)]
    self.weight = [0 for _ in range(n)]
   
  def root(self, t):
    if t == self.par[t]:
      return t
    # 経路圧縮してみる
    r = self.root(self.par[t])
    self.weight[t] += self.weight[self.par[t]]
    self.par[t] = r
    return r
   
  def rec_weight(self, t):
    if t == self.par[t]:
      return 0
    return self.weight[t] + self.rec_weight(self.par[t])
   
  def same(self, x, y):
    return self.root(x) == self.root(y)
     
  def unite(self, x, y, w):
    rootx = self.root(x)
    rooty = self.root(y)
    if rootx != rooty:
      if y != rooty:
        # 直接yにつなげる
        self.weight[rootx] = w - self.rec_weight(x)
      else:
        # 根につなげる
        self.weight[rootx] = w - (self.weight[x] - self.weight[y])
      # ここで親を更新
      self.par[rootx] = y
    else:
      return w == self.diff(x, y)
 
  def diff(self, x, y):
    return self.rec_weight(x) - self.rec_weight(y)

n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]


wuft = WeightedUnionFindTree(n+1)
flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  a = wuft.unite(l, r, d)
  if a is not None:
    if a == False:
      flag = False
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.weight)]
print()
"""

print("Yes" if flag else "No")
#from scipy.misc import comb
from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    ans = (comb(R+1, i, exact = True)*comb(i+(B-i)-1, B-i))%(10**9+7)
    print(int(ans))

### FIXED CODE ###

from scipy.misc import comb
#from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    # R+i C i
    #tmp1 = comb(R+1, i, exact = True)%10000000007
    tmp1 = comb(N-K+1, i, exact=True)
    rest = B - i
    # i H rest
    #tmp2 = comb(B-1, i-1, exact = True)%10000000007
    tmp2 = comb(K-1, i-1, exact=True)

    ans = (tmp1*tmp2)%1000000007
    print(int(ans))
s = list(input())
k = int(input())
a = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    a.add(s[i:j + 1])
a = sorted(a)
print(a[k - 1])

### FIXED CODE ###

s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])
print(len(set(map(input().split()))))

### FIXED CODE ###

a = list(map(int, input().split()))
print(len(set(a)))