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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
t=[]
for i in range(n):
  st,tt=input().split()
  s.append(st)
  t.append(int(tt))
x=str(input())
ans=0
for i in range(n):
  ans=ans+t[i]
  if s[i]==x:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
songs = []
times = []
for _ in range(N):
  song,time = input().split()
  songs.append(song)
  times.append(int(time))
start = input()
number = songs.index(start)
if number == len(songs):
  print(0)
else:
  print(sum(times[1:]))

Submission status: Wrong Answer

Solution code:
n = int(input())
cum = 0
d = dict()
for _ in range(n):
    a, b = input().split()
    b = int(b)
    cum += b
    d[a] = b
c = input()
print(cum - d[c])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    a=sys.stdin.readlines()
    #print(a)
    N,X=int(a[0]),a[-1]
    #print(N)
    slept=0
    ans=0
    for i in range(1,1+N):
        t,l=a[i].split()
        #print(t,l)
        
        if slept:ans+=int(l)
        if t==X:slept=1
    print(ans)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
song = {}
if n == 1:
    print(0)
else:
    for i in range(n):
        title, time = input().split()
        song[title] = int(time)

    check = input()
    flag = False
    ans = 0
    for k, v in song.items():
        if k == check:
            flag = True
            continue
        if flag:
            ans += v
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

Submission status: Wrong Answer

Solution code:
print(6348)

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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:]))
			exit(0)













if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s, t = map(str, input().split())
    t = int(t)
    d[s] = t
x = input()
ans = 0
flag = False
for i, v in d.items():
    if i == x:
        flag = True
        continue
    if flag:
        ans += v
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
d = 0
a = int(input())
for i in range(a):
    b, c = map(str, input().split())
    c = int(c)
    d += c
e = input()

print(d)

Submission status: Wrong Answer

Solution code:
d = 0
a = int(input())
for i in range(a):
    b, c = map(str, input().split())
    c = int(c)
    d += c

print(d)

Submission status: Wrong Answer

Solution code:
CD = {}
ans = 0
sw = 0
for i in range(int(input())):
    name, track = input().split()
    CD[name] = int(track)
dead_title = input()
for s, t in CD.items():
    if s == dead_title:
        sw = 1
    if sw:
        ans += t
ans -= CD[dead_title]
print(ans)

Submission status: Wrong Answer

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 _ in range(n):
  for t,tt in s:
    if key == 1:
      ans += int(tt)
    if t == key_s:
      key = 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a={}
for i in range(n):
    st,IN=map(str,input().split())
    a[st]=int(IN)
x=input()
s=0
f=0
for key,value in a.items():
    if f==1:
        s+=(value)
    if key==x:
        f=1
    
print(s)

Submission status: Wrong Answer

Solution code:

N = int(input())
i = 0
songs = []
result = 0

while N-i:
    songs.append(input().split())
    i+=1
X = input()
point = len(songs)

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

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

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 0
songs = []
while N-i:
  songs.append(input().split())
  i+=1
X = input()

Submission status: Wrong Answer

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

print(largelist)

Submission status: Wrong Answer

Solution code:
N = int(input())

dict = {}
for i in range(N):
    key, value = input().split()
    val = int(value)
    dict[key] = val
X = input()

flg = 0
ans = 0
for i in dict:
    if flg == 1:
        ans += dict[i]
    if i == X:
        flg = 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
song_dic = {}
for _ in range(n):
    song, sec = input().split()
    song_dic[song] = int(sec)

last_song = input()

for s in list(song_dic):
    song_dic.pop(s)
    if last_song in s:
        break

time = 0
for t in song_dic.values():
    time += t
print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())

dict = {}
for i in range(N):
    key, value = input().split()
    val = int(value)
    dict[key] = val
X = input()
print(dict)

flg = 0
ans = 0
for i in dict:
    if flg == 1:
        ans += dict[i]
    if i == X:
        flg = 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
song_dic = {}
for i in range(n):
    song, sec = input().split()
    song_dic[song] = int(sec)

last_song = input()

for s in list(song_dic):
    song_dic.pop(s)
    if last_song in s:
        break
        
time = 0
sum(t for t in song_dic.values())
print(time)

Submission status: Wrong Answer

Solution code:
#dwango A
import numpy as np
N = int(input())
L = []
for i in range(N):
    L += [input().split()]
