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())
from collections import defaultdict
sl = []
tl = []
for i in range(n):
  s, t = input().split()
  t = int(t)
  sl.append(s)
  tl.append(t)
x = input()
ans = 0
for i in range(sl.index(x) + 1, n):
  ans += tl[i]
print(ans)

Solution (Python):
N =int(input())
A =[]
B =[]
for i in range(N):
    a,b = input().split()
    A.append(a)
    B.append(int(b))
X =input()
n = A.index(X)
ans = 0
for i in range(n+1,N):
    ans += B[i]
print(ans)

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

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

s_list = []
k_list = []
for i in range(n):
  si, ki = input().split()
  s_list.append(si)
  k_list.append(int(ki))

x = input()
index = s_list.index(x)

time = 0
for i in range(index+1, n):
  time += k_list[i]

print(time)

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

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

Solution (Python):

N=int(input())

titles=[]
times=[]

for i in range(N):
    data=input().split(" ")
    titles.append(data[0])
    times.append(int(data[1]))

X=input()


index=titles.index(X)

ans=0

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

print(ans)

Solution (Python):
n = int(input())
names = []
mins = []
for i in range(n):
  na,m = input().split()
  names.append(na)
  mins.append(int(m))
t = input()
c = 0
for i in range(len(names)):
  if not(t == names[i]):
    c += mins[i]
  else:
    c += mins[i]

    break
print(sum(mins)-c)

Solution (Python):
N = int(input())
s, t = map(str, input().split())
ss = []
tt = []
ss.append(s)
tt.append(t)

for i in range(N - 1):
    s_, t_ = map(str, input().split())
    ss.append(s_)
    tt.append(t_)
tt = [int(j) for j in tt]

X = str(input())

index = ss.index(X)
tt = tt[(index + 1):]
x = sum(tt)

print(x)

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

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

last = input()
num = float("inf")
ans = 0

for i, m in enumerate(temp):
    if m.split()[0] == last:
        num = i
    if num < i:
        ans += int(m.split()[1])

print(ans)

Solution (Python):
N = int(input())
s = []
for i in range(N):
  n, t = input().split()
  s.append([n, int(t)])
X = input()
cnt = 0
f = False
for i in range(N):
  if f:
    cnt += s[i][1]
  if s[i][0] == X:
    f = True
print(cnt)

Solution (Python):
n = int(input())
s1 = []
t1 = []
for i in range(n):
  d =list( map(str,input().split()))
  s1.append(d[0])
  t1.append(int(d[1]))
print(sum(t1[s1.index(input())+1:]))

Solution (Python):
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]

N = int(fetch_one_line())
s_t = fetch_inputs(N)
X = fetch_one_line()

flag = False
sum_time = 0
for tmp in s_t:
    s, t = tmp.split(" ")
    if not flag and s == X:
        flag = True
        continue

    t = int(t)
    if flag:
        sum_time += t

print(sum_time)

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

SleepingTime = 0

for i in range(N):
  if S[i][0] == X:
    for j in range(i+1, N):
      SleepingTime += int(S[j][1])

print(SleepingTime)

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

X = input()

count = 0
flg = False
for s, t in tune:
    if s == X:
        flg = True
        continue
    if flg:
        count += int(t)

print(count)

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

x=input()
ans=0
flag=False
for i in a:
    if i[0]==x:
        flag=True
        continue
    if flag==True:
        ans+=i[1]
print(ans)

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

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

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()
num = [i for i, k in enumerate(s) if x == k]
print(sum(t[num[0]+1:n]))

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

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

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

Solution (Python):
n=int(input())
lis=[]
lit=[]
for i in range(n):
    s,t=map(str,input().split())
    lis.append(s)
    lit.append(t)
a=input()
lit = [int(s) for s in lit]
for i in range(lis.index(a)+1):
    del lit[0]
print(sum(lit))

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

name = []
time = []

for _ in range(n):
  a, b = input().split()
  name.append(a)
  time.append(int(b))

x = input()
result = 0

num = name.index(x)

