Harryxun/stf_run huggingface dataset:
from operator import itemgetter
from collections import OrderedDict
n, q = [int(el) for el in input().split(' ')]
data = OrderedDict({i:0 for i in range(n,0,-1)})
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    data[a] += v
    print(*max(data.items(), key=itemgetter(1)))

### FIXED CODE ###

n = int(input())
data = [0] * n
for _ in range(n):
    a, v = [int(el) for el in input().split()]
    data[a-1] += v
result = max(data)
print(data.index(result)+1, result)
from collections import Counter
N,A,B =map(int,input().split()) 

blue = 'b' * A
red = 'r' * B

set_balls = blue + red
all_balls = set_balls* ( N // ( A + B ) + 1 )
all_balls = all_balls[:N]
c = Counter(all_balls)
print(c['b'])


### FIXED CODE ###

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

# import collections

# blues = 'b' * A
# reds = 'r' * B

# set_balls = blues + reds

# all_balls = set_balls * ( N // ( A + B ) + 1 )

# balls_N = all_balls[:N]

# c = collections.Counter(balls_N)
# print(c['b'])

p = N//(A+B)

if N - p*(A+B) < A:
    print(A*p + N - p*(A+B) )
else:
    print(A*p+A)
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph import NegativeCycleError
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
start = []
goal = []
score = []
for i in range(m):
    a, b, c = map(int, input().split())
    start.append(a-1)
    goal.append(b-1)
    score.append(-c)

path1 = csr_matrix((score, (start, goal)), shape=(n, n), dtype=int)
try:
    score = bellman_ford(path1, indices=0)
    print(-int(score[-1]))
except NegativeCycleError:
    print("inf")


### FIXED CODE ###

def BellmanFord(edges, num_v, source):
    #グラフの初期化
    inf = float("inf")
    dist = [inf for i in range(num_v)]
    dist[source-1] = 0

    #変の和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]-1] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                if i == num_v - 1 and edge[1] == num_v:
                    return -1

    return dist

num_v, num_e = map(int, input().split())
edges = []
for _ in range(num_e):
    a, b, c = map(int, input().split())
    edges.append((a, b, -c))

dist = BellmanFord(edges, num_v, 1)
if dist == -1:
    print("inf")
else:
    print(-dist[-1])
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
  	flg = True
    break
print("NO") if flg else print("YES")


### FIXED CODE ###

str1, str2 = input().split()
num1, num2 = map(int,input().split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d"  %(num1, num2))
N, Q = list(map(int, input().split()))

points = [[] for _ in range(N)]
counters = [0 for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    points[a - 1].append(b)

operations = []
for _ in range(Q):
    operations.append(list(map(int, input().split())))

# print(points)
# print(operations)


def dfs(points, counters, i, count):
    counters[i - 1] += count
    for next_point in points[i - 1]:
        dfs(points, counters, next_point, count)


for operation in operations:
    dfs(points, counters, operation[0], operation[1])
# print(counters)

print(' '.join(map(str, counters)))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
graph = [[] for i in range(N)]

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

# print(graph)
v = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    v[p - 1] += x
# print(v)


seen_points = [True] * N
seen_points[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if seen_points[i]:
            seen_points[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)
def substring():
    sub = []
    words = input()
    num = int(input())
    for i in range(len(words)):
        for j in range(len(words)):
            word = words[i:j+1]
            if word not in sub:
                sub.append(word)
    sub.sort()
    del sub[0]
    print(sub[num-1])
    
if __name__ == '__main__':
    substring()

### FIXED CODE ###

def substring():
    a = input()
    K = int(input())
    atra = set()
    
    for i in range(len(a)):
        for j in range(i + K + 1):
            if i >= j:
                continue
            atra.add(a[i:j])
    atra = sorted(atra)
    print(atra[K - 1])
    
if __name__ == '__main__':
    substring()
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = c[0]
jud = []
for i in range(n):
    if i not in jud:
        l = []
        j = p[i] - 1
        while j not in jud:
            jud.append(j)
            l.append(c[p[j]-1])
            j = p[j] - 1
        le = len(l)
        if le == 0:
            continue
        l *= (k//le +2)
        # for ii in range(le):
        #     val = l[ii]
        #     ans = max(ans,val)
        #     for cnt in range(ii+1, ii + k):
        #         val += l[cnt]
        #         ans = max(val, ans)

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = c[0]
jud = []
for i in range(n):
    if i not in jud:
        l = []
        j = p[i] - 1
        while j not in jud:
            jud.append(j)
            l.append(c[p[j]-1])
            j = p[j] - 1
        le = len(l)
        su = sum(l)
        l *= 2
        if su > 0:
            v = (k//le)*su
            ans = max(ans, v)
        for ii in range(le):
            val = 0
            for cnt in range(0, le):
                val += l[ii + cnt]
                if su > 0:
                    v = val + ((k - cnt - 1)//le)*su
                    ans = max(ans, v)
                else:
                    ans = max(ans, val)

print(ans)
import sys
sys.setrecursionlimit(500000)

h, w, k = map(int, input().split())
s = []
ans = [[0] * w for _ in range(h)]
cnt = 0
#prev = 1

for i in range(h):
    s.append(input())

#print(s)

for i in range(h):
    if '#' not in s[i]:
        continue
    shouldCover = False

    for j in range(w):
        if j == 0 and s[i][j] == '.':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = True
        elif s[i][j] == '#' and shouldCover:
            ans[i][j] = cnt
            shouldCover = False
        elif s[i][j] == '#':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = False
        else:
            ans[i][j] = cnt

def solve(cur, nxt, down):
    if down:
        if '#' in s[nxt]:
            for j in range(w):
                ans[cur][j] = ans[nxt][j]
        else:
            solve(cur, nxt+1, down)
    else:
        if '#' in s[nxt]:
            for j in range(w):
                ans[cur][j] = ans[nxt][j]
        else:
            solve(cur, nxt-1, down)


for i in range(h):
    if all(ans[i][j] == 0 for j in range(w)):
        if i == h - 1:
            solve(i, i-1, False)
        else:
            #print('down!')
            solve(i, i+1, True)

for i in range(h):
    print(*ans[i])
#print(ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

h, w, k = map(int, input().split())
s = []
ans = [[0] * w for _ in range(h)]
cnt = 0
#prev = 1

for i in range(h):
    s.append(input())

#print(s)

for i in range(h):
    if '#' not in s[i]:
        continue
    shouldCover = False

    for j in range(w):
        if j == 0 and s[i][j] == '.':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = True
        elif s[i][j] == '#' and shouldCover:
            ans[i][j] = cnt
            shouldCover = False
        elif s[i][j] == '#':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = False
        else:
            ans[i][j] = cnt

def solve(cur, nxt, down):
    if nxt < 0 or nxt > h-1:
        return
    if down:
        if '#' in s[nxt]:
            for k in range(cur, nxt):
                for j in range(w):
                    ans[k][j] = ans[nxt][j]
        else:
            solve(cur, nxt+1, down)
    else:
        if '#' in s[nxt]:
            for k in range(cur, nxt, -1):
                for j in range(w):
                    ans[k][j] = ans[nxt][j]
        else:
            solve(cur, nxt-1, down)


for i in range(h):
    if all(ans[i][j] == 0 for j in range(w)):
        if i == h - 1:
            solve(i, i-1, False)
        else:
            #print('down!')
            solve(i, i+1, True)

for i in range(h):
    print(*ans[i])
#print(ans)
b = input()
if b="A":
  print("T")
elif b="C":
  print("G")
elif b="G":
  print("C")
else:
  print("A")

### FIXED CODE ###

b = input()
if b=="A":
  print("T")
elif b=="C":
  print("G")
elif b=="G":
  print("C")
else:
  print("A")
n = input()
a = input()
Max = -10000000
Min = a
for i in range(n):
    x = int(input())
    if (Max < (x-Min)):
        Max = x-Min
    if (x < Min):
        Min = x
print(Max)

### FIXED CODE ###

n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n-1):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)
#coding:utf-8
from bisect import bisect_right

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

start,left = map(int,input().split())
right = left
cnt = 0
for i in range(M-1):
    data = list(map(int,input().split()))
    if data[0] != start:
        start = data[0]
        if data[1] >= left:
            cnt += 1
            left = data[1]
            right = left
    else:
        right = data[1]
    
if data[1] >= right:
    cnt += 1

print(cnt)


### FIXED CODE ###

#coding:utf-8

N,M = map(int,input().split())
List = sorted([list(map(int,input().split())) for i in range(M)], key=lambda x:x[1])

cnt = 1
maxa = 0
b = List[0][1]
for i in range(1,M):
    newB = List[i][1]
    maxa = max(maxa,List[i][0])
    if newB > b:
        if maxa >= b:
            cnt += 1
            b = newB
        maxa = 0
        
print(cnt)
n = int(input())

words = []
for i in range(n):
    words.append(input())

ret = "Yes"
if len(set(words)) != n:
    ret = "No"
else:
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            ret = "No"
            break

print(ret)

### FIXED CODE ###

a, b = map(int, input().split())
if a == 2 or b == 2:
    print('No')
else:
    print('Yes')
h,w,k=list(map(int,input().split()))

s=[list(map(int,[x for x in input()])) for _ in range(h)]

cnt=10000

for i in range(2**(h-1)):
    split=[0]*h

    for j in range(h-1):
        split[j]=(i>>j)&1
    
    curcnt=sum(split)
    
    sumlst=[0]*(curcnt+1)

    j=0
    while j<w:
        l=0
        ch=0

        while ch<h:
            sumlst[l]+=s[ch][j]
            
            if sumlst[l]>k:
                curcnt+=1
                sumlst=[0]*(sum(split)+1)
                j-=1
                continue

            if split[ch]==1:
                l+=1
            
            ch+=1
        
        j+=1
    
    cnt=min(cnt,curcnt)

print(cnt)

### FIXED CODE ###

h,w,k=list(map(int,input().split()))
s=[list(map(int,[x for x in input()])) for _ in range(h)]

cnt=10001

for i in range(2**(h-1)):
    split=[0]*h
    curcnt=0
    for j in range(h):
        if (i>>j)&1:
            split[j]=1
            curcnt+=1
        
    nsplit=curcnt+1
    sumlst=[[0]*(nsplit) for _ in range(w)]

    cw=0
    memo=0
    chk=0
    flag=False
    while cw<w:
        l=0
        for ch in range(h):
            sumlst[memo][l]+=s[ch][cw]

            if sumlst[memo][l]>k:
                memo+=1
                chk+=1
                break

            if split[ch]:
                l+=1
        else:
            chk=0
            cw+=1
            continue

        if chk>1:
            break
    else:
        cnt=min(cnt,curcnt+memo)

print(cnt)
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
X = input()
M = X.count("1")+1
m = M-2
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)

### FIXED CODE ###

def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
L[N] = -1
X = input()
M = X.count("1")+1
m = max(1,M-2)
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
        if M == 2:
            A = N
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)
S = input()
Dictionary = {"SAT":1,"FRI":2,"THU":3,"WED":4,"TUE":5,"MON":6,"SUN":7}
Day = Dictionary[S]
print(DAY)


### FIXED CODE ###

S = input()
Dictionary = {"SAT":1,"FRI":2,"THU":3,"WED":4,"TUE":5,"MON":6,"SUN":7}
Day = Dictionary[S]
print(Day)
ans = A * B
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
n = int(input())
ans = 0
for i in range(1,n + 1):
    if 10 <= i < 100 or 1000 <= i < 10000 or i == 100000:
        continue
    else:
        ans += 1
print(ans)

### FIXED CODE ###

a, b, c = map(int,input().split())
print(b + c - a if b + c - a > 0 else 0)
N = int(input()) 
height = list(map(int, input().split())) #入力：花の高さ
water_count = 0 #水やり回数
while True:
    index = [i for i, v in enumerate(height) if v >0] #水をやる必要のある花のリスト インデックスが連続した範囲でしか水やりできない
    
    # 花の水やり範囲を決定
    min_index = index[0] #インデックスの最小値
    max_index = index[0] #インデックスの最大値
    
    while True:
        if (max_index+1) in index:
            max_index += 1
        else:
            break
    
    for flower in range(min_index, max_index+1):
        height[flower] -= 1 #水やりカウンタ増やす
    water_count += 1
        
    if sum(height) == 0: #水やりが終わったら終了
        break
print(water_count)

### FIXED CODE ###

def solve(height):
    
    water_count = 0 #水やり回数

    while True:
        index = [i for i, v in enumerate(height) if v >0] #水をやる必要のある花のリスト インデックスが連続した範囲でしか水やりできない
    
        # 花の水やり範囲を決定
        min_index = index[0] #インデックスの最小値
        max_index = index[0] #インデックスの最大値
    
        while True:
            if (max_index+1) in index:
                max_index += 1
            else:
                break
    
        for flower in range(min_index, max_index+1):
            height[flower] -= 1 
        water_count += 1 #水やりカウンタ増やす
        
        if sum(height) == 0: #水やりが終わったら終了
            break
    print(water_count)
    
def solve_zero(height): #元々のリストがすべて０のとき
    print(0)

if __name__ == "__main__":
    N = int(input()) 
    height = list(map(int, input().split())) #入力：花の高さ
    if sum(height) == 0:
        solve_zero(height)
    else:
        solve(height)
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7
from scipy.special import comb

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

n, k = na()
a = na()
cl = 0
cr = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i] < a[j]:
            cl += 1
        if a[i] > a[j]:
            cr += 1
ans = (cr*k %mod + (cl+cr) * comb(k, 2, exact=True)) % mod
print(ans)

### FIXED CODE ###

import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

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

n, k = na()
a = na()
cl = 0
cr = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i] < a[j]:
            cl += 1
        if a[i] > a[j]:
            cr += 1
ans = (cr*k %mod + (cl+cr) * k*(k-1)//2) % mod
print(ans)
N=int(input())
D=int(input())
X=int(input())
S=0
for i in range(1,N):
  A=int(input())
  A_=(D//A)+1
  S+=A_
print(S+X) 


### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A<=B:
  min1=A
else:
  min1=B
if C<=D:
  min2=C
else:
  min2=D
  
print(min1+min2)
N = int(input())
X = str(input())

def popcount(X):
  counter = 0
  for i in range(N):
    if X[i] == "1":
      counter += 1
  return counter

    
def converter(N,X):
  conv_counter = 0
  for i in range(N):
    conv_counter += int(X[i])*(2**((N-1)-i))
  return conv_counter

def decorder(N,X):
  #10進数のXをＮ桁の2進数に直す
  reslist = []
  for i in range(N):
    p = int(X) // 2**((N-1)-i)
    reslist.append(str(p))
    X = str(int(X) - p*(2**((N-1)-i)))
  #print("reslist",reslist)
  res = "".join(reslist)
  return res

def bit_change(X,P):
  LISTX = list(X)
  change_num = abs(int(X[P])-1)
  LISTX[P] = str(change_num)
  X = "".join(LISTX)
  return X


def main(N,X):
  for i in range(N):
    result = 0
    #二進数のBIT変換
    target = bit_change(X,i)
    #print("target",target)
    
    if converter(N,target) == 0:
      flag = 0
    else:
      flag = 1
    #print("flag:",flag)
    
    while flag == 1:
      result += 1
      pop_count = popcount(target)
      conv = converter(N,target)
      target_10 = conv % pop_count
      
      if target_10 == 0:
        flag = 0
        
      else:
        target = decorder(N,target_10)
	  
    print(result)
    
main(N,X)
    
#print(decorder(N,X))
    
  


### FIXED CODE ###

S = input().split()

counter = 0
for _ in range (int(S[0]),int(S[1])+1):
  if _ % int(S[2]) == 0:
    counter += 1
  
print(counter)
inlist = input()
inlist_list = inlist.split(' ')
ans_list = inlist_list.sort()
a = ans_list.pop[0]
b = ans_list.pop[1]
c = ans_list.pop[2]

print(a+" "+b+" "+c)

### FIXED CODE ###

inlist = raw_input()
inlist = inlist.split(' ')
inlist.sort()
a = inlist[0]
b = inlist[1]
c = inlist[2]

print(a+" "+b+" "+c)
from collections import deque

S = input()
pre, post = deque(), deque()
Q = int(input())
reversed = False
for _ in range(Q):
  query = input().split()
  if query[0] == '1':
    reversed = not reversed
    pre, post = post, pre
  else:  # query[0] == 2
    F, C = query[1:]
    if F == '1':
      if reversed:
        pre.append(C)
      else:
        pre.appendleft(C)
    else:  # F == '2'
      if reversed:
        post.appendleft(C)
      else:
        post.append(C)
if reversed:
  print(''.join(pre[::-1]) + S[::-1] + ''.join(post[::-1]))
else:
  print(''.join(pre) + S + ''.join(post))

### FIXED CODE ###

from collections import deque

S = input()
pre, post = deque(), deque()
Q = int(input())
reversed = False
for _ in range(Q):
  query = input().split()
  if query[0] == '1':
    reversed = not reversed
    pre, post = post, pre
  else:  # query[0] == 2
    F, C = query[1:]
    if F == '1':
      if reversed:
        pre.append(C)
      else:
        pre.appendleft(C)
    else:  # F == '2'
      if reversed:
        post.appendleft(C)
      else:
      	post.append(C)
if reversed:
  print(''.join(pre)[::-1] + S[::-1] + ''.join(post)[::-1])
else:
  print(''.join(pre) + S + ''.join(post))
K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    s=S-math.ceil(K/3)*3
    print((s+2)*(s+1)//2)
else:
    s=3*K-S
    print((s+2)*(s+1)//2)

### FIXED CODE ###

K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    m=0
    for i in range(K+1):
        s=S-i
        if s<=K:
            m+=s+1
            
        else:
            c=s-K
            a=s-2*c
            m+=a+1         
    print(m)

else:
    s=3*K-S
    print((s+2)*(s+1)//2)
N = int(input())
S = input()
if S[0:N//2] == S[N//2:N]:
    print("yes")
    
elif S[0:N//2] != S[N//2:N]
    print("No")

else:
    print("No")

### FIXED CODE ###

N = int(input())
S = input()
if N % 2 != 0:
    print("No")
elif S[:N//2] == S[N//2:]:
    print("Yes")
else:
    print("No")
temp = input()
temp = temp.split()
town_num = int(temp[0])
move = int(temp[1])

town = input()
town = town.split()
town = [int(s) for s in town]
data = [0] * 1000

position = 1

if move < 1000:
    for i in range(move):
      position = town[position-1]

else:
    for i in range(town_num):
        data[i] = town[position-1]
        position = town[position-1]
        if data[i] == data[4] and i > 4:
            count = i
            break
    cycle = count - 4
    try:
        period = (move-4)%cycle
        position = data[period+4]
        position = town[position-1]-1
    except ZeroDivisionError:
        a = 1


print(position)

### FIXED CODE ###

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

journey = [1]

for i in range(2*n + 100):
    nxt = a[journey[-1]]
    journey.append(nxt)
    
if k < n + 1:
    print(journey[k])
    exit()

loop_end = n

loop_start = n-1

while(journey[loop_start] != journey[loop_end]):
    loop_start -= 1

period = loop_end - loop_start

k %= period
while k<= n:
    k += period

print(journey[k])
from collections import defaultdict
N, M = map(int, input().split())
G = defaultdict(list)
for i in range(M):
    l, r, d = map(int, input().split())
    l, r = l - 1, r - 1
    G[l].append((r, d))
    G[r].append((l, -d))
used = [False] * (N + 1)
dist = [0] * (N + 1)
flag = False


def dfs(v, d0):
    global flag
    if used[v]:
        if dist[v] != d0:
            flag = True
        return
    else:
        used[v] = True
        dist[v] = d0

    if v in G:
        for w, d1 in G[v]:
            dfs(w, d0 + d1)


for i in range(1, N + 1):
    if not used[i]:
        dfs(i, 0)

if flag:
    print("No")
else:
    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")
print(*sorted(map(int, i.split())))

### FIXED CODE ###

print(*sorted(map(int, input().split())))
N, K = map(input().split())
print(N-K+1)

### FIXED CODE ###

N, K = map(int, input().split())
print(N-K+1)