Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
A = []
def update(i, x):
    A[i] = x
    
def find(x,y):
    print(min(A[x:y+1]))

n, q = map(int,input().split())

for i in range(n):
    A.append(2**31-1)
    
for i in range(q):
    com, x, y = [int(i) for i in input().split()]
    if com == 0:
        update(x, y)
    else:
        find(x,y)


Fixed submission:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
n, q = map(int, readline().split())
 
N0 = 2**(n-1).bit_length()
INF = 2**31-1
data = [INF]*(2*N0)

def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
 
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s
 
 
ans = []
for q in range(q):
    t, x, y = map(int, readline().split())
    if t:
        ans.append(str(query(x, y+1)))
    else:
        update(x, y)
write("\n".join(ans))
write("\n")
Buggy python submission (verdict: Time Limit Exceeded):
import sys;

def putQueen(i, row, col, dpos, dneq):
    if(i == 8):
        global finding
        if(finding == 0):
            return
        finding = 0
        printBoard(row[0:])
    

    for j in range(8):
        if i in myset:
            putQueen(i+1,row[0:], col[0:], dpos[0:], dneq[0:])
            continue
        if(col[j] == 1 or dpos[i+j] == 1 or dneq[i-j+7] == 1):
            continue
        row[i] = j
        col[j] = dpos[i+j] = dneq[i-j+7] = 1
        putQueen(i+1,row[0:], col[0:], dpos[0:], dneq[0:])
        col[j] = dpos[i+j] = dneq[i-j+7] = 0

def printBoard(row):
    for k in range(8):
        if(row[k] == 0):
            print("Q.......")
        elif(row[k] == 1):
            print(".Q......")
        elif(row[k] == 2):
            print("..Q.....")
        elif(row[k] == 3):
            print("...Q....")
        elif(row[k] == 4):
            print("....Q...")
        elif(row[k] == 5):
            print(".....Q..")
        elif(row[k] == 6):
            print("......Q.")
        else:
            print(".......Q")

n = (int)(input());
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dpos = [0 for i in range(15)]
dneq = [0 for i in range(15)]

myset = set()

for i in range(n):
    r,c = map(int, input().split());
    myset.add(r)
    row[r] = c
    col[c] = 1
    dpos[r+c] = 1
    dneq[r-c+7] = 1

finding = 1

putQueen(0,row, col, dpos, dneq)



Fixed submission:
import sys;

def putQueen(i, row, col, dpos, dneq):
    global finding
    if(finding == 0):
        return
        
    if(i == 8):
        finding = 0
        printBoard(row[0:])
        return
    

    for j in range(8):
        if i in myset:
            putQueen(i+1,row[0:], col[0:], dpos[0:], dneq[0:])
            continue
        if(col[j] == 1 or dpos[i+j] == 1 or dneq[i-j+7] == 1):
            continue
        row[i] = j
        col[j] = dpos[i+j] = dneq[i-j+7] = 1
        putQueen(i+1,row[0:], col[0:], dpos[0:], dneq[0:])
        col[j] = dpos[i+j] = dneq[i-j+7] = 0

def printBoard(row):
    for k in range(8):
        if(row[k] == 0):
            print("Q.......")
        elif(row[k] == 1):
            print(".Q......")
        elif(row[k] == 2):
            print("..Q.....")
        elif(row[k] == 3):
            print("...Q....")
        elif(row[k] == 4):
            print("....Q...")
        elif(row[k] == 5):
            print(".....Q..")
        elif(row[k] == 6):
            print("......Q.")
        else:
            print(".......Q")

n = (int)(input());
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dpos = [0 for i in range(15)]
dneq = [0 for i in range(15)]

myset = set()

for i in range(n):
    r,c = map(int, input().split());
    myset.add(r)
    row[r] = c
    col[c] = 1
    dpos[r+c] = 1
    dneq[r-c+7] = 1

finding = 1

putQueen(0,row, col, dpos, dneq)
Buggy python submission (verdict: Runtime Error):
import sys;

