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

Solution (Python):
n = int(input())
playlist = []
for _ in range(n):
    playlist.append(input().split())

x = input()

ans = 0
flg = False
for play in playlist:
    if flg:
        ans += int(play[1])
    if play[0] == x:
        flg = True

print(ans)

Solution (Python):
n=int(input())
a=[]
for i in range(n):
    st,IN=map(str,input().split())
    a.append([st,IN])
a=a[::-1]
x=input()
ss=0
for y in a:
    if y[0]==x:
        break
    ss+=int(y[1])
print(ss)

Solution (Python):
N = int(input())
s = ['']*N
t = ['']*N
for i in range(N):
    s[i], t[i] = input().split()
t = list(map(int, t))
t.append(0)
x = input()

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):
N=int(input())
li = []
ti = []
for i in range(N):
  l,t = input().split()
  li.append(l)
  ti.append(int(t))
S=input()
print(sum(ti[li.index(S)+1:]))

Solution (Python):
n=int(input())
dic={}
sl=[]
for i in range(n):
  s,t=map(str,input().split())
  dic[s]=int(t)
  sl.append(s)
x=input()

ans=0
flag=False
for s in sl:
  if flag:
    ans+=dic[s]
  if s==x:
    flag=True
print(ans)

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.buffer.readline())
S, T = list(zip(*[sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(N)]))
X = sys.stdin.buffer.readline().decode().rstrip()
T = list(map(int, T))

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

Solution (Python):
N = int(input())

ts = [0]*N
ms = [0]*N
for i in range(N):
  t_i, m_i = input().split()
  m_i = int(m_i)
    
  ts[i] = t_i
  ms[i] = m_i
    
X = input()

ind = ts.index(X)
ind_m = ms[ind]
ans = sum(ms[ind:]) - ind_m

print(ans)

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

tmp = -1
for i in range(N):
    if st[i][0] == X:
        tmp = i
        break

ans = 0
for i in range(tmp+1,N):
    ans += st[i][1]
print(ans)

Solution (Python):
n = int(input())
a = []
for i in range(n):
	s,t = map(str, input().split())
	t = int(t)
	a.append([s,t])
x = input()
a.reverse()
ss = 0
for i in range(n):
	if a[i][0] == x:
		print (ss)
		exit()
	ss += a[i][1]
print (ss)

Solution (Python):
N = int(input())
P = [input().split() for i in range(N)]
M = input()

chk = 0
value = 0
for i, (k, v) in enumerate(P):
  if k == M:
    chk = int(v)
  elif chk != 0:
    value += int(v)

print(value)

Solution (Python):
N = int(input())
A = [""] * N
B = [0] * N
for i in range(N):
    s, t = input().split()
    A[i] = s
    B[i] = int(t)
X = input()
c = 0
for i in range(N):
    c += B[i]
    if A[i] == X:
        print(sum(B) - c)
        exit()

Solution (Python):

N = int(input()) 

s = [list(map(str, input().split())) for i in range(N+1)]


list_music = []
list_time = []
sleep_music = s[N]


for i in range(N):
    for j in range(2):
        
        if j == 0:
            list_music.append(s[i][j])
        elif j == 1:
            list_time.append(int(s[i][j]))




sleep_point = list_music.index(sleep_music[0])

sleep_time = 0
for i in range(sleep_point+1, N):
    
    sleep_time += list_time[i]



print(sleep_time)

Solution (Python):
N=int(input())
S=["a"]*N
T=[0]*N

for i in range(N):
  S[i],T[i]=input().split()
X=input()
flag=0
x=0
for i in range(N):
  if flag==1:
    x+=int(T[i])
  elif X==S[i]:
    flag=1
print(x)

Solution (Python):
n = int(input())
playList = []
sumTerm = 0
for i in range(n) :
    song = input().split()
    song[1] = int(song[1])
    playList.append(song)
    sumTerm += song[1]
