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())
lst = [input().split() for _ in range(N)]
X = input()
ans = 0
f = 0
for m in lst:
    if not f:
        if m[0] == X:
            f = 1
        continue    
    ans += int(m[1])
print(ans)

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

ind = lists.index(X) + 1
print(sum(listt[ind:]))

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

for i in range(n):
    if s[i] == k:
        key = i+1
        
ans = sum(t[key:])
print(ans)

Solution (Python):
N = int(input())
sl, tl = [], []
for _ in range(N):
    s, t = input().split()
    sl.append(s)
    tl.append(int(t))
X = input()
ind = sl.index(X)
if ind == N - 1:
    print(0)
else:
    print(sum(tl[ind + 1:]))

Solution (Python):
N=int(input())
A=[]

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

X=str(input())
result=0
flg=0

for i in range(N):
    if flg==1:
        result+=A[i][1]

    if A[i][0]==X:
        flg=1

print(result)

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

sub = 0
for i in range(n):
    if s[i] == x:
        sub = i + 1
        break

ans = 0
for i in range(sub, n):
    ans += int(t[i])

print(ans)

Solution (Python):
N = int(input())
s = ["" for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    s_str, t_str = input().split()
    s[i] = s_str
    t[i] = int(t_str)
    
X = input()
ans = 0
count = False
for i in range(N):
    if count:
        ans += t[i]
    if s[i] == X:
        count = 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
flg = False
for i in range(N):
    if flg:
        ans += t[i]
    if s[i] == X:
        flg = True
print(ans)

Solution (Python):
n=int(input())
A=[list(input().split()) for i in range(n)]
m=input()
cnt,flag=0,0
for nam,time in A:
    if nam==m:
        flag=1
        continue
    if flag==1:
        time=int(time)
        cnt +=time
print(cnt)

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

awake = 0
for i in range(N):
    awake += t[i]
    if s[i] == X:
        break
    
print(total - awake)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N = I()
    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()
    xi = 0

    for i in range(N):
        if s[i] == X:
            xi = i
            break

    ans = 0

    for i in range(N):
        if xi < i:
            ans += t[i]

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
title = []
time = []
for _ in range(N):
  x, y = input().split()
  title.append(x)
  time.append(int(y))

X = input()
id = title.index(X) + 1
print(sum(time[id:]))

Solution (Python):
def examA():
    N = I()
    S = [""]*N; T = [""]*N
    for i in range(N):
        S[i],T[i] = LSI()
        T[i] = int(T[i])
    X = SI()
    ans = 0
    flag = False
    for i in range(N):
        if flag:
            ans +=T[i]
        if S[i]==X:
            flag = True
    print(ans)
    return

def examB():
    return

def examC():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

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

t = False

c = 0

for i in s:
    if t:
        c += int(i[1])
    if i[0] == x:
        t = True

print(c)

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

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

Solution (Python):
N = int(input())
lst = []
for z in range(N):
    a,b = input().split()
    lst.append([a, int(b)])
x = input()
idx = 0
for i in range(N):
    if lst[i][0] == x:
        idx = i
        break
s = 0
for i in range(idx+1,N):
    s += lst[i][1]
print(s)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=II()
    st=[input().split() for _ in range(n)]
    x=input()
    total=0
    flag=False
    for s,t in st:
        if flag:total+=int(t)
        if s == x: flag = True
    print(total)
main()

Solution (Python):

import sys


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    neta=False
    neteru=0
    for i in range(N):
        if neta:
            neteru+=t[i]
        if s[i]==X:
            neta=True
    print(neteru)
    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))  
    s = [str()] * (N)  
    t = [int()] * (N)  
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  
    solve(N, s, t, X)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
st = [input().split() for i in range(N)]
X = input()
flag = False
ans = 0
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())

s = []
t = []
for _ in range(n):
    tmps, tmpt = map(str, input().split())
    s.append(tmps), t.append(int(tmpt))

