Harryxun/stf_run huggingface dataset:
import math
import functools


def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    memG = 0
    for i in range(N):
        tmp = As[:i] + As[i + 1 :]
        g = functools.reduce(math.gcd, tmp)
        if g > memG:
            memG = g
    print("{}".format(memG))


sub()


### FIXED CODE ###

from functools import lru_cache, reduce


@lru_cache(maxsize=None)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]
    # As = sorted(As, reverse=True)

    memG = 0
    # if N == 2:
    # memG = gcd(As[0], As[1])
    if N < 10:
        for i in range(N):
            tmp = As[:i] + As[i + 1 :]
            g = reduce(gcd, tmp)
            if g > memG:
                memG = g
    else:
        gLeft = {0: As[0], 1: gcd(As[0], As[1])}
        for i in range(2, N):
            gI = gcd(gLeft[i - 1], As[i])
            gLeft[i] = gI
        gRight = {N - 1: As[N - 1], N - 2: gcd(As[N - 1], As[N - 2])}
        for i in range(2, N):
            gI = gcd(gRight[N - i], As[N - 1 - i])
            gRight[N - 1 - i] = gI

        buf = []
        for i in range(N):
            leftG = None
            if (i - 1) in gLeft:
                leftG = gLeft[i - 1]
            rightG = None
            if (i + 1) in gRight:
                rightG = gRight[i + 1]
            # tmpG = None
            if leftG is None:
                leftG = rightG
            elif rightG is None:
                rightG = leftG
            buf.append(gcd(leftG, rightG))
            # tmpG = gcd(leftG, rightG)
            # if tmpG > memG:
            #     memG = tmpG
        memG = max(buf)

    print("{}".format(memG))


sub()
a, b, k = map(int, input().split())
mx = round(max(a, b) * 0.5)
match, ans = 0, 0

for i in range(mx + 1):
    if ((a % (mx - i)) == 0) and ((b % (mx - i)) == 0):
        
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)


### FIXED CODE ###

a, b, k = map(int, input().split())
mx = max(a, b)
match, ans = 0, 0

for i in range(mx):
    if ((a % (mx - i)) == 0) and ((b % (mx - i)) == 0):
        
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**7)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if 0 <= a <= 2*(10**7) and  p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    p[a] = ret
    return ret

x0 = int(x,2)%(cnt-1)
x1 = int(x,2)%(cnt+1)
xx0 = [1]
for i in range(n+1):
  xx0.append((xx0[-1]*2)%(cnt-1))
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))

y = list(x)  
for i in range(n):
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    xx = xx0[n-i-1]
    print(calc((x0-xx)%(cnt-1))+1)
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**7)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if 0 <= a <= 2*(10**7) and  p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    if 0 <= a <= 2*(10**7):
      p[a] = ret
    return ret

if cnt > 1:
  x0 = int(x,2)%(cnt-1)
  xx0 = [1]
  for i in range(n+1):
    xx0.append((xx0[-1]*2)%(cnt-1))
x1 = int(x,2)%(cnt+1)
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))

y = list(x)  
for i in range(n):
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    if cnt == 1:
      print(0)
    else:
      xx = xx0[n-i-1]
      print(calc((x0-xx)%(cnt-1))+1)
while True:
        a,op,b=input().split()
        a=int(a)
        b=int(b)
            
        if '?' in op: break
        print(eval(a+op+b))


### FIXED CODE ###



while 1:
     s=input()
     if '?' in s: break
     print(int(eval(s)))
A,B=map(int,input())
if A + B >= A - B:
    if A + B>=A * B:
        print(A + B)
    else :
        print(A * B)
else :
    if A - B >= A * B:
        print(A - B)
    else:
        print(A * B)


### FIXED CODE ###

A,B=map(int,input().split())
if A + B >= A - B:
    if A + B>=A * B:
        print(A + B)
    else :
        print(A * B)
else :
    if A - B >= A * B:
        print(A - B)
    else:
        print(A * B)
s = input()
t = input()
 
count = 0
 
for i in range(3):
	if s[i] == t[i]:
	count += 1  
  	print(count)

### FIXED CODE ###

s = input()
t = input()
 
count = 0
 
for i in range(3):
		if s[i] == t[i]:
			count += 1  
    
print(count)
n,t=map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
d=list()
s1=0
s2=0
for i in range(n):
  d.append([c[i][1]/c[i][0],c[i][0]])
while s1=<t-0.5:
  s2+=c[d.index(d.pop(max(d)))][1]
  s1+=c[d.index(d.pop(max(d)))][0]
print(s2)

### FIXED CODE ###

