Problem:


Score : 100 points

Problem Statement

We have A apples and P pieces of apple.

We can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.

Find the maximum number of apple pies we can make with what we have now.

Constraints

All values in input are integers.

0 \leq A, P \leq 100

Input

Input is given from Standard Input in the following format:

A P

Output

Print the maximum number of apple pies we can make with what we have.

Sample Input 1

1 3

Sample Output 1

3

We can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.

Sample Input 2

0 1

Sample Output 2

0

We cannot make an apple pie in this case, unfortunately.

Sample Input 3

32 21

Sample Output 3

58



Sample input:
1 3


Sample output:
3

Submission status: Runtime Error

Solution code:
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in list1:
    print(i[2])

Submission status: Runtime Error

Solution code:
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in lis:
    print(i[2])

Submission status: Runtime Error

Solution code:
A,P=map(int,input().split())
B=0
C=0
B=A*3+P
C=B%0
if C==0:
    print(B/2)
else:
    print((B-1)/2)

Submission status: Runtime Error

Solution code:
A=int(input("enter no. of apples:"))
print("number of apple pies =", 3*A/2)

Submission status: Runtime Error

Solution code:
A=int(input("enter no. of apples:"))
print("number of apple pies =", A/2)

Submission status: Runtime Error

Solution code:
A, P = int(input())
P += A * 3
print(int(P / 2))

Submission status: Runtime Error

Solution code:
n=A*3
pe=n+P
apple=pe//2

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(n):
  s,p=[x for x in input().rstrip().split()]
  l.append([s,int(p),i+1])
l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])

for s,p,i in l:
  print(i)

Submission status: Runtime Error

Solution code:
n = int(input())
list_shop = []
 
for i in range(n):
  t = []
  a, b = input().split()
  t.append(a)
  t.append(b)
  t.append(str(i + 1))
  list_shop.append(t)
 
check = 0
c = []
 
list_shop = sorted(list_shop, key=lambda x: x[0])
 
for i in range(len(list_shop) - 1):
  if(list_shop[i][0] == list_shop[i + 1][0]):
    check = 1
  else:
    check = 0
 
  c.append(list(map(int, list_shop[i][1:3])))
  if(check == 1):
    continue
  else:
    c.sort(key=lambda x:x[0], reverse=True)
    for j in c:
      print(int(j[1]))
    c = []
 
if(check == 1):
  c.append(list(map(int, list_shop[n - 1][1:3])))
  c.sort(key=lambda x:x[0], reverse=True)
  for i in c:
    print(i[1])
else:
  print(int(list_shop[n - 1][2]))

Submission status: Runtime Error

