Problem:


Score : 200 points

Problem Statement

Niwango created a playlist of N songs.
The title and the duration of the i-th song are s_i and t_i seconds, respectively.
It is guaranteed that s_1,\ldots,s_N are all distinct.

Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)
However, he fell asleep during his work, and he woke up after all the songs were played.
According to his record, it turned out that he fell asleep at the very end of the song titled X.

Find the duration of time when some song was played while Niwango was asleep.

Constraints

1 \leq N \leq 50

s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.

s_1,\ldots,s_N are distinct.

There exists an integer i such that s_i = X.

1 \leq t_i \leq 1000

t_i is an integer.

Input

Input is given from Standard Input in the following format:

N
s_1 t_1
\vdots
s_{N} t_N
X

Output

Print the answer.

Sample Input 1

3
dwango 2
sixth 5
prelims 25
dwango

Sample Output 1

30

While Niwango was asleep, two songs were played: sixth and prelims.

The answer is the total duration of these songs, 30.

Sample Input 2

1
abcde 1000
abcde

Sample Output 2

0

No songs were played while Niwango was asleep.

In such a case, the total duration of songs is 0.

Sample Input 3

15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu

Sample Output 3

6348



Sample input:
3
dwango 2
sixth 5
prelims 25
dwango


Sample output:
30

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
titles = []
times = []
for i in range(N):
  s, t = input().split()
  titles.append(s)
  times.append(int(t))
X = input()
idx = titles.index(X)
print(int(np.sum(times[idx+1:])))

Submission status: Accepted

Solution code:
N = int(input())

S = []
T = []

for i in range(N):
  s, t = input().split()
  S.append(s)
  T.append(int(t))

X = input()

for i, s in enumerate(S):
  if s == X:
    idx = i
    break

print(sum(T[idx+1:]))

Submission status: Accepted

Solution code:

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	S = []
	T = []
	for i in range(N):
		s, t = list(input().split())
		t = int(t)
		S.append(s)
		T.append(t)

	X = input()
	ans = 0
	val = None
	for i in range(N):
		if S[i] == X:
			val = i
			break
	for i in range(val + 1, N):
		ans += T[i]

	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = int(input())
    s = []
    t = []
    for i in range(n):
        x,y = input().split()
        s.append(x)
        t.append(int(y))
    x = input()
    sleep = False
    ans = 0
    for i in range(n):
        if s[i]==x:
            sleep = True
            continue
        if sleep:
            ans += t[i]
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
st = []
for i in range(n):
    st.append([str(i) for i in input().split()])
x = str(input())

a = 0
for i in range(n):
    if st[i][0] == x:
        a = i
        break
ans = 0
for i in range(a+1, n):
    ans += int(st[i][1])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
data = []
for i in range(n):
    s, t = input().split()
    data.append([s, int(t)])
x = input()
ans = 0
flag = False
for i in range(n):
    if flag:
        ans += data[i][1]
    if x == data[i][0]:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
m = []
for i in range(N):
	s,t = input().split()
	m.append((s,int(t)))
X = input()
ans = 0
flag = False
for i in range(N):
	if flag:
		ans += m[i][1]
	if not flag and m[i][0] == X:
		flag = True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
songs = []
for _ in range(N):
    s, t = input().split()
    t = int(t)
    songs.append((s, t))
X = input()

ans = 0
isAsleep = False
for s, t in songs:
    if isAsleep:
        ans += t
    if s == X:
        isAsleep = True

print(ans)

Submission status: Accepted

Solution code:

N  = int (input())

songs = [input().split(" ") for  _ in range(N)]
X = input()
flag = False
ans = 0
for song in songs:
    s,t = song
    if flag:
        ans += int(t)
    if s == X:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
st = []
for _ in range(n):
    st.append([i for i in input().split()])
x = input()
i = 0
while st[i][0] != x:
    i += 1

i += 1
ans=0
for j in range(i, n):
    ans += int(st[j][1])
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ss = []
tt = []
for _ in range(N):
    s,t = input().split()
    ss.append(s)
    tt.append(int(t))

x = input()
i = ss.index(x)

print(sum(tt[i+1:]))

