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())
L = []
for i in range(N):
  L.append(list(input().split()))
S = input()
ans = 0
f = 0
for i in range(N):
  if f == 1:
    ans += int(L[i][1])
  if L[i][0] == S:
    f = 1
print(ans)

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

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

Solution (Python):
N = int(input())
A = [list(input().split()) for i in range(N)]
X = input()
b = 0
ans = 0
for a in A:
    if b == 0:
        if a[0] == X:
            b = 1
    else:
        ans += int(a[1])
print(ans)

Solution (Python):
def main():
    N = int(input())
    st = [list(input().split()) for i in range(N)]
    X = input()
    ans = 0
    for i in range(N):
        if st[i][0] == X:
            i += 1
            break

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

    return ans

print(main())

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

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

ans=0
c=False
for s,t in l:
  if c:
    ans+=int(t)
  if x==s:
    c=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 = s.index(input())
ans = 0
for i in range(x+1,n):
    ans += t[i]
print(ans)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()


N = I()
ST = [tuple(map(str,S().split())) for _ in range(N)]
X = S()

ans = 0
for i in range(N):
    s,t = ST[i]
    ans += int(t)
    if s == X:
        break

print(sum(int(ST[i][1]) for i in range(N))-ans)

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

cnt = 0
flg = False
for s, t in ST:
    if flg:
        cnt += int(t)
    if s == X:
        flg = True

print(cnt)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

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

X = input()
ok = False
ans = 0
for i in range(N):
    title, time = lis[i]
    if ok:
        ans += time
    if title==X:
        ok = True
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline
N = int(input())
musics = []
for _ in range(N):
    s, t = input().split()
    musics.append((s.strip(), int(t)))

X = input().strip()
ans = 0
flag = False
for s, t in musics:
    if flag:
        ans += t
    if s == X:
        flag = True

print(ans)

Solution (Python):
from itertools import accumulate


def LS():
    return list(input().split())


N = int(input())
title = []
time = []
for _ in range(N):
    s, t = LS()
    time.append(int(t))
    title.append(s)
time.append(0)
Tsum = list(accumulate(time))
X = input()
for i in range(N):
    if title[i] == X:
        break
print(Tsum[N]-Tsum[i])

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N = I()
ST = [LS() for _ in range(N)]
X = S()

ans = 0
for i in range(N):
    s,t = ST[i]
    ans += int(t)
    if s == X:
        break

print(sum(int(ST[i][1]) for i in range(N))-ans)

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

ss = {}
tt = []
for i in range(n):
    s, t = map(str, input().split())
    ss[s] = i + 1
    tt.append(t)

x = input()

print(sum([int(x) for x in tt[ss[x]:]]))

Solution (Python):
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    s = []
    t = []
    for i in range(N):
        x, y = input().split()
        s.append(x)
        t.append(int(y))
    X = rs()
    a = sum(t)
    b = 0
    for x, y in zip(s, t):
        b += y
        if x == X:
            break
    print(a - b)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [list(input().split()) for _ in range(N)]
x = input().strip()
for i in range(N):
    if A[i][0]==x:
        ind = i
        break
cnt = 0
for i in range(ind+1,N):
    cnt += int(A[i][1])
print(cnt)

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

not_listened = False
ans = 0
for i in range(N):
    if not_listened:
        ans += t[i]
    if s[i] == X:
        not_listened = True
print(ans)

Solution (Python):

N = int(input())
s, t = [], []
for _ in range(N):
    tmp = input().split()
    s.append(tmp[0])
    t.append(int(tmp[1]))
X = input()

idx = s.index(X)
print(sum(t[idx + 1:]))

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

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

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

print(ans)

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

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


flag=0
ans=0
for i in range(N):
  if flag: ans += st[i][1]
  if st[i][0]==X:flag=1
    
print(ans)

Solution (Python):
N = int(input())
jisyo = {}
for i in range(N):
  AA = input().split()
  jisyo[AA[0]] = AA[1]
SS = input()
count = 0
total = 0
for i,j in jisyo.items():
  if count == 1:
    total += int(j)
  if i == SS:
    count = 1
print(total)

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

time=0
s=False
for i in range(N):
    if s:
        time+=st[i][1]
    if st[i][0]==X:
        s=True
print(time)

Solution (Python):
import sys
import itertools


def main():
    N = int(input())
    songs = []
    time = []
    for _ in range(N):
        s, t = input().split()
        t = int(t)
        songs.append(s)
        time.append(t)
    X = input()
    time = list(itertools.accumulate(time))
    ans = time[-1] - time[songs.index(X)]
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    s_list = [None for _ in range(n)]
    t_list = [None for _ in range(n)]
    for i in range(n):
        s, t = input().split()
        s_list[i] = s
        t_list[i] = int(t)
    x = input()

    x_index = s_list.index(x)
    ans = sum(t_list[x_index + 1:])

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    playlist = list()

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

    st = input()
    add_flag = 0
    ans = 0

    for p in playlist:

        if add_flag:
            ans += p[1]

        if p[0] == st:
            add_flag = 1

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
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()
a = s.index(x)
ans = sum(t[a+1:])
print(ans)

