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 sys
#input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	s=[]
	t=[]
	for i in range(n):
		a,b=input().split()
		s.append(a)
		t.append(int(b))
	x=input()
	for i in range(n):
		if x==s[i]:
			print(sum(t[i+1:]))


if __name__ == "__main__":
	main()

Submission status: Accepted

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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	s=[]
	t=[]
	for i in range(n):
		a,b=input().split()
		s.append(a)
		t.append(int(b))
	x=input()
	for i in range(n):
		if x==s[i]:
			ans=sum(t[i+1:])
			print(ans)
			exit(0)


if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
ST = []
for i in range(N):
    s, t = stdin.readline().rstrip().split()
    ST.append((s, int(t)))
X = stdin.readline().rstrip()
for i in range(N):
    if ST[i][0] == X:
        print(sum(st[1] for st in ST[i+1:]))

Submission status: Accepted

Solution code:
N = int(input())
song = ["a"] * N
time = [0] * N
for i in range(N):
	s, t = input().split()
	song[i] = s
	time[i] = int(t)
X = input()

idx = 0
for i in range(N):
	if X == song[i]:
		idx = i
		break

ans = 0
for i in range(idx+1, N):
	ans += time[i]

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
name=["" for _ in range(N+1)]
time=[0 for _ in range(N+1)]
for i in range(N):
    n,t=input().split()
    name[i+1]=n
    time[i+1]=time[i]+int(t)
print(time[N]-time[name.index(input())])

Submission status: Accepted

Solution code:
n = int(input())

dic = {}
for i in range(n):
    dic[i] = input().split()

x = input()

start = 0

for i, (k, v) in enumerate(dic.items()):
    if v[0] not in [x]:
        pass
    else:
        start = i+1
        break

if start==0:
    print(0)

else:
    ans = 0
    for i, (k, v) in enumerate(dic.items()):
        if i < start:
            pass
        else:
            ans += int(v[1])
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
lst=[]
for i in range(n):
  s,t=input().split()
  t=int(t)
  lst.append([s,t])
x=input()
a=0
for i in range(n):
  if lst[i][0]==x:
    idx=i
    break
for j in range(idx+1,n):
  a+=lst[j][1]
print(a)

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

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

    s = [0] * n
    t = [0] * n

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

    x = input()

    idx = s.index(x)
    ans = 0

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

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans-tmp)

Submission status: Accepted

Solution code:
N = int(input())
S = []
T = []
for i in range(N):
    si, ti = tuple(input().split())
    S.append(si)
    T.append(int(ti))
X = input()

i = S.index(X)
print(sum(T[i + 1:]))

Submission status: Accepted

Solution code:
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t[i] = map(str, input().split())
    t[i] = int(t[i])
x = input()
ans = 0
flag = False
for i, v in zip(s, t):
    if i == x:
        flag = True
        continue
    if flag:
        ans += v
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
p=[list(map(str,input().split())) for _ in range(N)]
X=input()
flag=0
cnt=0
for i in range(N):
 if flag==1:
  cnt=cnt+int(p[i][1])
 if p[i][0]==X:
  flag=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
s,t=[],[]
#s:曲名
#t:再生時間
for i in range(n):
    S,T=input().split()
    s.append(S)
    t.append(int(T))
x=input()
#print(s,t,sep='\n')

wake=0
for a,b in zip(s,t):
    wake+=b
    if a==x:
        print(sum(t)-wake)
        exit()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
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())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
ab = [input().split() for i in range(n)]
x = input()
res = 0
f = False
for i in range(n):
    a,b = ab[i]
    b = int(b)
    if a == x:
        f = True
        continue
    if f:
        res += b
print(res)

Submission status: Accepted

Solution code:
N=int(input())
s,t=list(),list()
for i in range(N):
  a,b=input().split()
  s.append(a)
  t.append(int(b))
X=input()
m = N
result = 0
for n in range(N):
  if X == s[n]:
    m = n
  if m < n:
    result += t[n]
print(result)

Submission status: Accepted

Solution code:
n = int(input())
strList = []
timeList = []
for x in range(n):
    s, t = map(str, input().split())
    strList.append(s)
    timeList.append(int(t))
x = input()
id = strList.index(x)
if timeList.count == id: print(0)
else: print(sum(timeList[id + 1:]))

Submission status: Accepted

Solution code:
n =int(input())
s=[""]*n
t=[0]*n
for i in range(n):
    s[i],t[i] = input().split()
    t[i] = int(t[i])
