CodeEff/ECCO huggingface dataset:
# Original solution
N, T = list(map(int,input().split()))

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

ans = 0

for i in range(N-1):
  stop = TL[i] + T
  if stop >= TL[i+1]:
    ans += TL[i+1]-TL[i]
  else:
    ans += T
ans += T
print(ans)

# Optimized solution
N,T = list(map(int,input().split()))
L = list(map(int,input().split())) 

ans = 0
end = 0
for i in range(N):
  ans += min(L[i]+T-end,T)
  end = L[i] + T
print(ans)
# Original solution
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
t.append(t[-1])
ans = 0
for i in range(1, N+1):
  if t[i] - t[i-1] > T:
    ans += T
  elif t[i] == t[i-1]:
    ans += T
  elif t[i] - t[i-1] <= T:
    ans += t[i] - t[i-1]
  
print(ans)

# Optimized solution
n,t = list(map(int, input().split()))
T = list(map(int, input().split()))
ans = 0
for i in range(1,n):
    if T[i] - T[i-1] < t:
        ans += T[i] - T[i-1]
    else: ans += t
ans += t
print(ans)
# Original solution
n,t = list(map(int, input().split()))
T = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if T[i+1]-T[i]<t: ans += T[i+1]-T[i]
    else: ans += t
print((ans+t))

# Optimized solution
n,T = list(map(int, input().split()))
t = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if t[i+1]-t[i] >= T: ans += T
    else: ans += t[i+1]-t[i]
print((ans+T))
# Original solution
def main():
    n,t = list(map(int,input().split()))
    a = list(map(int,input().split()))
    res = t
    for i in range(1,n):
        if a[i-1]+t <= a[i]:
            res += t
        else:
            res += t - (a[i-1]+t-a[i])
    print(res)

if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n,t = list(map(int,input().split()))
    tl = list(map(int,input().split()))
    res = t
    for i in range(1,n):
        res += t - max((tl[i-1]+t-tl[i]),0)
    print(res)

if __name__ == '__main__':
    main()
# Original solution
N,T=list(map(int,input().split()))
t=[int(i) for i in input().split()]
ans = T
for i in range(N-1):
    ans += min(t[i+1] - t[i],T)
print(ans)

# Optimized solution
N,T= list(map(int,input().split()))
t = [int(j) for j in input().split()]
ans =T
b = 0
for i in t:
    ans+=min(i-b,T)
    b = i
print(ans)
# Original solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = list(map(int, input().split()))
    T = list(map(int, input().split()))

    res = 0
    for i in range(1, n):
        if T[i - 1] + t < T[i]:
            res += t
        else:
            res += T[i] - T[i - 1]

    print((res + t))


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = list(map(int, input().split()))
    T = list(map(int, input().split()))

    res = 0
    for i in range(n - 1):
        res += t if T[i] + t <= T[i + 1] else T[i + 1] - T[i]

    print((res + t))


if __name__ == '__main__':
    resolve()
# Original solution
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
LST = []

for a in A:
  LST.append((a,1))
  LST.append((a+T,-1))
  
LST.sort()

prev = -1
s = 0
ans = 0
for x,y in LST:
  if y == 1:
    s += 1
    if s == 1:
      prev = x
  elif y == -1:
    s -= 1
    if s == 0:
      ans += (x - prev)
  
print(ans)



# Optimized solution
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = 0
for i in range(N-1):
  ans += min(T,A[i+1] - A[i])
  
print((ans+T))
# Original solution
N,T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = T
for i in range(1,N):
  if t[i]-t[i-1] >= T:
    ans += T
  else:
    ans += t[i] - t[i-1]
  
print(ans)

# Optimized solution
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = N * T # 総和
cur = 0 # いつまで出るか
for i in range(N):
    if cur > t[i]:
        ans -= cur - t[i]
    cur = t[i] + T
print(ans)
# Original solution
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
cnt = 0
cur = 0
for i in range(1,N):
    b = A[i]
    a = A[i-1]
    if b-a<T:
        cur += b-a
    else:
        cnt += cur+T
        cur = 0
cnt += cur+T
print(cnt)

# Optimized solution
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
cnt = 0
cur = 0
for i in range(1,N):
    if A[i]-A[i-1]>T:
        cnt += A[i-1]-cur+T
        cur = A[i]
cnt += A[N-1]+T-cur
print(cnt)
# Original solution
# coding: utf-8
# Your code here!

N, T = list(map(int, input().split()))
a = list(map(int, input().split()))
total_t, crrnt_t, a_len = 0, 0, len(a)