n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
dp=[[0]*(t+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(t+1):
    if j!=t:
      if j-l[i-1][0]>=0:
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
    else:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+l[i-1][1])
    dp[i][j]=max(dp[i-1][j],dp[i][j])
print(max(dp[n]))
n, k = map(int, input().split())
if n == k:
  print(0)
  exit()
l = k%n
print(min(l, k-l))

### FIXED CODE ###

n, k = map(int, input().split())
if n == k:
  print(0)
  exit()
l = n%k
print(min(l, k-l))
N, A, B = int(input())

if N * A >= B:
  print(B)
else:
  print(N * A)

### FIXED CODE ###

N, A, B = map(int, input().split())
 
if N * A >= B:
  print(B)
else:
  print(N * A)
while True:
  try:
    a, b = map(int, input().split(" "))
    print(len(str(a + b)))
     
  expect: break


### FIXED CODE ###

while True:
  try:
    a, b = map(int, input().split(" "))
    print(len(str(a + b)))

  except:
    break
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + a[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+b[i])
i = 0
ans = 0
j = m
while acum1[i]<k:
    while acum2[j]>k-acum1[i] and j>0:
        j -= 1
    ans = max(ans,i+j)
    i+=1
print(ans)
        

### FIXED CODE ###

#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)
if a*b%2==0:
  return 'Even'
else:
  return 'Odd'

### FIXED CODE ###

a, b = map(int, input().split())
if a*b%2==0:
  print('Even')
else:
  print('Odd')
#!/usr/bin/env python3

def solve(x):
    def dp(x):
        if x == 0:
            return True
        elif x < 0:
            return False
        for i in range(100,106):
            if dp(x-i):
                return True
        
        return False

    return dp(x)



def main():
    X = int(input())
    print(int(solve(X)))
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def solve(x):
    if x >= 2000:
        return True
    memo = [True] + [False]*x

    def dp(k):
        if k == 0:
            return True
        for i in range(100,106):
            if k-i >= 0 and memo[k-i]:
                return True
        
        return False
    
    for i in range(x):
        memo[i+1] = dp(i+1)
    return memo[x]



def main():
    X = int(input())
    print(int(solve(X)))
    return

if __name__ == '__main__':
    main()
a, b = map(int, input().split())

import math
g = math.gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

gg = prime_factorize(g)
print(len(list(set(gg))) + 1)


### FIXED CODE ###

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

from fractions import gcd
g = gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

gg = prime_factorize(g)
print(len(list(set(gg))) + 1)
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,q=map(int,input().split())
s=input()
td=[]
for i in range(q):
    td.append(input().split())

#左に集まる中でもっとも右の点を探す
ok1=-1
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==-1:
            break
    if tmp==-1:
        left=mid+1
        ok1=max(ok1,mid)
    else:
        right=mid

#右に集まる中でもっとも左の点を探す

ok2=n
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==n:break
    if tmp == n:
        right=mid
        ok2=min(ok2,mid)
    else:
        left=mid+1

print(max(0,ok2-ok1-1))
# print(ok2,ok1)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,q=map(int,input().split())
s=input()
td=[]
for i in range(q):
    td.append(input().split())

#左に集まる中でもっとも右の点を探す
ok1=-1
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==-1 or tmp==n:
            break
    if tmp==-1:
        left=mid+1
        ok1=max(ok1,mid)
    else:
        right=mid

#右に集まる中でもっとも左の点を探す

ok2=n
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==n or tmp==-1:break
    if tmp == n:
        right=mid
        ok2=min(ok2,mid)
    else:
        left=mid+1

print(max(0,ok2-ok1-1))
# print(ok2,ok1)
N,K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h.sort()
dif = []
for i in range(N-1):
    dif[i] = h[i+1]-h[i]
print(min(dif))

### FIXED CODE ###

N,K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h.sort()
res = 10**9
for i in range(N-K+1):
    if res > h[i+K-1]-h[i]:
        res = h[i+K-1]-h[i]
print(res)
import sys
sys.setrecursionlimit(100000)
def num_steps(steps, cache={}):
    if steps in out or steps < 0 :
        return 0
    elif steps == 0:
        return 1

    if steps in cache:
        return cache[steps]
    else:
        one = num_steps(steps-1, cache)
        two = num_steps(steps-2, cache)
        ans = one + two
        cache[steps] = ans

        return ans%mod

n, m = map(int, input().split())
out = set(int(input()) for _ in range(m))
mod = 1000000007

print(num_steps(n))



### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
def num_steps(steps, cache={}):
    if steps in out or steps < 0 :
        return 0
    elif steps == 0:
        return 1

    if steps in cache:
        return cache[steps]
    else:
        one = num_steps(steps-1, cache)
        two = num_steps(steps-2, cache)
        ans = one + two
        cache[steps] = ans

        return ans%mod

n, m = map(int, input().split())
out = set(int(input()) for _ in range(m))
mod = 1000000007

print(num_steps(n))
while True:
    try:
        n = int(input())
    except ValueError:
        break
    if n == 0:
        break
    c = 0
    for i in range(2, 1001):
        for a in range(1, 1001):
            if i*a+(0.5*(i-1)*i) == n:
                c += 1
    print(c)



### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    c = 0
    for i in range(2, 1001//2):
        for a in range(1, 1001//2):
            if i*a+(0.5*(i-1)*i) == n:
                c += 1
    print(c)
s = str(input())
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy'):
    print('Rainy')
else:
    print('Sunny')


### FIXED CODE ###

s = str(input())
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
A, B, C, K = map(int, input().split())
if((K-A)>0):
    Y = K-A
else:
    Y = 0
    print(K)
    exit()
if((Y-B)>0):
    Z = Y-B
else:
    Z = 0

X = A + 0 * Y + (-1) * Z
print(X)











	



### FIXED CODE ###

S = input()
T = input()

if(S==T[0:len(S)]):
  print('Yes')
else:
    print('No')
n,m=int(input().split())
print((n-1)*(m-1))

### FIXED CODE ###

n,m = map(int,input().split())
print((n-1)*(m-1))
a = input().split(" ")
mem = [0] * int(a[0])
for i in range(int(a[2])):
  mem[int(input())-1] += 1
for i in mem:
  if int(a[1])-int(a[2])+mem[i] < 1:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

a = input().split(" ")
mem = [0] * int(a[0])
for i in range(int(a[2])):
  mem[int(input())-1] += 1
for i in range(int(a[0])):
  if int(a[1])-int(a[2])+mem[i] < 1:
    print("No")
  else:
    print("Yes")
ABCDE=[]
modABCDE=[]
for i in range(5):
  ABCDE+=[int(input())]
  if ABCDE[i]%10!=0:
    modABCDE+=[ABCDE[i]%10]  
MIN=min(modABCDE)
ans=sum(ABCDE)-sum(modABCDE)+(len(modABCDE)-1)*10+MIN
print(ans)

### FIXED CODE ###

ABCDE=[]
modABCDE=[]
for i in range(5):
  ABCDE+=[int(input())]
  if ABCDE[i]%10!=0:
    modABCDE+=[ABCDE[i]%10]  
if modABCDE!=[]:
  MIN=min(modABCDE)
else:
  MIN=10  
ans=sum(ABCDE)-sum(modABCDE)+(len(modABCDE)-1)*10+MIN
print(ans)
text = input()
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for s in text:
    alphabet = alphabet.replace(s, '')

if alphabet is False:
    print('None')
else:
    print(alphabet[0])

### FIXED CODE ###

text = input()
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for s in text:
    alphabet = alphabet.replace(s, '')

if alphabet is '':
    print('None')
else:
    print(alphabet[0])
n, k = map(int, input().split())

a = []
for i in range(n):
    n = abs(n - k)
    a.append(n)
    
print(min(a))

### FIXED CODE ###

n, k = map(int, input().split())
s = n % k
s2 = k - s
print(min(s, s2))
a,b=map(int,input().split())
if a>b:
  print('GREATER')
elif a==b:
  print('EQUAL')
else:
  print('LESS')

### FIXED CODE ###

a=int(input())
b=int(input())
if a>b:print('GREATER')
elif a==b:print('EQUAL')
else:print('LESS')
W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(N)]
X1, X2, Y1, Y2 = 0, W, 0, H

for x, y, a in P:
    if a == 1:  # ai=1
        X1 = max(X1, x)
    elif a == 2:  # ai=2
        X2 = min(X2, x)
    elif a == 3:  # ai=3
        Y1 = max(Y1, y)
    elif a == 4:  # ai=4
        Y2 = min(Y2, y)

if X2 <= X1 or Y2 <= Y1:
    S = 0
else:
    S = (X2 - X1) * (Y2 - Y1)

print(S)

### FIXED CODE ###

[a,b,c]=list(map(int,input().split()))
if a+b==c or a+c==b or b+c==a :
    print("Yes")
else:
    print("No")
N = int(input())

n = 1000 - N
if 1000 < N:
  m = n * (-1)
  print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)





### FIXED CODE ###

N = int(input())

n = 1000 - N
if N == 2000 or N == 3000 or N == 4000 or N ==5000 or N == 6000 or N == 7000 or N == 8000 or N == 9000 or N == 10000or N == 0:
  print(0)
elif 1000 < N:
  m = n * (-1)
  if m < 10:
    print(1000-m)
  elif m < 100:
    print(1000-(int(str(m)[-2])*10) + (int(str(m)[-1])))
  else:
    print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)