Submission status: Accepted

Solution code:
n = int(input())
st = [list(input().split()) for _ in range(n)]
x = input()

ans = 0
sleep = False
for s, t in st:
    if sleep:
        ans += int(t)
    if s == x:
        sleep = True

print(ans)

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    L1=[]
    L2=[]
    for i in range(N):
        s,t=input().split()
        t=int(t)
        L1.append(s)
        L2.append(t)
    X=input()
    print(sum(L2[L1.index(X)+1:]))

main()

Submission status: Accepted

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N = int(input())
st = [list(input().split()) for _ in range(N)]
X = input()


cnt = 0
flg = False
for sti in st:
    if flg:
        cnt += int(sti[1])
    if sti[0] == X:
        flg = True
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
st = [input().split() for _ in range(n)]
f = input()
s, t = zip(*st)
b = s.index(f)
ans = 0
for i in range(b+1, n):
  ans += int(t[i])
print(ans)

Submission status: Accepted

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


def main():
    N = int(input())
    st = []
    for _ in range(N):
        s, t = [x for x in input().split()]
        st.append([s, int(t)])

    X = input().strip()

    is_start = False
    ans = 0
    for s, t in st:
        if is_start:
            ans += t
        if s == X:
            is_start = True

    print(ans)
    

    



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ST = [tuple(input().split()) for _ in range(N)]
X = input()
flg = False
cnt = 0
for s, t in ST:
    if flg:
        cnt += int(t)
    else:
        if X == s:
            flg = True
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
st = [list(input().split()) for _ in range(N)]
X = input()
ret = 0
flg = False
for s, t in st:
    if flg:
        ret += int(t)
        continue
    if X == s:
        flg = True
print(ret)

Submission status: Accepted

Solution code:
N = int(input())
S = [list(input().split()) for _ in range(N)]
s = input()

ans = 0
flag = False
for song in S:
    title = song[0]
    leng = song[1]
    if flag:
        ans += int(leng)
    if title == s:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
arr = []
for _ in range(N):
    s, t = input().split()
    arr.append((s, int(t)))

X = input()
flag = False
ans = 0
for s, t in arr:
    if flag:
        ans += t
    if s == X:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ST=[input().split() for i in range(N)]
X=input()
f,r=0,0
for i in range(N):
    if f:
        r+=int(ST[i][1])
    if ST[i][0]==X:
        f=1
print(r)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = [input().split() for _ in [0]*n]
    name = input()
    l = [[i, int(j)] for i, j in l]
    flag = 0
    ans = 0
    for i, j in l:
        if flag == 1:
            ans += j
        if i == name:
            flag = 1
    print(ans)


main()

Submission status: Accepted

Solution code:
n=int(input())
p=[]
for i in range(n):
	s,t=map(str,input().split())
	t=int(t)
	p.append([s,t])
x=input()
ans=0
f=0
for i in range(n):
	if p[i][0]==x:
		f=1
	elif f:
		ans+=p[i][1]
print(ans)

Submission status: Accepted

Solution code:
#%%
n = int(input())
s = []
t = []
for i in range(n):
    a ,b = input().split()
    b = int(b)
    s.append(a)
    t.append(b)
x = input()
ind = s.index(x)

ans = 0
for i in range(ind+1, n):
    ans += t[i]
print(ans)

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
p,T=[],[]
for i in range(n):
    s,t=input().split()
    t=int(t)
    p.append(s)
    T.append(t)
x=input()

l=0
for i in range(n):
    ans+=l*T[i]
    if p[i]==x:
        l=1
        
    
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
raw = []
for _ in range(n):
  a,b = input().split()
  b = int(b)
  raw.append([a,b])
t = input()
ans = 0
att = 0
for i in range(n):
  ans += att * raw[i][1]
  if raw[i][0] == t:
    att = 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(str,input().split())) for i in range(n)]
x=str(input())
ans=0
c=0
for i in range(n):
    if c==1:
        ans+=int(l[i][1])
    if l[i][0]==x:
        c=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    a,b = input().split()
    b = int(b)
    l.append([a, b])
s = input()

