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



Sample input:
3
dwango 2
sixth 5
prelims 25
dwango


Sample output:
30

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

X = input()

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

print(ans)

Submission status: Accepted

Solution code:
import re

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

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

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

k = 0

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

print(k)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

title = input()

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

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

print(time)

Submission status: Accepted

Solution code:
#第六回ドワンゴからの挑戦状　A

N=int(input())

largelist=[]

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

#print(largelist)

X=input()
answer=0

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

print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

total = 0

ff = False

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

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())

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

x = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

x = 0
sleeping_time=0

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

print(sleeping_time)

Submission status: Accepted

Solution code:
n = int(input())

s=[]
t=[]

for i in range(n):
    ss,tt = input().split()
    s.append(ss)
    t.append(tt)

x = input()

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
st=[]

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

x=input()

for j in range(n):
	if st[j][0]==x:
		k=j+1
		break
ans=0
while k < n:
	ans+=int(st[k][1])
	k+=1

print(ans)

Submission status: Accepted

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

a = 0

while a == 0:
  for j in range(N):
    if s[j] == X:
      a = 1
      b = j + 1
#print(b)

A = 0
for n in t[b:]:
  A+= int(n)
print(A)

Submission status: Accepted

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

i = 0
time = 0
while list[i][0] != x:
    i += 1
else:
    for i in range(i + 1, n):
        time += list[i][1]
        i += 1
print(time)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    s = []
    t = []
    for i in range(N):
        add_s , add_t = input().split()
        s.append(add_s)
        t.append(int(add_t))
    check = False

    X = input()
    result = 0
    for i in range(N):
        if check:
            result += t[i]
        elif s[i] == X:
            check = True
    print(result)
solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
L = []
for i in range(n):
    s, t = LS()
    t = int(t)
    L += [[s, t]]


x = S()
ret = 0
for i in range(n - 1, -1, -1):
    s, t = L[i]
    if x == s:
        break
    ret += t



print(ret)

Submission status: Accepted

Solution code:
N = int(input())
play_list = []
time_sum = 0
sleep = 0
l = 51

for i in range(N):
    for j in range(1):
        song = input().split()
        play_list.append(song)

last_song = input()

for i in range(N):
    if last_song in play_list[i][0]:
        sleep = int(play_list[i][1])
        l = i
    if i >= l:
        time_sum += int(play_list[i][1])

print(time_sum - sleep)

Submission status: Accepted

Solution code:
from itertools import accumulate
n=int(input()) 
S=[]
T=[0]*n
for i in range(n):
    s,t=input().split()
    S.append(s)
    T[i]=int(t)
x=input()
Tsum=list(accumulate(T))
print(Tsum[-1]-Tsum[S.index(x)])

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    ST = []
    ans = 0
    for _ in range(n):
        s, t = input().split()
        t = int(t)
        ans += t
        ST.append([s, t])
    X = input()
    for s, t in ST:
        ans -= t
        if s == X:
            break
    print(ans)
solve()

Submission status: Accepted

Solution code:
N = int(input())
T_arr = []
S_arr = []
count = 0
while N > 0:
    S,T = (input().split())
    T_arr.append(int(T))
    S_arr.append(S)
    N -= 1
LS = input()
print (sum(T_arr[S_arr.index(LS) + 1:]))

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for _ in range(N):
  lst.append(list(input().split()))
X = input()
t = 0

for i,l in enumerate(lst):
  if l[0] == X:
    for j in range(i+1,N):
      t+=int(lst[j][1])

print(t)

Submission status: Accepted

Solution code:
n=int(input())
song=[input().split() for i in range(n)]
last=input()

import numpy as np

songs = np.array(song)
b=np.argwhere(songs==last)

c=b[0]
d=c[0]
#print(d)

del song[:(int(d)+1)]
#print(song)

x=[song[i][1] for i in range(n-(d+1))]
time=[int(i) for i in x]
print(sum(time))

Submission status: Accepted

Solution code:

# https://atcoder.jp/contests/abc086/tasks/abc086_a
n_music = int(input())
music_name = []
music_time = []
for i in range(n_music):
    si, ti = input().split()
    music_name.append(si)
    music_time.append(int(ti))

asleep_music = input()

for k in range(n_music):
    if music_name[k] == asleep_music:
        break

asleep_time = 0
for j in range(n_music):
    if j > k:
        asleep_time += music_time[j]

print(asleep_time)

Submission status: Accepted

Solution code:
n = int(input())
l = [input().split() for _ in range(n)]
f = 0
x = input()
ans = 0
for a,b in l:
  if f:
    ans += int(b)
  elif x == a:
    f = 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = [None for _ in range(N)]
T = [None for _ in range(N)]

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

X = input()