r = [0] * (n+1)
for i in range(1,n+1):
  r[i] = r[i-1] + t[i-1]
x=input()
ind = s.index(x)
print(r[n] - r[ind+1])

Submission status: Accepted

Solution code:
n=int(input())
s=[0]*n
t=[0]*n
for i in range(n):
    s[i],t[i]=input().split()
    t[i]=int(t[i])
print(sum(t[s.index(input())+1:]))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [input().strip("\n").split() for _ in range(N)]
    X = input().strip("\n")
    sec = 0
    lastId = 0
    for i in range(N):
        if P[i][0] == X: 
            lastId = i
            break
    for i in range(lastId + 1, N):
        sec += int(P[i][1])
    print(sec)
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

ans = 0
I = []
for i in range(N):
  if st[i][0] != X and len(I) == 0:
    continue
  elif st[i][0] == X:
    I.append(i)
  else:
    ans += int(st[i][1])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
music = []
time = []
for i in range(N):
    m,t = input().split()
    music.append(m)
    time.append(int(t))

S = input()
ans = 0
ans += sum(time[music.index(S)+1:])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
st = []
for i in range(n):
    st.append([str(i) for i in input().split()])
x = str(input())

tmp = 0
i = 0
while True:
    if st[i][0] == x:
        tmp += int(st[i][1])
        break
    else:
        tmp += int(st[i][1])
        i += 1
sum_t = 0
for i in range(n):
    sum_t += int(st[i][1])
print(sum_t - tmp)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for _ in range(n):
    si, ti = input().split()
    s.append(si)
    t.append(int(ti))
x = input()
ans = sum(t)
for i in range(n):
    ans -= t[i]
    if s[i] == x:
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
st = []
for _ in range(n):
    st.append([str(i) for i in input().split()])
x = str(input())
y = 0
flag = False
ans = 0
for i in range(n):
    st[i][1] = int(st[i][1])
    if flag:
        ans += st[i][1]
    if st[i][0] == x:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
S = []
T = []

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

x = str(input())

for i in range(n):
    if S[i] == x:
        j = i

if j == n-1:
    print(0)
else:
    print(sum(T[j+1:]))

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for s, t in st:
    ans += int(t)