x = input()

tmpSumTerm = 0

for i in range(n) :
    tmpSumTerm += playList[i][1]
    if playList[i][0] == x :
        print(sumTerm - tmpSumTerm)
        break

Solution (Python):
N = int(input())
ST = []
cnt = 0
for _ in range(N):
    s, t = input().split()
    ST.append([s, t])
    cnt += int(t)
X = input()

for i in range(N):
    s, t = ST[i]
    cnt -= int(t)
    if s == X:
        break
print(cnt)

Solution (Python):
N = int(input())
music_list = [list(input().split()) for i in range(N)]
X = input()
switch = 0
time = 0
for i, j in music_list:
    if switch==1:
        time+=int(j)
    if i == X:
        switch=1
print(time)

Solution (Python):
import sys

def solve():
    N = int(input())
    playlist = dict()
    time = [0] * (N + 1)
    for i in range(N):
        s, t = map(str, input().split())
        playlist[s] = i
        time[i + 1] = time[i] + int(t)
    w = input()

    print(time[N] - time[playlist[w] + 1])


    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    N = int(input())
    S,T = [],[]
    for _ in range(N):
        s,t = map(str,input().split())
        t = int(t)
        S.append(s)
        T.append(t)
    X = input()
    T_cumsum = [T[0]]
    for i in range(1,N):
        T_cumsum.append(T_cumsum[-1]+T[i])
    
    for i in range(N):
        if S[i]==X:
            idx = i
            break
    
    print(sum(T)-T_cumsum[i])

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = [""] * N
T = [0] * N
for i in range(N):
    s, t = input().split()
    S[i] = s
    T[i] = int(t)
X = input()

t = 0
for i in range(N):
    t += T[i]
    if S[i] == X:
        break
print(sum(T) - t)

Solution (Python):
length_of_input = int(input())

playlist = []
for i in range(length_of_input):
    current_line_list = input().split()
    playlist.append({"title": current_line_list[0], "length": int(current_line_list[1])})

last_awake_title = input()

duration_of_sleep = 0
sleeping_flag = False

for music_obj in playlist:
    if sleeping_flag:
        duration_of_sleep += music_obj["length"]
    else:
        if music_obj["title"] == last_awake_title:
            sleeping_flag = True

print(duration_of_sleep)

Solution (Python):
n = int(input())
s, t = zip(*[input().split() for _ in range(n)])
x = input()

print(sum(map(int, t[s.index(x)+1:])))

Solution (Python):
n = int(input())
s, t = [], []
for i in range(n):
    ss = input().split()
    s.append(ss[0])
    t.append(int(ss[1]))
x = input()
start = n
for i in range(n):
    if s[i] == x:
        start = i + 1
res = 0
for i in range(start, n):
    res += t[i]
print(res)

Solution (Python):
N=int(input())
S=[]
T=[]
total=0
for i in range(N):
    s,t=map(str,input().split())
    t=int(t)
    total+=t
    S.append(s)
    T.append(t)
X=input()
flag=True
a=0
j=0
while flag:
    a+=T[j]
    if S[j]==X:
        flag=False
    j+=1
print(total-a)

Solution (Python):
N = int(input())
song_title = []
song_len = []
for i in range(N):
    t, l = input().split()
    song_title.append(t)
    song_len.append(int(l))


X = input()
last = 0
for i in range(N):
    if song_title[i] == X:
        last = i
        break

ans = 0
for i in range(last + 1, N):
    ans += int(song_len[i])
print(ans)

Solution (Python):
n = int(input())
lst1 = [list(input().split()) for i in range(n)]
x = input()

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

print(ans)

Solution (Python):
N = int(input())
s = [""] * N
t = [0] * N
for i in range(N):
    a, b = map(str, input().split())
    s[i] = a
    t[i] = int(b)
X = input()

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

print(ans)

