Harryxun/stf_run huggingface dataset:
import numpy as np

N=int(input())
dp=[0]*(N+1)


for i in range(N):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[i+1] = dp[i]+max(a,b,c)
        flg = [a,b,c].index(max([a,b,c]))
    else:
        if flg==0:
            dp[i+1] = dp[i] + max(b,c)
            flg = [a,b,c].index(max([b,c]))
        elif flg==1:
            dp[i+1] = dp[i] + max(a,c)
            flg = [a,b,c].index(max([a,c]))
        else:
            dp[i+1] = dp[i] + max(a,b)
            flg = [a,b,c].index(max([a,b]))

# print(dp)
print(dp[N])


### FIXED CODE ###

N=int(input())
dp=[]
for j in range(N+1):
    dp.append([0,0,0])

for i in range(N):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[i+1][0] = dp[i][0]+a
        dp[i+1][1] = dp[i][1]+b
        dp[i+1][2] = dp[i][2]+c
    else:
        dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a)
        dp[i+1][1] = max(dp[i][0]+b, dp[i][2]+b)
        dp[i+1][2] = max(dp[i][0]+c, dp[i][1]+c)

# print(dp,sep="\n")
print(max(dp[N][0],dp[N][1],dp[N][2]))
a=[]
while True:
 n = input()
 if n == -1:
  break
 a.append(n)
for i in range(len(a))
 print(f'Case {i+1}: {a[i]}')

### FIXED CODE ###

import sys
i=1
for e in sys.stdin:
 if'0\n'==e:break
 print(f'Case {i}: {e[:-1]}');i+=1
a, b, c = map(int,input().split())
if a = b:
    print("Yes")
elif a = c:
    print("Yes") 
else:
    print("No")

### FIXED CODE ###

a, b, c = map(int,input().split())
if a == b:
    if a == c:
        print("No")
    else:
        print("Yes")
elif a == c:
    print("Yes") 
elif b == c:
    print("Yes")
else:
    print("No")
DIV = 100000
n, m = map(int, raw_input().split())
l = [input() for _ in range(n-1)]
ans = [0]*(n-1)
pos = 0
for _ in xrange(m):
    k = input()
    if k > 0:
        for i in xrange(k): ans[pos+i] += 1
    else:
        for i in xrange(-1, k-1, -1):       
            ans[pos+i] += 1
    pos += k
print sum((ans[i] * l[i]) % DIV for i in xrange(n-1)) % DIV

### FIXED CODE ###

DIV = 100000
n, m = map(int, raw_input().split())
l = [0]*n
for i in range(n-1):
    k = input()
    l[i+1] = l[i] + k
ans = pos = 0
for _ in xrange(m):
    k = input()
    ans = (ans + abs(l[pos + k] - l[pos])) % DIV
    pos += k
print ans
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
if B<N:
    x = np.arange(0, B, 1)
else:
    x = np.arange(0, N+1, 1)

print(int(max(fun(x))))


### FIXED CODE ###

import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))
A, B, C, D = map(int, input().split())

x = A / D
y = A % D
p = C / B
q = C % B

if (p < x):
  print("Yes")
elif (p == x):
  if (y == 0 and q <> 0):
    print("No")
  else:
    print("Yes")
else:
  print("No")


### FIXED CODE ###

A, B, C, D = map(int, input().split())
 
flg = True
t = False
while(flg):
  C -= B
  if (C <= 0):
    t = True
    break
  A -= D
  if (A <= 0) :
    t = False
    break

if (t):
  print("Yes")
else:
  print("No")
S = input()


def makeRepeat(arr):
    repeat = [[arr[0], 0]]
    for x in arr:
        if x == repeat[-1][0]:
            repeat[-1][1] += 1
        else:
            repeat.append([x, 1])
    return repeat


ans = []
repeats = makeRepeat(S)
for i, (ch, count) in enumerate(repeats):
    if ch != "?":
        ans.append(ch * count)
    else:
        if i - 1 >= 0:
            prev = S[i - 1]
        nxt = None
        if i + 1 < len(repeats):
            nxt = S[i + 1]

        if prev == "P":
            q, r = divmod(count, 2)
            ans.append("DP" * q + "D" * r)
        elif nxt == "D":
            q, r = divmod(count, 2)
            ans.append("P" * r + "DP" * q)
        else:
            ans.append("D" * count)