for s, t in st:
    ans -= int(t)
    if s == X: break
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [[i for i in input().split()] for j in range(N)]
    X = input()
    ans = 0
    flag = False
    for a, b in A:
        if a == X:
            flag = True
            continue
        if flag:
            ans += int(b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=[]
b=[0]*n
t_sum=0
for i in range(n):
    s,t=input().split()
    tt=int(t)
    t_sum+=tt
    a.append(s)
    b[i]=t_sum
x=input()
print(t_sum-b[a.index(x)])

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

l, m = [], []

for _ in range(N):
    s, t = input().split()
    t = int(t)
    l.append(s)
    m.append(t)

X = input()

idx = l.index(X)
for i in range(idx+1, N):
    ans += m[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ss = []
ts = []
for _ in range(n):
	s, t = input().split()
	ss.append(s)
	ts.append(int(t))
x = input()

idx = ss.index(x)
ans = 0
for i in range(idx+1, n):
	ans += ts[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
sl = []
tl = []
for _ in range(n):
    s, t = input().split()
    sl.append(s)
    tl.append(int(t))
x = input()

ans = 0
flag = False
for i in range(n):
    if flag:
        ans += tl[i]
    if sl[i] == x:
        flag = True
print(ans)

Submission status: Accepted

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

for j in range(N):
    if(X == S[j][0]):
        for k in range(j+1, N):
            ans += int(S[k][1])
        print(ans)
        exit()

Submission status: Accepted

Solution code:
N = int(input())
s = [None] * N
t = [None] * N
for i in range(N):
    s[i], t[i] = input().split()
    t[i] = int(t[i])
X = input()
for i in range(N):
    if s[i] == X:
        print(sum(t[i + 1:]))

Submission status: Accepted

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

Submission status: Accepted

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

s = input()
idx = L1.index(s)
print(sum(L2[idx+1:]))

Submission status: Accepted

Solution code:
n = int(input())
S = []
T = []
for _ in range(n):
  s, t = input().split()
  S.append(s)
  T.append(int(t))
x = input()
index = S.index(x)
if index == n - 1:
  print(0)
else:
  print(sum(T[index+1:]))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    st = [0]*N
    for i in range(N):
        s,t = input().split()
        st[i] = [s,int(t)]
    X = input()
    ans = 0
    flag = False
    for i in range(N):
        if flag:
            ans += st[i][1]
        if st[i][0] == X:
            flag = True
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
dat = []
for i in range(n):
    t = input().split()
    dat.append((t[0], int(t[1])))
m = input()
f = False
res = 0
for i in range(n):
    if f:
        res += dat[i][1]
    else:
        if m == dat[i][0]:
            f = True
print(res)

Submission status: Accepted

Solution code:
N = int(input())
S = []
T = []

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

X = input()
num = None

for i in range(N):
    if X == S[i]:
        num = i + 1
        break

total = sum(T[num:N])

print(total)

Submission status: Accepted

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

N = int(input())
s = list()
t = list()
for i in range(N):
    _s, _t = map(str, input().split())
    s.append(_s)
    t.append(int(_t))
X = input()

ans = 0
for i in range(s.index(X) + 1, N):
    ans += t[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
ans = 0
for i in range(n):
    s1,t1 = input().split()
    s.append(str(s1))
    t.append(int(t1))
x = str(input())
for j in range(n):
    if s[j] == x:
        print(sum(t[j+1:n+1]))

Submission status: Accepted

Solution code:
N = int(input())
lists= []
for i in range(N):
    a,b = [x for x in input().split()]
    lists.append([a,int(b)])
X = input()
add_time = False
add = 0
for i in range(N):
    if add_time == True:
        add += lists[i][1]
    if X == lists[i][0]:
        add_time = True

print(add)

Submission status: Accepted

Solution code:
n = int(input())

st = [input().split() for _ in range(n)]
# print(st)
x = input()

ans = 0
slept = False
for i in range(n):
    if slept:
        ans += int(st[i][1])
    if st[i][0] == x:
        slept = True

print(ans)

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 = str(input())
ind = int(S.index(X))
print(sum(T[ind+1:]))

Submission status: Accepted

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

time = 0
flag = False
for i in st:
  if flag:
    time += int(i[1])
  if i[0]==x:
    flag = True
print(time)

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=str(input())

ind=S.index(X)
print(sum(T[ind+1:]))

Submission status: Accepted

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

S,T = zip(*ST)

i = S.index(X)
print(sum(map(int,T[i+1:])))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = [0] * N
    T = [0] * N
    for i in range(N):
        S[i], T[i] = input().split()
    X = input()
    idx = S.index(X)
    ans = sum(map(int, T[idx+1:]))
    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 = flag = 0
for s, t in st:
    if flag: ans+=int(t)
    if s==x: flag=1
print(ans)

Submission status: Accepted

Solution code:
# Falling Asleep

# prepare input
N = int(input()) # データ数
playlist = [] # プレイリスト
for i in range(N):
    s, t = input().split()
    t = int(t)
    playlist.append([s,t])
X = input() # 寝落ちした時の曲

# Xのある要素を線形探索 O(N)
p = 0
for i in range(N):
    if playlist[i][0]==X:
        p = i
        break

# 時間の集計
playlist = playlist[p+1:] # プレイリストのカット
time = 0
for i in playlist:
    time = time + i[1]

# 結果の出力
print(time)

Submission status: Accepted

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

begin_idx=s.index(X)+1

print(sum(t[begin_idx:]))

Submission status: Accepted

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

    dict = {}
    total = 0
    for _ in range(N):
        s, t = input().split()
        total += int(t)
        dict[s] = total

    X = input()
    print(total-dict[X])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    ss,tt = map(str,input().split())
    s.append(ss)
    t.append(tt)
x = input()

ans = 0
for i in range(n-1):
    if ans != 0:
        ans += int(t[i+1])
    elif s[i] == x:
        ans += int(t[i+1])
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[input().split() for i in range(n)]
x=input()
time=0
for i in range(n):
    time += int(l[i][1])
    if l[i][0]==x:
        time=0


print(time)

Submission status: Accepted

Solution code:
N = int(input())
music = []
for i in range(N):
    music.append(input().split())
X = (input())
Time = 0
kama = False
for s,t in music:
    if kama:
        Time += int(t)
    if s == X:
        kama = True
            
print(Time)

Submission status: Accepted

Solution code:
N = int(input())
ST = list()
for _ in range(N):
  ST.append(list(input().split()))

X = input()
time = 0
play = 0
for i in range(N):
  if play==0:
    if play==0 and ST[i][0] == X:
      play = 1
    continue
  time += int(ST[i][1])
  
print(time)

Submission status: Accepted

Solution code:
from collections import namedtuple

Music = namedtuple('Music', 'title time')

N = int(input())

music = []

for _ in range(N):
  s, t = input().split()
  music.append(Music(s, int(t)))
  
X = input()

index = [m.title for m in music].index(X)

print(sum([m.time for m in music][index + 1:]))

Submission status: Accepted

Solution code:
N=int(input())
a=[list(input().split()) for _ in range(N)]
X=input()
count=0
flag=0
for i in range(N):
    if X==a[i][0]:
        flag=1
    elif flag==1:
        count+=int(a[i][1])
print(count)

Submission status: Accepted

Solution code:
n=int(input())
p=[input().split() for _ in range(n)]
x=input()
ans=0
flag=False
for i in p:
    if i[0]==x:
        flag=True
        continue
    if flag:
        ans+=int(i[1])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for _ in range(n):
    name,time = map(str,input().split())
    s.append(name)
    t.append(int(time))
target = input()
start = s.index(target)
ans = 0
for i in range(start+1,n):
    ans += t[i]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
p_list = []
for i in range(N):
  s = input().split(' ')
  p_list.append(s)
X = input()
flg = False
time = 0
count = 0
for sound in p_list:
  if sound[0] == X:
    time = int(sound[1])
    flg = True
  if flg:
    count += int(sound[1])
print(count-time)

Submission status: Accepted

Solution code:
S = []
T = []

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

X = input()
x = S.index(X)

print(sum(T[x:]) - T[x])

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
#これだけでも二次元リストができる
st = [input().split() for _ in range(n)]
x = input()
flag = False
ans = 0
#print(st)

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
title = []
time = []
for i in range(n):
    line = input().split()
    title += [line[0]]
    time += [int(line[1])]
key = input()
a = title.index(key)
print(sum(time[a+1:]))

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()

print(sum(T[S.index(X)+1:]))

Submission status: Accepted

Solution code:
total = 0
a = int(input())
f = [];
g = [];
for i in range(a):
    b, c = map(str, input().split())
    c = int(c)
    f.append(b)
    g.append(c)
e = input()
h = f.index(e)
j = len(f)
for i in range(j-h-1):
    total += int(g[h+i+1])
print(total)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split() for i in range(n)]
x = input()
ind = 0
ans = 0

for i in range(n):
	if s[i][0] == x:
		ind = i

for j in range(ind+1,n):
	ans += int(s[j][1])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
sum_ = 0
for i in range(n):
  s, t = map(str, input().split())
  t = int(t)
  sum_ += t
  d[s] = sum_
x = str(input())
print(d[s]-d[x])

Submission status: Accepted

Solution code:
n = int(input())
song_list = [input().split() for _ in range(n)]
last_song = input()

count = 0
flag = False

for song in song_list:
    if flag == True:
        count += int(song[1])
    elif song[0] == last_song:
        flag = True

print(count)

Submission status: Accepted

Solution code:
n = int(input())
slst = []
tlst = []
for _ in range(n):
  s,t = map(str,input().split())
  slst.append(s)
  tlst.append(int(t))
x = input()
print(sum(tlst[slst.index(x)+1:]))

Submission status: Accepted

Solution code:
N=int(input())
S=[]
T=[]
for i in range(N):
  x,y=map(str,input().split())
  S.append(x)
  T.append(int(y))
X=str(input())
p=S.index(X)
print(sum(T[p+1:]))

Submission status: Accepted

Solution code:
N = int(input())
ST = [list(input().split()) for _ in [0]*N]
X = input()

ans = 0
for i,st in enumerate(ST):
    s,t = st
    if X==s:
        break
for s,t in ST[i+1:]:
    ans += int(t)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

s = []
t = []
for i in range(N):
    a,b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

f = False
ans = 0
for i in range(N):
    if f:
        ans += t[i]
    else:
        if x == s[i]:
            f = True

print(ans)

Submission status: Accepted

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

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()

print(sum(T[S.index(X)+1:]))

Submission status: Accepted

Solution code:
n = int(input())
s, t = [], []
for i in range(n):
    si, ti = input().split()
    ti = int(ti)
    s.append(si)
    t.append(ti)
x = input()

bit = 0
ans = 0
for i in range(n):
    if s[i] == x:
        bit = 1
    else:
        if bit == 1:
            ans += t[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
li_s = list()
for i in range(n):
    li_s.append(tuple(input().split()))
x = input()

sum = 0
for idx, v in enumerate(li_s):
    sum += int(v[1])
    if v[0] == x:
        sum = 0
print(sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
playlist = []

for i in range(n):
    s, t = input().split()
    playlist.append((s, t))
last_song = input().rstrip()

init = False
ans = 0
for title, time in playlist:
    if init:
        ans += int(time)
    if title == last_song:
        init = True

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
playlist = [input().split() for _ in range(N)]
X = input()
sleep = 0
ans = 0
for i in range(N):
  if(sleep == 1):
    ans += int(playlist[i][1])
  if(playlist[i][0] == X):
    sleep = 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li=[]
ans=0
flug=0

for i in range(n):
    li.append(input().split())

x=input()

for j in range(n):
    if flug==0:
        if li[j][0]==x:
            flug=1
    else:
        ans+=int(li[j][1])

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=[""]*n
t=[""]*n
for i in range(n):
  s[i],t[i]=input().split()
x=input()
for i in range(n):
  if s[i]==x:
    ans=0
    for j in range(i+1,n):
      ans+=int(t[j])
    break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[list(input().split()) for _ in range(n)]
x=input()
s=0
for i in range(n):
  if a[i][0]==x:
    p=i
    break
for i in range(p+1,n):
  s+=int(a[i][1])
print(s)

Submission status: Accepted

Solution code:

N= int(input())
st = [list(map(str,input().split())) for _ in range(N)]
x = input()

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

Submission status: Accepted

Solution code:
n = int(input())
li_a = list()
for i in range(n):
    li_a.append(input().split())

s = input()
sum_t =0
for i in range(n):
    if li_a[i][0]==s:
        x = i+1
        break
for i in range(x,n):
    sum_t += int(li_a[i][1])
print(sum_t)

Submission status: Accepted

Solution code:
def solve(n, s, t, x):
    for i in range(n):
        if s[i] == x:
            return sum(t[i+1:])
    return 0

n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t[i] = input().split()
    t[i] = int(t[i])
x = input()
print(solve(n, s, t, x))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    st = [LS() for _ in range(n)]
    x = S()
    f = False
    r = 0
    for s,t in st:
        if f:
            r += int(t)
        if s == x:
            f = True

    return r


print(main())

Submission status: Accepted

Solution code:
n= int(input())
s = [0]*n
t = [0]*n
u = [0]*n
v = {}
for i in range(n):
  a, b = input().split()
  s[i] = a
  t[i] = int(b)
x = input()

u[n-1]=0
v[s[n-1]]=0
for i in range(n-2,-1,-1):
  u[i] = t[i+1]+u[i+1]
  v[s[i]] = u[i]

print(v[x])

Submission status: Accepted

Solution code:
n=int(input())
box1=[]
box2=[]
for i in range(n):
    i=input().rstrip().split(" ")
    box1.append(i[0])
    box2.append(int(i[1]))
num=box1.index(input())
del box2[:num+1]
print(sum(box2))

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    aList = [list(input().split()) for i in range(N)]
    X = input()

    sleep = False
    ans = 0

    for item in aList:
        if sleep == True:
            ans += int(item[1])
        if X == item[0]:
            sleep = True

    print(ans)
    
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
M = [""] * N
T = [0] * N

for i in range(N):
  m, t = input().split(" ")
  M[i] = m
  T[i] = int(t)

X = input()

id = M.index(X)
s = sum(T[id+1:])
print(s)

Submission status: Accepted

Solution code:
n = int(input())
titles = []
times = []
for i in range(n):
    title,m = input().split()
    titles.append(title)
    times.append(int(m))
print(sum(times[titles.index(input())+1:]))

Submission status: Accepted

Solution code:
N = int(input())
D = []

for i in range(N):
    s, t = input().split()
    D.append([s, int(t)])

m = input()
n = 0
for i in range(N):
    if m in D[i]:
        n = i
        break

print(sum([d[1] for d in D[n + 1:]]))

Submission status: Accepted

Solution code:
n=int(input())
s=['']*n
a=[0]*n
for i in range(n):
  s[i],v=input().split()
  a[i]=int(v)
x=input()
flg=False
ans=0
for i in range(n):
  if flg:
    ans+=a[i]
  if s[i]==x:
    flg=True
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    s_, t_ = map(str, input().split())
    s.append(s_)
    t.append(int(t_))
x = input()

for i in range(n):
    if s[i] == x:
        break

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    idx = 0
    for i,r in enumerate(s):
        if r == X:
            idx = i

    print(sum(t[idx+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()