Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###


n = int(input())

ans = 0

while n > 0:
    ans += n % 10
    n //= 10

if ans % 9 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###


n = int(input())

ans = 0

l = [int(x) for x in list(str(n))]
ans = sum(l)

if ans % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
sum = 0
while (1 == 1):
    #Cがある時
    if c > 0:
        c = c - 1
        sum = sum + 1
        if a > 0:
            a = a - 1
        elif b > 0:
            b = b -1
            sum = sum + 1
        else :
            break
    # Cがない時
    else :
        if b > 0:
            b = b -1
            sum = sum + 1
        else :
            break

# 出力
print("{}" .format(sum))

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
result = 0
if a + b + 1 >= c:
  result = b + c
else:
  result = b + (a + b + 1)
# 出力
print("{}" .format(result))
### BUGGY CODE ###

from collections import deque

S_deque = deque(input())
Q = int(input())

for _ in range(Q):
  item = list(input().split())
  if item[0] == '1':
    S_deque = deque(reversed(S_deque))

  else:
    if item[1] == '1':
      S_deque.appendleft(item[2])

    else:
      S_deque.append(item[2])

S = list(S_deque)
print(''.join(S))

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

S_deque = list(input())
S_deque = deque(S_deque[:-1])
Q = int(input())

top_flag = 1 # 0なら末尾、1なら最初

for _ in range(Q):
  item = list(input().split())
  if item[0] == '1':
    if top_flag == 0:
      top_flag = 1
    else:
      top_flag = 0

  else:
    in_flag = top_flag + int(item[1])
    if in_flag % 2 == 0:
      S_deque.appendleft(item[2])
    else:
      S_deque.append(item[2])

if top_flag == 0:
  S_deque.reverse()
else:
  pass

print(''.join(S_deque))
### BUGGY CODE ###

n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
total_act = 0
total_act2 = 1
total = 1
for i in range(n + 1):
    if str(i) in a:
        total *= total_act
        total_act = 0
        total_act2 = 1
    else:
        total_act3 = total_act2 + total_act
        total_act2 = total_act
        total_act = total_act3
total *= total_act
print(total%1000000007)


### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
if m == 0:
    for i in range(n + 1):
        if str(i) in a:
            total *= total_act
            total_act = 0
            total_act2 = 1
        else:
            total_act3 = total_act2 + total_act
            total_act2 = total_act
            total_act = total_act3
    total *= total_act
    print(total % 1000000007)
else:
    b.append(int(a[0]))
    for i in range(len(a) - 1):
        b.append(int(a[i + 1]) - int(a[i]) - 1)
        if int(a[i + 1]) - int(a[i]) - 1 == 0:
            print(0)
            exit()
    b.append(n - int(a[-1]))

    for i in range(max(b)):
        total_act3 = total_act2 + total_act
        total_act2 = total_act
        total_act = total_act3
        c.append(total_act)

    for i in b:
        total *= c[i - 1]
    print(total % 1000000007)
### BUGGY CODE ###

s = input()

flag = 0
cnt = 0
n = int(input())

for i in range(n):
    que = input()
    if(len(que) == 1):
        cnt += 1
    else:
        que = que.split()
        if(que[1]=="1" and cnt%2 == 0):
            s = que[2] + s
        if(que[1]=="1" and cnt%2 == 1):
            s = s + que[2]
        if(que[1]=="2" and cnt%2 == 0):
            s = s +que[2] 
        if(que[1]=="2" and cnt%2 == 1):
            s = que[2] + s

if(cnt%2 == 0):
    print(s)
else:
    print(s[::-1])



### FIXED CODE ###

s = input()

flag = 0
cnt = 0
n = int(input())

que_ar = [input() for _ in range(n)]

f_x = ["" for _ in range(n)]
b_x = ["" for _ in range(n)]


f = n-1
b = 0

for i in range(n):
    que = que_ar[i]
    if(len(que) == 1):
        cnt += 1
    else:
        que = que.split()
        if(cnt%2 == 0):
            if(que[1]=="1"):
                f_x[f] = que[2]
                f -= 1
            else:
                b_x[b] = que[2]
                b += 1
        else:
            if(que[1]=="1"):
                b_x[b] = que[2]
                b += 1
            else:
                f_x[f] = que[2]
                f -= 1

s = "".join(f_x)+s+"".join(b_x)             
                
