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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = input()

ans = 0
flg = False
for play in playlist:
    if flg:
        ans += int(play[1])
    if play[0] == x:
        flg = True

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    st,IN=map(str,input().split())
    a.append([st,IN])
a=a[::-1]
x=input()
ss=0
for y in a:
    if y[0]==x:
        break
    ss+=int(y[1])
print(ss)

Submission status: Accepted

Solution code:
N = int(input())
s = ['']*N
t = ['']*N
for i in range(N):
    s[i], t[i] = input().split()
t = list(map(int, t))
t.append(0)
x = input()

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
N=int(input())
li = []
ti = []
for i in range(N):
  l,t = input().split()
  li.append(l)
  ti.append(int(t))
S=input()
print(sum(ti[li.index(S)+1:]))

Submission status: Accepted

Solution code:
n=int(input())
dic={}
sl=[]
for i in range(n):
  s,t=map(str,input().split())
  dic[s]=int(t)
  sl.append(s)
x=input()

ans=0
flag=False
for s in sl:
  if flag:
    ans+=dic[s]
  if s==x:
    flag=True
print(ans)

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
S, T = list(zip(*[sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(N)]))
X = sys.stdin.buffer.readline().decode().rstrip()
T = list(map(int, T))

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

Submission status: Accepted

Solution code:
N = int(input())

ts = [0]*N
ms = [0]*N
for i in range(N):
  t_i, m_i = input().split()
  m_i = int(m_i)
    
  ts[i] = t_i
  ms[i] = m_i
    
X = input()

ind = ts.index(X)
ind_m = ms[ind]
ans = sum(ms[ind:]) - ind_m

print(ans)

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

tmp = -1
for i in range(N):
    if st[i][0] == X:
        tmp = i
        break