for i in range(num+1, n):
  result += time[i]

print(result)

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






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

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

s = []

for i in range(N):
    s.append(list(input().split()))
    
X = input()

ans = 0

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

print(ans)

Solution (Python):
n = int(input());
s = [0]*n;
t = [0]*n;
t_sum = 0;
for i in range(n) :
	si = input().split(' ');
	s[i] = si[0];
	t[i] = int(si[1]);
	t_sum += t[i];

x = input().rstrip('\n');

for i in range(n) :
	t_sum -= t[i];
	if s[i] == x :
		break;

print(t_sum);

Solution (Python):



num = int(input())

musics = []

for i in range(0,int(num)):
  music = list(map(str, input().split()))
  musics.append(music)

sleep = input()

flg = False

ans = 0
for i in range(0,int(num)):
  if flg:
    ans = ans + int(musics[i][1])

  if musics[i][0] == sleep:
    flg = True
         
print(ans)

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

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

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

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

ans = 0
for i in range(N):
  if s_t[i][0] == X:
    for j in range(i + 1, N):
      ans+=int(s_t[j][1])
    break
print(ans)

Solution (Python):
N = int(input())
ST = [list(map(str, input().split())) for _ in range(N)]
X = input()
ans = 0
for st in ST:
  if st[0] != X:
    ans += int(st[1])
  elif st[0] == X:
    ans = 0
print(ans)

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

ST_list = []
for i in range(N):
  s, t = map(str, input().split())
  ST_list.append([
    s ,int(t)
  ])
  
X = str(input())
  
cnt = sum(list( node[1] for node in ST_list ))

for node in ST_list:
  cnt -= node[1]
  if X == node[0]:
    break
  
print(cnt)

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

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

X = input()

index = s.index(X)
ans = sum(t)
for i in range(index+1):
    ans -= t[i]
print(ans)

Solution (Python):
N = int(input())
k =[]
for i in range(N):
    k.append([x for x in input().split()])
X = input()
counter = 0
iscounter=False
for i in range(N):
    if iscounter == False:
       if k[i][0] == X:
         iscounter = True
    else:
      counter += int(k[i][1])
print(counter)

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

a = 0
for i,s in enumerate(st):
  if s[0] == X:
    a = i + 1
    break

st = st[a:]
b = 0
for s in st:
  b = b + int(s[1])
print(b)

Solution (Python):
N = input()
name = []
name2time = {}
for i in range(int(N)):
    I = input()
    s, t = I.split()
    name.append(s)
    name2time[s] = int(t)
X = input()
index = name.index(X)
name = name[index+1:]
time = 0
for music in name:
    time += name2time[music]
print(time)

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

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

Solution (Python):
N = int(input())
si = [[]]*N
for i in range(N):
  s, t = map(str,input().split())
  si[i] = [s,int(t)]
X = input()
flg = False
ans = 0
for i in si:
  if flg:
    ans += i[1]
  if i[0]==X:
    flg = True
print(ans)

Solution (Python):
N = int(input())
playlist = {}
taiou = {}

for i in range(N):
    s_i, t_i = input().split()
    taiou[s_i] = i
    playlist[i] = int(t_i)

X = input()

cnt = 0
for j in range(taiou[X], N):
    cnt += playlist[j]

print(cnt - playlist[taiou[X]])

Solution (Python):
n = int(input())
st = [input() for _ in range(n)]
x = input()
s = [''] * n 
t = [0] * n
for i in range(n):
  s[i], t[i] = st[i].split()
  t[i] = int(t[i])
index_a = s.index(x)
result=0
for j in range(index_a+1, n):
  result += t[j]
print(result)

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

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

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

m = s.index(x)

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

print(ans)

Solution (Python):
n = int(input())
time = 0
d = dict()
for _ in range(n):
    s, t = input().split()
    time += int(t)
    d[s] = time
print(time - d[input()])

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

for i in range(N):
    s_a, t_a = input().split()
    s.append(s_a)
    t.append(int(t_a))
X = input()