def init(n_):
    length = 1;
    while(length < n_):
        length*=2
    element=[0]*(2*length-1)
    for i in range(2*length-1):
        element[i] = initial
    return element

def update(k,a,element):
    k+=n
    element[k]=a
    while(k > 0):
        k = (int)((k-1)/2)
        element[k] = min(element[k*2+1],element[k*2+2])

def findmin(a, b):
    return findquery(a,b+1,0,0,n)

def findquery(a, b, k, l, r):
    if(r <= a or b <= l):
        return initial
    if(a <= l and r <= b):
        return element[k]

    vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))
    vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)
    return min(vl,vr)

n,q = map(int, input().split());

initial = pow(2,31)-1
element = init(n)

for i in range(q):
    query,key,value = map(int, input().split());
    if(query == 0):
        update(key,value,element)
    else :
        print(findmin(key,value))


Fixed submission:
import sys;

def init(n_):
    length = 1;
    while(length < n_):
        length*=2
    element=[0]*(2*length-1)
    for i in range(2*length-1):
        element[i] = initial
    return element,length

def update(k,a,element):
    k+=n-1
    element[k]=a
    while(k > 0):
        k = (int)((k-1)/2)
        element[k] = min(element[k*2+1],element[k*2+2])

def findmin(a, b):
    return findquery(a,b+1,0,0,n)

def findquery(a, b, k, l, r):
    if(r <= a or b <= l):
        return initial
    if(a <= l and r <= b):
        return element[k]

    vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))
    vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)
    return min(vl,vr)

n,q = map(int, input().split());

initial = pow(2,31)-1
element,n = init(n)

for i in range(q):
    query,key,value = map(int, input().split());
    if(query == 0):
        update(key,value,element)
    else :
        print(findmin(key,value))
Buggy python submission (verdict: Runtime Error):
# Disjoint Set: Union Find Trees
[p, rank] = [[], []]
[n, q] = list(map(int, input().split()))
w = [0 for i in range(n)]
path_c = [[] for i in range(n)]

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)

def findSet(x):
    global p
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]

def link(x, y):
    global p, rank
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1

def union(x, y):
    link(findSet(x), findSet(y))

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   

def relate(x, y, z):
    global w, path_c
    path_c[x].append((y, z))
    #print(w)
    if w[y] == 0:
        w[y] = w[x] + z
    else:
        update(x, y, z)
        #w[x] = w[y] - z
    #print("cost:", w[y])
    union(x, y)

def update(x, y, z):
    global w, path_c
    w[x] = w[y] - z
    for i in range(len(path_c[x])):
        update(path_c[x][i][0], x, path_c[x][i][1])


def diff(x, y):
    if same(x, y) == 1:
        global w
        return abs(w[y] - w[x])
        '''
        global d
        total = 0
        d = [0 for i in range(n)]
        d[x] = 1
        return cost(x, y, n, total)
        '''
    else:
        return "?"     

'''
print(p)
print(rank)
print(w)
print("\n")
'''

for i in range(n):
    makeSet(i)

#w = [0 for i in range(n)]

for i in range(q):
    data = list(map(int, input().split()))
    if data[0] == 0:
        relate(data[1], data[2], data[3])
    else:
        print(diff(data[1], data[2]))
    '''
    print("\n")
    print(p)
    print(rank)
    print(w)
    print("\n")
    '''


Fixed submission:
# Disjoint Set: Union Find Tree
p = []
rank = []

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)

def findSet(x):
    global p
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]

def link(x, y):
    global p, rank
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1

def union(x, y):
    link(findSet(x), findSet(y))    

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   

[n, q] = list(map(int, input().split()))
for i in range(n):
    makeSet(i)

for i in range(q):
    [com, x, y] = list(map(int, input().split()))
    if com == 0:
        union(x, y)
    else:
        print(same(x, y))
Buggy python submission (verdict: Runtime Error):

cx1, cy1, r1 = map(float, raw_input().split())
cx2, cy2, r2 = map(float, raw_input().split())