ans = 0
for i in range(tmp+1,N):
    ans += st[i][1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
	s,t = map(str, input().split())
	t = int(t)
	a.append([s,t])
x = input()
a.reverse()
ss = 0
for i in range(n):
	if a[i][0] == x:
		print (ss)
		exit()
	ss += a[i][1]
print (ss)

Submission status: Accepted

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

chk = 0
value = 0
for i, (k, v) in enumerate(P):
  if k == M:
    chk = int(v)
  elif chk != 0:
    value += int(v)

print(value)

Submission status: Accepted

Solution code:
N = int(input())
A = [""] * N
B = [0] * N
for i in range(N):
    s, t = input().split()
    A[i] = s
    B[i] = int(t)
X = input()
c = 0
for i in range(N):
    c += B[i]
    if A[i] == X:
        print(sum(B) - c)
        exit()

Submission status: Accepted

Solution code:
# 標準入力
N = int(input()) #1行目のNを取得する
#s = [input() for i in range(N+1)] #複数行の数値の入力を取得
s = [list(map(str, input().split())) for i in range(N+1)]
# print(N)
# print(s)
list_music = []
list_time = []
sleep_music = s[N]
# print(sleep_music[0])

for i in range(N):
    for j in range(2):
        # print(s[i][j])
        if j == 0:
            list_music.append(s[i][j])
        elif j == 1:
            list_time.append(int(s[i][j]))

# print("タイトル：" + str(list_music))
# print("時間：" + str(list_time))

sleep_point = list_music.index(sleep_music[0])
# print((sleep_point))
sleep_time = 0
for i in range(sleep_point+1, N):
    # print(i)
    sleep_time += list_time[i]

# sleep_time = sum(int(list_time) for i in range(sleep_point+1, N))
# sleep_time = sum(int(i) for i in list_time(range(sleep_point+1, N)))
print(sleep_time)

Submission status: Accepted

Solution code:
N=int(input())
S=["a"]*N
T=[0]*N

for i in range(N):
  S[i],T[i]=input().split()
X=input()
flag=0
x=0
for i in range(N):
  if flag==1:
    x+=int(T[i])
  elif X==S[i]:
    flag=1
print(x)

Submission status: Accepted

Solution code:
n = int(input())
playList = []
sumTerm = 0
for i in range(n) :
    song = input().split()
    song[1] = int(song[1])
    playList.append(song)
    sumTerm += song[1]
x = input()

tmpSumTerm = 0

for i in range(n) :
    tmpSumTerm += playList[i][1]
    if playList[i][0] == x :
        print(sumTerm - tmpSumTerm)
        break

Submission status: Accepted

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

for i in range(N):
    s, t = ST[i]
    cnt -= int(t)
    if s == X:
        break
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
music_list = [list(input().split()) for i in range(N)]
X = input()
switch = 0
time = 0
for i, j in music_list:
    if switch==1:
        time+=int(j)
    if i == X:
        switch=1
print(time)

Submission status: Accepted

Solution code:
import sys

def solve():
    N = int(input())
    playlist = dict()
    time = [0] * (N + 1)
    for i in range(N):
        s, t = map(str, input().split())
        playlist[s] = i
        time[i + 1] = time[i] + int(t)
    w = input()

    print(time[N] - time[playlist[w] + 1])


    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S,T = [],[]
    for _ in range(N):
        s,t = map(str,input().split())
        t = int(t)
        S.append(s)
        T.append(t)
    X = input()
    T_cumsum = [T[0]]
    for i in range(1,N):
        T_cumsum.append(T_cumsum[-1]+T[i])
    
    for i in range(N):
        if S[i]==X:
            idx = i
            break
    
    print(sum(T)-T_cumsum[i])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
length_of_input = int(input())

playlist = []
for i in range(length_of_input):
    current_line_list = input().split()
    playlist.append({"title": current_line_list[0], "length": int(current_line_list[1])})

last_awake_title = input()

duration_of_sleep = 0
sleeping_flag = False

for music_obj in playlist:
    if sleeping_flag:
        duration_of_sleep += music_obj["length"]
    else:
        if music_obj["title"] == last_awake_title:
            sleeping_flag = True

print(duration_of_sleep)

Submission status: Accepted

Solution code:
n = int(input())
s, t = zip(*[input().split() for _ in range(n)])
x = input()

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

Submission status: Accepted

Solution code:
n = int(input())
s, t = [], []
for i in range(n):
    ss = input().split()
    s.append(ss[0])
    t.append(int(ss[1]))
x = input()
start = n
for i in range(n):
    if s[i] == x:
        start = i + 1
res = 0
for i in range(start, n):
    res += t[i]
print(res)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
T=[]
total=0
for i in range(N):
    s,t=map(str,input().split())
    t=int(t)
    total+=t
    S.append(s)
    T.append(t)
X=input()
flag=True
a=0
j=0
while flag:
    a+=T[j]
    if S[j]==X:
        flag=False
    j+=1
print(total-a)

Submission status: Accepted

Solution code:
N = int(input())
song_title = []
song_len = []
for i in range(N):
    t, l = input().split()
    song_title.append(t)
    song_len.append(int(l))


X = input()
last = 0
for i in range(N):
    if song_title[i] == X:
        last = i
        break

ans = 0
for i in range(last + 1, N):
    ans += int(song_len[i])
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main(n: int, s_t: list, x: str):
    ans = 0
    i = 0

    for s, _ in s_t:
        i += 1
        if s == x:
            break

    for _, t in s_t[i:]:
        ans += int(t)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    s = [input().split() for _ in range(n)]
    x = input()

    main(n, s, x)

Submission status: Accepted

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

for i in range(n):
    if ss[i] == x:
        ans = sum(tt[i+1:])
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
music_list = [input().split(' ') for i in range(N)]
X = input()
sleep_switch = False
total_time = 0
for music in music_list:
    if not sleep_switch:
        if music[0] == X:
            sleep_switch = True
    else:
        total_time += int(music[1])
print(total_time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力().split()
    曲名.append(入力された値[ぜろ])
    時間.append(入力された値[いち])
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)

Submission status: Accepted

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

ans = 0
flag = 0
for s,t in st:
    if not flag:
        if s == X:
            flag = 1
    else:
        ans += int(t)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
k = []
sum = 0
for i in range(N):
    t = input().split()
    sum += int(t[1])
    k.append(t)
X = input()
for i in range(N):
    if k[i][0] == X:
        sum -= int(k[i][1])
        print(sum)
        break
    else:
        sum -= int(k[i][1])

Submission status: Accepted

Solution code:
n = int(input())

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

x = input()

sleep = False
ans = 0
for title, time in playlist:
    if sleep:
        ans += time
    if title == x:
        sleep = True

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Q=[None]*N
for i in range(N):
  s,t=input().split()
  Q[i]=[s,t]
X=input()
countable=False
ans=0
for i in range(len(Q)):
  if countable:
    ans+=int(Q[i][1])
  if Q[i][0]==X:
    countable=True
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()
    T[i] = int(T[i])

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

Submission status: Accepted

Solution code:
n = int(input())
sl = [" " for i in range(n)]
tl = [0 for i in range(n)]

for i in range(n):
    st, tt = input().split()
    sl[i] = st
    tl[i] = int(tt)

X = input()


index = sl.index(X)
ans = 0
for i in range(index + 1, n):
    ans += tl[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s=[input().split() for i in range(n)]
title = input()
answer = []
a = False
id = 0
for i in range(n):
  if title == s[i][0]:
    id = i
sum = 0
for i in range(id+1,n):
  sum += int(s[i][1])
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s=[0]*n
t=[0]*n
ans=0
for i in range(n):
    s[i],t[i]=map(str ,input().split())
x = input()
for i in range(len(t[s.index(x)+1:])):
    ans+=int(t[-i-1])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = [""]*N #[]*Nとしてしまうと, 要素が何もないのでindex指定ができない
t = [""]*N

for i in range(N):
    s[i],t[i] = input().split()
    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)

Submission status: Accepted

Solution code:
N = int(input())

songs = []
result = 0

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

X = input()
point = len(songs)

for j in range(N):
    if songs[j][0] == X:
        point = j+1
        break

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


print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    b=0
    while i<N and s[i]!=X:
        c+=int(t[i])
        i+=1
    #print(c)
    #print(i)
    for k in range(N):
        b+=int(t[k])
    #print(b)
    return b-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=str(input())
print(f(X,s,t))

Submission status: Accepted

Solution code:
N = int(input())
m = []
for _ in range(N):
    m.append(list(input().split()))
X = input()
ans = 0
flg = False
for i in m:
    if flg:
        ans += int(i[1])
    if i[0] == X:
        flg = True
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for _ in range(n):
	ar, time = map(str, input().split())
	s.append(ar)
	t.append(time)
x = input()
summ = 0
init = s.index(x)
for i in range(init+1, n):
	summ += int(t[i])
print(summ)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
music = deque([input().split() for _ in range(n)]) 
name = input()
for i in range(n):
  hoge = music.popleft()
  if(hoge[0] == name):
    print(sum([int(m[1]) for m in music]))
    exit()
print(0)

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(str,input().split())))
x = str(input())
#print(l)
for i in range(n):
    if l[i][0] == x:
        s = i
        break