Solution (Python):
n = int(input())
playlist = []
duration = []

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

index = playlist.index(input())

durations = sum(duration[index + 1: ])
print(durations)

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

Solution (Python):
def main():
    n = int(input())
    S, T = [], []
    for _ in range(n):
        s, t = input().split()
        S.append(s)
        T.append(int(t))
    x = input()
    print(sum(T[S.index(x) + 1:]))

if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
s=list()
t=list()
st=[]
for i in range(N):
    st.append(input().split())
X=input()
ans=0
count=False
for j in range(N):
    if count:
        ans+=int(st[j][1])
    if st[j][0]==X:
        count=True
print(ans)

Solution (Python):
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import itertools
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  S=[]
  T=[]
  for _ in [0]*N:
    s,t=pin().split()
    S.append(s)
    T.append(int(t))
  U=list(itertools.accumulate(T))
  X=pin()[:-1]
  print(sum(T)-U[S.index(X)])
  return 

main()

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

lst = []

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

X = input()

index = 0

for i in range(N):
   if lst[i][0] == X:
      index = i
      break

ans = 0

for i in range(index + 1, N):
   ans += int(lst[i][1])

print(ans)

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

c=input()
memo=0
ans=0
for i in range(n):
    if memo==1:
        ans+=l[i][1]
    if l[i][0]==c:
        memo=1

print(ans)

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

Solution (Python):
N = int(input())
name=[""]*N
time=[0]*N
for i in range(N):
  a=input()
  name[i]=a.split()[0]
  time[i]=int(a.split()[1])
