Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update(k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[1])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)

Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
bn = (n-1).bit_length()
b_num = 2**bn
mx = 10**9
segl=[mx]*2*b_num 

xs = []
for s, t, x in [[int(c) for c in input().split()] for _ in range(n)]:
    xs += [(s-x,0,x,i), (t-x,1,x,i)]
for _ in range(Q):
    xs.append((int(input()),2,0,0))
xs.sort()
ys = set()
for x in xs:
    if x[1]==2:
        for _ in range(bn):
            nys = set()
            ys = nys
        print(segl[0] if segl[0]!= mx else -1)
        ys = set()
        continue
    segl[x[3]+b_num-1] = mx if x[1] else x[2]
    ys.add((x[3]+b_num-2)//2)


Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update( k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[0])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)


Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)

Buggy python submission (verdict: Runtime Error):
import sys
class SegTree:
    def __init__(self, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

input = sys.stdin.readline

n,Q=map(int,input().split())
xs = []
qs = []
for i in range(n):
    s,t,x=map(int,input().split())
    xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
for _ in range(Q):
    xs.append((int(input()), 2, 0,0))
xs.sort(key=lambda x:x[0])

mx,XN = 10**9,n
st = SegTree(XN, mx, min)
for t,r,x,i in xs:
    if r == 2:
        c = st.query(0,XN)
        print(c if c!= mx else -1)
    else:
        st.update(i, x if r else mx)


Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)

Buggy python submission (verdict: Runtime Error):
import sys
#from bisect import bisect_left as bl
input = sys.stdin.readline

n,Q=map(int,input().split())
xs,qs = [],[]
for _ in range(n):
    s,t,x=map(int,input().split())
    s,t,x=s-x,t-x,x
    xs += [(s,1,x), (t,0,x)]
for _ in range(Q):
    qs.append(int(input()))

xs.sort(key=lambda x:x[0])

Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)

Buggy python submission (verdict: Runtime Error):
import sys
#from bisect import bisect_left as bl
input = sys.stdin.readline

n,Q=map(int,input().split())
xs,qs = [],[]
for _ in range(n):
    s,t,x=map(int,input().split())
    s,t,x=s-x-0.5,t-x-0.5,x
    xs += [(s,1,x), (t,0,x)]
for _ in range(Q):
    qs.append(int(input()))

xs.sort()

h=set()
qi = 0
q = qs[qi]
for t,r,x in xs:
    if q < t:
        if h:
            c = -1
        else:
            c = -1
        while True:
            if q < t:
                print(c)
                Q-=1
                if Q:
                    qi += 1
                    q = qs[qi]
                    continue
                sys.exit()
            break
    if r:
        h.add(x)
    else:
        h.remove(x)
print("-1\n"*Q)


Fixed submission:
a, b = map(int, input().split())
print((a*3 + b)//2)