x = input()

ans_li = []
count = False
for i in range(n):
    if count:
        ans_li.append(t[i])

    if s[i] == x:
        count = True

print(sum(ans_li))

Solution (Python):
def main():
    N = int(input())
    S = []
    for i in range(N):
        s, t = input().split()
        S.append([s,int(t)])
    X = input()
    ans = 0
    flag = False
    for i in range(N):
        if S[i][0] == X:
            flag = True
            continue
        if flag:
            ans += S[i][1]

    print(ans)



if __name__ == "__main__":
    main()

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
input = sys.stdin.readline
N = int(input())
a = []
res = 0
for _ in range(N):
  s, t = input().split()
  t = int(t)
  a.append((s, t))
  res += t
s = input()[: -1]
for i in range(N):
  res -= a[i][1]
  if a[i][0] == s:
    break
print(res)

Solution (Python):

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

res = 0
flag = False
for i in range(n):
    s,t = st[i]
    if flag:
        res += t
    elif s==x:
        flag = True

print(res)

Solution (Python):
N = int(input())
L = [list(input().split()) for i in range(N)]
X = input()
j = 0
ans = 0
for i in range(N):
  if j != 0:
    ans += int(L[i][1])
  if L[i][0] == X:
    j = 1
print(ans)

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

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

Solution (Python):
from itertools import accumulate

N = int(input())
title = []
time = []
for i in range(N):
    s, t = input().split()
    title.append(s)
    time.append(int(t))
time.append(0)
time = list(accumulate(time[::-1]))
X = input()
ind = title.index(X)
print(time[N-ind-1])

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

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

Solution (Python):
def read():
    N = int(input().strip())
    S = list()
    T = list()
    for i in range(N):
        s, t = input().strip().split()
        s = str(s)
        t = int(t)
        S.append(s)
        T.append(t)
    X = str(input().strip())
    return N, S, T, X

def solve(N, S, T, X):
    start = S.index(X)
    return sum(T[start+1:])

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Solution (Python):
N = int(input())
data = []

for _ in range(N):
	item = input().strip().split()
	data.append((item[0], int(item[1])))

X = input().strip()

i = 0
while X != data[i][0]:
	i += 1

i += 1
time = 0
while i < N:
	time += data[i][1]
	i += 1

print(time)

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

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

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

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

S, T = [], []
for s, t in ST:
  S.append(s)
  T.append(int(t))


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

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

    if flag:
        ans += t[i]

    if s[i]==x:
        flag = 1
print(ans)

Solution (Python):


n=int(input())
s=[tuple(input().split()) for _ in range(n)]
w=input()

cnt=0
flag=False
for e in s:
    if flag:
        cnt+=int(e[1])
    if e[0]==w:
        flag=True
    
print(cnt)

Solution (Python):
N=int(input())
time=0
d={}
for i in range(N):
    si,ti=input().split()
    time+=int(ti)
    d[si]=time

print(time-d[input()])

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

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

print(ans)

Solution (Python):
N = int(input())
S = []
T = []
for i in range(N):
    [stmp,ttmp] = list(input().split())
    S.append(stmp)
    T.append(int(ttmp))
X = input()
output = 0
flag = 0
for i in range(N):
    if flag == 1:
        output += T[i]
    if S[i]==X:
        flag += 1
print(output)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    N = I()
    s, t = [], []
    for _ in range(N):
        _s, _t = LS()
        _t = int(_t)
        s.append(_s)
        t.append(_t)
    X = S()
    for i, title in enumerate(s):
        if title == X:
            break
    i += 1
    cnt = 0
    for j in range(i, N):
        cnt += t[j]
    print(cnt)
main()

Solution (Python):

import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

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

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



if __name__ == '__main__':
    main()

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

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

ans = sum(T[index:])
print(ans)

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

x = input()
ans = 0
for i in range(N):
    ans += t_list[i]
    if x == s_list[i]:
        break