print(sum(time[name.index(input())+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 = input()
print(sum(t[s.index(x)+1:]))

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

cnt = False
ans = 0
for s, t in S:
    if s == X:
        cnt = True
    elif cnt:
        ans += t

print(ans)

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

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

Solution (Python):
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    s, t = [list(i) for i in zip(*[input().split() for i in range(N)])]
    t = list(map(int, t))
    k = s.index(input())
    print(sum(int(t[i]) for i in range(k+1, N)))



if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
st=[]
a=0
b=0
for i in range(N):
    st.append(list(map(str,input().split())))
X=str(input())
for i in range(N):
    if st[i][0]==X:
        a=i
for i in range(a+1,N):
    b+=int(st[i][1])
print(b)

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

insleep = s.index(x)
ans = sum(t[insleep+1:])
print(ans)

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

ind = s.index(X)
print(sum(t[ind+1:]))

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

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

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

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


X=input()

answer=0
flg=False
for s,t in stlist:
  if s==X:
    flg=True
  else:
    if flg:
      answer+=int(t)
      
print(answer)

Solution (Python):
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    title = defaultdict(int)
    cumsum = [0]
    for i in range(1, N + 1):
        s, t = readline().strip().decode('utf-8').split()
        title[s] = i
        cumsum.append(cumsum[-1] + int(t))
    X = readline().decode('utf-8').strip()
    ans = cumsum[-1] - cumsum[title[X]]
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    stList = [list(map(str, readline().rstrip().split())) for _ in range(n)]
    x = readline().rstrip()
    sumT = 0
    flg = False

    for i in range(n):
        s, t = stList[i][0], int(stList[i][1])
        if flg != True:
            if s == x:
                flg = True
                continue
        if flg == False:
            continue
        sumT += t
    print(sumT)


if __name__ == '__main__':
    main()

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

ans = 0
found = False
for s in l:
  if found:
    ans += s[1]
    continue
  if s[0] == X:
    found = True
    
print(ans)

Solution (Python):
import collections
n = int(input())
s_ls = []
dic = collections.defaultdict(int)
for i in range(n):
    [s,t] = [j for j in input().split()]
    s_ls.append(s)
    dic[s] = int(t)
x = input()
f = 0
ans = 0
for i in range(n):
    if f:
        ans += dic[s_ls[i]]
    if x == s_ls[i]:
        f = 1
print(ans)

Solution (Python):
n = int(input())
name = []
time = []
for i in range(n):
    a,b = input().split()
    name.append(a)
    time.append(b)
count = 0
for i in range(name.index(input()) + 1,n):
    count += int(time[i])
print(count)

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

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

Solution (Python):
n = int(input())
cnt = 0
st = [list(map(str,input().split())) for _ in range(n)]
x = input()
ch = 0
for i in range(n):
    if ch == 1:
        cnt += int(st[i][1])
    if st[i][0] == x:
        ch = 1
print(cnt)

Solution (Python):
n = int(input())
ans = 0
music = {}
for i in range(n):
    a, b = input().split()
    ans += int(b)
    music[a] = ans
print(ans-music[input()])

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s, t = zip(*(input().split() for _ in range(N)))
t = list(map(int, t))
X = input()

print(sum(t[s.index(X)+1:]))

Solution (Python):

n = int(input())
sName = []
sTime = []
for i in range(n):
	m = input().split()
	sName.append(m[0])
	sTime.append(int(m[1]))
lsName = input()
lsInd = sName.index(lsName)
if lsInd == n - 1:
	result = 0
else:
	times = sTime[lsInd + 1:]
	result = sum(times)
print(result)

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

ans = 0
flag = False
for s, t in songs:
    if flag:
        ans += t
    if s == x:
        flag = True

print(ans)

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

X = input()

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

Solution (Python):
n = int(input())
l = []
flag = False
ans = 0

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

x = input()

for s, t in l:
    if flag == True:
        ans += t
    elif s == x:
        flag = True

print(ans)

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

x = input()

ans = 0
p = 0
for i in range(n):
    if p == 0 and lis[i][0] == x:
        p = 1
    elif p == 1:
        ans += lis[i][1]
print(ans)

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

Solution (Python):
n = int(input())
dic = {}
time = []
for i in range(n):
  s, t = map(str, input().split())
  dic[s] = i + 1
  time.append(int(t))
ans = 0
song = input()
ans = sum(time[dic[song]:])
print(ans)

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

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

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

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

print(ans)

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

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

Solution (Python):
n=int(input())
s=[]
t=[]
for i in range(n):
  st,tt=input().split()
  s.append(st)
  t.append(int(tt))
x=str(input())
temp=0
ans=sum(t)
for i in range(n):
  temp=temp+t[i]
  if s[i]==x:
    break
print(ans-temp)

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


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

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union































def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    
    n = ii()
    name = []
    duration = []
    for _ in range(n):
        s, t = isp()
        name.append(s)
        duration.append(int(t))
    
    x = input()
    ind = name.index(x)
    print(sum(duration[ind+1:]))


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
songs = []
times = []
for _ in range(N):
  song,time = input().split()
  songs.append(song)
  times.append(int(time))
start = input()
number = songs.index(start)
if number == len(songs):
  print(0)
else:
  print(sum(times[number+1:]))

Solution (Python):
n=int(input())
s=[]
t=[]
for i in range(n):
	st=list(input().split())
	s.append(st[0])
	t.append(int(st[1]))
x=input()

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

Solution (Python):
n=int(input())
S=[]
T=[]
time=0
for i in range(n):
    s,t=map(str,input().split())
    S.append(s)
    T.append(int(t))
x=input()
for i in range(50):
    if S[i]==x:
        break
for j in range(i+1,n):
    time+=T[j]
print(time)

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

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

for i in range(n):
    if s[i]==x:
        flag=1
        continue
    if flag == 1:
        ans+=t[i]
print(ans)

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

Solution (Python):
n = int(input())
dic = {}
total = 0
for _ in range(n):
    s, t = input().split()
    total += int(t)
    dic[s] = total
x = input()
total -= dic[x]
print(total)

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    n = int(input())
    s_arr = []
    t_arr = []
    for _ in range(n):
        s, t = list(map(str, input().split()))
        t = int(t)
        s_arr.append(s)
        t_arr.append(t)
    x = input()[:-1]
    print(sum(t_arr[s_arr.index(x) + 1:]))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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

Solution (Python):
n=int(input())
a=[(input().split()) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
  if i[0]==x:
    cnt=0
print(cnt)

Solution (Python):
def resolve():
    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:]))
resolve()

Solution (Python):
N = int(input())
clips = [input().split() for _ in range(N)]
X = input()
FLG = 0
ans = 0

for title,time in clips:
    if FLG:
        ans += int(time)
    if title == X:
        FLG = 1
    
print(ans)

Solution (Python):
N = int(input())
clips = [input().split() for _ in range(N)]
X = input()
ans = 0

for i,title in enumerate(clips):
    if X in title:
        for j in range(i+1, N):
            ans += int(clips[j][1])
        break

print(ans)

Solution (Python):
n=int(input())
S=[]
T=[]
for i in range(n):
    s,t=input().split()
    S.append(s)
    T.append(int(t))
print(sum(T[S.index(input())+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 = input()
y = s.index(x)
print(sum(t[y+1:]))

Solution (Python):
n = int(input())
s, t  = [], []
for i in range(n):
    ST = list(map(str, input().split()))
    s.append(ST[0])
    t.append(int(ST[1]))

x = input()
idx = s.index(x)
print(sum(t[idx+1:]))

Solution (Python):
n = int(input())
playlists = []

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

titles, playtimes = list(zip(*playlists))
lastmusic = input()

lastmusic_timing = titles.index(lastmusic)
print(sum(playtimes[lastmusic_timing + 1:]))

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

s = ['a']*N
t = ['a']*N

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

finish = input()

index = s.index(finish)

sum = 0
for i in range(index+1,N):
	sum += int(t[i])
print(sum)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
L = SLL(N)
Q = S()
flag = 0
sl = 0
for a,b in L:
  if flag == 1:
    sl += int(b)
  if a == Q:
    flag = 1
    
print(sl)

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

ans, f = 0, 0
for s, t in st:
  if f:
    ans += t
  if s == x:
    f = 1
print(ans)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    list =[]
    sumN=0
    for i in range(n):
        a = [str(i) for i in input().split()]
        list.append(a)
        sumN += int(a[1])
    x = input()

    for i in list:
        sumN -= int(i[1])
        if x == i[0]:
            break
    print(sumN)

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

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

i = s.index(x)
print(sum(t[i+1:]))