is_sleep = False
sleep_t = 0
for n in range(N):
    if is_sleep:
        sleep_t += T[n]
    if S[n] == X:
        is_sleep = True

print(sleep_t)

Submission status: Accepted

Solution code:
N = int(input().rstrip())
src = [list(input().split()) for _ in range(N)]
for row in src:
    row[1] = int(row[1])
X = input()

total = 0
for row in src:
  total += row[1]

awake = 0
for row in src:
    if row[0] != X:
      awake += row[1]
    else:
      awake += row[1]
      break
ans = total - awake
print(ans)

Submission status: Accepted

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

result = 0
for i in range(N):
  if s_list[i] == x:
    result = i

print(sum(t_list[result + 1::]))

Submission status: Accepted

Solution code:
n=int(input())
s=[]
t=[]

ans=0

for i in range(n):
    ss,tt=input().split()
    s.append(ss)
    t.append(int(tt))
X=input()

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

print(ans)

Submission status: Accepted

Solution code:
N=int(raw_input())

S = ["" for i in range(N)]
T = [0 for i in range(N)]

for i in range(N):
    s = raw_input().split()
    S[i] = s[0]
    T[i] = int(s[1])

#print S, T

X = raw_input()

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

print time

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ST = [list(input().split()) for i in range(N)]
X = input()
S = [ ST[i][0] for i in range(N)]
time = [int(ST[i][1]) for i in range(N)]
# print(ST)
# print(time)
idx = S.index(X)
# print(idx)
print(sum(time[idx+1:]))

Submission status: Accepted

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

flag = 0
total = 0
for title, time in playlist:
  if flag == 1:
    total += int(time)
  if title == last:
    flag = 1
    
print(total)

Submission status: Accepted

Solution code:
import sys
lines = sys.stdin.readlines()
n = lines.pop(0)
e = lines.pop(-1).strip()
r = 0
s = False
for l in lines:
    l = l.strip()
    n, t = l.split(' ')
    if s:
        r += int(t)
    elif n == e:
        s = True
print(r)

Submission status: Accepted

Solution code:
# 行数
N = int(input().strip())

# 2次元配列
grid = []

z = 0
flag = '0'

for i in range(N):
    array = list(map(str, input().strip().split()))
    grid.append(array)

X = input()

for s, t in grid:
    if flag == '1':
        z += int(t)
    if s == X:
        flag = '1'

print(z)

Submission status: Accepted

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

time = 0
is_sleep = False
for s, t in playlist:
    if is_sleep:
        time += t
    if s == X:
        is_sleep = True

print(time)

Submission status: Accepted

Solution code:
n = int(input())
s_rec = []
t_rec = []
for sub_n in range(n):
    s, t = input().split()
    s_rec.append(s)
    t_rec.append(int(t))
x = input()
for i in range(n):
    if x == s_rec[i]:
        print(sum(t_rec[i+1:]))
        break

Submission status: Accepted

Solution code:
n = input()
n = int(n)
s = []
t = []
for i in range(n):
  tmp = input().split(" ")
  s.append(tmp[0])
  t.append(int(tmp[1]))

tgt = input()

nm = s.index(tgt)
print(sum(t[(nm+1): ]))

Submission status: Accepted

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

ans = 0
flag = 0
for t in T:
	if flag == 0:
		pass
	else:
		ans+=int(t[1])
		
	if t[0] == X:
		flag = 1
		
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    _n = input()
    n = int(_n)

    songs = [("", 0)] * n
    for i in range(n):
        inp = input().split()
        songs[i] = (inp[0], int(inp[1]))

    x = input()

    start = 0

    for i in range(0, len(songs)):
        s, _ = songs[i]
        if s == x:
            start = i + 1
            break

    res = 0
    for i in range(start, len(songs)):
        _, t = songs[i]
        res += t

    print(res)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    lst = []
    for _ in range(N):
        name, time = input().split()
        lst.append((name, int(time)))
    x = input()

    total = 0
    for n, t in reversed(lst):
        if n == x:
            break
        total += t

    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import os


N = int(input())

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

s_ = input()

ist = [ i for i, s, t in sts if s == s_]

i = ist[0]

ans = 0
for k in range(i+1, len(sts)):
    ans += sts[k][2]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t = list()
l= list()
for i in range(N):
  tmp = input().split(" ")
  t.append(tmp[0])
  l.append(int(tmp[1]))
d = input()
rec = 0
ans = 0
for i in range(N):
  if rec==1:
    ans += l[i]
  if t[i] == d:
    rec=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N, = map(int, input().split())
titles = [None] * N
total_durations = np.zeros(N+1, dtype=np.int)

for i in range(N):
	title, duration = input().split()
	duration = int(duration)
	
	titles[i] = title
	total_durations[i+1] = total_durations[i] + duration