L = np.array(L).reshape(N,2)
X = input()
cnt = 0
for j in range(N):
    if L[j,0] in X:
        for k in range(j+1, N):
            cnt += int(L[k, 1])
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
song_dic = {}
for i in range(n):
    song, sec = input().split()
    song_dic[song] = int(sec)

last_song = input()



for s in list(song_dic):
    del song_dic[s]
    if last_song in s:
        break
        
time = 0
for t in song_dic.values():
    time += t
print(time)

Submission status: Wrong Answer

Solution code:
n = int(input())
time = {}
for i in range(n):
    s, t = input().split()
    time[s] = int(t)
x = input()
answer = 0
flag = False
for s, t in time.items():
    if flag:
        answer += t
    if s == x:
        flag = True
print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
music_list = []
title = []
for _ in range(N):
    inp = input().split()
    title.append(inp[0])
    music_list.append(int(inp[1]))
X = input()
print(sum(music_list[title.index(X):]))

Submission status: Wrong Answer

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

mlist = []

for i in sys.stdin:
  mlist.append(i)
#print(mlist)

n = mlist.pop(0)
x = mlist.pop()

sflag = False
ttotal = 0
for i in mlist:
  st = i.split()
  t = st.pop()
  #print(s)
  #print(t)
  if sflag == True:
    ttotal += int(t)
    #print("ttotal = ", ttotal)
  if ' '.join(st) == x:
    #print("s = ", s)
    sflag = True
  
#print(n)
#print(mlist)
#print(x)
print(ttotal)

Submission status: Wrong Answer

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 i[0] == x:
    flag = True
  if flag:
    sum_time += i[1]
print(sum_time)

Submission status: Wrong Answer

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):
    print (str(l[i][0]), x)
    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: Wrong Answer

Solution code:
number=0
i=0
N = int(input())
P={}
sum=0
setting=0
for i in range(N):
    test=(input().split( ))
    P[test[0]]=test[1]
Z=(input())

i=0
for keys in P:
    i+=1
    if number<N and setting!=0:
        sum+=int(P[keys])
    if Z==keys:
        number=i
        setting=1
print(sum)

Submission status: Wrong Answer

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, N):
                ans += m_time[j]
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import itertools
number=0
i=0
N = int(input())
P={}
sum=0
setting=0
for i in range(N):
    test=(input().split( ))
    P[test[0]]=test[1]
Z=(input())

i=0
for keys in P:
    i+=1
    if number<N and setting!=0:
        sum+=int(P[keys])
    if Z==keys:
        number=i
        setting=1
print(sum)

Submission status: Wrong Answer

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

triger=0
j=0
A=0
for i in S:
  if i==X:
    triger=1
  if triger==1:
    A+=T[j]
  j+=1
print(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
play_list = [[i for i in input().split()] for N in range(N)]
last_song = input()
time_sum = 0

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

print(time_sum - sleep)

Submission status: Wrong Answer

Solution code:
import sys

mlist = []

for i in sys.stdin:
  mlist.append(i)

n = mlist.pop(0)
x = mlist.pop()

sflag = False
ttotal = 0
for i in mlist:
  st = i.split()
  t = st.pop()
  #print(s)
  #print(t)
  if sflag == True:
    ttotal += int(t)
    #print("ttotal = ", ttotal)
  if ' '.join(st) == x:
    #print("s = ", s)
    sflag = True
  
#print(n)
#print(mlist)
#print(x)
print(ttotal)

Submission status: Wrong Answer

Solution code:
N = int(input())

playlists = []
times = []
for i in range(N):
    music, time = input().split(" ")
    playlists.append(music)
    times.append(int(time))

sleep = input()

index = playlists.index(sleep)

ans = 0
times = times[index+1:]
for t in times:
    ans += t

Submission status: Wrong Answer

Solution code:
import sys

mlist = []

for i in sys.stdin:
  mlist.append(i)

n = mlist.pop(0)
x = mlist.pop()

sflag = False
ttotal = 0
for i in mlist:
  s, t = i.split()
  #print(s)
  #print(t)
  if sflag == True:
    ttotal += int(t)
    #print("ttotal = ", ttotal)
  if s == x:
    #print("s = ", s)
    sflag = True
  
#print(n)
#print(mlist)
#print(x)
print(ttotal)

Submission status: Wrong Answer

Solution code:
n = int(input())
dict = {}
for i in range(n):
    k,v = input().split()
    v = int(v)
    dict[k] = v

x = input()
del dict[x]
print(sum(dict.values()))

Submission status: Wrong Answer

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

print(*li1)
print(*li2)

asleep = li1.index(x)
print(sum(li2[asleep+1:]))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

Submission status: Wrong Answer

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

n = int(input())
dic = {}

for i in range(n):
    l,d = list(map(str,input().split()))
    dic[l] = d

a = str(input())

flag = False
time = 0

for key,value in dic.items():
    if flag == False:
        if key == a:
            flag = True
    else:
        time += int(value)

print(time)

Submission status: Wrong Answer

Solution code:
N=int(input())
ls1=[]
for _ in range(N):
  title,time=input().split()
  ls1.append([title,float(time)])
X=input()
i=0
a=0
flag=False
while flag==False:
  if ls1[i][0]==X:
    i+=1
    break
  i+=1
while i<N:
  a+=ls1[i][1]
  i+=1
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())