N, X=map(int, input().split())
L=list(map(int, input().split()))

l=0
counter=0
while l<=X:
  l+=L[counter]
  counter+=1
  
print(counter)

### FIXED CODE ###

import numpy as np

temp=list(map(int, input().split()))

N=temp[0]
X=temp[1]

L=list(map(int, input().split()))

ind=1
while np.sum(L[:ind])<=X and ind<=N:
  ind+=1
  
print(ind)
x = map(int, input().split())
print(2*x*3.14)

### FIXED CODE ###

x,y = map(int, input().split())
a,b = map(int, input().split())
print((x-a)*(y-b))
def attk(HP,Magic,D0):
    T = HP // Magic[0][0]
    MD0 = T * Magic[0][1]
    MD1 = (T+1) * Magic[0][1]
    Z = HP % Magic[0][0]
    ND = Magic[0][1]
    if Z == 0:
        return MD0
    if len(Magic) == 1:
        return MD1
    Magic.pop(0)
    A = attk(Z,Magic,ND)
    if D0 > MD0+A:
        if MD1 > MD0+A:
            return MD0+A
        else:
            return MD1
    else:
        return D0



H,N = map(int,input().split())
A =[]
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b,a/b))
#print(A)
B = sorted(A, key=lambda s: s[1]) 
C = sorted(B, key=lambda s: s[2], reverse=True) 
#print(C)