Solution (Python):
def main(n: int, s_t: list, x: str):
    ans = 0
    i = 0

    for s, _ in s_t:
        i += 1
        if s == x:
            break

    for _, t in s_t[i:]:
        ans += int(t)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    s = [input().split() for _ in range(n)]
    x = input()

    main(n, s, x)

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

for i in range(n):
    if ss[i] == x:
        ans = sum(tt[i+1:])
        break

print(ans)

Solution (Python):
N = int(input())
music_list = [input().split(' ') for i in range(N)]
X = input()
sleep_switch = False
total_time = 0
for music in music_list:
    if not sleep_switch:
        if music[0] == X:
            sleep_switch = True
    else:
        total_time += int(music[1])
print(total_time)

Solution (Python):
n=int(input())
t=[input().split() for i in range(n)]
x=input()
s=[g[1] for g in t]
o=[l[0] for l in t]
ans=0
for i in range(n):
    if x==o[i]:
        for j in range(i+1,n):
            ans+=int(s[j])
print(ans)

Solution (Python):
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力().split()
    曲名.append(入力された値[ぜろ])
    時間.append(入力された値[いち])
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)

Solution (Python):
N = int(input())
st = []
for i in range(N):
    st.append(list(map(str, input().split())))
X = input()

ans = 0
flag = 0
for s,t in st:
    if not flag:
        if s == X:
            flag = 1
    else:
        ans += int(t)
print(ans)

Solution (Python):
N = int(input())
k = []
sum = 0
for i in range(N):
    t = input().split()
    sum += int(t[1])
    k.append(t)
X = input()
for i in range(N):
    if k[i][0] == X:
        sum -= int(k[i][1])
        print(sum)
        break
    else:
        sum -= int(k[i][1])

Solution (Python):
n = int(input())

playlist = []
for _ in range(n):
    title, time = input().split()
    time = int(time)
    playlist.append([title, int(time)])

x = input()

sleep = False
ans = 0
for title, time in playlist:
    if sleep:
        ans += time
    if title == x:
        sleep = True

print(ans)

Solution (Python):
N=int(input())
Q=[None]*N
for i in range(N):
  s,t=input().split()
  Q[i]=[s,t]
X=input()
countable=False
ans=0
for i in range(len(Q)):
  if countable:
    ans+=int(Q[i][1])
  if Q[i][0]==X:
    countable=True
print(ans)

Solution (Python):
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()
INDEX = S.index(X)
print(sum(T[INDEX+1:]))

Solution (Python):
n = int(input())
sl = [" " for i in range(n)]
tl = [0 for i in range(n)]

for i in range(n):
    st, tt = input().split()
    sl[i] = st
    tl[i] = int(tt)

X = input()


index = sl.index(X)
ans = 0
for i in range(index + 1, n):
    ans += tl[i]

print(ans)

Solution (Python):
N=int(input())
s=[]
t=[]
for i in range(N):
    a,b=input().split()
    s.append(a)
    t.append(int(b))
X=s.index(input())
print(sum(t[X+1:]))

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

Solution (Python):
*l,s=open(0).read().split()
print(sum(map(int,l[l.index(s)+3::2])))

Solution (Python):
n = int(input())
s=[input().split() for i in range(n)]
title = input()
answer = []
a = False
id = 0
for i in range(n):
  if title == s[i][0]:
    id = i
sum = 0
for i in range(id+1,n):
  sum += int(s[i][1])
print(sum)

Solution (Python):
n = int(input())
s=[0]*n
t=[0]*n
ans=0
for i in range(n):
    s[i],t[i]=map(str ,input().split())
x = input()
for i in range(len(t[s.index(x)+1:])):
    ans+=int(t[-i-1])
print(ans)

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

Solution (Python):
N = int(input())
s = [""]*N 
t = [""]*N

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

index=0
for i in range(N):
    if s[i]==X:
        index=i+1