dict = {}
for i in range(N):
    key, value = input().split()
    val = int(value)
    dict[key] = val
X = input()

flg = 0
ans = 0
for i in dict:
    if flg == 1:
        ans += dict[i]
    if i == X:
        flg = 1    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

P = []

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

X = input()

end_index = 0

for i in range(N):
    p = P[i]

    if p[0]==X:
        end_index = i
        break

count = 0

for i in range(end_index, N, 1):
    count = count + P[i][1]
print(count)

Submission status: Wrong Answer

Solution code:
#dwango
import numpy as np
N = int(input())
L = []
for i in range(N):
    L += [input().split()]
L = np.array(L).reshape(N,2)
X = input()
cnt = 0
for j in range(N):
    if L[j,0] in X:
        for k in range(j+1, N):
            cnt += int(L[k, 1])
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
from fractions import gcd

def main():
    N = int(input())
    a = [list(map(str, input().split())) for i in range(N)]
    song = input()
        
    count = 0
    for i in range(N-1,0,-1):
        if a[i][0] == song:
            print(count)
            return
        else:
            count+= int(a[i][1])
            
main()

Submission status: Wrong Answer

Solution code:
N = int(input())

ST = list()

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

X = input()

result = None

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

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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



print(cnt)

Submission status: Wrong Answer

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

    break
print(sum(mins)-c)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N = int(readline())
st = [tuple(readline().split()) for _ in range(N)]
X = str(readline())
flag = False
answer = 0

for s, t in st:
    if flag:
        answer += int(t)
    if s == X:
        flag = True

print(answer)

Submission status: Wrong Answer

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

ans=0
sum=0
for i,j in l:
 print(i,j)
 if i!=x:
  ans+=int(j)
 else:
  ans+=int(j)
  break
for i,j in l:
 sum+=int(j)
print(sum-ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
ST=[]
for i in range(n):
  s,t=map(str,input().split())
  ST.append((s,t))
chk=False
x=input()
ans=0
for s,t in ST:
  if chk:
    ans+=int(t)
  else:
    if s==x:
      chk=True
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t[i] = map(str, input().split())
x = input()
a = 0
b = 0
c = 0
while a <= n - 1:
  if s[a] == x:
     while b <= n - 1:
       c += int(t[b])
       b += 1
  else:
    a += 1
    b += 1
else:
  print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0] * n
t = [0] * n
y = [0] * n
for i in range(n):
    s[i], t[i] = map(str, input().split())
x = input()
a = 0
b = 0
c = 0
while a <= n - 1:
  if s[a] == x:
     while b <= n - 1:
       c += int(t[b])
       b += 1
  else:
    a += 1
    b += 1
else:
  print(c)

Submission status: Accepted

Solution code:
N = int(input())
L = []
for i in range(N):
  L.append(list(input().split()))
S = input()
ans = 0
f = 0
for i in range(N):
  if f == 1:
    ans += int(L[i][1])
  if L[i][0] == S:
    f = 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [list(input().split()) for i in range(N)]
X = input()
b = 0
ans = 0
for a in A:
    if b == 0:
        if a[0] == X:
            b = 1
    else:
        ans += int(a[1])
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    st = [list(input().split()) for i in range(N)]
    X = input()
    ans = 0
    for i in range(N):
        if st[i][0] == X:
            i += 1
            break

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

    return ans

print(main())

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

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

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()


N = I()
ST = [tuple(map(str,S().split())) for _ in range(N)]
X = S()

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

print(sum(int(ST[i][1]) for i in range(N))-ans)