print(sum(t_list) -  ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
N = int(input())
cur = 0
dic = {}
for i in range(N):
    s,t = input().split()
    t = int(t)
    cur += t
    dic[s] = cur
q = input()
print(cur-dic[q])

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

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

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

print(ans)

Solution (Python):
n=int(input())
l=[input().split() for i in range(n)]
x=input()
ct=0
f=0
for i in range(n):
  if f==1:
    ct+=int(l[i][1])
  if l[i][0]==x:
    f=1
print(ct)

Solution (Python):
N = int(input())
S = []
T = []
for i in range(N):
    s, t = input().split()
    t = int(t)
    S += [s]
    T += [t]
X = input()
flag = False
ans = 0
for i in range(N):
    if flag:
        ans += T[i]
    if S[i] == X:
        flag = True
print(ans)

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

ans = 0
f = False
for a in st:
  if f:
    ans += int(a[1])
    continue
  if a[0] == x:
    f = True
print(ans)

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

tar = 0

for i in range(n):
    if x == title[i]:
        tar = i
        break
ans = 0
for i in range(tar+1, n):
    ans += time[i]

print(ans)

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

ans = 0

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

print(ans)

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

Solution (Python):
N=int(input())
arr1=[]
arr2=[]
for _ in range(N):
    x,y=input().split()
    arr1.append(x)
    arr2.append(int(y))
X=input()

print(sum(arr2[arr1.index(X)+1:]))

Solution (Python):
N=int(input())
M=[]
G=[]
for _ in range(N):
    a,b=input().split()
    G.append(a)
    M.append(int(b))
X=input()
flag = False
sum_=0
for i in range(N):
    if flag:
        sum_ += M[i]
    if G[i] == X:
        flag = True

print(sum_)

Solution (Python):
def main():

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

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

if __name__ == '__main__':
    print(main())

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

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

ans = 0
flag = False
for st in ST:
    a, b = st
    b = int(b)
    if X == a:
        flag = True
        continue
    
    if flag is True:
        ans += b
print(ans)

Solution (Python):
import sys

n = int(input())
playlist = []
playtime = []
for _ in range(n):
    s, t = input().split()
    playlist.append(s)
    playtime.append(int(t))
x = input()
i = playlist.index(x)
print(sum(playtime[i + 1:]))

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, T, X):
    i = S.index(X)
    return sum(T[i+1:])


def main():
    N = read_int()
    S, T = [], []
    for _ in range(N):
        s, t = read_str_n()
        t = int(t)
        S.append(s)
        T.append(t)
    X = read_str()
    print(slv(N, S, T, X))


if __name__ == '__main__':
    main()

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

f = 0
ans = 0
for i in range(N):
    if f == 0 and S[i] == X:
        f = 1
    elif f == 1:
        ans += T[i]
        
print(ans)

Solution (Python):

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()
start = S.index(X)
ans = 0
for i in range(start+1, N):
    ans += T[i]
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
P = [list(map(str, input().split())) for _ in range(N)]
S = input().rstrip()

ind = -1
for a, b in P:
    if a == S:
        ind = 0
    elif ind != -1:
        ind += int(b)

print(ind)

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

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

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

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

Solution (Python):


from collections import defaultdict


def getlist():
	return list(map(int, input().split()))


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

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

	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

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

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

def gcd(a,b): 
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

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

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

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

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

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

if __name__=='__main__':
    main()

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

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

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

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

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
isAsleep = False
for s, t in songs:
    if isAsleep:
        ans += t
    if s == X:
        isAsleep = True

print(ans)

Solution (Python):

N  = int (input())

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

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

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

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

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

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

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

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

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

print(ans)

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

main()

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

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


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

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

Solution (Python):
import sys
input = sys.stdin.readline


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

    X = input().strip()

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

    print(ans)
    

    



if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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


main()

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

Solution (Python):

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

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