X, = map(str, input().split())
falling_asleep_index = titles.index(X)
print(
	total_durations[N]
	- total_durations[falling_asleep_index+1])

Submission status: Accepted

Solution code:
musics = []
times = []

n = int(input())

for i in range(n):
    s, t = input().split()
    musics.append(str(s))
    times.append(int(t))

x = str(input())

sleep = musics.index(x)

ans = sum(times) - sum(times[0:sleep+1])
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Ss = []
Ts = []
for _ in range(N):
    S,T = input().split()
    Ss.append(S)
    Ts.append(int(T))

END = input()

r = 0
while Ss[-1] != END:
    r += Ts.pop()
    Ss.pop()
print(r)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    song_list = [input().split() for _ in range(N)]
    sleep_song = input()
    flag = False
    sleep_time = 0
    for name, time in song_list:
        if flag:
            sleep_time += int(time)
        if name == sleep_song:
            flag = True

    print(sleep_time)
resolve()

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
k=[]
for _ in range(n):
    s,t=input().split()
    s.rstrip()
    t=int(t)
    k.append((s,t))
x=input().rstrip()
ans=0
for i in k:
    ans+=i[1]
    if i[0]==x:
        break
s=0
for i in k:
    s+=i[1]
print(s-ans)

Submission status: Accepted

Solution code:
N = int(input())
playlist = []
for i in range(N):
	playlist += input().split()
X = input()
index = playlist.index(X) + 1
ans = 0
for i in range(index+2,N*2,2):
	ans+=int(playlist[i])
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
s=['']*N
t=[0]*N
for i in range(N):
    s[i],t[i]=input().split()
X=str(input())
switch=0
total=0
for i in range(N):
    if X==s[i]:
        switch=1
        total-=int(t[i])
    if switch==1:
        total+=int(t[i])
print(total)

Submission status: Accepted

Solution code:
N = int(input())
song = []
for i in range(N):
    s, t = map(str, input().split())
    song.append([s, int(t)])
X = input()
start = False
sleep = 0
for i in song:
    if start:
        sleep = sleep + i[1]
    if i[0] == X:
        start = True
print(sleep)

Submission status: Accepted

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

ans = 0
flag = False

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
s = []
t = []
for i in range(n):
    p,q = map(str,input().split())
    s.append(p)
    t.append(int(q))
x = input()
#print(n,s,t,x)
idx = s.index(x)
#print(idx)
print(sum(t[idx+1:]))

Submission status: Accepted

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

res=0
flg=False
for s,t in ss_and_ts:
  if flg:
    res+=int(t)
  elif x==s:
    flg=True
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
musics = []
dict_musics = {}
for i in range(N):
  a, b = map(str,input().split())
  musics.append([a,int(b)])
  dict_musics[a] = int(b)
X = input() 

times = []
for i in range(N): times.append(musics[i][1])
print(sum(times[times.index(dict_musics[X])+1:]))

Submission status: Accepted

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

for i in range(n):
  if s_t[i][0] == x:
    print(sum(t_[1] for t_ in s_t[i+1:]))

Submission status: Accepted

Solution code:
n = int(input())

s = []
t = []
tsum = 0

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

x = input()
tinter = 0

for j in range(n):
    tinter = tinter + t[j]
    
    if s[j] == x:
        break
        
print(tsum - tinter)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = [stdin.readline().rstrip().split() for _ in range(n)]
x = [stdin.readline().rstrip() for _ in range(n)][0]

k = 0
for i in range(len(a)):
  name = a[i][0]
  time = a[i][1]
  if name == x:
    k = i
  else:
    pass
s = 0 
for i in range(len(a)):
  if i <= k:
    pass
  else:
    s = s + int(a[i][1])
print(s)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    n = 1
    slist = []
    tlist = []
    while n <= N:
        s,t = input().split()
        s_n = str(s)
        t_n = int(t)
        slist.append(s_n)
        tlist.append(t_n)
        n += 1
    X = str(input())
    x = slist.index(X)
    sec = 0
    if x+1 < len(tlist):
        for i in range(x+1,len(tlist)):
            sec += tlist[i]
    print(sec)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=[0]*n
t=['0']*n
c=0
for i in range(n):
    s[i],t[i]=input().split()
    t[i]=int(t[i])
x=input()
a=s.index(x)
for i in range(a+1,n):
    c+=t[i]
print(c)

Submission status: Accepted

Solution code:
# N is Amount of song
N = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X = input()
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
        else:
            continue
    else:
        continue
print(ans)

Submission status: Accepted

Solution code:
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)
  elif s == X:
    flag = True

print(ans)

Submission status: Accepted

Solution code:
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)
print(sum(T[index+1:]))