res = 0
flag = False
for a, b in l:
    if flag:
        res += b
    else:
        if a == s:
            flag = True
print(res)

Submission status: Accepted

Solution code:

N = int(input())

st = []
dic = {}

a = 0

for i in range(N):

    s,t = input().split()
    t = int(t)
    a += t
    dic[s] = a

X = input()
print (a - dic[X])

Submission status: Accepted

Solution code:
n=int(input())
ST=[list(map(str,input().split())) for _ in range(n)]
x=input()

flag=False
ans=0
for s,t in ST:
  t=int(t)
  if flag: ans+=t
  if s==x: flag=True
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    ms = []
    for _ in range(n):
        s, t = input().split()
        t = int(t)
        ms.append((s, t))

    x = input()
    ret = 0
    flg = False
    for s, t in ms:
        if s == x:
            flg = True
        else:
            if flg:
                ret += t
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
N = int(input())
music = []
for _ in range(N):
    s, t = map(str, input().split())
    music.append([s, t])
X = input()

flag = False
ans = 0
for s, t in music:
    if flag:
        ans += int(t)
    if s == X:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
SS = []
SD = []
for i in range(N):
    s, t = input().split()
    SS.append(s)
    SD.append(int(t))

X = input()
count = 0
play = False
for i in range(1, N):
    if SS[i-1] == X: play = True
    if play: count += SD[i]

print(count)

Submission status: Accepted

Solution code:
N = int(input())
st = [input().split() for _ in range(N)]
X = input()

ret = 0
flag = False
for s, t in st :
  t = int(t)
  if flag :
    ret += t
  
  if s == X:
    flag = True
    
print(ret)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n = inp()
    s = []
    for _ in range(n):
        t = inpls()
        t[1] = int(t[1])
        s.append(t)
    x = input()
    key = 0
    ans = 0
    for i in range(n):
        if key:
            ans += s[i][1]
        if s[i][0]==x:
            key = 1
    print(ans)          

if __name__ == "__main__":
    main()

Submission status: Accepted

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

N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input().strip()

ANS=0
flag=0

for s,t in ST:
    if flag==1:
        ANS+=int(t)
        
    if s==X:
        flag=1

print(ANS)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
readline = sys.stdin.readline


N = int(readline())
C = Counter()

cnt = 0
for _ in range(N):
    s, t = readline().strip().split()
    C[s] = cnt + int(t)
    cnt += int(t)
print(cnt - C[readline().strip()])

Submission status: Accepted

Solution code:
N = int(input())
X = []
for _ in range(N):
    a, b = input().split()
    X.append((a, int(b)))

s = input()
ans = 0
f = 0
for a, b in X:
    if f:
        ans += b
    if a == s:
        f = 1
print(ans)

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,t = (input().split())
    query.append((s,t))
  x = input()
  
  ans = 0
  sleep = False
  for i in range(n):
    s,t = query[i]
    if sleep:
      ans += int(t)
    if s == x:
      sleep = True
  print(ans)
solve()

Submission status: Accepted

Solution code:
N = int(input())
st = []
for _ in range(N):
    s, t = input().split()
    t = int(t)
    st.append((s, t))
X = input()

flag = False
ans = 0
for s, t in st:
    if s == X:
        flag = True
        continue
    if flag:
        ans += t
print(ans)

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    st = [list(map(str, readline().rstrip().decode('utf-8').split())) for _ in range(n)]
    x = str(readline().rstrip().decode('utf-8'))
    b = True
    cnt = 0
    for s, t in st:
        if not b:
            cnt += int(t)
        if s == x:
            b = False
    print(cnt)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
s = [list(input().split()) for i in range(n)]
a = input()

sum_ = 0
flag = False
for i in range(n):
    if flag:
        sum_ += int(s[i][1])
    if s[i][0] == a:
        flag = True
print(sum_)

Submission status: Accepted

Solution code:
N = int(input())
st = [input().split() for _ in range(N)]
X = input()
a = 0
b = 0
for s, t in st:
    t = int(t)
    b+=t
    if s == X:
        a = b
print(b-a)

Submission status: Accepted

