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):
import sys








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


if __name__ == "__main__":
	main()

Solution (Python):










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


if __name__ == "__main__":
	main()

Solution (Python):










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


if __name__ == "__main__":
	main()

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

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

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

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

print(ans)

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

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

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

x = input()

start = 0

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

if start==0:
    print(0)

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

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

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

Solution (Python):









import sys



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

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

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

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

    x = input()

    idx = s.index(x)
    ans = 0

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

    print(ans)



if __name__ == '__main__':
    main()

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

print(ans-tmp)

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

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

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
flag = False
for i, v in zip(s, t):
    if i == x:
        flag = True
        continue
    if flag:
        ans += v
print(ans)

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

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


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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

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

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

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

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])
print(sum(t[s.index(input())+1:]))

Solution (Python):
import sys

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

if __name__ == "__main__":
    solve()

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

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

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

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

Solution (Python):

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

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

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

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

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

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

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

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

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

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

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

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

print(ans)

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


if __name__ == '__main__':
    main()

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

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

l, m = [], []

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

X = input()

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

print(ans)

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

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

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

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

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

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

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

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

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

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

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

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

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

if __name__ == '__main__':
    main()

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

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()
num = None

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

total = sum(T[num:N])

print(total)

Solution (Python):


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

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

print(ans)

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

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

print(add)

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

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

x = input()

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

print(ans)

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

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

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

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

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

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

S,T = zip(*ST)

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

Solution (Python):
def main():
    N = int(input())
    S = [0] * N
    T = [0] * N
    for i in range(N):
        S[i], T[i] = input().split()
    X = input()
    idx = S.index(X)
    ans = sum(map(int, T[idx+1:]))
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):



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


p = 0
for i in range(N):
    if playlist[i][0]==X:
        p = i
        break


playlist = playlist[p+1:] 
time = 0
for i in playlist:
    time = time + i[1]


print(time)

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

begin_idx=s.index(X)+1

print(sum(t[begin_idx:]))

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

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

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


if __name__ == '__main__':
    main()

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

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

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


print(time)

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

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

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

Solution (Python):
from collections import namedtuple

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

N = int(input())

music = []

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

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

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

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

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

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

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

Solution (Python):
S = []
T = []

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

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

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

Solution (Python):

n = int(input())

st = [input().split() for _ in range(n)]
x = input()
flag = False
ans = 0


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

print(ans)

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

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

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

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

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

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

print(ans)

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

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

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

print(ans)

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

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

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

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

count = 0
flag = False

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

print(count)

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

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

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

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

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

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

print(ans)

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

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):
    si, ti = input().split()
    ti = int(ti)
    s.append(si)
    t.append(ti)
x = input()

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

print(ans)

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

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

Solution (Python):

import sys
input = sys.stdin.readline

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

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

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

print(ans)

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

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

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

x=input()

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

print(ans)

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

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

Solution (Python):

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

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

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

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

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

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

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

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

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


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

    return r


print(main())

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

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

print(v[x])

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

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

    sleep = False
    ans = 0

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

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

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

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

X = input()

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

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

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

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

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

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

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

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


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

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

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    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())
a = [0] * N
b = [0] * N
bi= [0] * N
for i in range(N):
    a[i],b[i]= map(str, input().split())
    bi[i] =int(b[i]) 
X =input()
for j in range(N):
    if X==a[j]:
        B = sum(bi[j+1:])
        print(B)

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

for i in range(N):
  s, t = input().split()
  t = int(t)
  songs.append((s, t))
  
X = input()
found = False
ans = 0
for i in range(len(songs)):
  s, t = songs[i]
  if s == X:
    found = True
    continue
  
  if found:
    ans += t
    
print(ans)

Solution (Python):
def FallenAsleep():
    playlist = []
    timelist = []
    N = int(input())
    for _ in range(N):
        s, t = input().split()
        playlist.append(s)
        timelist.append(int(t))
    X = input()
    num = playlist.index(X)
    if num == N:
        print(0)
        return()
    else:
        print(sum(timelist[num + 1:]))
        return()



FallenAsleep()

Solution (Python):
n = int(input())
ans = 0
s = [list(map(str,input().split())) for i in range(n)]
key_s = str(input())
key = 0
for t,tt in s:
  if key == 1:
    ans += int(tt)
  if t == key_s:
    key = 1
print(ans)

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

    st.append(s)
    tt.append(t)

x = input()

ans = 0
flag = 'no'
for i in range(n+1):
    if (flag == 'yes'):
        ans += tt[i]
        
    if st[i] == x:
        flag = 'yes'

print(ans)

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

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

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

Solution (Python):
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
st = [SL() for i in range(N)]
g = S()


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

Solution (Python):
N = int(input())
s = {}
t = []
for i in range(N):
    st = input().split()
    s[st[0]] = i
    t.append(int(st[1]))
X = input()
print(sum(t[s[X]+1:]))

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

M = []

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

X = input()

res = sum(map(lambda m: m[1], M))

for m in M:
    res -= m[1]
    if X == m[0]:
        break

print(res)

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

Solution (Python):
n = int(input())
title = []
p_time = []
for i in range(n):
  buf = input().split()
  title.append(buf[0])
  p_time.append(int(buf[1]))
s_title = input()
for i in range(n):
  p_time.pop(0)
  if title[i] == s_title:
    break
print(sum(p_time))