import math
distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )
rsum = r1 + r2
rmax = math.max(r1, r2)
rmin = math.min(r1, r2)

import sys
if distance > rsum:
  print(4)
elif abs(distance - rsum) < sys.float_info.epsilon:
  print(3)
else:
  if rmax < distance + rmin:
    print(2)
  elif abs(rmax - distance - rmin) < sys.float_info.epsilon:
    print(1)
  else:
    print(0)


Fixed submission:

cx1, cy1, r1 = map(float, input().split())
cx2, cy2, r2 = map(float, input().split())

import math
distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )
rsum = r1 + r2
rmax = max(r1, r2)
rmin = min(r1, r2)

import sys
if distance > rsum:
  print(4)
elif abs(distance - rsum) < sys.float_info.epsilon:
  print(3)
else:
  if rmax < distance + rmin:
    print(2)
  elif abs(rmax - distance - rmin) < sys.float_info.epsilon:
    print(1)
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):

n, q = map(int, input().split())

n_ = 1 # 実際に確保した配列のサイズ
while n_ < n:
  n_ *= 2

seg_tree = [0 for i in range(2*n_-1)]

def add(i, x):
  i += n_ - 1
  seg_tree[i] += x
  while i > 0 :
    i = int((i - 1)/2)
    #seg_tree[i] = seg_tree[i*2+1] + seg_tree[i*2+2]
    seg_tree[i] += x

def getSum(s, t):
  return query(s, t+1, 0, 0, n_)

def query(a, b, k, l, r):
  if r <= a or b <= l :
    return 0
  if a <= l and r <= b:
    return seg_tree[k]

  vl = query(a, b, k*2+1, l, int((l+r)/2))
  vr = query(a, b, k*2+2, int((l+r)/2), r)
  return vl + vr


output = []

for i in range(q):
  line = list(map(int, input().split()))

  if line[0] == 0:
    add(line[1], line[2])

  else :
    output.append(getSum(line[1],line[2]))


for ans in output:
  print(ans)


Fixed submission:

n, q = map(int, input().split())

n_ = 1 # 実際に確保した配列のサイズ
while n_ < n:
  n_ *= 2

seg_tree = [0 for i in range(2*n_-1)]

def add(i, x):
  i += n_ - 1
  seg_tree[i] += x
  while i > 0 :
    i = int((i - 1)/2)
    #seg_tree[i] = seg_tree[i*2+1] + seg_tree[i*2+2]
    seg_tree[i] += x

def getSum(s, t):
  return query(s, t+1, 0, 0, n_)

def query(a, b, k, l, r):
  if r <= a or b <= l :
    return 0
  if a <= l and r <= b:
    return seg_tree[k]

  vl = query(a, b, k*2+1, l, int((l+r)/2))
  vr = query(a, b, k*2+2, int((l+r)/2), r)
  return vl + vr


output = []

for i in range(q):
  # print(seg_tree)
  line = list(map(int, input().split()))

  if line[0] == 0:
    add(line[1]-1, line[2])

  else :
    output.append(getSum(line[1]-1,line[2]-1))


for ans in output:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

v, e = map(int, input().split()) # 頂点数vと辺数eを入力

g = [[] for i in range(v)] # グラフの要素数を確保

for i in range(e):
 s, t = map(int, input().split()) 
 g[s].append(t) # グラフに辺を挿入


ans = 0 # 答え
color = ['WHITE' for i in range(v)] # 全て未探索
stack = []
color[0] = 'GRAY'
stack.append(0)

while len(stack) != 0:
 u = stack.pop()

 for adj in g[u]:
  if color[adj] == 'GRAY':
   ans = 1
   stack.clear()
   break
  elif color[adj] == 'WHITE':
   stack.append(adj)
   color[adj] == 'GRAY'

print(ans)


Fixed submission:

v, e = map(int, input().split()) # 頂点数vと辺数eを入力

g = [[] for i in range(v)] # グラフの要素数を確保

for i in range(e):
 s, t = map(int, input().split()) 
 g[s].append(t) # グラフに辺を挿入