time = 0
flag = False
for j in range(N):
    if flag == True:
        time += t[j]
    if s[j] == X:
        flag = True
print(time)

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

spl = 0
ti = 0
flg = 0

for l in ll:
    if flg == 1:
        ti += int(l[1])
    if l[0] == x:
        flg = 1


print(ti)

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

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

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

ans = 0
i = 0
for s, t in ST:
    if i != 0:
        ans += int(t)
    else:
        if s == X:
            i = 1

print(ans)

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

for i in range(N):
    ls = input().split()
    s[i] = ls[0]
    t[i] = ls[1]
    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())
list = []
for i in range(n):
    a,b=input().split()
    list.append((a, int(b)))
    
s = input()
    
t = 0
for i in range(n):
  if list[i][0] == s:
    for j in range(i+1,n):
      t = t + list[j][1]
    break

print(t)

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

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

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

Solution (Python):
N = int(input())
s,t = list(),list()
for i in range(N):
    S,T = input().split()
    s.append(S)
    t.append(int(T))
index = s.index(str(input()))
print(sum(t[index+1:]))

Solution (Python):

N = int(input())

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

X = str(input())

ans = sum(t_list)
for i in range(N):
    if X == s_list[i]:
        ans -= t_list[i]
        break
    else:
        ans -= t_list[i]
print(ans)

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

for i in range(n):
    if d[i][0]==x:
        num = i
        break

ans = 0
for i in d[(num+1):]:
    ans += int(i[1])
print(ans)

Solution (Python):
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import functools
N = int(input())
music = []
for i in range(N):
    music.append(list(map(str,input().split())))
stop = input()
i = 0
while stop != music[i][0]:
    i += 1
ans = 0
for j in range(N-i-1):
    ans += int(music[i+j+1][1])
print(ans)

Solution (Python):
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

s2ss = lambda s: [int(c) for c in s.split(' ')]

def main():
    N = i2n()
    t_total = 0
    d = {}
    for _ in range(N):
        s,t = sys.stdin.readline().rstrip().split(' ')
        t_total += int(t)
        d[s] = t_total
    X = i2s()
    print(t_total - d[X])

main()

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

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

kyoku = input()

for i in range(N):
    if kyoku == music_list[i][0]:
        index = i

result = 0

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

print(result)

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

s=[a[i][0] for i in range(n)]
t=[int(a[i][1]) for i in range(n)]

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

Solution (Python):
A = int(input())
C = []
for i in range(A):
    B = list(map(str,input().split()))
    C.append(B)
D = input()
for i in range(A):
    if C[i][0] == D:
        F = i
E = A - F - 1
F += 1
total = 0
for i in range(F,A):
    total += int(C[i][1])
print(total)

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


name = input()
idx = ilst.index(name)

total = 0
for j in range(idx+1, n):
    total += mlst[j][1]
print(total)

Solution (Python):
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

n = INT()
tune = {}
times = []
for i in range(n):
    title, time = input().split()
    time = int(time)
    tune[title] = i
    times.append(time)
x = input()
ind = tune[x]
print(sum(times[ind+1:]))

Solution (Python):
n=int(input())
listm=[]
listt=[]
ans=0
for i in range(n):
    m,t=input().split()
    listm.append(m)
    listt.append(t)
lastm=input()
index=listm.index(lastm)
for i in range((index+1),n):
    ans+=int(listt[i])
print(ans)

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

for i,st in enumerate(sT):
    T[i] = int(st)

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

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

time_t = 0
for k, l in st:
    time_t += int(l)

time = 0
for i, j in st:
    if i == x:
        time += int(j)
        break
    else:
        time += int(j)

print(time_t - time)

Solution (Python):
N=int(input())
s_ts=[]
for i in range(N):
    inp=input().split()
    s_ts.append((str(inp[0]),int(inp[1])))

X=str(input())

S=0
is_passed=False
for s_t in s_ts:
    s=s_t[0]
    t=s_t[1]

    if is_passed:
        S+=t
    
    if s == X:
        is_passed=True

print(S)

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

ST = list()

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

X = input()

result = None