for i in range(a_len - 1):
    if a[i] + T > a[i + 1]: 
        total_t += a[i + 1] - a[i]
    else: 
        total_t += T
    crrnt_t = a[i + 1]

print((total_t + T))

# Optimized solution
# coding: utf-8
# Your code here!

N, T = list(map(int, input().split()))
a = list(map(int, input().split()))
total_t, a_len = 0, len(a)

for i in range(a_len - 1):
    if a[i] + T > a[i + 1]: 
        total_t += a[i + 1] - a[i]
    else: 
        total_t += T

print((total_t + T))
# Original solution
N,T = list(map(int,input().split()))
t = list(map(int,input().split()))
cnt = 0
for i in range(1,N):
    emp_time=(t[i]-t[i-1])-T
    if emp_time >= 0:
        cnt += T
    else:
        cnt += t[i]-t[i-1]
print((cnt+T))

# Optimized solution
# coding: utf-8
n, t = list(map(int,input().split()))
T = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if T[i+1] - T[i] >= t:
        ans += t
    else:
        ans += T[i+1] - T[i]
print((ans+t))
# Original solution
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ret = 0
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
    ret += min(T,diff)
print((ret+T))


# Optimized solution
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ret = 0
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
    ret += T if T<diff else diff
print((ret+T))
# Original solution
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
#ret = 0
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
# for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
#     ret += T if T<diff else diff
ret = sum([min(T, ts[ind+1]-ts[ind]) for ind in range(N-1)])
print((ret+T))


# Optimized solution
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ret = T
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
    ret += T if T<diff else diff
print(ret)
# Original solution
def resolve():
  N, T = list(map(int, input().split()))
  tt = list(map(int, input().split()))
  ans = 0
  last = 0

  for t in tt:
    if t >= last:
      ans += T
      last = t + T
    else:
      ans += t + T - last
      last = t + T

  print(ans)

  return

if __name__ == "__main__":
  resolve()


# Optimized solution
def resolve():
  N, T = list(map(int, input().split()))
  t = list(map(int, input().split()))
  ans = 0
  till = 0
  for now in t:
    if till > now:
      ans -= till - now
    till = now + T
    ans += T
  print(ans)
  return

if __name__ == "__main__":
  resolve()
# Original solution
N,T = list(map(int,input().split()))
ts = list(map(int,input().split()))

ans = 0
until = 0
for t in ts:
    ans += min(T, t+T-until)
    until = t+T
print(ans)

# Optimized solution
N,T = list(map(int,input().split()))
ts = list(map(int,input().split()))

ans = 0
prev = ts[0]
for t in ts[1:]:
    ans += min(T, t-prev)
    prev = t
ans += T
print(ans)
# Original solution
n, t = list(map(int, input().split()))
times = list(map(int, input().split()))

p = 0
ans = 0
for time in times:
    start = min(p, time)
    ans += t - max(0, p - time)
    p = time + t
print(ans)


# Optimized solution
N, T = list(map(int, input().split()))
times = list(map(int, input().split()))
ans = 0
t = 0
for time in times:
    if time >= t:
        ans += T
        t = time + T
    else:
        diff = t - time
        ans += T - diff
        t = time + T
print(ans)
# Original solution
N,T = list(map(int,input().split()))
L = list(map(int,input().split()))
ans = 0
for i in range(len(L)) :
    if i != N-1 :
        if L[i+1]-L[i] > T :
            ans += T
        else :
            ans += L[i+1]-L[i]
    else :
        ans += T
print(ans)


# Optimized solution
N,T = list(map(int,input().split()))
L = list(map(int,input().split()))
ans = T
for i in range(N-1) :
    ans += min(L[i+1]-L[i],T)
print(ans)
# Original solution
N, T = list(map(int, input().split()))
ans = 0
t_start = 0
t_stop = 0
for t in map(int, input().split()):
    if t >= t_stop:
        ans += t_stop - t_start
        t_start = t
    t_stop = t + T
print((ans + t_stop - t_start))


# Optimized solution
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
print((sum(min(T, t[i + 1] - t[i]) for i in range(N - 1)) + T))
# Original solution
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = 0

for i in range(1, N):
    if t[i] - t[i - 1] >= T:
        ans += T
    else:
        ans += t[i] - t[i - 1]

print((ans + T))


# Optimized solution
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = 0

for i in range(1, N):
    d=t[i]-t[i-1]
    if d >= T:
        ans += T
    else:
        ans += d

