Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
default = 2**31 - 1

mindict = {}
answer_stk = []

for i in range(q) :
    query, x, y = map(int, input().split())
    
    if query == 0 :
        mindict[x] = y
    else :
        min_between = default
        for k in mindict.keys() :
            if k >= x and k <= y :
                min_between = min(min_between, mindict[k])
                
        answer_stk.append(min_between)
        
for a in answer_stk :
    print(a)
                
    


Fixed submission:
n, q = map(int, input().split())

# max_num
INF = 2**31 - 1

# generate seg tree
seg_size = 2

while seg_size < n :
    seg_size *= 2
    
seg_size = seg_size * 2 - 1
seg_tree = [INF for x in range(seg_size)]

answer_stk = []

# update 
def update(i, x) :
    # leaf for index @ i
    idx = seg_size // 2 + i
    seg_tree[idx] = x
    
    while idx :
        idx = (idx - 1) // 2
        l_child = seg_tree[idx * 2 + 1]
        r_child = seg_tree[idx * 2 + 2]
        
        seg_tree[idx] = min(l_child, r_child)

# query
def query(s, t, l, r, curnode) :
    # no overlap then return INF
    if s > r or t < l :
        return INF
    
    # full overlap then return current node
    if s <= l and t >= r :
        return seg_tree[curnode]
    
    # partial overlap then return min for next
    else :
        l_child = curnode * 2 + 1
        r_child = curnode * 2 + 2
        
        l_value = query(s, t, l, (l + r) // 2, l_child)
        r_value = query(s, t, (l + r) // 2 + 1, r, r_child)
        
        return min(l_value, r_value)
    
# do main query
for i in range(q) :
    q, x, y = map(int, input().split())
    
    # update
    if q == 0 :
        update(x, y)
        
    # query 
    else :
        answer_stk.append(query(x, y, 0, seg_size // 2, 0))
        
for a in answer_stk :
    print(a)

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())

answer = []
# create segtree
size = 2

while size < n :
    size *= 2
    
size = size * 2 - 1
segtree = [2**31 - 1 for x in range(size)]

# update query
def update(i, x) :
    ind = size // 2 + i
    segtree[ind] = x
    
    while ind :
        ind = (ind - 1) // 2 # parent
        ch1 = segtree[ind * 2 + 1]
        ch2 = segtree[ind * 2 + 2]
        segtree[ind] = min(ch1, ch2)
    
def query(s, t, l, r, p) :
    if s > r or t < l :
        return 2**31 - 1
    if s <= l and t >= l :
        return segtree[p]
    else :
        vl = query(s, t, l, (l + r) // 2, p * 2 + 1)
        vr = query(s, t, (l + r) // 2, r, p * 2 + 2)
        
        return min(vl, vr)
    
for i in range(q) :
    com, x, y = map(int, input().split())
     
    if com == 0 :
        update(x, y)
    else :
        answer.append(query(x, y, 0, size // 2, 0))

# print(answer)

for a in answer :
    print(a)
    



Fixed submission:
n, q = map(int, input().split())

# max_num
INF = 2**31 - 1

# generate seg tree
seg_size = 2

while seg_size < n :
    seg_size *= 2
    
seg_size = seg_size * 2 - 1
seg_tree = [INF for x in range(seg_size)]

answer_stk = []

# update 
def update(i, x) :
    # leaf for index @ i
    idx = seg_size // 2 + i
    seg_tree[idx] = x
    
    while idx :
        idx = (idx - 1) // 2
        l_child = seg_tree[idx * 2 + 1]
        r_child = seg_tree[idx * 2 + 2]
        
        seg_tree[idx] = min(l_child, r_child)

# query
def query(s, t, l, r, curnode) :
    # no overlap then return INF
    if s > r or t < l :
        return INF
    
    # full overlap then return current node
    if s <= l and t >= r :
        return seg_tree[curnode]
    
    # partial overlap then return min for next
    else :
        l_child = curnode * 2 + 1
        r_child = curnode * 2 + 2
        
        l_value = query(s, t, l, (l + r) // 2, l_child)
        r_value = query(s, t, (l + r) // 2 + 1, r, r_child)
        
        return min(l_value, r_value)
    
# do main query
for i in range(q) :
    q, x, y = map(int, input().split())
    
    # update
    if q == 0 :
        update(x, y)
        
    # query 
    else :
        answer_stk.append(query(x, y, 0, seg_size // 2, 0))
        
for a in answer_stk :
    print(a)