for i in range(N-1):
    if C[N-1-i][2] ==C[N-2-i][2]:
        C.pop(N-1-i)
#print(C)
TDMAX = (H // C[0][0])*C[0][1]
if (H%C[0][0])!=0:
    TDMAX += C[0][1]
TD = attk(H,C,TDMAX)
print(TD)

### FIXED CODE ###

H,A = map(int,input().split())
X = int(H // A)
if (H%A)!=0:
    X += 1
print(X)
if A>B:
  print("2A-1")
if A<B:
  print("2B-1")
if A==B:
  print("A+B")

### FIXED CODE ###

A, B = map(int, input().split())
if A>B:
  print(2*A-1)
if A<B:
  print(2*B-1)
if A==B:
  print(A+B)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
n = int(input())
a_list = []
a_dic = {}
for ai in input().split():
    int_ai = int(ai)
    a_list.append(int_ai)
    if int_ai in a_dic:
        a_dic[int_ai] += 1
    else:
        a_dic[int_ai] = 1

a_solution_dic = {}
a_solution_dic_at_k = {}
for key in a_dic:
    if a_dic[key] == 1:
        del a_dic[key]
    a_solution_dic[key] = int(a_dic[key] * (a_dic[key]-1) / 2)
    #a_solution_dic_at_k[key] = int((a_dic[key]-1) * (a_dic[key]-2) / 2)


for k, ak in enumerate(a_list):
    sum_select = 0
    if a_dic[ak] <= 2:
        pass
    else:
        sum_select += int((a_dic[ak]-1) * (a_dic[ak]-2) / 2)
    for key in a_solution_dic:
        if key != ak:
            sum_select += a_solution_dic[key]


    print(sum_select)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
n = int(input())
a_list = []
a_dic = {}
for ai in input().split():
    int_ai = int(ai)
    a_list.append(int_ai)
    if int_ai in a_dic:
        a_dic[int_ai] += 1
    else:
        a_dic[int_ai] = 1

a_solution_dic = {}
all_sum_select = 0
for key in list(a_dic.keys()):
    all_sum_select += int(a_dic[key] * (a_dic[key]-1) / 2)
    #a_solution_dic_at_k[key] = int((a_dic[key]-1) * (a_dic[key]-2) / 2)

for k, ak in enumerate(a_list):
    sum_select_at_k = all_sum_select + int((a_dic[ak]-1) * (a_dic[ak]-2) / 2) \
                       - int(a_dic[ak] * (a_dic[ak]-1) / 2)


    print(sum_select_at_k)
H, W, D = map(int, input().split())
A = [[] * W for i in range(H)]
dic = {}
for i in range(H):
    a = list(map(int, input().split()))
    A[i] = a
    for j in range(W):
        dic[a[j]] = (i + 1, j + 1)

rec = {}


def cal(L, R):
    global rec
    if L == R:
        return 0
    if (L, R) in rec:
        return rec[(L, R)]
    else:
        p = abs(dic[L + D][0] - dic[L][0]) + abs(dic[L + D][1] - dic[L][1])
        rec[(L, R)] = cal(L + D, R) + p
        return rec[(L, R)]


Q = int(input())
for i in range(Q):
    L, R = map(int, input().split())
    print(cal(L, R))

### FIXED CODE ###

from collections import defaultdict
H, W, D = map(int, input().split())
A = [[] * W for i in range(H)]
dic = {}
for i in range(H):
    a = list(map(int, input().split()))
    A[i] = a
    for j in range(W):
        dic[a[j]] = (i + 1, j + 1)

d = defaultdict(int)
for i in range(D + 1, H * W + 1):
    d[i] = d[i - D] + abs(dic[i][0] - dic[i - D][0]) + abs(dic[i][1] - dic[i - D][1])


Q = int(input())
for i in range(Q):
    L, R = map(int, input().split())
    print(d[R] - d[L])
# 解説みたよ
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
d = defaultdict(int)
n, m = map(int, input().split())
es = [[] for i in range(n)]
l, r, d = [0] * m, [0] * m, [0] * m
for i in range(m):
    l[i], r[i], d[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
    es[l[i]].append((r[i], d[i]))
    es[r[i]].append((l[i], -d[i]))
INF = 1000000000000
value = [INF] * n


def dfs(v):
    for i, d in es[v]:
        if value[i] == INF:
            value[i] = value[v] + d
            dfs(i)


for i in range(n):
    if value[i] == INF:
        value[i] = 0
        dfs(i)

for i, j, k in zip(l, r, d):
    if value[j] - value[i] != k:
        print("No")
        exit()
print("Yes")


### FIXED CODE ###

# 解説みたよ
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [[] for i in range(n)]
l, r, d = [0] * m, [0] * m, [0] * m
for i in range(m):
    l[i], r[i], d[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
    es[l[i]].append((r[i], d[i]))
    es[r[i]].append((l[i], -d[i]))
INF = 1000000000000
value = [INF] * n


def dfs(v):
    for i, di in es[v]:
        if value[i] == INF:
            value[i] = value[v] + di
            dfs(i)


for i in range(n):
    if value[i] == INF:
        value[i] = 0
        dfs(i)

for i, j, k in zip(l, r, d):
    if value[j] - value[i] != k:
        print("No")
        exit()
print("Yes")
# A
N = int(input())
if N==1: print('hello, world')
else:
    A, B = [int(x) for x in input().split()]
    print(A+B)
    

### FIXED CODE ###

# A
N = int(input())
if N==1: print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)
a=list(input())
print(a.replace("1","9").replace("9","1"))

### FIXED CODE ###

a=input()
print(a.replace("1","x").replace("9","1").replace("x","9"))
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())


def main():
	s = input().split()
    n=int(s[0])
    d = {'AC':0,'WA':0,'TLE':0,'RE':0}
    for i in range(n):
        s = input().split()
        d[s[0]]+=1
    for i in d:
        print(i,' x ',d[i])
main()
'''
if __name__ == '__main__':
    main()
'''
 



### FIXED CODE ###

s = input().split()
n=int(s[0])
d = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(n):
    s = input().split()
    d[s[0]]+=1
for i in d:
    print(i,' x ',d[i])
a[]=list(map(int,input().split()))
n=min(a[1],a[3])-max(a[0],a[2])
print(n if n>0 else 0)

### FIXED CODE ###

a=list(map(int,input().split()))
n=min(a[1],a[3])-max(a[0],a[2])
print(n if n>0 else 0)
import itertools

    vec =  input()
    
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    print(res)



### FIXED CODE ###

import itertools

A1,A2,A3 = map(int,input().split())
    
vec = [A1,A2,A3]
com = list(itertools.permutations(vec))
    
all_cos = [0,0,0,0,0,0]
for i in range(6):
    tmp_com = com[i]
        
    tmp_A1 = tmp_com[0]
    tmp_A2 = tmp_com[1]
    tmp_A3 = tmp_com[2]
        
    cos1 = 0
    cos2 = abs(tmp_A1 - tmp_A2)
    cos3 = abs(tmp_A2 - tmp_A3)
        
    all_cos[i] = cos1 + cos2 + cos3
    
res = min(all_cos)
print(res)
import math
a,b = map(int,input().split())
gcd = math.gcd(a,b)
print((a*b)//gcd)

### FIXED CODE ###

def computeGCD(x, y):
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small + 1):
        if ((x % i == 0) and (y % i == 0)):
            gcd = i

    return gcd
a,b = map(int,input().split())
gcd = computeGCD(a,b)
print((a*b)//gcd)