print((ans + T))
# Original solution
d = int(eval(input()))
print(('Christmas' + (25-d)*' Eve'))

# Optimized solution
print(('Christmas'+(25-int(eval(input())))*' Eve'))
# Original solution
D= int(eval(input()));

C = "Christmas";
E = " Eve";

if D==25:
    print(C);
elif 21 < D < 25:
    print((C+(E*(25-D))));


# Optimized solution
D = int(eval(input()))

chris = 'Christmas'
eve = ' Eve'
num = 25

if D in range(22,25):
    num -= D
    eve = ' Eve' * num
    chris += eve

print(chris)
# Original solution
D = int(eval(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")

# Optimized solution
# -*-coding: utf-8 -*-
D = int(eval(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")
# Original solution
a='Christmas'
for i in range (0,25-int(eval(input()))):
  a+=' Eve'
print(a)

# Optimized solution
print(('Christmas'+(25-int(eval(input())))*' Eve'))
# Original solution
d = int(eval(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")

# Optimized solution
print(("Christmas"+" Eve"*(25-int(eval(input())))))
# Original solution
D=int(eval(input()))
List=["Christmas"+" Eve"*i for i in range(3,-1,-1)]
print((List[D-22]))

# Optimized solution
D=int(eval(input()))
print(("Christmas"+" Eve"*(-(D-25))))
# Original solution
d = int(eval(input()))
if d == 25:
  print("Christmas")
elif d == 24:
  print("Christmas Eve")
elif d == 23:
  print("Christmas Eve Eve")
elif d == 22:
  print("Christmas Eve Eve Eve")


# Optimized solution
print(("Christmas" + (" Eve" * (25 - int(eval(input()))))))
# Original solution
d=int(eval(input()));print(("Christmas"+" Eve"*(25-d)))

# Optimized solution
print(("Christmas"+" Eve"*(25-int(eval(input())))))
# Original solution
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    D = int(sys.stdin.readline().rstrip())
    print(('Christmas' + ' Eve'*(25-D)))



if __name__ == '__main__':
    main()


# Optimized solution
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    D = ii()
    print(('Christmas' + ' Eve'*(25-D)))


if __name__ == '__main__':
    main()
# Original solution
d = int(eval(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')

# Optimized solution
n = int(eval(input()))
if n==22:
  print('Christmas Eve Eve Eve')
elif n==23:
  print('Christmas Eve Eve')
elif n==24:
  print('Christmas Eve')
else:
  print('Christmas')
# Original solution
import itertools
import math
import fractions
import functools
import copy

D = int(eval(input()))

if D == 25: print("Christmas")
if D == 24: print("Christmas Eve")
if D == 23: print("Christmas Eve Eve")
if D == 22: print("Christmas Eve Eve Eve")

# Optimized solution
def main():
    n = int(eval(input()))
    # t, a = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()

    if n == 25:
        print("Christmas")
    elif n== 24:
        print("Christmas Eve")
    elif n==23:
        print("Christmas Eve Eve")
    elif n==22:
        print("Christmas Eve Eve Eve")


if __name__ == '__main__':
    main()
# Original solution
num = 25 - int(eval(input()))
s = "Christmas"
for _ in range(num):
    s = "{} {}".format(s, "Eve")
print(s)

# Optimized solution
d = int(eval(input()))
msg = 'Christmas'
for _ in range(25 - d):
	msg += ' Eve'
print(msg)
# Original solution
day = int(eval(input()))

if day == 25:
	print('Christmas')
elif day == 24:
	print('Christmas Eve')
elif day == 23:
	print('Christmas Eve Eve')
else:
	print('Christmas Eve Eve Eve')

# Optimized solution
day = int(eval(input()))
print(('Christmas' + ' Eve' * (25 - day)))
# Original solution
d = int(eval(input()))

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

# Optimized solution
d = int(eval(input()))

print(("Christmas"+" Eve"*(25-d)))
# Original solution
d=25-int(eval(input()));print(("Christmas"+" Eve"*d))

# Optimized solution
print(("Christmas"+" Eve"*(25-int(eval(input())))))
# Original solution
d = int(eval(input()))
if d == 25:
    print('Christmas')
elif d == 24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
elif d==22:
    print('Christmas Eve Eve Eve')

# Optimized solution
print(('Christmas'+' Eve'*(25-int(eval(input())))))
# Original solution
N = int(eval(input()))
if N == 25 :
    print("Christmas")
elif N == 24 :
    print("Christmas Eve")
elif N == 23 :
    print("Christmas Eve Eve")
elif N == 22 :
    print("Christmas Eve Eve Eve")


# Optimized solution
N = int(eval(input()))
plus = " Eve"
ans = "Christmas" + plus*(25-N)
print(ans)
# Original solution
D = int(eval(input()))
x = "Christmas" + (" Eve")*(25-D)
print(x)

# Optimized solution
D = int(eval(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")
# Original solution
d = int(eval(input()))
if d == 25:
    print('Christmas')
elif d == 24:
    print('Christmas Eve')
elif d == 23:
    print('Christmas Eve Eve')
elif d == 22:
    print('Christmas Eve Eve Eve')

# Optimized solution
d = int(eval(input()))
count = 25

if d == 25:
    print('Christmas')
else:
    count -= d
    print(('Christmas' + ' Eve' * count))
# Original solution
import copy as c
n=int(eval(input()))
lis=[int(a) for a in input().split()]
count=0
alis=c.copy(lis)
alis=sorted(alis)
prev=False
for i in range(n):
	if lis[i]==alis[i]:
		if not prev:
			count+=1
			prev=True
			continue
	prev=False

print(count)
#wrong solutiuon

# Optimized solution
#import copy as c
n=int(eval(input()))
lis=[int(a) for a in input().split()]
count=0
prev=False
for i in range(n):
	if lis[i]==i+1:
		if not prev:
			count+=1
			prev=True
			continue
	prev=False

print(count)
#wrong solutiuon
# Original solution
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

seq = 0
ans = 0
for i in range(N):
    A[i] -= i+1
    if A[i] == 0:
        seq += 1
    else:
        ans += (seq+1)//2
        seq = 0
ans += (seq+1)//2
print(ans)


# Optimized solution
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

seq = 0
ans = 0
for i in range(1, N+1):
    if A[i-1] == i:
        seq += 1
    else:
        ans += (seq+1)//2
        seq = 0
ans += (seq+1)//2
print(ans)
# Original solution
n=int(eval(input()))
p=[int(i) for i in input().split()]
a=[]
for i in range(n):
    if p[i]==i+1:
        a.append(i+1)
i=0
b=0
while(i<len(a)):
 if a[i]+2 in a:
   b+=2
   i=a.index(a[i]+2)+1
 else:
   b+=1
   if a[i]+1 in a:
     i+=2
   else:
     i+=1
print(b)


# Optimized solution
n=int(eval(input()))
p=[int(i) for i in input().split()]

a=0
b=0
for i in range(n):
    if p[i]==i+1:
        if a==0 or t==i:
           a+=1
        else:
           b+=(a+1)//2
           a=1
        t=i+1
b+=(a+1)//2

print(b)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
f=[True if a[i]==i+1 else False for i in range(n)]
ans=0
for i in range(n-1):
    if f[i] and f[i+1]:
        f[i]=False
        f[i+1]=False
        ans+=1

ans+=sum(f)
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
f=[True if a[i]==i+1 else False for i in range(n)]
ans=0
for i in range(n-1):
    if f[i]:
        f[i]=False
        f[i+1]=False
        ans+=1

if f[n-1]:
    ans+=1
print(ans)
# Original solution
n, q = list(map(int, input().split()))

A = [2147483647] * n

def update(i, x):
    A[i] = x

def find(s, t):
    print((min(A[s:t+1])))


for i in range(q):
    com, x, y = list(map(int, input().split()))
    if com == 0:
        update(x, y)
    else:
        find(x, y)

# Optimized solution
n, q = list(map(int, input().split()))

# make a list whose length is 2^i - 1.
num = 1
max_v = 2147483647

while num < n:
    num *= 2

A = [max_v for i in range(2 * num - 1)]


def update(i, x):
    i += num - 1
    A[i] = x

    while i > 0:
        i = (i - 1) // 2
        A[i] = min(A[i * 2 + 1], A[i * 2 + 2])

def find(a, b, k, l, r):
    if r <= a or b <= l:
        return max_v
    if a <= l and r <= b:
        return A[k]
    else:
        vl = find(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = find(a, b, k * 2 + 2, (l + r) // 2, r)
        return min(vl, vr)


for i in range(q):
    com, x, y = list(map(int, input().split()))
    if com == 0:
        update(x, y)
    else:
        ans = find(x, y + 1, 0, 0, num)
        print(ans)
# Original solution
# coding: utf-8
class SqrtDecomposition:
    # RMQ用平方分割
    
    # n:要素数 init:配列初期値
    def __init__(self,n,init=0):
        self.data=[init for i in range(n)]
        #self.sqrt_n=int(n**0.5)+1
        self.sqrt_n=512
        self.bucket=[init for i in range(self.sqrt_n)]
    
    # x を y にする
    def update(self,x,y):
        self.data[x] = y
        tmp = self.data[x//self.sqrt_n * self.sqrt_n]
        for i in range(x//self.sqrt_n * self.sqrt_n, min(x//self.sqrt_n * self.sqrt_n + self.sqrt_n, n)):
            if tmp > self.data[i]:
                tmp = self.data[i]
        self.bucket[x//self.sqrt_n] = tmp
    
    # [x,y) の最小を求める
    def find(self,x,y):
        tmp = 10**19
        for i in range(self.sqrt_n):
            l,r=i*self.sqrt_n,(i+1)*self.sqrt_n
            if r <= x or y <= l :
                continue
            if x <= l and r <= y :
                tmp = min(tmp, self.bucket[i]);
            else:
                for j in range(max(x, l),min(y, r)):
                    tmp = min(tmp, self.data[j]);
        return tmp


n,q = list(map(int,input().split()))
sd=SqrtDecomposition(n,2**31-1)
for i in range(q):
    c,x,y=list(map(int,input().split()))
    if c==0:
        sd.update(x,y)
    else:
        print((sd.find(x,y+1)))





# Optimized solution
# coding: utf-8
import sys
input=lambda : sys.stdin.readline().rstrip()

class SqrtDecomposition:
    # RMQ用平方分割
    
    # n:要素数 init:配列初期値
    def __init__(self,n,init=0):
        self.data=[init for i in range(n)]
        #self.sqrt_n=int(n**0.5)+1
        self.sqrt_n=int(n**0.5)+1
        self.bucket=[init for i in range(self.sqrt_n)]
    
    # x を y にする
    def update(self,x,y):
        self.data[x] = y
        tmp = self.data[x//self.sqrt_n * self.sqrt_n]
        for i in range(x//self.sqrt_n * self.sqrt_n, min(x//self.sqrt_n * self.sqrt_n + self.sqrt_n, n)):
            if tmp > self.data[i]:
                tmp = self.data[i]
        self.bucket[x//self.sqrt_n] = tmp
    
    # [x,y) の最小を求める
    def find(self,x,y):
        tmp = 10**19
        for i in range(self.sqrt_n):
            l,r=i*self.sqrt_n,(i+1)*self.sqrt_n
            if r <= x or y <= l :
                continue
            if x <= l and r <= y :
                tmp = min(tmp, self.bucket[i]);
            else:
                for j in range(max(x, l),min(y, r)):
                    tmp = min(tmp, self.data[j]);
        return tmp


n,q = list(map(int,input().split()))
sd=SqrtDecomposition(n,2**31-1)
for i in range(q):
    c,x,y=list(map(int,input().split()))
    if c==0:
        sd.update(x,y)
    else:
        print((sd.find(x,y+1)))
# Original solution

A = []

def update(i, x):
    A[i] = x

def find(s, t):
    return min(A[s:t+1])

if __name__ == "__main__":
    n, q = list(map(int, input().split()))
    A = [2**31 - 1] * n 
    for i in range(q):
        com, x, y = list(map(int, input().split()))
        if com == 0:
            update(x, y)
        else:
            m = find(x, y)
            print(m)



# Optimized solution
import sys

INF = 2**31 - 1


class RMQ:

    def __init__(self, n):
        tmp = 1
        while tmp < n:
            tmp *= 2
        self.n = tmp * 2 - 1
        self.A = [INF] * (2 * self.n - 1)

    def update(self, i, x):
        i = self.n // 2 + i
        self.A[i] = x
        while i:
            i = (i - 1) // 2
            self.A[i] = min(self.A[i * 2 + 1], self.A[i * 2 + 2])

    def find(self, a, b, k, l, r):
        if r < a or b < l:
            return INF
        if a <= l and r <= b:
            return self.A[k]
        vl = self.find(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = self.find(a, b, k * 2 + 2, (l + r) // 2 + 1, r)
        return min(vl, vr)


line = sys.stdin.readline()
n, q = list(map(int, line.split()))
t = RMQ(n)
for i in range(q):
    line = sys.stdin.readline()
    com, x, y = list(map(int, line.split()))
    if com == 0:
        t.update(x, y)
    else:
        print((t.find(x, y, 0, 0, t.n // 2)))