ans=0
"""
if index==N:
    print(0)
    exit()
else:
"""
for i in range(index,N):
    ans+= t[i]

print(ans)

Solution (Python):
N = int(input())

songs = []
result = 0

for i in range(N):
    songs.append(input().split())

X = input()
point = len(songs)

for j in range(N):
    if songs[j][0] == X:
        point = j+1
        break

for i in range(point, N):
    result += int(songs[i][1])


print(result)

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

Solution (Python):
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    b=0
    while i<N and s[i]!=X:
        c+=int(t[i])
        i+=1
    
    
    for k in range(N):
        b+=int(t[k])
    
    return b-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=str(input())
print(f(X,s,t))

Solution (Python):
N = int(input())
m = []
for _ in range(N):
    m.append(list(input().split()))
X = input()
ans = 0
flg = False
for i in m:
    if flg:
        ans += int(i[1])
    if i[0] == X:
        flg = True
print(ans)

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

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

Solution (Python):
n = int(input())
s = []
t = []
for _ in range(n):
	ar, time = map(str, input().split())
	s.append(ar)
	t.append(time)
x = input()
summ = 0
init = s.index(x)
for i in range(init+1, n):
	summ += int(t[i])
print(summ)

Solution (Python):
from collections import deque

n = int(input())
music = deque([input().split() for _ in range(n)]) 
name = input()
for i in range(n):
  hoge = music.popleft()
  if(hoge[0] == name):
    print(sum([int(m[1]) for m in music]))
    exit()
print(0)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    l.append(list(map(str,input().split())))
x = str(input())

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

Solution (Python):
import itertools
N=int(input())
S=[]
for i in range(N):
    S.append(input().split())

X=input()


flag=False
time=0
for i in S:
    if flag:
        time+=int(i[1])

    if i[0]==X:
        flag=True

print(time)

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
S = []
T = []
for i in range(N):
    s,t = [(x) for x in stdin.readline().rstrip().split()]
    S.append(s)
    T.append(int(t))
X = (stdin.readline().rstrip())
ans = sum(T[S.index(X)+1:])
print(ans)

Solution (Python):
N = int(input())
ts = []
titles = []
cnt = 0
for i in range(N):
    s,t = input().split()
    titles.append(s)
    cnt += int(t)
    ts.append(int(t))
X = input()

for i,s in enumerate(titles):
    if s == X:
        ind = i
        break

print(sum(ts[ind+1:]))

Solution (Python):

N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)

Solution (Python):
N=int(input())
st=[list(map(str,input().split())) for _ in range(N)]
X=input()

A=[]
answer=0

for i in range(N):
    A.append(st[i][0])

b=A.index(X)

for j in range(b+1,N):
    answer+=int(st[j][1])

print(answer)

Solution (Python):
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq


def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()

def main():
    N = ri()
    S = ["a"] * N
    T = [0] * N
    for i in range(N):
        ss = rsa()
        S[i] , T[i] = ss[0], int(ss[1])
    X = rs()

    ans = 0
    sleep = False
    for i in range(N):
        if S[i] == X:
            sleep = True
            continue
        if sleep:
            ans += T[i]
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
a = int(input())
List = [input().split() for i in range(a)]
word = input()
sum = 0
slsum = 0
for list in List:
  sum += int(list[1])


for sleep in List:
  slsum += int(sleep[1])
  if sleep[0] == word:
    break
sum = sum - slsum
print(sum)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=[None]*n
    T=[None]*n
    for i in range(n):
        s,t=input().split()
        S[i]=s
        T[i]=int(t)

    k=S.index(input())
    ans=0
    for i in range(k+1,n):
        ans+=T[i]

    print(ans)
resolve()

Solution (Python):
n = int(input())
st = [list(input().split()) for i in range(n)]
x = input()
a = 0
ans = 0
for s,t in st:
  if a:
    ans += int(t)
  if s == x:
    a = 1