Submission status: Accepted

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


ans = 0
flag = False
for i in music_list:
    if i[0] == X:
        flag = True
    elif flag:
        ans += int(i[1])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t=int(input())
p=t
a,b=[],[]
while(t):
  n, m =map(str, input().split())
  a.append(n)
  b.append(m)
  t-=1
s=str(input())
m,ans=0,0
m=a.index(s)
for i in range(m+1,p):
    ans+=int(b[i])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

s = []
t = []

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

X = input()

total = 0
flag = 0

for i in range(N):
    if flag == 1:
        total += t[i]
    if s[i] == X:
        flag = 1

print(total)

Submission status: Accepted

Solution code:
n = int(input())

grid = []
for i in range(n+1):
  grid.append(input())

b = grid[-1]
flag = True
work_time = 0
total_time = 0

for i in grid:
  if i == b:
    break
  c,d = i.split()
  total_time += int(d)
  if c == b:
    work_time += int(d)
    flag = False
  if flag:
    work_time += int(d)

print(str(total_time - work_time))

Submission status: Accepted

Solution code:
# coding: utf-8

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 = input()
inemuri = False
inemuri_t = 0

for j in range(n):
    if inemuri:
        inemuri_t += t_list[j]
    
    if x == s_list[j]:
        inemuri = True

print(inemuri_t)

Submission status: Accepted

Solution code:
n = int(input())
lst = []

for i in range(n):
  a, b = input().split()
  b = int(b)
  lst.append([a, b])
x = input()
sum_time = 0
flag = False
for i in lst:
  if flag:
    sum_time += i[1]
  if i[0] == x:
    flag = True
print(sum_time)

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()

for i in range(N):
  if X == st_list[i][0]:
    j = i
    break

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

print(ans)

Submission status: Accepted

Solution code:
number_of_music=int(input())
music_counter=0
music_dict={}
dict_counter=number_of_music
while dict_counter > 0:
  music_counter+=1
  input_string=input().split()
  music_dict[music_counter]={input_string[0]:input_string[1]}
  dict_counter-=1
start_music=input()

counter_start=0
music_counter=0
dict_counter=number_of_music
while dict_counter > 0:
  music_counter+=1
  for key,value in music_dict[music_counter].items():
    if key==start_music:
      counter_start=music_counter
      break
  dict_counter-=1
result=0
dict_counter=number_of_music
while dict_counter > 0 and counter_start < number_of_music:
  counter_start+=1
  for key,value in music_dict[counter_start].items():
    result+=int(value)
  dict_counter-=1
print (result)

Submission status: Accepted

Solution code:
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 = str(input())

u = t_list[s_list.index(X)+1:]
s = 0
for i in range(len(u)):
    s = s + u[i]
print(s)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    music = []
    m_time = []
    for _ in range(N):
        a, b = input().split()
        music.append(a)
        m_time.append(int(b))
    X = input()
    ans = 0
    for i, a in enumerate(music):
        if a == X:
            for j in range(i+1, N):
                ans += m_time[j]
    print(ans)
main()

Submission status: Accepted

Solution code:
n = int(input())
song = []
for i in range(n):
    song.append(input().split(" "))
all_song = song.copy()
x = input()
last = 1
time = 0
num = len(song)
for song in song:
    if last == num:
        break
    if song[0] == x:
        for song in all_song[last:]:
            time += int(song[1])
        break
    last += 1
print(time)

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N = int(input())
st = []
for i in range(N):
    k = input().split()
    st.append((k[0],int(k[1])))
X = input()
i = 0
while st[i][0] != X:
    i += 1
ans = 0
for j in range(i+1,N):
    ans += st[j][1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = {}
for i in range(0,n):
    #print (i)
    line = input()
    l[i] = line.strip().split()
x = str(input())
time = 0

for i in range(0,n):
    if l[i][0] == x:
        l.pop(i)
        break
    l.pop(i)

for i in l:
    time += int((l[i][1]))

print (time)

Submission status: Accepted

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

#print(playlist, X)
total = 0
found = False
for s, t in playlist:
    if found:
        total += t
    if s == X:
        found = True
print(total)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

a = int(input())
l = [list(input().split()) for i in range(a)]
b = input()
c = 0
ll = []

for _,i in enumerate(l):
  if b == i[0]:
    c += 1
    break
  c += 1

del l[0:c]
for i in l:
    ll.append(i[1])

lll = [int(s) for s in ll]
print(sum(lll))

Submission status: Accepted

Solution code:
import numpy as np

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

arr = np.array(playlist)
position = tuple(nd[0] for nd in np.where(arr == x))[0]

arr_num = arr[:, 1].astype(int)

if position - 1 == n:
  print(0)
else:
  print(arr_num[position + 1:].sum())