Harryxun/stf_run huggingface dataset:
N = int(input())
H = list(map(int,input().split()))
count = 1
Max = H[0]
for i in range(1:N):
     if Max <=H[i]:
         Max = H[i]
         count += 1

print(count)
     


### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
count = 1
x = H[0]
for i in range(N-1):
     if x <=H[i+1]:
         x = H[i+1]
         count += 1

print(count)
N,M = map( int, input().split() )
break_list = []
for i in range(M):
    break_list.append( int( input() ) )
k = 1    
fib = [0] * (N + 1)
if 1 in break_list:
    fib[1] = 0
else:
    fib[1] = 1
    
if 0 in break_list:
    k = -1
    
fib[0] = 1
for i in range(N - 1):
    if i + 2 in break_list:
        fib[i + 2] = 0
    else:
        fib[i + 2] = fib[i] + fib[i + 1]
    
if k > -1:
    print( fib[i+2] %  1000000007 )

else:
    print(0)

### FIXED CODE ###

N,M = map( int, input().split() )
break_list = []
for i in range(M):
    break_list.append( int( input() ) )

break_list.append(-10)
t = 0
fib = [0] * (N + 1)
if break_list[0] == 1:
    fib[1] = 0
    t += 1
else:
    fib[1] = 1
    
fib[0] = 1

for i in range(N - 1):
    if ( i + 2 ) ==  break_list[t]:
        fib[i + 2] = 0
        t += 1
    else:
        fib[i + 2] = fib[i] + fib[i + 1]
 
if N == 1:
    print( fib[1] )
else:
    print( fib[i+2] %  1000000007 )
N = input()
S = split(input())

turns_num_list = list()
for i, s in enumerate(S):
  left = [S == "E" for j in S[0:j]].count()
  right = [S[j] == "W" for j in S[j+1:]].count()
  turns_num_list.append(left+right)

print(min(turns_num_list))

### FIXED CODE ###

N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)
a,op,b = map(str, input().split())
a = int(a)
b = int(b)
if op == '+':
    result = a + b
else op == '-':
    result = a - b 
    
print("{}".format(result))


### FIXED CODE ###

a,op,b = map(str, input().split())
a = int(a)
b = int(b)
if op == '+':
    result = a + b
elif op == '-':
    result = a - b

print("{}".format(result))
mport sys
A, B = map(int, input().split())

count = 0
num = []

for i in range(A, B+1):
    while i != 0:
        num.append(i%10)
    
    if num[0] == num[4] and num[1] == num[3]:
        count += 1


print(count)

### FIXED CODE ###

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

count = 0

for i in range(A, B+1):
    num = []
    while i != 0:
        num.append(i%10)
        i = int(i/10)
    
    if num[0] == num[4] and num[1] == num[3]:
        count += 1


print(count)
h,w,a,b,=map(int,input().split())
ans='No'
if h==1 and b==0:
        ans=['1']*a+['0']*(w-a)
        print(''.join(ans))
elif w==1 and a==0:
        ans=['1']*b+['0']*(h-b)
        for i in ans:
                print(i)
else:
    ans1='0'*a+'1'*(w-a)
    ans2='1'*a_+'0'*(w-a)
    for i in range(h):
        if i<=b-1:
            print(ans1)
        else:
            print(ans2)

### FIXED CODE ###

h,w,a,b,=map(int,input().split())
ans='No'
if h==1 and b==0:
        ans=['1']*a+['0']*(w-a)
        print(''.join(ans))
elif w==1 and a==0:
        ans=['1']*b+['0']*(h-b)
        for i in ans:
                print(i)
else:
    ans1='0'*a+'1'*(w-a)
    ans2='1'*a+'0'*(w-a)
    for i in range(h):
        if i<=b-1:
            print(ans1)
        else:
            print(ans2)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)

### FIXED CODE ###

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

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    if v >= 2:
        ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)
import sys
input = sys.stdin.readline
def search2019(x):
    """
    i: 始める場所
    x: 数字のみからなる文字列
    """
    xLen = len(x)
    if xLen < 4:
        return 0
    else:
        ans = 0

        for i in range(3,xLen):
                Slice = int(x[0:i+1])
                if (Slice != 0 and Slice % 2019 == 0):
                    #print(i)
                    #print(S,Slice)
                    ans += 1 + search2019(x[i+1:xLen])
                    break
        return ans

S = str(input())
S = S[0:len(S)-1]
#print(S)
#print(search2019(S))