print(ans)

Solution (Python):
n=int(input())
ls=[]
lt=[]
for i in range(n):
    s,t=input().split()
    ls.append(s)
    lt.append(int(t))
x=input()
ans=sum(lt)
tmp=0
for i in range(n):
    tmp+=lt[i]
    if ls[i]==x:
        ans-=tmp
        print(ans)
        exit()

Solution (Python):
N = int(input())
sx = list()
sy = list()
sec=0
for i in range(N):
    si = input().split()
    sx.append(si[0])
    sy.append(int(si[1]))
X = input()
xi = sx.index(X)+1
for i in sy[xi:]:
    sec += i
print(sec)

Solution (Python):


cnt = int(input())
musics = {}
titles = []
seconds = []

for i in range(0, cnt):
    title, second = input().split()
    second = int(second)
    titles.append(title)
    seconds.append(second)
    musics[title] = second

ind = titles.index(input())
print(sum(seconds[ind + 1:]))

Solution (Python):
n = int(input())
musics = [input().split() for _ in range(n)]
x = input()
not_yet = True
ans = 0
for m, s in musics:
	if not not_yet:
		ans += int(s)
	if x == m:
		not_yet = False
print(ans)

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
	b, c= input().split()
	a.append([b,int(c)])
x=input()
ans=0
for i in range(n):
	if a[n-i-1][0]==x:
		break
	ans+=a[n-i-1][1]
print(ans)

Solution (Python):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

S, T = zip(*ST)

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

print(res)

Solution (Python):
def main():
    N = int(input())
    A = [input().split() for i in range(N)]
    S = input()
    flag = False
    ans = 0
    for i, a in enumerate(A):
        if a[0] == S:
            flag = True
        elif flag:
            ans += int(a[1])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = [0]*(N+1)
T = [0]*(N+1)
flag = -1
ans = 0

for i in range(1,N+1):
    S[i],T[i] = input().split()
X = input()
for i in range(1,N+1):
    if X == S[i]:
        flag = 1
        continue
    if flag == 1:
        ans += int(T[i])
print(ans)

Solution (Python):
def a_falling_asleep():
    N = int(input())
    Playlist = []
    for _ in range(N):
        s, t = input().split()
        Playlist.append((s, int(t)))
    X = input()

    ans = 0
    is_sleeping = False
    for s, t in Playlist:
        if is_sleeping:
            ans += t
            continue
        if s == X:
            is_sleeping = True
    return ans

print(a_falling_asleep())

Solution (Python):
def main():
    N = int(input())
    s = []
    t = []
    for i in range(N):
        a,b = map(str, input().split())
        s.append(a)
        t.append(int(b))
    X = input()

    last = s.index(X)

    t = t[last+1:]

    print(sum(t))


if __name__ == "__main__":
    main()

Solution (Python):

a = int(input())

name_list = []
time_list = []

for i in range(a):
  music = input().split()
  name_list.append(music[0])
  time_list.append(int(music[1]))
  
b = input()
c = name_list.index(b)
d = len(time_list)

e = sum(time_list[c+1:d])
print(e)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(0,n):
  _s, _t = input().split()
  s.append(_s)
  t.append(_t)
x = input()

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

Solution (Python):
def solve():
    N = int(input())
    s = ['' for _ in range(N)]
    t = [0] * N
    for i in range(N):
        si, ti = map(str, input().split())
        s[i], t[i] = si, int(ti)
    X = input()
    
    idx = s.index(X) + 1
    ans = sum(t[idx:])
    print(ans)


if __name__ == '__main__':
    solve()

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

Solution (Python):
import sys
n = int(input())
s_ls = []
t_ls = []
for i in range(n):
    s, t = [i for i in sys.stdin.readline().split()]
    t = int(t)
    s_ls.append(s)
    t_ls.append(t)
x = input()
print(sum(t_ls[s_ls.index(x)+1:]))