color = ['WHITE' for i in range(v)] # 全て未探索

def dfs(u):
 color[u] = 'GRAY'

 for adj in g[u]:
  if color[adj] == 'GRAY':
   return 1
  elif color[adj] == 'WHITE':
   if dfs(adj) == 1:
    return 1

 color[u] = 'BLACK'
 return 0

ans = 0
for u in range(v):
 color[i in range(v)] = 'WHITE'
 if dfs(u) == 1:
  ans = 1
  break

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

ss = [set([i]) for i in range(n)]

for _ in range(nq):
    q,x,y = map(int, input().split())
    if q == 0:
        sx = {}
        sy = {}
        for s in ss:
            if x in s:
                sx = s
            if y in s:
                sy = s
        ss.remove(sx)
        ss.remove(sy)
        ss.append(sx | sy)
    else:
        for s in ss:
            if x in s:
                if y in s:
                    print(1)
                else:
                    print(0)



Fixed submission:
n, nq = map(int, input().split())
set_list = list(range(n))

def find(n):
    global set_list
    if set_list[n] == n:
        return n
    result = set_list[n] = find(set_list[n])
    return result

def same(x, y):
    set_list[find(y)] = find(x)

def unite(x, y):
    return find(x) == find(y)

for _ in range(nq):
    com,x,y = map(int, input().split())
    if com == 0:
        same(x, y)
    else:
        if unite(x, y):
            print(1)
        else:
            print(0)
Buggy python submission (verdict: Runtime Error):



nv,ne = [int(i) for i in input().split()]

a = []

for i in range(nv):
    a.append([])

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    a[s].append(t)

done = []

flag = 0

def put_forword(index):
    global f

    if index in done:
        return

    done.append(index)

    for s in a[index]:

        if s == 0:
            f = 1
            return
        put_forword(s)

put_forword(0)
print(f)



Fixed submission:

nv,ne = [int(i) for i in input().split()]

g = [[] for i in range(nv)]

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    g[s].append(t)

visited = []
f = 0

def pursue_from(index, origin):

    if visited[index]:
        return

    visited[index] = True

    for next_index in g[index]:

        if next_index == origin:
            global f
            f = 1
            return
        pursue_from(next_index, origin)

for i in range(nv):
    visited = [False for i in range(nv)]

    pursue_from(i, i)

    if f == 1:
         break

print(f)

Buggy python submission (verdict: Runtime Error):

nv,ne = [int(i) for i in input().split()]

g = [[] for i in range(nv)]

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    g[s].append(t)

done = []
f = 0

def put_forword(index):
    global f

    if index in done:
        return

    done.append(index)

    for i in g[index]:

        if i == 0　and done.count() == nv:
            f = 1
            return
        put_forword(i)

put_forword(0)

print(f)



Fixed submission:

nv,ne = [int(i) for i in input().split()]

g = [[] for i in range(nv)]

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    g[s].append(t)

visited = []
f = 0

def pursue_from(index, origin):

    if visited[index]:
        return

    visited[index] = True

    for next_index in g[index]:

        if next_index == origin:
            global f
            f = 1
            return
        pursue_from(next_index, origin)

for i in range(nv):
    visited = [False for i in range(nv)]

    pursue_from(i, i)

    if f == 1:
         break

print(f)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

MIN = 0
for i in range(N-L+1):
  MIN = alist[i]
  for j in range(1, L):
    if alist[i+j] < MIN:
      MIN = alist[i+j]
  if i != N-L:
    print(MIN, end=' ')
  else:
    print(MIN)




Fixed submission:
# -*- coding: utf-8 -*-

N,L = list(map(int, input().split()))
alist = list(map(int, input().split()))
arr = []
for i in range(L):
  while arr and alist[i] <= alist[arr[-1]]:
    arr.pop()
  arr.append(i)
for i in range(L, N):
  print(alist[arr[0]], end=' ')
  while arr and arr[0] <= i-L:
    arr.pop(0)
  while arr and alist[i] <= alist[arr[-1]]:
    arr.pop()
  arr.append(i)