ans = 0
for i in range(s+1,n):
    ans += int(l[i][1])
print(ans)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
S=[]
for i in range(N):
    S.append(input().split())

X=input()


flag=False
time=0
for i in S:
    if flag:
        time+=int(i[1])

    if i[0]==X:
        flag=True

print(time)

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(str,input().split())))
x=input()
ans=0
f=0
for i in l:
    if f==1:
        ans+=int(i[1])
    if i[0]==x:
        f=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
S = []
T = []
for i in range(N):
    s,t = [(x) for x in stdin.readline().rstrip().split()]
    S.append(s)
    T.append(int(t))
X = (stdin.readline().rstrip())
ans = sum(T[S.index(X)+1:])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ts = []
titles = []
cnt = 0
for i in range(N):
    s,t = input().split()
    titles.append(s)
    cnt += int(t)
    ts.append(int(t))
X = input()

for i,s in enumerate(titles):
    if s == X:
        ind = i
        break

print(sum(ts[ind+1:]))

Submission status: Accepted

Solution code:

N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)

Submission status: Accepted

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

A=[]
answer=0

for i in range(N):
    A.append(st[i][0])

b=A.index(X)

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

print(answer)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S = ["a"] * N
    T = [0] * N
    for i in range(N):
        ss = rsa()
        S[i] , T[i] = ss[0], int(ss[1])
    X = rs()

    ans = 0
    sleep = False
    for i in range(N):
        if S[i] == X:
            sleep = True
            continue
        if sleep:
            ans += T[i]
    
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
List = [input().split() for i in range(a)]
word = input()
sum = 0
slsum = 0
for list in List:
  sum += int(list[1])
#print(sum)

for sleep in List:
  slsum += int(sleep[1])
  if sleep[0] == word:
    break