if(cnt%2 == 0):
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i<=n-1:
            a,b,c=s[i],s[j],s[2*j-i]
            if a==b or b==c or c==a:
                pass
            else:
                ans-=1

print(ans)

### FIXED CODE ###

from collections import Counter
n=int(input())
s=list(input())
C=Counter(s)
r,g,b=C["R"],C["G"],C["B"]
ans=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<=n-1 and s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans-=1

print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect

N, Q = map(int, input().split())
S = input()

ac_list = []
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ac_list.append(i)

for i in range(Q):
    l, r = map(int, input().split())
    li_index = bisect.bisect_left(ac_list, l-1)
    ri_index = bisect.bisect_left(ac_list, r-1)
    ans = len(ac_list[li_index:ri_index])
    print(ans)

### FIXED CODE ###

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

N, Q = map(int, input().split())
S = input()

t = [0] * (N+1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i: i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    k = min(50,k)

    dp = [[0]*n for _ in range(k+1)]
    for i in range(n):
        dp[0][i] = A[i]

    flag = False
    for i in range(1,k+1):
        pos = [0]*n
        neg = [0]*n

        for j in range(n):
            pwr = dp[i-1][j]
            pos[max(0,j-pwr)]+=1
            neg[min(n-1,j+pwr)]+=1

        ac_pos = 0
        ac_neg = 0
        for j in range(n):
            ac_pos += pos[j]
            ac_neg += neg[j]
            pos[j] = ac_pos
            neg[j] = ac_neg

        if pos[0]==n and neg[n-2]==0:
            flag = True
            break

        dp[i][0] = pos[0]
        for j in range(1,n):
            dp[i][j] = pos[j] - neg[j-1]

    
    if flag:
        for j in range(n-1):
            print(n, end=" ")  
        print(n)

    else:
        for j in range(n-1):
            print(dp[i][j], end=" ")
        print(dp[i][n-1])
main()

### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    k = min(50,k)

    dp = [[0]*n for _ in range(k+1)]
    for i in range(n):
        dp[0][i] = A[i]

    flag = False
    for i in range(1,k+1):
        pos = [0]*n
        neg = [0]*n

        for j in range(n):
            pwr = dp[i-1][j]
            pos[max(0,j-pwr)]+=1
            neg[min(n-1,j+pwr)]+=1

        ac_pos = 0
        ac_neg = 0
        for j in range(n):
            ac_pos += pos[j]
            ac_neg += neg[j]
            pos[j] = ac_pos
            neg[j] = ac_neg

        if pos[0]==n and neg[n-2]==0:
            flag = True
            break

        dp[i][0] = pos[0]
        for j in range(1,n):
            dp[i][j] = pos[j] - neg[j-1]

    
    if flag:
        for j in range(n-1):
            print(n, end=" ")  
        print(n)

    else:
        for j in range(n-1):
            print(dp[i][j], end=" ")
        print(dp[i][n-1])
main()
### BUGGY CODE ###

NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
candidate_list = []
tree_dict = {}
#Make tree dict
for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0])
    b = int(ab[1])
    tree_dict[i+1] = {
                'count': 0,
                'has_trees': []
            }
    candidate_list.append((a,b))
tree_dict[N] = {
    'count': 0,
    'has_trees': []
    }
candidate_list.reverse()
 
for candidate in candidate_list:
    a = candidate[0]
    b = candidate[1]
    tree_dict[a]['has_trees'] += tree_dict[b]['has_trees'] + [b]
        
 
for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    tree_dict[p]['count'] += x
out_put_list = [0] * N
for k, v  in tree_dict.items():
    out_put_list[k-1] += v['count']
    for idx in v['has_trees']:
        out_put_list[idx-1] += v['count']
print(' '.join(map(str,out_put_list)))

### FIXED CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
out_put_list = [0] * N
tree_list = {}
for i in range(N):
    tree_list[i] = []

for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0]) -1
    b = int(ab[1]) -1
    tree_list[a].append(b)

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    out_put_list[p-1] += x

for i in range(len(tree_list)):
    for num in tree_list[i]:
        out_put_list[num] += out_put_list[i]