print(alist[arr[0]])
Buggy python submission (verdict: Runtime Error):
MAX = 10003 
N, Q =  (int(x) for x in  input().split())
ws = [0 for i in range(MAX)] 
par = [-1 for i in range(N)]

def weight(x):
    root(x)
    return ws[x]

def root(x):
    if par[x] < 0: return x
    p = root(par[x])
    ws[x] = ws[x] + ws[par[x]]
    par[x] = p
    return par[x]
    return y


def unite(y, x, z):
    z = z + weight(x)
    z = z - weight(y)
    x = root(x)
    y = root(y)
    if x == y: return 0
    if par[y] < par[x]:
        tmp = x
        x = y 
        y = tmp 
        z = -z
     
    par[x] = par[x] + par[y]
    par[y] = x
    ws[y] = z
    return 1 

def diff(x,y):
    if root(x) != root(y) :return False
    ans = ws[x] - ws[y]
    return ans



for q in range(Q):
    t, *cmd =  (int(x) for x in  input().split())
    if t:
        x, y = cmd
        z = diff(x, y)
        if z==False:print("?")
        else :print(z)
    else:
        x, y, z = cmd
        unite(x, y, z)




Fixed submission:
MAX = 100005
ws = [0 for i in range(MAX)] 
par = [-1 for i in range(MAX*2)]


def weight(x):
    root(x)
    return ws[x]

def root(x):
    if par[x] < 0: return x
    p = root(par[x])
    ws[x] = ws[x] + ws[par[x]]
    par[x] = p
    return par[x]


def unite(y, x, z):
    z = z + weight(x)
    z = z - weight(y)
    x = root(x)
    y = root(y)
    if x == y: return 0
    if par[y] < par[x]:
        tmp = x
        x = y 
        y = tmp 
        z = -z
     
    par[x] = par[x] + par[y]
    par[y] = x
    ws[y] = z
    return 1 

def diff(x,y):
    if root(x) != root(y) :return 0
    ans = ws[x] - ws[y]
    return 1 ,ans


if __name__=='__main__':
   global ans
   N, Q =  (int(x) for x in  input().split())
   for q in range(Q):
        t, *cmd =  (int(x) for x in  input().split())
        if t:
            x, y = cmd
            z = diff(x, y)
            if z==False :print("?")
            else :print(z[1])
        else:
            x, y, z = cmd
            unite(x, y, z)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


def get_sliding_minimum_element(nums, k):
    res = []
    queue = []
    for i, v in enumerate(nums):
        if queue and queue[0] <= i - k:
            queue = queue[1:]
        while queue and nums[queue[-1]] > v:
            queue.pop()
        queue.append(i)
        if i + 1 >= k:
            res.append(nums[queue[0]])
    return res


line = sys.stdin.readline()
n, l = map(int, line.split())
arr = list(map(int, input().split()))
res = get_sliding_minimum_element(arr, l)
print(' '.join(map(str, res)))



Fixed submission:
import sys


def get_sliding_minimum_element(nums, k):
    res = []
    queue = []
    for i, v in enumerate(nums):
        if queue and queue[0] <= i - k:
            queue = queue[1:]
        while queue and nums[queue[-1]] > v:
            queue.pop()
        queue.append(i)
        if i + 1 >= k:
            res.append(nums[queue[0]])
    return res


b = [0 for _ in range(1000000)]
deq = [0 for _ in range(1000000)]

line = sys.stdin.readline()
n, l = map(int, line.split())
arr = list(map(int, input().split()))
s = 0
t = 0
for i in range(n):
    while s < t and arr[deq[t - 1]] >= arr[i]:
        t -= 1
    deq[t] = i
    t += 1
    if i - l + 1 >= 0:
        b[i - l + 1] = arr[deq[s]]
        if deq[s] == i - l + 1:
            s += 1

for i in range(n-l+1):
    if i == n - l:
        print(str(b[i]), end='')
    else:
        print(str(b[i]) + " ", end='')