Solution code:
A=int(input(" enter no of apples")
P=int(input(" enter no of peices ")
n=A*3
pe=n+P
apple=pe//2
print(apple)

Submission status: Runtime Error

Solution code:
A=int(input(" enter no of apples")
P=int(input(" enter no of peices ")
n=A*3
pe=n+P
apple=pe//2
print(apple)

Submission status: Runtime Error

Solution code:
A,P = map(int, input().split())
print(((A*3)+P))//2)

Submission status: Runtime Error

Solution code:
import heapq
from collections import deque
from functools import lru_cache

N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0

for l in range(0,K + 1):
  for r in range(0,K - l + 1):
    d = K - r - l
    tmp = 0
    have = []
    if l + r > N:
      continue
    for i in range(0,l):
      tmp += V[i]
      have.append(V[i])
    for j in range(N - r,N):
      tmp += V[j]
      have.append(V[j])
    h = len(have)
    #print(have)
    have = sorted(have)
    for k in range(0,d):
      #print(have,sum(have))
      if k >= h:
        break
      if have[k] > 0:
        break
      tmp -= have[k]
    ans = max(tmp,ans)
    
print(ans)

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
print(int((a*3+b)/2))

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
s=a*3
reuslt=(p+s)//2

print(result)

Submission status: Runtime Error

Solution code:
a,p = map(int,input().split())
p = 3a + p
print(p//2)

Submission status: Runtime Error

Solution code:
print(eval(input().replace(" ","//")))

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
_a=a*3
print(int(sum(_a+p)//2))

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
_a=a*3
print(sum(_a+p)/2)

Submission status: Runtime Error

Solution code:
a,p=mp()
print((a*3+p)//2)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
  a.append(list(input().split()))
for i in range(0,n):
  a[i].append(i+1)
for i in range(0,len(a)):
  a[i][1]=int(a[i][1])

a.sort(key=lambda x:(x[0],-x[1]),reverse = False)
for i in range(0,n):
  print(a[i][2])

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
  a.append(list(input().split()))
for i in range(0,n):
  a[i].append(i+1)
for i in range(0,len(a)):
  a[i][1]=int(a[i][1])

a.sort(key=lambda x:(x[0],-x[1]),reverse = False)
for i in range(0,n):
  print(a[i][2])

 #数字と文字の混合リストをどう入力するか。

Submission status: Runtime Error

Solution code:
N = int(input())

ss = dict()
sss = dict()
for i in range(N):
    s, p = input().split()
    sss[s, p] = i + 1
    if s in ss:
        ss[s] = ss[s] + ',' + p
    else:
        ss[s] = p

ss_sorted = sorted(ss.items())

for tmp_ss in ss_sorted:
    s = tmp_ss[0]
    ps = list(map(int, tmp_ss[1].split(',')))
    ps.sort(reverse=True)
    for p in ps:
        print(sss[s, str(p)])

Submission status: Runtime Error

Solution code:
from sys import argv

debug = "a" in argv
n = int(input())
ls = []
la = ls.append
for i in range(1, n + 1):
    s = input().split()
    la((i, s[0], int(s[1])))
if debug:
    print("ls:",ls)
ls = sorted(ls, key=lambda x: x[2], reverse=1)
ls = sorted(ls, key=lambda x: x[1])
if debug:
    print("ls(sorted):",ls)
if debug:
    print("debug end")
for x in ls:
    print(x[0])

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
print((a*3+p)//2

Submission status: Runtime Error

Solution code:
import copy

N, K = map(int, input().split())
V = [int(i) for i in input().split()]

value = 0
# k+1個取って，ret-1個戻す
num = min(N,K)
for k in reversed(range(num)):
    for ret in range(K-k): 
        if (ret < k+1):
            for i in range(k+1+1): # 左右の分け方
                tmp = []
                V_tmp = copy.copy(V)
                tmp.extend(V_tmp[:i]) # 左端
                V_tmp = V_tmp[i:]
                if (k+1-i) > 0:
                    tmp.extend(V_tmp[-(k+1-i):]) #右端
                if V_tmp == []:
                    break
                tmp = list(filter(lambda x: x not in sorted(tmp)[:ret],tmp))
                value = max(value,sum(tmp))
print(value)

Submission status: Runtime Error

Solution code:
a,　p=map(int,input().split())
ans=(a*3+b)//2
print(ans)

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
ans=(a*3+b)//2
print(ans)

Submission status: Runtime Error

Solution code:
a,p = map(int,input().split())

print int((3*a+p)/2)

Submission status: Runtime Error

Solution code:
a,p = input.split(" ")
print( (a*3+p)//2 )

Submission status: Runtime Error

Solution code:
a=int(input())
p=int(input())
print(int((3*a+p)/2))

Submission status: Runtime Error

Solution code:
A, P = map(int, input())

print(int((A*3+ P) //2))

Submission status: Runtime Error

Solution code:
import math
A,P=map(int, input().split())
print(math.floor((3*a+P)/2))

Submission status: Runtime Error

Solution code:
n=int(input())
X=[]
for i in range(n):
    s,p=input().split()
    X.append((s,100-int(p),i+1))
X=sorted(X,key=lambda x:(x[0],x[1]))
for i in range(n):
    print(X[i][2])

Submission status: Runtime Error

Solution code:
a,p = map(int,input().split())
if 3*a+b < 2:
  print(0)
elif (3*a+b) % 2 == 0:
  print((3*a+b)//2)
else:
  print((3*a+b-1)//2)

Submission status: Runtime Error

Solution code:
import itertools
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

#%%
cnt = 0
for bits in itertools.product([0, 1], repeat=n):
    # ライトの配列の初期化
    lights = [0] * m

    # 電球ごとのONになってるスイッチの数をカウント
    # スイッチのindexでループを回す
    for i in range(n):
        if bits[i] == 1: #スイッチがONのとき
            sw = i + 1 # スイッチの番号
            for j in range(len(ks)): # 全部のlight-switchの配線を確認
                if sw in ks[j][1:]: # 配線がつながってるとき
                    lights[j] += 1 # そのlightに1を加算

    # カウント終了後条件判別
    # 一つもスイッチがONになってないとライトが付きもしない
    # if 0 not in lights:
        # 2で割ったあまり
    m_lights = [l%2 for l in lights]
    if m_lights == p:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
a,p = map(int, input().split())

cnt = a * 3

print(int(cnt/p))

Submission status: Runtime Error

Solution code:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    N, M = iip(False)
    #A = [iip(False) for i in range(N)]

    A = []
    P = []
    for i in range(M):
        A.append(iip()[1:])

    for i, p in enumerate(iip()):
        P.append(p)

    pat = 0
    for i in range(2**N):
        for denkyuu in range(M):
            ns = 0
            sn = i
            for s in range(N):
                if s+1 in A[denkyuu]:
                    ns += sn % 2
                    print("a", denkyuu, s+1)
                sn //= 2
            if ns % 2 != P[denkyuu]:
                pat -=1
                print(i, denkyuu, P[denkyuu], sn)
                break

        #print(i)
        pat += 1

    print(pat)

    #print(A)
    #print(P)






#####################################################ライブラリ集ここから

def YesNo(s):
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
 a,b=map(int,input())
print((3*a+b)//2)

Submission status: Runtime Error

Solution code:
 a,b=map(int,input().split())
print((3a+b)//2)

Submission status: Runtime Error

Solution code:
 a,b=map(int,input())
print((3a+b)//2)

Submission status: Runtime Error

Solution code:
a, p = map(int, input().split())

apple = 3 * a + b
pie = apple // 2

print(pie)

Submission status: Runtime Error

Solution code:
import heapq
import sys
sys.setrecursionlimit(10 ** 7)

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

event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append([s-x,1,x])
    event.append([t-x,-1,x])

for i in range(q):
    event.append([int(input()),2,i])
event.sort()

ans=[0]*q

stop=set()
hq=[]
for e in event:
    t,op,x=map(lambda x:x,e)
    if op==1:
        heapq.heappush(hq,x)
        stop.add(x)
    elif op==-1:
        stop.remove(x)

    else:
        while hq and hq[0] not in stop:
            heapq.heappop(hq) 
        ans[x]=hq[0] if hq else -1
    
for x in ans:
    print(x)

Submission status: Runtime Error

Solution code:
n = int(input())
s_p_list = []

for i in range(n):
    s_p_list.append(input().split())
    s_p_list[i].append(i+1)

result = sorted(s_p_list, key=lambda x: (x[0], -int(x[1]))) #sortedは非破壊的

for i in result:
  print(i[2])

Submission status: Runtime Error

Solution code:
a,p = map(int,input())
print((a * 3 + p)//2)

Submission status: Runtime Error

Solution code:
a,p = map(int,input().split())
ans = (2*a + P)//2
print(ans)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
v = list(map(int,input().split()))

ans=0
for i in range(min(k,n)+1):
    for j in range(min(k,n)-i+1):
        t=sorted(v[:i]+v[:~j:-1])
        for l in range(min(min(n,k)-i-j,len(t))):
            if t[l]<0:
                t[l]=0
        ans=max(ans,sum(t))

print(ans)

Submission status: Runtime Error

Solution code:
a,p = map(int,input().split())
print((3*a+b)//2)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())

sp_list=[]
for i in range(N):
    s,p = input().rstrip().split()
    sp_list.append( [i+1,s,int(p)] )
#-----

sp_list.sort( key=lambda x:(x[1],-x[2]) )

for i,s,p in sp_list:
    print(i)

Submission status: Runtime Error

Solution code:
a,p=map(int,input())
print((3*a+p)//2)

Submission status: Runtime Error

Solution code:
lst = list()
for idx in range(int(input())):
  k,v = input().split()
  lst.append((k,int(v), idx+1))
lst.sort(key=lambda t: (t[0],-t[1]), reverse=False)
for t in lst:
  print(t[2])

Submission status: Runtime Error

Solution code:
number = input().split(" ")
A = int(number[0])
P = int(number[1])
apple = (A * 3) + P
print(math.floor(apple / 2))

Submission status: Runtime Error

Solution code:
x, y = map(int, input().split())
print(3*x+y)//2

Submission status: Runtime Error

Solution code:
a,p=map(int, input())
p+=a*3
print(p//2)

Submission status: Runtime Error

Solution code:
A,P=input().split()
print((3*A+2)//2)

Submission status: Runtime Error

Solution code:
apple=input()
kakera=input()
applepai=input()

apple=int(apple)
kakera=int(kakera)
applepai=int(applepai)

if kakera(2):
  print(applepai+1)
elif apple(1):
  print(kakera+3)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
read = sys.stdin.read

def main():
  n, q = map(int, input().split())
  event = []
  stop = set()
  for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))
  event.sort()
  event.append((float("inf"), 0, 0))
  D = list(map(int, read().split()))
  now = 0
  for t, b, x in event:
    while t > D[now]:
      if stop:
        print(min(stop))
      else:
        print(-1)
      now += 1
      if now == q:
        exit()
    if b == 1:
      stop.add(x)
    else:
      stop.remove(x)
      
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
A, P = map(int, input())
print((A*3+P)//2)

Submission status: Runtime Error

Solution code:
A, P = map(int, input().split())

a = A*3 + P

if a > 0:
  print(math.floor(a/2))
else:
  print(0)

Submission status: Runtime Error

Solution code:
A, P = map(int, input().split())

a = A*3 + P

print(math.floor(a/2))

Submission status: Runtime Error

Solution code:
#128 b
n=int(input())
res=[]
for i in range(n):
    a,b=list(input().split())
    b=-1*int(b)
    res.append([a,b,i+1])
res=sorted(res)
for x in res:
    print(x[2])

Submission status: Runtime Error

Solution code:
#128 b 
n=int(input())
res=[]
for i in range(n):
    a,b=list(input().split())
    b=-1*int(b)
    res.append([a,b,i+1])
res=sorted(res)
for x in res:
    print(x[2])

Submission status: Runtime Error

Solution code:
import sys

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

def main():
    N,Q = list(map(int,input().split()))

    road = []
    x_list = []

    for i in range(N):
        s,t,x = list(map(int,input().split()))
        road.append([0,s-x,x])
        road.append([1,t-x,x])

    for i in range(Q):
        road.append([2,int(input()),i])

    from collections import defaultdict

    counter = defaultdict(int)
    counter[10**27] = 1
    ans = [0]*Q

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

    q = [10**27]

    from heapq import heappop,heappush

    for id,_,x in road:
        if id==0:
            heappush(q,x)
            counter[x]+=1
        elif id==1:
            counter[x]-=1
        else:
            while counter[q[0]]==0:
                heappop(q)
            #print(q)
            if q[0]<10**27:
                ans[x] = q[0]
            else:
                ans[x] = -1
    print("\n".join(map(str,ans)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a, p = input().split()
print((a*3 + p) // 2)

Submission status: Runtime Error

Solution code:
a, p = input().split()
ptint((a*3 + p) // 2)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
A,P = map(int,input().split())
print((A*3+B)//2)

Submission status: Runtime Error

Solution code:
A,P=map(int,input())
print((A*3+P)//2)

Submission status: Runtime Error

Solution code:
P, Q, R = map(int, input().split())
time = [P+Q, P+R, Q+R]
print(min(time))

Submission status: Runtime Error

Solution code:
A, P = int( x ) for x in input().split()
print( ( A * 3 + P ) // 2 )

Submission status: Runtime Error

Solution code:
A, P = int( x ) for x in input()
print( ( A * 3 + P ) // 2 )

Submission status: Runtime Error

Solution code:
A, P = map(int, input().split())

print((A * 3 + p) // 2)

Submission status: Runtime Error

Solution code:
A, P = map(int, input().split())

print((3A + P)//2)

Submission status: Runtime Error

Solution code:
a,p=list(map(int, input().split()))
print((3a+p)//2)

Submission status: Runtime Error

Solution code:
a,p=map(int, input().split())
print((3a+p)//2)

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
print((3a+p)//2)

Submission status: Runtime Error

Solution code:
a,p=map(int,input().split())
pritn((3a+p)//2)

Submission status: Runtime Error

Solution code:
A,P = map(int,input())
print(int(((3*A)+P)//2))

Submission status: Runtime Error

Solution code:
l=list(map(int,input().split()))
a=l[0]
p=l[1]
print((3a+p)//2)

Submission status: Runtime Error

Solution code:

A, P = map(int, raw_input.split())

N_piec = A * 3  + P
N_pie  = N_piec / 2
print N_pie

Submission status: Runtime Error

Solution code:
arguments = input("test")
arguments_as_list = arguments.split(" ")
list_to_integer = list(map(int, arguments_as_list))
apples_pieces = list_to_integer[0]*3
pieces = list_to_integer[1]


print(int((apples + pieces)//2))

Submission status: Runtime Error

Solution code:
arguments = input()
arguments_as_list = arguments.split(" ")
list_to_integer = list(map(int, arguments_as_list))
apples = list_to_integer(0)
pieces = list_to_integer(1)

print((apples//3 + pieces)//2)

Submission status: Runtime Error

Solution code:
def applpie(apples, pieces):
  x = apples//3
  y = apples + pieces
   return y//2

Submission status: Runtime Error

Solution code:
A,P=map(int(input().split())
print((3*A+P)//2)

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = II()
    sp = []
    for i in range(n):
        sp.append(input().split())
    another = [(s[0], -1 * int(s[1]),num) for num,s in enumerate(sp)]
    another.sort()
    for s,p,q in another:
        print(q+1)

    return

#C
def C():
    n, m = LI()
    ks = LIR_(m)
    p = LI()
    patern = itertools.product(range(2), repeat=n)
    ans = 0
    for on in patern:
        ki = [0 for i in range(m)]
        for num, oni in enumerate(on):
            if oni:
                for i,ksi in enumerate(ks):
                    ksi = ksi[1::]
                    if num in ksi:
                        ki[i] ^= 1
        for num, pi in enumerate(p):
            if pi != ki[num]:
                break
        else:
            ans += 1
    print(ans)

            
    return

#D
def D():
    N, K = LI()#random.randint(1,50),random.randint(1,100)
    v = LI()#[random.randint(-10 ** 2, 10 ** 2) for i in range(N)]
    ans = 0
    for a in range(min(N, K) + 1):
        for b in range(min(N, K) + 1):
            if a + b > min(K,N):
                break
            if a == b == 0:
                continue
            deletes = K - a - b
            left = v[:a]
            right = v[:-b-1:-1]
            x = left + right
            x.sort()
            tmp = sum(x)
            for delete in range(min(deletes, len(x))):
                if x[delete] >= 0:
                    break
                tmp -= x[delete]
            ans = max(ans,tmp)
    
    print(ans)
                

    return


#E
def E():  
    N,q = LI()
    STX = LIR(N)
    D = IR(q)
    LV = (q - 1).bit_length()
    N0 = 1 << LV

    data = [inf] * (N0 << 1)
    INF = inf

    def update(l, r, x):
    
        #  区間[l, r)のdataの値を更新
        L = N0 + l; R = N0 + r
        while L < R:
            if R & 1:
                R -= 1
                data[R] = min(data[R-1], x)
            if L & 1:
                data[L] = min(data[L-1], x)
                L += 1
            L >>= 1; R >>= 1

    def query(x):
        L = N0 + x - 1
        #  xの最小値を求める
        s = INF
        while L >= 0:
            s = min(s, data[L])
            L = (L - 1) >> 1
        return s

    for s, t, x in STX:
        XS = max(-1, s - x)
        XT = max(-1, t - x)
        XS_index = bisect_left(D, XS)
        XT_index = bisect_left(D, XT)
        update(XS_index, XT_index, x)

    for i in range(q):
        a = query(i)
        print(a if a != inf else -1)
#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
cnt=0

for i in range(2**n):
    pattern=format(i,"b").zfill(n)
    point=0
    
    for j in range(m):
        swi=0
        for k in s[j]:
            if pattern[k-1]=="1":
              swi +=1
        if swi%2==p[j]:
          point +=1
    if point==m:
      cnt +=1
      
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s,p=list(map(int,input().split()))
li=[]
for i in range(0,n):
  li.append((i+1,s[i],p[i]))

new_li=sorted(li,key=lambda x:x[1])
new2_li=sorted(new_li,key=lambda x:x[2])

for j in range(0,n):
  print(new2_li[j][0])

Submission status: Runtime Error

Solution code:
a,p=map(int(input().split()))
x=3*a+p
print(x//2)

Submission status: Runtime Error

Solution code:
a,p=int(input().split())
x=3*a+p
if x%2==0:
  print(x/2)
else:
  print((x-1)/2)

Submission status: Runtime Error

Solution code:
x = int(input())
y = int(input())
print(int((x*3+y)/2))

Submission status: Runtime Error

Solution code:
inp = raw_input('')
a, p = [int(i) for i in inp.split(' ')]
numberofpies = p//2
p=p%2
p+=(a*3)
numberofpies+=(p//2)
print(numberofpies)

Submission status: Runtime Error

Solution code:
n = int(input())
isp = []
S = []
P = []
for _ in range(n):
    s, p = input().split()
    p = int(p)
    S.append(s)
    P.append(p)
for i in range(n):
    isp.append([i+1, S[i], P[i]])
isp = sorted(isp, key=lambda x: x[2], reverse=True)
isp = sorted(isp, key=lambda x: x[1])
for i in range(n):
    print(isp[i][0])

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = map(int, input().split())

ks_list = []
for i in range(M):
    ks = list(map(int, input().split()))
    ks_list.append(ks)
    
p = list(map(int, input().split()))
ans = 0

for x in range(2 ** N + 1):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
print((a*3+p)//2)

Submission status: Runtime Error

Solution code:
A,P = int(input())
N = 3*A+P
print(N//2)

Submission status: Runtime Error

Solution code:
A=int(input())
P=int(input())
print((3*A+P)//2)

Submission status: Runtime Error

Solution code:
#printがpaiはおかしいのかな・・・
A,B= map(int, input().split())
print((3*A+P)//2)

Submission status: Runtime Error

Solution code:
#まさかまたこの分けわからん式入れたらいいんか・・・？
A,B= map(int, input().split())

pai=int((3*A+P)//2)
print(pai)

Submission status: Runtime Error

Solution code:
A=int(inport())
P=int(inport())

pai=int((3 * A + P) // 2)
print(pai)

Submission status: Runtime Error

Solution code:
A=int(inport())
P=int(inport())

pai=int((3*A+P)/2)
print(pai)

Submission status: Runtime Error

Solution code:
A=int(inport())
P=int(inport())

pai=(3*A+P)/2
print(pai)

Submission status: Runtime Error

Solution code:
#欠片は３Aに加えPもあるから３A+Pだ
import math
A=int(inport())
P=int(inport())

pai=(3*A+P)/2
print(math.floor(pai))

Submission status: Runtime Error

Solution code:
import math
A=int(inport())
P=int(inport())

#3A/2=pai
P=3*A
pai=P/2
print(math.floor(pai))

Submission status: Runtime Error

Solution code:
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)