print(*out_put_list)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):print(ans[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

from itertools import combinations
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
println = stdout.write

def main():
    N, M = map(int, input().split())
    XYZ = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = -float('inf')
    for cake in combinations(XYZ, M):
        x, y, z = 0, 0, 0
        for i, j, k in cake:
            x += i; y += j; z += k
        for xm in (x, -x):
            for ym in (y, -y):
                for zm in (z, -z):
                    ans = max(ans, xm + ym + zm)
    print(ans)

main()


### FIXED CODE ###

from itertools import combinations, product
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
println = stdout.write

def main():
    N, M = map(int, input().split())
    XYZ = [tuple(map(int, input().split())) for _ in [0] * N]

    cake = [0] * N
    ans = -float('inf')
    for kx, ky, kz in product((1, -1), repeat=3):
        for i, (x, y, z) in enumerate(XYZ):
            cake[i] = sum((x * kx, y * ky, z * kz))
        cake.sort(reverse=1)
        ans = max(ans, sum(cake[:M]))
    print(ans)

main()
### BUGGY CODE ###

import numpy as np

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

expect = {}
for i in range(1, 1001):
    prob = 1 / float(i)
    expect[i] = sum(np.arange(1, i+1)) * prob

p_mapped = [expect[i] for i in p]

max = 0
for i in range(len(p_mapped)-K+1):
    answer = np.sum(p_mapped[i:i+K])
    if answer >= max:
        max = answer
print(max)

### FIXED CODE ###

import numpy as np

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

p_mapped = [(i + 1) / 2 for i in p]
p_m_cumsum = np.cumsum(p_mapped)

max = 0
for i in range(len(p_m_cumsum)-K+1):
    if i != 0:
        answer = p_m_cumsum[i+K-1] - p_m_cumsum[i-1]
    else:
        answer = p_m_cumsum[i+K-1]
    if answer >= max:
        max = answer
print(max)
### BUGGY CODE ###

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
now = 1
for i in range(k):
    now*=a[i]
for i in range(k,n):
    new = (now/a[i-k])*a[i]
    if now < new:
        print("Yes")
    else:
        print("No")
    now = new

### FIXED CODE ###

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(k,n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[set()for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].add(b)
  g[b].add(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

### FIXED CODE ###

import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])
### BUGGY CODE ###

def get_prime_factorized(N):
    result    = []
    base, exp = 2, 0
    while base ** 2 <= N:
        while N % base == 0:
            N    = N // base
            exp += 1
        if exp > 0:
            result.append([base, exp])
        base, exp = base + 1, 0
    if N > 1:
        result.append([N, 1])
    return result

def re_func_divisior(prime_factorized):
    base, exp = prime_factorized.pop()
    P = re_func_divisior(prime_factorized) if prime_factorized else [[]]
    Q = [[base ** k] for k in range(exp + 1)]
    return [p + q for p in P for q in Q]

def get_list_divisor(N, reverse=True):
    try:
        prime_factorized = get_prime_factorized(N)
        res    = re_func_divisior(prime_factorized)
        result = []
        for k in res:
            for i, x in enumerate(k):
                if i == 0:
                    r = x
                else:
                    r *= x
            result.append(r)
        result = sorted(result, reverse=reverse)
    except:
        result = [N]
    return result


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

X = get_list_divisor(sum(A))

is_break = False

for x in X:
    POS = sorted([a % x for a in A if a % x != 0])
    NEG = [x - pos for pos in POS]
    for sep in range(1, len(POS)):
        sum_POS = sum(POS[:sep])
        if sum_POS == sum(NEG[sep:]) and sum_POS <= K:
            is_break = True
            break
    if is_break:
        break

print(x)


### FIXED CODE ###

import numpy as np


def get_prime_factorized(N):
    result    = []
    base, exp = 2, 0
    while base ** 2 <= N:
        while N % base == 0:
            N    = N // base
            exp += 1
        if exp > 0:
            result.append([base, exp])
        base, exp = base + 1, 0
    if N > 1:
        result.append([N, 1])
    return result

def re_func_divisior(prime_factorized):
    base, exp = prime_factorized.pop()
    P = re_func_divisior(prime_factorized) if prime_factorized else [[]]
    Q = [[base ** k] for k in range(exp + 1)]
    return [p + q for p in P for q in Q]

def get_list_divisor(N, reverse=True):
    try:
        prime_factorized = get_prime_factorized(N)
        res    = re_func_divisior(prime_factorized)
        result = []
        for k in res:
            for i, x in enumerate(k):
                if i == 0:
                    r = x
                else:
                    r *= x
            result.append(r)
        result = sorted(result, reverse=reverse)
    except:
        result = [N]
    return result


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

X = get_list_divisor(sum(A))

is_break = False

for x in X:
    POS = sorted([a % x for a in A if a % x != 0])
    NEG = [x - pos for pos in POS]
    POS_cumsum = np.cumsum(POS)
    NEG_cumsum = np.cumsum(NEG[::-1])[::-1]
    for sep in range(1, len(POS)):
        if POS_cumsum[sep-1] == NEG_cumsum[sep] and POS_cumsum[sep-1] <= K:
            is_break = True
            break
    if is_break:
        break

print(x)
### BUGGY CODE ###

# AGC 012 A - AtCoder Group Contest
N = int(input())
an = list(map(int,input().split()))

lists = [[] for _ in range(N)]
for k in range(N):
    lists[k].append(max(an))
    del an[an.index(max(an))]
    lists[k].append(max(an))
    del an[an.index(max(an))]

for k in range(N):
    lists[k].append(max(an))
    del an[an.index(max(an))]
    
sasa = 0
for j in range(N):
    sasa += lists[j][1]
print(sasa)

### FIXED CODE ###

# AGC 012 A - AtCoder Group Contest
N = int(input())
an = list(map(int,input().split()))

lists = [[] for _ in range(N)]
an.sort(reverse=True)

for k in range(N):
    lists[k].append(an[2*k])
    lists[k].append(an[2*k+1])
                    
for i in range(N):
    lists[i].append(an[2*N-1+i])

sasa = 0
for j in range(N):
    sasa += lists[j][1]
print(sasa)
### BUGGY CODE ###

S = input()

# i~nまでの値をmod2019したときの数
ls = [0for i in range(2019)]

# 0文字の時
ls[0] += 1

for i in range(len(S)):
    x = int(S[i:])%2019
    ls[x] += 1

count = 0
for i in range(2019):
    x = ls[i]
    count += x*(x-1)/2

print(int(count))



### FIXED CODE ###

S = input()
digits = list(map(int,S))
# S = S[::-1]→これが時間かかる

# i~nまでの値をmod2019したときの数
# ls = [0for i in range(2019)]
ls = [0] * 2019

# 0文字の時
ls[0] += 1

x = 0
pow10 = 1
count = 0
for i in reversed(digits):
    x += i*pow10
    x %= 2019
    count += ls[x]
    ls[x] += 1
    pow10 *= 10
    pow10 %= 2019

# for x in ls:
#     count += x*(x-1)/2

print(int(count))
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3
abcbdab
bdcaba
abc
abc
abc
bc
"""
import sys


def lcs(A, B):
    m, n = len(A), len(B)
    count_list = [[0] * (n + 1) for _ in range(m + 1)]

    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if A[i - 1] == B[j - 1]:
                count_list[i][j] = count_list[i - 1][j - 1] + 1
            elif count_list[i - 1][j] >= count_list[i][j - 1]:
                count_list[i][j] = count_list[i - 1][j]
            else:
                count_list[i][j] = count_list[i][j - 1]

    return count_list[m][n] - 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    pair_num = int(_input[0])

    word_list = _input[1:]
    # assert len(word_list) == 2 * pair_num
    for k in range(0, len(word_list), 2):
        print(lcs(word_list[k], word_list[k + 1]))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3
abcbdab
bdcaba
abc
abc
abc
bc

output:
4
3
2

"""
import sys


def lcs(A, B):
    m, n = len(A), len(B)
    count_list = [[0] * (n + 1) for _ in range(m + 1)]

    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if A[i - 1] == B[j - 1]:
                count_list[i][j] = count_list[i - 1][j - 1] + 1
            elif count_list[i - 1][j] >= count_list[i][j - 1]:
                count_list[i][j] = count_list[i - 1][j]
            else:
                count_list[i][j] = count_list[i][j - 1]

    return count_list[m][n]


def lcs_better(A, B):
    costs = [0]
    for c in B:
        for index in range(len(costs) - 1, -1, -1):
            # print(costs, index + 1)
            x_findex_index = A.find(c, costs[index])
            if x_findex_index != -1:
                if index + 1 < len(costs):
                    costs[index + 1] = min(costs[index + 1], x_findex_index + 1)
                else:
                    costs.append(x_findex_index + 1)
    return len(costs) - 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    pair_num = int(_input[0])

    word_list = _input[1:]
    # assert len(word_list) == 2 * pair_num
    for k in range(0, len(word_list), 2):
        print(lcs_better(word_list[k].strip(), word_list[k + 1].strip()))
### BUGGY CODE ###

# ABC170

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

a.sort()
maxa = max(a)
dp = [True for _ in range(maxa+1)]

ans = 0
for ai in a:
    if dp[ai]:
        for i in range(0, maxa+1, ai):
            dp[i] = False
        if a.count(ai) == 1:
            ans += 1

print(ans)


### FIXED CODE ###

# ABC170

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

a.sort()
a_max = max(a)
dp = [True for _ in range(a_max+1)]

ans = 0
for i in range(n):
    if dp[a[i]]:
        for j in range(0, a_max+1, a[i]):
            dp[j] = False
        if i > 0:
            if a[i] == a[i-1]:
                continue
        if i < n-1:
            if a[i] == a[i+1]:
                continue
        ans += 1

print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

n = int(input())
ans = 1
dummy1,dummy2 = divmod(n,2)
for i in range(1,dummy1+1):
  ans *= i
  ans *= n+1-i
  ans = ans % (10**9+7)
if dummy2 == 1:
  ans = ((dummy1+1)*ans % (10**9+7))
print(ans)
### BUGGY CODE ###


N,K = map(int,input().split())
S = input()

#N = 10 ** 5
#K = 3
#S = "01" * ((10 ** 5) // 2 )

lis = []

nowchar = -1
num = 0

for i in range(N):

        if nowchar == S[i]:

            num += 1

        elif nowchar != -1:

            lis.append([nowchar,num])

            nowchar = S[i]
            num = 1

        else:

            nowchar = S[i]
            num = 1

lis.append([nowchar,num])


nlis = []
zeronum = 0
summ = 0
ans = 0


while True:

    if zeronum <= K:

        ans = max(ans,summ)

        if len(lis) == 0:
            break

        new = lis.pop(0)
        nlis.append(new)

        if new[0] == "0":
            zeronum += 1

        summ += new[1]

    else:

        old = nlis.pop(0)

        if old[0] == "0":
            zeronum -= 1

        summ -= old[1]

print (ans)
        
    


### FIXED CODE ###


N,K = map(int,input().split())
S = input()

#N = 10 ** 5
#K = 3
#S = "01" * ((10 ** 5) // 2 )

lis = []

nowchar = -1
num = 0

for i in range(N):

        if nowchar == S[i]:

            num += 1

        elif nowchar != -1:

            lis.append([nowchar,num])

            nowchar = S[i]
            num = 1

        else:

            nowchar = S[i]
            num = 1

lis.append([nowchar,num])


nlis = []
lisst = 0
lisla = -1
zeronum = 0
summ = 0
ans = 0


while True:

    if zeronum <= K:

        ans = max(ans,summ)

        if lisla == len(lis)-1:
            break

        new = lis[lisla+1]
        lisla += 1
        #nlis.append(new)

        if new[0] == "0":
            zeronum += 1

        summ += new[1]

    else:

        old = lis[lisst]
        lisst += 1

        if old[0] == "0":
            zeronum -= 1

        summ -= old[1]

print (ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]

for _ in range(m):
    l, r, d = [int(x) for x in input().split()]
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))