for s, t in ST:
    t = int(t)
    if result is None:
        if s == X:
            result = 0
    else:
        result += t

print(result)

Solution (Python):
import bisect
import itertools


N = int(input())
st = [input().split() for _ in range(N)]
s, t = list(zip(*st))
t = [int(i) for i in t]
X = input()

t_cumsum = list(itertools.accumulate(t))
sleep = s.index(X)
ans = t_cumsum[-1] - t_cumsum[sleep]
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()

switch = 0
ans = 0

for i in range(N):
    if(switch == 1):
        ans += t[i];
    if(s[i] == X):
        switch = 1
        continue

print(ans)

Solution (Python):
N=int(input())
kyoku = [list(map(str,input().split())) for x in range(N)]
S = input()
Sum=0
i=0
for x in range(0,N):
    if kyoku[x][0]==S:
        AA=x
for x in range(AA+1,N):
    Sum=Sum+int(kyoku[x][1])
print(Sum)

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

name = []
time = []
for i in range(N):
    a,b=input().split()
    name.append(a)
    time.append(int(b))
X = input()
for i in range(N):
    if X == name[i]:
        break
ans = sum(time[i+1:])
print(ans)

Solution (Python):

 
import math
import itertools
import sys
import copy
 




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


sum = 0
Xt = 0
for i in range(N) :
  if Xt == 1 :
    sum += int(L[i][1])
  if L[i][0] == X :
    Xt = 1
print (sum)

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

X = str(input())
X_index = s_list.index(X) + 1

result = 0
for i in range(X_index, N):
    result += t_list[i]

print(result)

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

sum = 0

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

print(sum)

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

    sl = 0
    res = 0
    for i in s:
        if i[0] == x:
            sl = 1
            continue
        if sl == 1:
            res += int(i[1])
            continue
    print(res)
    
if __name__ == '__main__':
    main()

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(str, input().split()))
n=ni()
ST=[]
for i in range(n):
    st=nl()
    ST.append(st)
x=si()

idx=0
for i,sstt in enumerate(ST):
    if sstt[0]==x:
        idx=i
    ST[i][1]=int(ST[i][1])

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

Solution (Python):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = num()
S,T = [],[]
for _ in range(N):
    si,ti = input().split()
    ti = int (ti)
    S.append(si)
    T.append(ti)
X = input()
idx = S.index(X)
print(sum(T[idx+1:]))

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

Solution (Python):

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

    s.append(a)
    t.append(int(b))

x=str(input())
count=0
for i in range(n):
    if s[i]==x:
        count=i
        break
ans=0
count+=1

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

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

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

X = input()


idx = s_list.index(X)
ans = sum(t_list[idx+1:])
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))
X = str(input())

for i in range(N):
    if S[i] == X:
        sleep = i
time = 0

for i in range(sleep+1,N):
    time += T[i]

print(time)

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

AB = [[i for i in input().split()] for _ in range(n)]
for i in range(n):
    AB[i][1] = int(AB[i][1])
X = input()
flag = False
ans = 0
for i in range(n):
    if flag:
        ans += AB[i][1]
    if AB[i][0] == X:
        flag=True
print(ans)

Solution (Python):
N = int(input())
ST = [list(input().split()) for _ in range(N)]
X = input()
for i,st in enumerate(ST):
  s=st[0]
  if X==s:
    r = i
    break
    
if r==(N-1):
  print(0)
  
else:
  ST=ST[r+1::]
  ans = 0
  for st in ST:
    ans += int(st[1])
    
  print(ans)

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):


N = int(input())

s = ["" for i in range(N)]
t = [0 for i in range(N)]

for i in range(N):
    xx = input().split()
    s[i] = xx[0]
    t[i] = int(xx[1])

X = input()

index = 0

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

ans = 0

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

print(ans)

Solution (Python):
N = int(input())
X = []
music = []
time = []
for i in range(N):
  X.append(list(map(str,input().split())))
  music.append(X[i][0])
  time.append(int(X[i][1]))
S = input()