Slen = len(S)
if (Slen < 4):
    print(0)

else:
    ans = 0
    for i in range(Slen - 3):
        for j in range(i+3, Slen):
            Slice = S[i:j+1]
            if ( int(Slice) != 0 and int(Slice) % 2019 == 0):
                ans += 1 + search2019(S[j+1:Slen])
                break
                #print(i, j)
    print(ans)
    #print(Slen)

### FIXED CODE ###

S = input()[::-1]
Surpus = [0] * 2019
Surpus[0] = 1

sum = 0
x = 1
for i in S:
    sum += int(i) * x
    Surpus[sum % 2019] += 1
    x *= 10
    x %= 2019

ans = 0
for i in Surpus:
    ans += i * (i - 1) // 2

print(ans)
import math
number = int(input())
if (number != 0):
    digit = int(math.log10(number))
else :
    digit=0

a=[]
while(True):
    if (number%10==0):
        a.append("0")
    elif (number%10!=0):
        a.append("1")
    
    number= int(number/10)
    if (number == 0):
        break
b= []
i = digit

while(i !=-1):
    b.append(a[i])
    i -= 1
print(b)

count1=0
count2=0
for j in range(0,digit+1):
    if (j % 2 ==0):
        if b[j]=="1":
            count1 +=1 
    elif (j %2 ==1):
        if b[j]=="0":
            count1 +=1
for j in range(0,digit):
    if (j % 2 ==0):
        if b[j]=="0":
            count2 +=1 
    elif (j %2 ==1):
        if b[j]=="1":
            count2 +=1
print(min(count1,count2))


### FIXED CODE ###

def case_1 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==0):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

def case_2 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==1):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

S=str(input())
size=len(S)
can_1=case_1(S,size)
can_2=case_2(S,size)
print(min(can_1,can_2))
# C
# Typical Stairs

N_M = input()

N = int(N_M.split(" ")[0])
M = int(N_M.split(" ")[1])

a = []

for i in range(M):

    a.append(int(input()))

#print(a)

import numpy as np

stairs = list(np.zeros(N + 1))

if 1 in a:

    stairs[1] = 0
    stairs[2] = 1

elif 2 in a:

    stairs[1] = 1
    stairs[2] = 0

elif 1 in a and 2 in a:

    stairs[1] = 0
    stairs[2] = 0

else:

    stairs[1] = 1
    stairs[2] = 2

for i in range(N + 1):
    
    if i in a:

        stairs[i] = 0
    
    elif i > 2:

        stairs[i] = int(stairs[i - 1] + stairs[i - 2])

    #print(stairs)

print(stairs[-1] % 1000000007)

### FIXED CODE ###

# A
# Airplane

P_Q_R = input()

P = int(P_Q_R.split(" ")[0])
Q = int(P_Q_R.split(" ")[1])
R = int(P_Q_R.split(" ")[2])

PQR =[P, Q, R]

import numpy as np

print(np.sum(PQR) - np.max(PQR))
a = int(input())

b = []

for i in range(a):
    b.append(input().split())

res = 0

for i in b:
    if (i[1] == 'BTC'):
        res += int(i[0])*380000
    else:
        res += int(i[0])

print(res) 

### FIXED CODE ###

a = str(input())

a = a[:4] + a[5:7] + a[8:]

a = int(a)

if (a > 20190430):
    print('TBD')
else:
    print('Heisei')
I,O,T,J,L,S,Z = map(int,input().split())
if (I<2 and O=0 and J<2 and L<2) and (I != 1 or J != 1 or L!= 1):
    print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))
else:
    print(0)


### FIXED CODE ###

I,O,T,J,L,S,Z = map(int,input().split())
print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0)*(L>0)*(J>0),(I//2+J//2+L//2)*2+O))
import collections 
N = int(input())
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}

ans = []
for i in range(N):
    si = input()
    a = [0]*26
    s = ""
    for j in range(10):
        a[dic[si[j]]] += 1
    for k in range(26):
        s = s + "a"
        s = s + str(a[k])
    ans.append(s)
c = collections.Counter(ans)
b = 0
for v in c.values():
    if v > 1:
        b += v*(v-1)//2
    else:
        break
print(b)
    

### FIXED CODE ###

from collections import Counter
N = int(input())
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}