Solution (Python):
n = int(input())
ls, lt = [], []
for i in range(n):
    s, t = input().split()
    ls.append(s)
    lt.append(int(t))
x = input()

print(sum(lt[ls.index(x)+1:]))

Solution (Python):
n = int(input())
ls, lt = [0] * n, [0] * n
for i in range(n):
    ls[i], lt[i] = input().split()
x = input()

print(sum(list(map(int, lt[ls.index(x)+1:]))))

Solution (Python):
n = int(input())
ans = 0
music = []
for i in range(n):
    s, t = input().split()
    music.append([s,t])

x = input()
flag = 0
for i in range(n):
    if flag == 1:
        ans += int(music[i][1])
    if music[i][0] == x:
        flag = 1

print(ans)

Solution (Python):
n = int(input())
ls, lt = [], []
for i in range(n):
    s, t = input().split()
    ls.append(s)
    lt.append(int(t))
x = input()
 
i = ls.index(x)
print(sum(lt[ls.index(x)+1:]))

Solution (Python):
n=int(input())
s=['' for _ in range(n)]
t=[0 for _ in range(n)]
for i in range(n):
  x,y=input().split()
  s[i]=x
  t[i]=int(y)
k=s.index(input())+1
print(sum(t[k:]))

Solution (Python):
N = int(input())

ST = []
for _ in range(N):
    s, t = tuple(input().split())
    ST.append((s, int(t)))

X = input()
isSleep = False
T = 0
for s, t in ST:
    if isSleep:
        T += t
    if s == X:
        isSleep = True

print(T)

Solution (Python):
n=int(input())
l=[(input().split()) for i in range(n)]
s=input()
ts,ls=[a for a in zip(*l)]
f=0
for i,d in enumerate(ts):
  if d==s:f=i;break
if f==n-1:print(0);exit()
print(sum(list(map(int,list(ls)[f+1:]))))

Solution (Python):



import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return list(map(proc, rl().split()))
    else:
        return rl().split()

def main():
    N = rl(int)
    a = []
    for _ in range(N):
        s, t = srl()
        t = int(t)
        a.append((s, t))
    q = rl()
    ret = sum(x[1] for x in a)
    for s, t in a:
        ret -= t
        if s == q:
            break
    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
L = []
for i in range(N):
    L += [input().split()]
X = input()
cnt = 0
flag = 0
for j, k in L:
    if j == X:
        flag = 1
        continue
    if flag:
        cnt += int(k)
print(cnt)

Solution (Python):
n = int(input())
l = [input().split() for i in range(n)]
x = input()
s = [l[i][0] for i in range(n)]
t = [int(l[i][1]) for i in range(n)]
num = s.index(x)
ans = sum(t[num+1::])
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n=int(readline())
st=read().split()
s=st[:-2:2]
t=[int(i) for i in st[1::2]]
x=st[-1]
print(sum(t[s.index(x)+1:]))

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

flag = False
r = 0
for s, t in ST:
    
    if s == X:
        flag = True
        continue
    if flag:
        r += t

print(r)

Solution (Python):
*t,a=open(0).read().split();print(sum(map(int,t[t.index(a)+3::2])))

Solution (Python):
import sys

read = sys.stdin.read

N, *st, X = read().split()
flag = False
answer = 0

for s, t in zip(*[iter(st)] * 2):
    if flag:
        answer += int(t)
        continue
    if s == X:
        flag = True

print(answer)

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

Solution (Python):
*t,a=open(0).read().split();print(sum(map(int,t[t.index(a)+3::2])))

Solution (Python):
N = int(input())

S = [""] * N
T = [0] * N

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

X = input()

ans = 0
flg = 0
for i in range(N):
    if flg == 1:
        ans += T[i]
    if S[i] == X:
        flg = 1

print(ans)

Solution (Python):
import re

n=int(input())
li = [input() for i in range(n)]
x = input()