sum = sum - slsum
print(sum)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=[None]*n
    T=[None]*n
    for i in range(n):
        s,t=input().split()
        S[i]=s
        T[i]=int(t)

    k=S.index(input())
    ans=0
    for i in range(k+1,n):
        ans+=T[i]

    print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ls=[]
lt=[]
for i in range(n):
    s,t=input().split()
    ls.append(s)
    lt.append(int(t))
x=input()
ans=sum(lt)
tmp=0
for i in range(n):
    tmp+=lt[i]
    if ls[i]==x:
        ans-=tmp
        print(ans)
        exit()

Submission status: Accepted

Solution code:
N = int(input())
sx = list()
sy = list()
sec=0
for i in range(N):
    si = input().split()
    sx.append(si[0])
    sy.append(int(si[1]))
X = input()
xi = sx.index(X)+1
for i in sy[xi:]:
    sec += i
print(sec)

Submission status: Accepted

Solution code:
# coding:UTF-8

cnt = int(input())
musics = {}
titles = []
seconds = []

for i in range(0, cnt):
    title, second = input().split()
    second = int(second)
    titles.append(title)
    seconds.append(second)
    musics[title] = second

ind = titles.index(input())
print(sum(seconds[ind + 1:]))

Submission status: Accepted

Solution code:
n = int(input())
musics = [input().split() for _ in range(n)]
x = input()
not_yet = True
ans = 0
for m, s in musics:
	if not not_yet:
		ans += int(s)
	if x == m:
		not_yet = False
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
ST = [readline().split() for _ in range(N)]
X = read().rstrip()

S, T = zip(*ST)

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

print(res)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [input().split() for i in range(N)]
    S = input()
    flag = False
    ans = 0
    for i, a in enumerate(A):
        if a[0] == S:
            flag = True
        elif flag:
            ans += int(a[1])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = [0]*(N+1)
T = [0]*(N+1)
flag = -1
ans = 0

for i in range(1,N+1):
    S[i],T[i] = input().split()
X = input()
for i in range(1,N+1):
    if X == S[i]:
        flag = 1
        continue
    if flag == 1:
        ans += int(T[i])
print(ans)

Submission status: Accepted

Solution code:
def a_falling_asleep():
    N = int(input())
    Playlist = []
    for _ in range(N):
        s, t = input().split()
        Playlist.append((s, int(t)))
    X = input()

    ans = 0
    is_sleeping = False
    for s, t in Playlist:
        if is_sleeping:
            ans += t
            continue
        if s == X:
            is_sleeping = True
    return ans

print(a_falling_asleep())

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    s = []
    t = []
    for i in range(N):
        a,b = map(str, input().split())
        s.append(a)
        t.append(int(b))
    X = input()

    last = s.index(X)

    t = t[last+1:]

    print(sum(t))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

a = int(input())

name_list = []
time_list = []

for i in range(a):
  music = input().split()
  name_list.append(music[0])
  time_list.append(int(music[1]))
  
b = input()
c = name_list.index(b)
d = len(time_list)

e = sum(time_list[c+1:d])
print(e)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    s = ['' for _ in range(N)]
    t = [0] * N
    for i in range(N):
        si, ti = map(str, input().split())
        s[i], t[i] = si, int(ti)
    X = input()
    
    idx = s.index(X) + 1
    ans = sum(t[idx:])
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
s_ls = []
t_ls = []
for i in range(n):
    s, t = [i for i in sys.stdin.readline().split()]
    t = int(t)
    s_ls.append(s)
    t_ls.append(t)
x = input()
print(sum(t_ls[s_ls.index(x)+1:]))

Submission status: Accepted

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

print(sum(lt[ls.index(x)+1:]))

Submission status: Accepted

Solution code:
n = int(input())
ls, lt = [0] * n, [0] * n
for i in range(n):
    ls[i], lt[i] = input().split()
x = input()

print(sum(list(map(int, lt[ls.index(x)+1:]))))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()
isSleep = False
T = 0
for s, t in ST:
    if isSleep:
        T += t
    if s == X:
        isSleep = True

print(T)

Submission status: Accepted

Solution code:
n=int(input())
l=[(input().split()) for i in range(n)]
s=input()
ts,ls=[a for a in zip(*l)]
f=0
for i,d in enumerate(ts):
  if d==s:f=i;break
if f==n-1:print(0);exit()
print(sum(list(map(int,list(ls)[f+1:]))))