ans = []
for i in range(N):
    si = input()
    a = [0]*26
    s = ""
    for j in range(10):
        a[dic[si[j]]-1] += 1
    for k in range(26):
        s = s + "a"
        s = s + str(a[k])
    ans.append(s)
c = Counter(ans)
b = 0
for v in c.values():
    if v > 1:
        b += v*(v-1)//2
    else:
        pass
print(b)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
  
def make_tree(graph, root) -> (list, list):
  INF = 10 ** 15
  dist = [INF] * len(graph)
  parent = [-1] * len(graph)
  stack = [root]
  dist[root] = 0
  parent[root] = root
  while stack:
    s = stack.pop()
    for g in graph[s]:
      if dist[g] > dist[s] + 1:
        dist[g] = dist[s] + 1
        parent[g] = s
        stack.append(g)
  return dist, parent
 
def lca(u, v, dist, parent):
  distu, distv = dist[u], dist[v]
  if distu > distv:
    for _ in range(distu - distv):
      u = parent[u]
  if distv > distu:
    for _ in range(distv - distu):
      v = parent[v]
  while u != v:
    u, v = parent[u], parent[v]
  return u

#root = 1
#dist, parent = make_tree(graph, root)
#print("dist:", dist[1:])
#print("parent:", parent[1:])

### FIXED CODE ###

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

print("Yes" if N == M else "No")
print(str.upper(input()[0]) + str.upper(input()[0]) + str.upper(input()[0]))


### FIXED CODE ###

s1, s2, s3 = input().split()
print(str.upper(s1[0] + s2[0] + s3[0]))
# 0028
import collections
array = []
i = 0
while True:
    try:
        array.append(int(input()))
        i += 1
    except ValueError:
        break
count = list(map(lambda a: array.count(a), array))
modes = list(set(filter(lambda a: array.count(a) == max(count), array)))
print(*modes, sep = '\n')

### FIXED CODE ###

# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError: break
s = set(array)
mx = max(sorted(s, reverse=True), key = array.count)
for a in sorted(s, key = array.count, reverse=True):
    print(a)
    if a == mx: break
import sys
S = str(input())
n = len(S)
for i in range(n):
    if S[i] == "U" or "D":
        if (S[i%2 == 1] and S[i%2 == 1] == "R") or (S[i%2 == 0] and S[i%2 == 0] == "L"):
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()

### FIXED CODE ###

s= input()
a = 0
for i in range(len(s)):
    if i%2:
        if s[i]=="R":
            a = 1
            break
    else:
        if s[i]=="L":
            a = 1
            break
if a == 0:
    print('Yes')
else:
    print('No')
x=int(input())
li=[2]
p=2
i=0
prime=False
if x==2:
    print(2)
else:
    while p<x or prime==False:
        prime=True
        p+=1
        for i in range(len(li)):
            if p%li[i]==0:
                prime=False
        if prime:
            li.append(p)
   
    print(max(li))
    


### FIXED CODE ###

li = list(input().split())
s=li[0]
t=li[1]

print(t+s)
#!/usr/bin/env python
# _*_ coding utf-8 _*_

A = int(input())
B = int(input())

sum = A + B

if sum <= 10:
    print(sum)

elif sum > 10:
    print("error")


### FIXED CODE ###

#!/usr/bin/env python
# _*_ coding: utf-8 _*_
a = input()
a.split()
a.split()[1]

A = int(a.split()[0])
B = int(a.split()[1])

sum = A + B

if sum < 10:
    print(sum)

elif sum >= 10:
    print("error")
n = int(input())
ans = 0
d = { 'JPY': 1, 'BTC': 380000.0}
for _ in range(n):
  a, b = input().split()
  ans += int(a) * d[b]
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
d = { 'JPY': 1, 'BTC': 380000.0}
for _ in range(n):
  a, b = input().split()
  ans += float(a) * d[b]
print(ans)
N = int(input())
x_list, y_list = [], []
for _ in range(N):
    x, y = map(int, input().split(" "))
    x_list.append(x)
    y_list.append(y)

vec_counts = {}
for x1, y1 in zip(x_list, y_list):
    for x2, y2 in zip(x_list, y_list):
        v = x1 - x2, y1 - y2
        if v != (0, 0):
            if v in vec_counts:
                vec_counts[v] += 1
            else:
                vec_counts[v] = 1

print(N - max(vec_counts.values()))

### FIXED CODE ###

N = int(input())
x_list, y_list = [], []
for _ in range(N):
    x, y = map(int, input().split(" "))
    x_list.append(x)
    y_list.append(y)