Submission status: Accepted

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

cnt = 0
flg = False
for s, t in ST:
    if flg:
        cnt += int(t)
    if s == X:
        flg = True

print(cnt)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

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

X = input()
ok = False
ans = 0
for i in range(N):
    title, time = lis[i]
    if ok:
        ans += time
    if title==X:
        ok = True
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
N = int(input())
musics = []
for _ in range(N):
    s, t = input().split()
    musics.append((s.strip(), int(t)))

X = input().strip()
ans = 0
flag = False
for s, t in musics:
    if flag:
        ans += t
    if s == X:
        flag = True

print(ans)

Submission status: Accepted

Solution code:
from itertools import accumulate


def LS():
    return list(input().split())


N = int(input())
title = []
time = []
for _ in range(N):
    s, t = LS()
    time.append(int(t))
    title.append(s)
time.append(0)
Tsum = list(accumulate(time))
X = input()
for i in range(N):
    if title[i] == X:
        break
print(Tsum[N]-Tsum[i])

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
ST = [LS() for _ in range(N)]
X = S()

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

print(sum(int(ST[i][1]) for i in range(N))-ans)

Submission status: Accepted

Solution code:
n = int(input())

ss = {}
tt = []
for i in range(n):
    s, t = map(str, input().split())
    ss[s] = i + 1
    tt.append(t)

x = input()

print(sum([int(x) for x in tt[ss[x]:]]))

Submission status: Accepted

Solution code:
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    s = []
    t = []
    for i in range(N):
        x, y = input().split()
        s.append(x)
        t.append(int(y))
    X = rs()
    a = sum(t)
    b = 0
    for x, y in zip(s, t):
        b += y
        if x == X:
            break
    print(a - b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [list(input().split()) for _ in range(N)]
x = input().strip()
for i in range(N):
    if A[i][0]==x:
        ind = i
        break
cnt = 0
for i in range(ind+1,N):
    cnt += int(A[i][1])
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 第6回 ドワンゴからの挑戦状 予選: A – Falling Asleep
N = int(input())
s, t = [], []
for _ in range(N):
    tmp = input().split()
    s.append(tmp[0])
    t.append(int(tmp[1]))
X = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
musics = [list(map(str, input().split())) for _ in range(n)]
x = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

#st = sorted(st,key=lambda x:x[1])
flag=0
ans=0
for i in range(N):
  if flag: ans += st[i][1]
  if st[i][0]==X:flag=1
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
jisyo = {}
for i in range(N):
  AA = input().split()
  jisyo[AA[0]] = AA[1]
SS = input()
count = 0
total = 0
for i,j in jisyo.items():
  if count == 1:
    total += int(j)
  if i == SS:
    count = 1
print(total)

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

time=0
s=False
for i in range(N):
    if s:
        time+=st[i][1]
    if st[i][0]==X:
        s=True
print(time)

Submission status: Accepted

Solution code:
import sys
import itertools


def main():
    N = int(input())
    songs = []
    time = []
    for _ in range(N):
        s, t = input().split()
        t = int(t)
        songs.append(s)
        time.append(t)
    X = input()
    time = list(itertools.accumulate(time))
    ans = time[-1] - time[songs.index(X)]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s_list = [None for _ in range(n)]
    t_list = [None for _ in range(n)]
    for i in range(n):
        s, t = input().split()
        s_list[i] = s
        t_list[i] = int(t)
    x = input()

    x_index = s_list.index(x)
    ans = sum(t_list[x_index + 1:])

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    playlist = list()

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

    st = input()
    add_flag = 0
    ans = 0

    for p in playlist:

        if add_flag:
            ans += p[1]

        if p[0] == st:
            add_flag = 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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()
a = s.index(x)
ans = sum(t[a+1:])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
playlist = []
duration = []

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

index = playlist.index(input())

durations = sum(duration[index + 1: ])
print(durations)

Submission status: Accepted

Solution code:
n = int(input())
l = list(list(map(str,input().split())) for _ in range(n))
x = input()
bit = 0
su = 0
for j,k in l:
  if j==x:
    bit = 1
    su -= int(k)
  if bit==1:
    su += int(k)
print(su)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    S, T = [], []
    for _ in range(n):
        s, t = input().split()
        S.append(s)
        T.append(int(t))
    x = input()
    print(sum(T[S.index(x) + 1:]))

if __name__ == '__main__':
    main()