Solution code:
n=int(input())
st=[input().split() for _ in range(n)]
x=input()
ans=0
flg=False
for s,t in st:
    if flg:
        ans+=int(t)
    if s==x:
        flg=True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
song = [list(input().split()) for _ in range(N)]

X = input()
ans = 0

flag = False
for i in range(N):
    if song[i][0] == X:
        flag = True
    elif flag:
        ans += int(song[i][1])

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li=[]
li2=[]
for _ in range(n):
	a,b=input().split()
	li.append(a)
	li2.append(int(b))
print(sum(li2[li.index(input())+1:]))

Submission status: Accepted

Solution code:
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""

N = int(input())
A = [input().split() for i in range(N)]
S = input()
ans = -1
for a in A:
	if ans != -1:
		ans += int(a[1])
	if a[0] == S:
		ans = 0
print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    ans = 0
    sl = False
    S=[]
    for i in range(N):
        s,t = ST().split()
        t = int(t)
        S.append((s,t))
    X = ST()
    for s,t in S:
        if s==X:
            sl=True
        else:
            if sl:
                ans+=t
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
st = [input().split() for i in range(N)]
X = input()

ans = 0
found = False
for s,t in st:
    if found:
        ans += int(t)
    if s==X:
        found = True

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    index = s.index(X)
    print(sum(t[index+1:]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
play = []
for i in range(n):
    s,t = input().split()
    t = int(t)
    play.append((s,t))
x = input()
flag = False
ans = 0
for s,t in play:
    if x == s:
        flag = True
    elif flag:
        ans += t
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
titles, times = [], []
for _ in range(N):
    s, t = input().split()
    titles.append(s)
    times.append(int(t))
idx = titles.index(input())
ans = 0
for i in range(idx+1, N):
    ans += times[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [list(input().split()) for i in range(n)]
b = input()
flg = 0
ans = 0
for i in range(n):
  if a[i][0] == b:
    flg = 1
  elif flg:
    ans += int(a[i][1])
print(ans)

Submission status: Accepted

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

n = int(input())
C = [list(input().split()) for i in range(n)]
s = input()

ans = 0
a=0
for i in range(n):
    if a==1:
        ans += int(C[i][1])
    if s == C[i][0]:
        a = 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    s,t=['']*N,[0]*N
    for i in range(N):
        s[i],t[i]=input().split()
        t[i]=int(t[i])
    S=input()
    print(sum(t[s.index(S)+1:]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = [input().split() for i in range(n)]
    d = defaultdict(lambda : 0)
    s = 0
    for pi,i in p:
        s += int(i)
        d[pi] += s
    print(s-d[input()])
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
ST = [readline().split() for _ in range(N)]
X = read().rstrip()

S,T = zip(*ST)

i = S.index(X)

answer = sum(map(int,T[i+1:]))
print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    ret = 0
    flg = False
    for i in range(N):
        if flg:
            ret += t[i]
        if s[i] == X:
            flg = True
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
u=0
for i in range(n):
    s,t=list(map(input().split()))
    t=int(t)
x=input()
p=s.index(x)
u += t[p+1:n]
print(u)

Submission status: Runtime Error

Solution code:
N=int(input())
u=0
for i in range(n):
    s,t=list(map(input().split()))
    t=int(t)
x=input()
p=s.found(x)
u += t[p+1:n]
print(u)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(list(map(int,input().split())) for _in range(n))
x = input()
bit = 0
su = 0
for j,k in l:
  if j==x:
    bit = 1
  if bit==1:
    su += k
print(su)

Submission status: Runtime Error

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
  s_temp,t_temp = map(int,input().split())
  s.append(s_temp)
  t.append(t_temp)
end = input()
print(sum(t[s.index(end)+1:]))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
 
int main()
{
  int n;
  cin >> n;
  map<string, int> tl;
  vector<int> ti;
  int t_t = 0;
  REP(i,n)
  {
    string s;
    int t;
    cin >> s >> t;
    t_t += t;
    tl[s] = i;
    ti.push_back(t_t);
  }
  string x;
  cin >> x;
  
  cout << ti[n-1] - ti[tl[x]] << endl;
  return 0;
}