vec_counts = {0: 0}
for x1, y1 in zip(x_list, y_list):
    for x2, y2 in zip(x_list, y_list):
        v = x1 - x2, y1 - y2
        if v != (0, 0):
            if v in vec_counts:
                vec_counts[v] += 1
            else:
                vec_counts[v] = 1

print(N - max(vec_counts.values()))
import math
a,b= input().split()
d = math.sqrt(int(a+b))

//小数判定
if d%1==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

import math
a,b= input().split()
d = math.sqrt(int(a+b))


if d%1==0:
  print("Yes")
else:
  print("No")
n,k=map(int,input().split(" "))

c=abs(n-k)
d=abs(c-k)
if(c+d==k):
    if(c>d):
        print(d)
    else:
        print(c)

if(k%n==0):
    if(n>k):
        print(0)
    else:
        print(n) 
    exit()

if(n>k):
    a=n-k*(n//k)
    b=k*(n//k+1)-n
    if(a>b):
        print(b)
    else:
        print(a)


### FIXED CODE ###

n,k=map(int,input().split(" "))

c=abs(n-k)
d=abs(c-k)
if(c+d==k):
    if(c>d):
        print(d)
    else:
        print(c)
    exit()
if(n>=k):
    if(n%k==0):
        print(0)
        exit()
    else:
        a=n-k*(n//k)
        b=k*(n//k+1)-n
        if(a>b):
            print(b)
        else:
            print(a)
        exit()
else:
    
    while(1):
        a=abs(n-k)
        if(n>a):
            n=a
        else:
            print(n)
            exit()
import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            if (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')

### FIXED CODE ###

import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            elif (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')
while True:
    a, op, b=map(int, input().split())
    if op=='+':
        result=a+b
    if op=='-':
        result=a-b
    if op=='*':
        result=a*b
    if op=='/':
        result=a/b
    if op=='?':
        break
    print(result)

### FIXED CODE ###

while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op == '+': print(a + b)
  elif op == '-': print(a - b)
  elif op == '*': print(a * b)
  elif op == '/': print(a // b)
  else: break
def Factorial(integer) :
    global M

    product = 1
    if integer == 0 : return 1
    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorialo(d[0])

print(res%(10**9+7))

### FIXED CODE ###


def Factorial(integer) :
    global M
    product = 1
    if integer == 0 : return 1

    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product%M


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorial(d[0])

print(res%(M))
k,n = map(int,input().split())
if k %2 ==0:
  ans = []
  ans.append(k//2)
  for i in range(n-1):
    ans.append(k)
  print(*ans)
else:
  ans = []
  for i in range(n):
    ans.append(k//2+1)
  sage = (n)//2
  for i in range(sage):
    ans[-1] -=1
    j = -1
    while ans[j] ==0:
      ans[j] = k
      j-=1
      ans[j]-=1
  print(*ans)

### FIXED CODE ###

k,n = map(int,input().split())
if k %2 ==0:
  ans = []
  ans.append(k//2)
  for i in range(n-1):
    ans.append(k)
  print(*ans)
else:
  ans = []
  for i in range(n):
    ans.append(k//2+1)
  sage = (n)//2
  for i in range(sage):
    if ans[-1] == 1:
      ans.pop()
    else:
      ans[-1] -= 1
      while len(ans) < n:
        ans.append(k)
  print(*ans)
N, K, Q = [int(s) for s in input().split()]
A = [0] * N
for i in range(N):
    A[int(input()) - 1] += 1

for a in A:
    print('Yes' if (K - Q + a) > 0 else 'No')

### FIXED CODE ###

S = input()
if S[0] == 'S':
    print('Cloudy')
elif S[0] == 'C':
    print('Rainy')
else:
    print('Sunny')
n,m=map(int,input().split())
c=[0]*m
for i in range(n):
    li=list(map(int,input().split()))
    for j in range(li[0]):
        c[li[j+1]-1]+=1
        ans=0
for i in range(n):
    if c[i]==n:
        ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
c=[0]*m
for i in range(n):
    li=list(map(int,input().split()))
    for j in range(li[0]):
        c[li[j+1]-1]+=1
        ans=0
for i in range(m):
    if c[i]==n:
        ans+=1
print(ans)
N, M = map(int, input().split())

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

visited = [0]*N
ans = 0
visited[0] = 1

def dfs(v):
    if 0 not in visited:
        return 1

    for i in G[v]:
        if visited[i] == 0:
            visited[i] = 1
            ans += dfs(i, visited)
            visited[i] = 0

    return ans

print(dfs(0))

### FIXED CODE ###


import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
n=int(input())
dp=[0 for i in range(n)]
l=list(map(int,input().split()))
def dp1(n1):
  if n1==n-1:
    ans=min(dp[n-2]+abs(l[n-2]-l[n-1]),dp[n-3]+abs(l[n-3]-l[n-1]))            
    dp[n-1]=ans
    return ans
  else:
    ans=min(dp[n1-2]+abs(l[n1-2]-l[n1-1]),dp[n1-3]+abs(l[n1-3]-l[n1-1]))
    dp[n1]=ans
    return ans
dp1(0)
print(dp[n-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
def dp1(n1):
  if dp[n1]!=-1:
    return dp[n1]
  else:
    ans=min(dp1(n1-1)+abs(l[n1-1]-l[n1]),dp1(n1-2)+abs(l[n1-2]-l[n1]))
    dp[n1]=ans
    return ans
print(dp1(n-1))
n, m = map(int, input().split())
ans = (n-1)*(m-1)
print(ans))

### FIXED CODE ###

n, m = map(int, input().split())
ans = (n-1)*(m-1)
print(ans)
n = int(raw_input())
  maxv = -1*10**9
  minv = 10**9

  for j in range(n-1):
    num = int(raw_input())
    maxv = max(maxv, num - minv)
    minv = min(minv, num)

  print maxv

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[""]*(n+1)
for i in range(m):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]=="":
        b[i]=0
        k=[i]
        while k:
            s=k.pop(i)
            for x,y in a[s]:
                if b[x]=="":
                    k.append(x)
                    b[x]=b[i]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a:
        if a[i]+q!=p:
            c="No"
print(c)

### FIXED CODE ###

n,m=map(int,input().split())
a=[[]for i in range(n+1)]
b=[""]*(n+1)
for i in range(m):
    l,r,d=map(int,input().split())
    a[l].append([r,d])
    a[r].append([l,-d])
for i in range(1,n+1):
    if b[i]=="":
        b[i]=0
        k=[i]
        while k:
            s=k.pop()
            for x,y in a[s]:
                if b[x]=="":
                    k.append(x)
                    b[x]=b[s]+y
c="Yes"
for i in range(1,n+1):
    for p,q in a[i]:
        if b[i]+q!=b[p]:
            c="No"
print(c)
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
i = bisect.bisect_left(a,0)
if i % 2 == 0:
    ans = abs(sum(a[:i]))+sum(a[i:])
else:
    ans = abs(sum(a[:i-1]))+abs(a[i]+a[i-1])+sum(a[i+1:])
print(ans)

### FIXED CODE ###

import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
i = bisect.bisect_left(a,0)
if i % 2 == 0:
    ans = abs(sum(a[:i]))+sum(a[i:])
else:
    if i == n:
        ans = abs(sum(a[:i-1]))+a[i-1]
    else:
        ans = abs(sum(a[:i-1]))+abs(a[i]+a[i-1])+sum(a[i+1:])
print(ans)
import math
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

### FIXED CODE ###

import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()
import numpy as np

N, M = list(map(int, input().split()))
s = [0]*M
c = [0]*M
for i in range(M):
    s[i], c[i] = list(map(int, input().split()))

max = 10 ** N - 1

smax = np.max(s)
min = 10 ** (smax - 1)

answer = -1
for i in range(max, min-1, -1):
    flag = 1
    for j in range(M):
        if int(str(i)[s[j]-1]) != c[j]:
            flag = 0
    if flag == 1:
        answer = i
print(answer)

### FIXED CODE ###

import numpy as np

N, M = list(map(int, input().split()))
s = [0]*M
c = [0]*M
check = 1
for i in range(M):
    s[i], c[i] = list(map(int, input().split()))
    if ((N > 2) & (s[i] == 1) & (c[i] == 0)):
        check = 0

if check == 0:
    print('-1')
else:
    if N > 1:
        max = 10 ** N - 1
        min = 10 ** (N - 1)
    else:
        max = 9
        min = 0

    answer = -1

    for i in range(max, min-1, -1):
        flag = 1
        for j in range(M):
            if s[j] <= N:
                if int(str(i)[s[j]-1]) != c[j]:
                    flag = 0
        if flag == 1:
            answer = i
    print(answer)