sleep_index = music.index(S)
print(sum(time[sleep_index+1:]))

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

Solution (Python):
N = int(input())
play = [input().split() for i in range(N)]
X = input()
music = [play[i][0] for i in range(N)] 
index = music.index(X)
zikan = [int(play[i][1]) for i in range(index + 1, N)]
print(sum(zikan))

Solution (Python):
from collections import OrderedDict
od = OrderedDict()

n = int(input())
for num in range(n):
  a, b = input().split()
  od[a] = b
  
s = input()

for k, v in od.items():
  if k != s:
    del od[k]
  else:
    del od[k]
    break

count = 0
for k, v in od.items():
  count += int(v)
  
print(count)

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


ans = 0
flag = 0

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

Solution (Python):
n=int(input())
a=[list(input().split()) for _ in range(n)]
b=[a[i][0] for i in range(n)]
c=[int(a[i][1]) for i in range(n)]
print(sum(c[b.index(input())+1:]))

Solution (Python):
all = int(input())
a = []
c = []
ans = []
f = False
for i in range(all):
    b = input().split()
    c.append(b[0])
    a.append(int(b[1]))
sleep = input()
for i in range(all):
    if not f:
        if c[i] == sleep:
            f = True
        continue
    else:
        ans.append(a[i])
ans = sum(ans)
print(ans)

Solution (Python):
n=int(input())
li=[[0 for i in range(2)] for j in range(n)]
ans=0
for i in range(n):
    s,t=map(str,input().split())
    li[i][0]=s
    li[i][1]=t
    ans+=int(t)
x=str(input())
for j in range(n):
    if li[j][0]!=x:
        ans-=int(li[j][1])
    else:
        ans-=int(li[j][1])
        break
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        st = []
        for _ in range(N):
            tmp = list(input().split())
            st.append((tmp[0].rstrip(), int(tmp[1])))
        X = input().rstrip()

        f = False
        ans = 0
        for i in range(N):
            name, time = st[i]
            if f:
                ans += time
            if name == X:
                f = True

        print(ans)



if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
N = int(input())
S = [""] * N
T = [""] * N
Alltime = 0
for i in range(N):
    S[i], T[i] = input().split()
    T[i] = int(T[i])
    Alltime += T[i]
X = (input())
Waketime = 0
for i in range(N):
    Waketime += T[i]
    if S[i] == X:
        break
print(Alltime - Waketime)

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

idx = 0
ans = 0

for i in range(n):
    if ls[i][0] == x:
        idx = i
        break

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

print(ans)

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

Solution (Python):
music_num = int(input())
music_list = []

for i in range(music_num):
    music_list.append(input().split(' '))

sleep_timing_music = input()
flag = False
sleep_time = 0

for j in music_list:
    if flag == True:
        sleep_time += int(j[1])
        
    if j[0] == sleep_timing_music:
        flag = True

print(sleep_time)

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

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

X = input()

time = 0
sleeping = False
for s, t in s_t:
    if sleeping:
        time += t
    if s == X:
        sleeping = True

print(time)

Solution (Python):
n = int(input())
songs = []
for i in range(n):
    a,b = input().split()
    songs.append([a,b])
sleep = input()
s =0
r =0
for a,b in songs:
    if r ==1:
        s+=int(b)
    if a == sleep:
        r=1
print(s)

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

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

total = 0
for j in music:
    total += int(j[1])
print(total)

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



idx = s.index(x)

ans = sum(t) - sum(t[: idx + 1])

print(ans)

Solution (Python):

"""
Created on Sat Jan 11 19:28:23 2020

@author: masat
"""

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

k = s_list.index(X)

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

print(time)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    tmps, tmpt = input().split()
    s.append(tmps)
    t.append(int(tmpt))
target = input()
sleep = s.index(target)
sum = 0
for i in range(sleep + 1, n):
    sum += t[i]
print(sum)

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

slist = []
tlist = []

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

X = input()

ind = slist.index(X)
if ind == len(tlist) - 1:
    print(0)
else:
    itlist = tlist[(ind+1):]
    print(sum(itlist))