d = [0] * n
visited = [0] * n

for i in range(n):
    if visited[i] != 0:
        continue
    stack = [i]
    d[i] = 0
    while stack:
        u = stack.pop()
        visited[u] = 1
        for v, d_ in g[u]:
            if d[v] == 0:
                d[v] = d[u] + d_
                stack.append(v)
            else:
                if d[v] != d[u] + d_:
                    print("No")
                    sys.exit()
print("Yes")


### FIXED CODE ###

n, m = map(int, input().split())
ed = [[] for _ in range(n)]  # グラフ
v = [None] * n
for _ in range(m):
  l, r, d = map(int, input().split())
  ed[l-1].append((r-1, d))  # l -> r
  ed[r-1].append((l-1, -d))  # r -> l

visited = [False] * n  # 訪問フラグ（非連結の可能性の為）

def dfs(start):
  s = [start]
  v[start] = 0
  while s:
    label = s.pop()
    if visited[label] == False:
      visited[label] = True
      for to, dist in ed[label]:
        if v[to] is None:
          v[to] = v[label] + dist
          s.append(to)
        else:
          if v[to] != v[label] + dist:
            return False
  return True

is_exist = True
for i in range(n):
  if v[i] is None:
    if not dfs(i):
      print('No')
      is_exist = False
      break
if is_exist:
  print("Yes")