print("\n", end='')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    inputs = list(map(int, [stdinput() for _ in range(n)]))
    inputs = sorted(inputs)

    cache = [2]
    primes = list(filter(lambda a: is_prime(a, cache), inputs))
    print(len(primes))

def is_prime(a, primes):
    if a == 2:
        return True
    for p in primes:
        if a % p == 0:
            return False
    for b in range(max(primes), a // 2):
        if any(map(lambda p: b % p != 0, primes)):
            primes.append(b)
        if a % b == 0:
            return False
    return True

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    inputs = list(map(int, [stdinput() for _ in range(n)]))

    primes = 0
    for a in inputs:
        if is_prime(a, None):
            primes += 1
    print(primes)

def is_prime(a, primes):
    # Search for num below a**0.5,
    # as when A can be devided by number > a**0.5,
    # it means existing number < a**0.5 also can devide A.
    for p in range(2, int(a ** 0.5)  + 1):
        if a % p == 0:
            return False
    return True

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    *A, = map(int, stdinput().split(' '))
    o = mergeSort(A, 0, n)

    print(*A)
    print(o)

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]

    cap = max(A) + 1
    L.append(cap)
    R.append(cap)

    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return i + j

def mergeSort(A, left, right):
    o = 0
    if left + 1 < right:
        mid = (left + right) // 2
        o += mergeSort(A, left, mid)
        o += mergeSort(A, mid, right)
        o +=  merge(A, left, mid, right)
    return o

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Fixed submission:
from sys import stdin, maxsize


def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    *A, = map(int, stdinput().split(' '))
    o = mergeSort(A, 0, n)

    print(*A)
    print(o)

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]

    cap = maxsize
    L.append(cap)
    R.append(cap)

    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return i + j

def mergeSort(A, left, right):
    o = 0
    if left + 1 < right:
        mid = (left + right) // 2
        o += mergeSort(A, left, mid)
        o += mergeSort(A, mid, right)
        o +=  merge(A, left, mid, right)
    return o

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')
Buggy python submission (verdict: Time Limit Exceeded):
T, P = input(), input()
for i in range(len(T)):
	if T[i:].startswith(P):
		print(i)

Fixed submission:
T, P = input(), input()
T_len = len(T)
P_len = len(P)
for i in range(T_len - P_len + 1):
	if T[i:i + P_len] == P:
		print(i)
Buggy python submission (verdict: Runtime Error):
def update(i, x):
    i += base
    while i>0:
        st[i] = min(st[i], x)
        i//=2


def find(a, b):
    return _find(a, b+1, 0, 0, n)


def _find(a, b, k, l, r):
    if b <= l or r <= a:
        return 2**31-1

    if a <= l and r <= b:
        return st[k]

    rl = _find(a, b, 2*k+1, l, (l+r)/2)
    rr = _find(a, b, 2*k+2, (l+r)/2, r)
    return min(rl, rr)


(_n, q) = map(int, input().split())

n=1
while(n<=_n):
    n *= 2
base = n-1
st = [2**31-1]*(2*n-1)

for i in range(q):
    (c, l, r) = map(int, input().split())
    if c:
        print(find(l, r))
    else:
        update(l, r)

Fixed submission:
def update(i, x):
    i += base
    st[i] = x
    while i>0:
        i = (i-1)//2
        st[i] = min(st[i*2+1], st[i*2+2])


def find(a, b):
    return _find(a, b+1, 0, 0, n)


def _find(a, b, k, l, r):
    if b <= l or r <= a:
        return 2**31-1

    if a <= l and r <= b:
        return st[k]

    rl = _find(a, b, 2*k+1, l, (l+r)/2)
    rr = _find(a, b, 2*k+2, (l+r)/2, r)
    return min(rl, rr)


(_n, q) = map(int, input().split())

n=1
while(n<=_n):
    n *= 2
base = n-1
st = [2**31-1]*(2*n-1)

for i in range(q):
    (c, l, r) = map(int, input().split())
    if c:
        print(find(l, r))
    else:
        update(l, r)