print("".join(ans))



### FIXED CODE ###

inf = float("inf")

S = input()



N = len(S)
bestP = [None for i in range(N)]
bestD = [None for i in range(N)]
if S[0] in ["?", "D"]:
    bestP[0] = 0
    bestD[0] = 1
else:
    bestP[0] = 0
    bestD[0] = 0
for i in range(1, N):
    bestP[i] = max(bestD[i - 1], bestP[i - 1])
    bestD[i] = max(bestD[i - 1] + 1, bestP[i - 1] + 2)
    if S[i] != "?":
        if S[i] == "P":
            bestD[i] = -inf
        else:
            assert S[i] == "D"
            bestP[i] = -inf

ans = [None for i in range(N)]
if bestP[-1] > bestD[-1]:
    ans[-1] = 'P'
else:
    ans[-1] = 'D'
for i in range(N - 2, -1, -1):
    if S[i] != '?':
        ans[i] = S[i]
    else:
        prev = ans[i + 1]
        if prev == 'D':
            if bestP[i] + 2 > bestD[i] + 1:
                ans[i] = 'P'
            else:
                ans[i] = 'D'
        else:
            if bestP[i] > bestD[i]:
                ans[i] = 'P'
            else:
                ans[i] = 'D'

print(''.join(ans))
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+i)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    print(1)
import math
A, B, N = map(int,input().split())
ans = 0
for i in range(1,min(N,B)):
  X = math.floor(A*i//B)-A*math.floor(i//B)
  if(X>=ans):
    ans = X
print(ans)


### FIXED CODE ###

N = int(input())
A, B = map(int, input().split())
for i in range(A, B+1):
  if i % N == 0:
    print('OK')
    break
else:
  print('NG')
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
def f(L):
    if A[L[-1]-1] not in L:
        L.append(A[L[-1]-1])
        return f(L)
    else:
        return L
P = f(L)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j
print(P[j + (k-j)%l])
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

def f(L, S):
    last = L[-1]-1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j

if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
q = iinput()
cnt = 0
for i in range(q):
    try: t,f,c = sarr()
    except: cnt += 1; cnt %= 2; continue
    if cnt:
        if f == "1": s = s + c
        if f == "2": s = c + s
    else:
        if f == "1": s = c + s
        if f == "2": s = s + c
    #print(s)

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



### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = col.deque(sinput().split())
q = iinput()
cnt = 0
for i in range(q):
    try: t,f,c = sarr()
    except: cnt += 1; cnt %= 2; continue
    if cnt: #反転の状態
        if f == "1": s.append(c)
        if f == "2": s.appendleft(c)
    else: #ノーマル状態
        if f == "1": s.appendleft(c)
        if f == "2": s.append(c)
    #print(s)

s = "".join(s)
s = s[::-1] if cnt else s
print(s)
n, m, p = map(int, input().split())
edge = []
for i in range(n):
    ai, bi, ci = map(int, input().split())
    edge.append((bi-1,ai-1,-ci+p))
dist = [float("inf") for i in range(n)]
dist[n-1] = 0
h = False
for i in range(n):
    updated = False
    for e in edge:
        if dist[e[1]] > dist[e[0]] + e[2]:
            dist[e[1]] = dist[e[0]] + e[2]
            updated = True
    if not updated:
        break
else:
    h = True

if h:
    print(-1)
else:
    print(max(0, -dist[0]))


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline()[:-1]


n, m, p = map(int, input().split())
edge0 = []
d = [[] for i in range(n)]
r = [[] for i in range(n)]
for i in range(m):
    ai, bi, ci = map(int, input().split())
    edge0.append((bi-1,ai-1,-ci+p))
    d[ai-1] += [bi-1]
    r[bi-1] += [ai-1]

p0 = [False for i in range(n)]
p0[0] = True
from collections import deque
q = deque([0])
while len(q)>0:
    x = q.popleft()
    for y in d[x]:
        if not p0[y]:
            p0[y] = True
            q.append(y)
pn = [False for i in range(n)]
pn[n-1] = True
q = deque([n-1])
while len(q) > 0:
    x = q.popleft()
    for y in r[x]:
        if not pn[y] and p0[y]:
            pn[y] = True
            q.append(y)

edge = []
for e in edge0:
    if pn[e[1]] and pn[e[0]]:
        edge += [e]


dist = [float("inf") for i in range(n)]
dist[n-1] = 0
h = False
for i in range(n):
    updated = False
    for e in edge:
        if dist[e[1]] > dist[e[0]] + e[2] and p0[e[1]] and p0[e[0]]:
            dist[e[1]] = dist[e[0]] + e[2]
            updated = True
    if not updated:
        break
else:
    h = True

if h:
    print(-1)
else:
    print(max(0, -dist[0]))
s = input()

cnt = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if int(s[i:j]) % 2019 == 0:
            cnt += 1
print(cnt)

### FIXED CODE ###

s, w = list(map(int, input().split()))

print("unsafe" if s <= w else "safe")
=int(input())
a=list(map(int,input().split()))
p=set()
cnt=[]
zero=0
for i in range(n):
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.add(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
p=list(p)
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if len(p)>=4:
		print("No")
		exit()
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")
import collections
x, n= map(int, input().split())
P = list(map(int, input().split()))
 
PX = list(map(lambda p: p-x,P))
CPX = collections.Counter(PX)
ans = 0
 
for i in range(max(max(P),x)):
  if P = []:
    ans = x
    break
  elif CPX[-i] == 0:
    ans = x -i
    break
  elif CPX[i] == 0:
    ans = x +i
    break

print(ans)

### FIXED CODE ###

import collections
x, n= map(int, input().split())
P = list(map(int, input().split()))
 
PX = list(map(lambda p: p-x,P))
CPX = collections.Counter(PX)
ans = 0

for i in range(100):
  if CPX[-i] == 0:
    ans = x -i
    break
  elif CPX[i] == 0:
    ans = x +i
    break

print(ans)
import numpy as np
n=int(input())
a=np.sort(np.array(input().split(" "),dtype="int32"))
a_=list(a[:])
for i in a:
	print(a_.index(i)+1,end=" ")

### FIXED CODE ###

n=int(input())
if n%2==0:
	print((n//2)/n)

else:
	print((n//2+1)/n)
import sys

input = [sys.argv[1],sys.argv[2]]

result = ""
n = len(input[1])
for i in range(0,n):
	result = result + input[0][i] + input[1][i]

if len(input[0])>n:
	result = result + input[0][-1]

print(result)


### FIXED CODE ###

import sys

x = sys.stdin.readline().strip()
y = sys.stdin.readline().strip()

result = ""
n = len(y)
for i in range(0,n):
	result = result + x[i] + y[i]

if len(x)>n:
	result = result + x[-1]

print(result)
a,b,c=map(int,input().split())	!map(int　でinputの中身をint性質にしている
print(b*a//2)					!//はint表示、/はreal表示。多分

### FIXED CODE ###

a,b,c=map(int,input().split())	#map(int　でinputの中身をint性質にしている
print(b*a//2)					#//はint表示、/はreal表示。多分
import sys
N, Q = [int(i) for i in input().split()]
tree = {i:[] for i in range(1,N+1)}
cost_ls = {i:0 for i in range(1,N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

yet = set()
def plus(node, _from):
    yet.add(node)
    #cost_ls[node] += num
    for child in tree[node]:
        if child == _from:
            continue
        cost_ls[child] += cost_ls[node]
        plus(child, node)

for _ in range(Q):
    p, x = map(int, input().split())
    cost_ls[p] += x

plus(1, 0)

print(' '.join(str(cost_ls[i]) for i in range(1,N+1)))

### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

N, Q = map(int, input().split())
V = {i: [] for i in range(1, N + 1)}
for _ in range(N - 1):
    a, b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)

C = {i: 0 for i in range(1, N + 1)}

for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x


def propagate(u, p):
    for v in V[u]:
        if v == p:
            continue
        C[v] += C[u]
        propagate(v, u)


propagate(1, 0)

print(' '.join(str(C[i]) for i in range(1, N + 1)))
N = int(input())
l = list()

for n in range(N):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(1, N):
        if a[i][0] != a[i-1][-1]:
            print("No")
            break
    print("Yes")
else:
    print("No")
    


### FIXED CODE ###

N = int(input())
l = list()

for n in range(N):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(0, N-1):
        if l[i+1][0] != l[i][-1]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")
a,b = map(int,input().split())
print(math.ceil((a+b)//2))

### FIXED CODE ###

import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
c_i=np.array([])
for i in range(N-1):
    if H[i]>=H[i+1]:
        count+=1
        if i==(N-2):
            c_i=np.append(c_i,count)
    else:
        c_i=np.append(c_i,count)
        count=0
print(np.max(c_i))

### FIXED CODE ###

import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
k=0
for i in range(N-1):
    count+=1
    if H[i]<H[i+1]:
        k=max(k,count-1)
        count=0
print(max(k,count))
S=list(map(str, input().split()))
a=S[0]
b=S[1]
print(math.floor(int(a)*float(b)))

### FIXED CODE ###

import math
S=list(map(str, input().split()))
a=S[0]
b=S[1]
c=b[0]+b[2]+b[3]
print(math.floor(int(a)*(int(c))//100))
def chmin(a, b):
  if a > b:
    a = b

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float(inf)]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1, min(i+k, n-2)):
    chmin(dp[j], dp[i] + abs(h[j]-h[i]))
print(h[n-1])
  

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	for j in range(1, min(K + 1, N - i)):
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])
n,m = map(int,input().split())
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
print(100*l[0]+10*l[1]+l[2])

### FIXED CODE ###

n,m = map(int,input().split())
if m == 0 and n != 1:
    print(10**(n-1))
    exit()
if m== 0 and n==1:
    print(0)
    exit()
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0 and n==1:
    print(0)
    exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
ans = 0
for i in range(n):
    ans += l[n-i-1]*10**i
print(ans)
n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y

print(l)

d = {}
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])



### FIXED CODE ###


n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}#辞書同士の追加はupdate

for i in range(1,n+1):
    d[i] =0
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])
A,B,C,D = map(int, input().split())

lcm_number = C*D // math.gcd(C, D)
all_number = B -A + 1

answer_C = B // C - (A-1) // C
answer_D = B // D - (A-1) // D
answer_lcm = B // lcm_number - (A-1) // lcm_number

print(all_number - answer_C - answer_D + answer_lcm)

### FIXED CODE ###

import fractions

A,B,C,D = map(int, input().split())
lcm_number = C*D // fractions.gcd(C, D)
all_number = B -A + 1

answer_C = B // C - (A-1) // C
answer_D = B // D - (A-1) // D
answer_lcm = B // lcm_number - (A-1) // lcm_number

print(all_number - answer_C - answer_D + answer_lcm)
x = N * 800
y = (N // 15) * 200
print(x - y)

### FIXED CODE ###

N = int(input())
x = N * 800
y = N // 15 * 200
print(x - y)
i=1
while True:
    n=int(input())
    i++
    print(f'Case {i}: {n}')



### FIXED CODE ###

i=1
while True:
    x=int(input())
    if(x==0):
        break
    print(f"Case {i}: {x}")
    i+=1
n=int(input())
s=input()
k=int(input())
ss = s[k-1]
for i in range(1,n):
  if s[i] != ss:
    s[i]='*'
print(s)

### FIXED CODE ###

n=int(input())
s=list(input())
k=int(input())
ss = s[k-1]
for i in range(0,n):
  if s[i] != ss:
    s[i]='*'
print("".join(s))
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())

# A以上B以下でCで割り切れる数の個数
x1 = (A-1) // C
x2 = B // C
x = x2 - x1
#print("x:", x)

# A以上B以下でDで割り切れる数の個数
y1 = (A-1) // D
y2 = B // D
y = y2 - y1
#print("y", y)

# A以上B以下でC,Dで割り切れる数の個数
z1 = (A-1) // lcm(C, D)
z2 = B // lcm(C, D)
z = z2 - z1
#print("lcm:{}".format(lcm(C, D)))
#print("z", z)

# A~B間の整数 - Cの倍数とDの倍数の個数 + CでもDでも割り切れる個数
not_d = B - A+1 - (x + y - z)
print(int(not_d))


### FIXED CODE ###

""" import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())

# A以上B以下でCで割り切れる数の個数
x1 = (A-1) // C
x2 = B // C
x = x2 - x1
#print("x:", x)

# A以上B以下でDで割り切れる数の個数
y1 = (A-1) // D
y2 = B // D
y = y2 - y1
#print("y", y)

# A以上B以下でC,Dで割り切れる数の個数
z1 = (A-1) // lcm(C, D)
z2 = B // lcm(C, D)
z = z2 - z1
#print("lcm:{}".format(lcm(C, D)))
#print("z", z)

# A~B間の整数 - Cの倍数とDの倍数の個数 + CでもDでも割り切れる個数
not_d = B - (A+1) - (x + y - z)
print(int(not_d))
 """

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

total = b - a + 1


def lem(A, B):
	AB = A * B
	while B != 0:
		A, B = B, A % B
	return AB // A


bsep = (b // c) + (b // d) - (b // lem(c, d))
asep = (a-1) // c + (a-1) // d - (a-1) // lem(c, d)

ans = total - bsep + asep
print(ans)
import sys
x, y = map(int, input().split())
#dp = [[0] * (y+1) for _ in range(x+1)]
#dp = [[0] * (x*2+1) for _ in range(x+1)]
dp = [[0] * (y+1) for _ in range(x+1)]
div = 10**9+7

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

if y > 2 * x or y < x / 2:
    print(0)
    sys.exit()

dp[0][0] = 1
dp[2][1] = 1
dp[1][2] = 1

#print(dp)

for i in range(2, x+1):
    #for j in range(i // 2, 2 * i + 1):
    for j in range(i // 2, y+1):
        #print(i, j)
        # if j > y:
        #     break
        if (i + j) % 3 != 0:
            continue
        if y == x / 2:
            dp[i][j] = dp[i-2][j-1] % div
        elif y == 2 * x:
            dp[i][j] = dp[i-1][j-2] % div
        else:
            #print('merge!', dp[i-1][j-2], dp[i-2][j-1])
            dp[i][j] = (dp[i-1][j-2] + dp[i-2][j-1]) % div

#print(dp)
print(dp[x][y])

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10**5)
x, y = map(int, input().split())
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

if y > 2 * x or y < x / 2:
    print(0)
    sys.exit()

cnt = (x + y) // 3
# p = cnt // 2
p = (2 * x - y) // 3
#print(cnt, p)

# Calclate cntCp
comb = Combination(1000000)
ans = comb(cnt, p)

print(ans)
n = int(input())
s = list(input())
k = int(input())
t = s[k]
for i in range(n):
    if s[i] != t:
        s[i] = "*"
print(*s,sep="")

### FIXED CODE ###

n = int(input())
s = list(input())
k = int(input())
t = s[k-1]
for i in range(n):
    if s[i] != t:
        s[i] = "*"
print(*s,sep="")
#C
import math
a, b, c, d = map(int, input().split())
bb = b - (b // c) - (b // d) + (b // (c * d / math.gcd(c, d)))
aa = a - (a // c) - (a // d) + (a // (c * d / math.gcd(c, d)))

print((bb-aa))

### FIXED CODE ###

#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)
d = int(input())

if d = 25:
  print("Christmas")
elif d = 24:
  print("Christmas Eve")
elif d = 23:
  print("Christmas Eve Eve")
else
  print("Christmas Eve Eve Eve")


### FIXED CODE ###

d = int(input())
string = 'Christmas'
for i in range(25-d):
  string += ' Eve'
print(string)
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				cnt += 1

print(cnt)
N=int(input())
h=list(map(int,input().split()))
Answer=h[0]

for i in range(N):
    if h[i]<=h[i+1]:
        m=h[i+1]-h[i]
        Answer=Answer+m
        
print(Answer)

### FIXED CODE ###

n=0
Answer=0
N=int(input())
h=list(map(int,input().split()))
h.insert(0,0)

for i in range(N):
    if h[n]<=h[n+1]:
        m=h[n+1]-h[n]
        Answer=Answer+m
    else :
        pass
    n=n+1
print(Answer)