i = 0
li0 = [re.sub("\\D", "", li[i]) for i in range(n)]

for i in range(n):
  if x in li[i]:
    j = i+1
    break
  else:
    j = 0

k = 0

for m in range(j,n):
  k = k + int (li0[m])

print(k)

Solution (Python):
N = int(input())
songs = []
times = [0]*N
for i in range(N):
    song, time = input().split()
    songs.append(song)
    times[i] = int(time)
X = input()
xidx = songs.index(X)
ans = sum(times[xidx+1:])
print(ans)

Solution (Python):
n=int(input())
dict=[]
sum=0
for i in range(n):
    a,b=input().split()
    c=int(b)
    sum+=c
    dict.append((a,c))
s=input()
for x in dict:
    sum-=x[1]
    if(x[0]==s):
        break

print(sum)

Solution (Python):
n = int(input())
l = [input().split() for _ in range(n)]
x = input()

flg = 0
ans = 0
for s, t in l:
    if flg == 1:
        ans += int(t)
    if s == x:
        flg = 1
print(ans)

Solution (Python):
N = int(input())
play_list = []
for i in range(N):
    play_list.append(list(input().split()))

title = input()

s = 0
for i in range(N):
    if play_list[i][0] == title:
        s = i
    else:
        s = s

time = 0
if s+1 == N:
    time = 0
else:
    for i in range(s+1, N):
        time += int(play_list[i][1])

print(time)

Solution (Python):


N=int(input())

largelist=[]

for i in range(N):
    S=input().split()
    
    largelist.append(S)



X=input()
answer=0

for i in range(N):
    if X==largelist[i][0]:
        for j in range(i+1,N):
            
            
            answer+=int(largelist[j][1])
        
    else:
        temp=0

print(answer)

Solution (Python):


n = int(input()) 
list_music = [input().split() for i in range(n)]
x = input()


flag=""
sum=0
for L in list_music:
  if flag == "true":
    sum += int(L[1])
    
  if L[0] == x:
    flag="true"

print(sum)

Solution (Python):
n = int(input())
data = {}
sum_time = 0

for i in range(n):
  title,pro_time = input().split()
  sum_time += int(pro_time)
  data[title] = sum_time
print(sum_time - data[input()])

Solution (Python):
n=int(input())
x = [input().split() for i in range(n)]
s = input()
a,b = [x[i][0] for i in range(n)],[int(x[j][1]) for j in range(n)]
p = a.index(s)
b = b[p+1::]
print(sum(b))

Solution (Python):
n=int(input())
l=[input() for i in range(n)]
target_song = input()

total = 0

ff = False

for i in l:
    s, t = i.split(" ")

    if s == target_song:
        ff = True
        continue
        
    if ff == True:
        total +=  int(t)

print(total)

Solution (Python):
n = int(input())

k = []
v = []
for i in range(n):
    a = input().split()
    k.append(a[0])
    v.append(int(a[1]))

x = input()

print(sum(v[k.index(x)+1::]))

Solution (Python):
n= int(input())
s= [input().split() for _ in range(n)]
x= input()
cnt=1
ans=0
for i in range(n):
  if x!=s[i][0]:
    cnt += 1
  else:
    break
for l in range(cnt,n):
  ans += int(s[l][1])
print(ans)

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

x = input()
sum = 0
flg = 0
for i in range(n):
 if flg == 1:
  sum += int(b[i])
 if x == a[i]:
  flg = 1

print(sum)

Solution (Python):
from collections import OrderedDict
number_of_music = int(input())
dict = OrderedDict()

for i in range(number_of_music):
  name,time=input().split()
  dict[name]=int(time)
  
music_name_sleep = input()

x = 0
sleeping_time=0

for key, val in dict.items():  
  if x==1:
    sleeping_time = sleeping_time + val
    
  if key == music_name_sleep:
    x=1

print(sleeping_time)