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())
sl = []
tl = []
cn = 0
tnp = 0

for i in range(n):
    s, t = map(str, input().split())
    t = int(t)
    sl.append(s)
    tl.append(t)

x = str(input())

for j in range(n):
    if sl[j] == x:
        cn = j

print(sum(tl) - sum(tl[:cn+1]))

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())
x = str(input())

counter = 0
switch = 0
for i in range(n):
    if switch == 1:
        counter += int(t[i])
    if s[i] == x:
        switch = 1

print(counter)

Submission status: Accepted

Solution code:
n=int(input())
_dict = []
for i in range(n):
    _dict.append(list(map(str, input().split())))
end_music = input()
for i in range(n):
    _dict[i][1]=int(_dict[i][1])


ans=0
start=False
for i in range(n):
    if start==True:
        ans+=_dict[i][1]
    if _dict[i][0]==end_music:
        start=True
print(ans)

Submission status: Accepted

Solution code:
ans = 0
flag = 0
N = int(input())
a = []
b = []

for i in range(N):
    c,d = input().split()
    a.append(c)
    b.append(d)

e = input()

for i in range(N):
    if a[i] == e:
        flag = 1
        continue
    if flag == 1:
        ans += int(b[i])

print(ans)

Submission status: Accepted

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

m_l = []
for i in s:
    m_l.append(i[0])

t = []
for j in s:
    t.append(int(j[1]))

m_s = n - m_l.index(x) - 1

ans = 0

for r in range(m_l.index(x)+1,n):
    ans += t[r]
print(ans)

Submission status: Accepted

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

r = [0]

for i in range(len(s)):
    r.append(int(t[i]) + r[i])

for i in range(len(s)):
    if(s[i] == x):
        v = i+1
        break
print(r[len(r)-1] - r[v])

Submission status: Accepted

Solution code:
# A - Falling Asleep

def main():
	numOfSongs = int(input())
	songList = [input().split() for i in range(numOfSongs)]
	asleepSong = input()
	index = search(songList, asleepSong)[0]
	seconds = sumSeconds(songList[(index+1):])
	print(seconds)
	# print(search(songList, asleepSong))

def search(list, value):
	return [i for i, x in enumerate(list) if x[0] == value]

def sumSeconds(lst):
	sum = 0
	for s in lst:
		sum += int(s[1])
	return sum

main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read

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

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

print(answer)

Submission status: Accepted

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

X = input()

cnt = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()    
    
print(sum(t_list[s_list.index(X)+1:]))

Submission status: Accepted

Solution code:
n = int(input())
sList = []
tLsit = []
result = 0
count = 0
Bool = False
for _ in range(n) :
    s, t = map(str, input().split())
    sList += [s]
    tLsit += [int(t)]
x = input()

for S in sList :
    if Bool :
        result += tLsit[count]
    if S == x :
        Bool = True
    count += 1

print(result)

Submission status: Accepted

Solution code:
N =int(input())
kyoku = [list(input().split()) for _ in range(N)]
X = input()
num = 0
for i in range(N):
    if kyoku[i][0] == X:
        num = i
print(sum(list([ int(i[1]) for i in kyoku[(num+1):] ])))

Submission status: Accepted

Solution code:
N = int(input())
S = []
T = []
answer = 0
START = 0

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

for i in range(N):
    if X == S[i]:
        START = i

for i in range(START+1,N):
    answer = answer + T[i]
print(answer)

Submission status: Accepted

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

ans = 0
asleep = 0
for i in range(n):
    if songs[i][0] == x:
        asleep = 1
    elif asleep:
        ans += int(songs[i][1])
    else:
        continue
print(ans)

Submission status: Accepted

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

X=input()
k=0
for i,j in enumerate(s):
    if j==X:
        k=i
        break
d=0
for i in range(k+1,N):
    d+=int(t[i])
print(d)

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range (N):
	title,time=input().split()
	S.append((title,time,i))
X = input()
ans = 0

for i in S:
	if i[0] == X:
		tmp = i[2]
		break
for i in S:
	if i[2]>tmp:
		ans =ans+int(i[1])

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
S = []
T = []
for _ in range(n):
    s,t = map(str, input().split())
    S.append(s)
    T.append(int(t))

x = input()

for i, s in enumerate(S):
    if s == x:
        ans = sum(T[i+1:])
        break

print(ans)

Submission status: Accepted

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

st = reversed(st)

sum = 0
for kyoku in st:
    if kyoku[0]  == x:
        break
    else:
        sum += kyoku[1]

print(sum)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
t=[]
for i in range(n):
    a,b=map(str,input().split())
    s.append(a)
    t.append(int(b))
sum_t=sum(t)
x=input()
idx=0
awake=0
for i in range(n):
    if s[i]!=x:
        awake+=t[i]
    else:
        awake+=t[i]
        break
print(sum_t-awake)

Submission status: Accepted

Solution code:
n=int(input())
p=[]
for i in range(n):
    s,t=input().split()
    p.append([s,int(t)])
p.append(["eol", 0])
x=input()
su=0
for i in p:
    su+=i[1]
sud=0
c=0
for i in p:
    sud+=p[c][1]
    if p[c][0]==x:
        break
    c+=1
print(su-sud)

Submission status: Accepted

Solution code:
# A - Falling Asleep
N = int(input())
s = list(input().split() for i in range(N))
X = str(input())
ans = 0
#print(N,s,X)
#print(s[0][0])
count = 0
for i in range(N):
    if str(s[i][0]) == X:
        break
    else:
        count += 1

#print(count)

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
songs = []
times = []
ans = 0
for _ in range(N):

    name, time = input().split(" ")
    songs.append(name)
    times.append(int(time))

X = input()

index = songs.index(X)
ans = sum(times[index+1:])
print(ans)

Submission status: Accepted

Solution code:

N = int(input())
H=[]
for i in range(N):
    H.append(input().split())
X = str(input())
for i in range(N):
    if X==str(H[i][0]):
        k=i
        break
ans=0
for i in range(k+1,N):
    ans+=int(H[i][1])
print(ans)

Submission status: Accepted

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

timeList = [int(time) for time in timeList]

sleepIndex = -1
for i, song in enumerate(songList):
  if song == x:
    sleepIndex = i
    break

print(sum(timeList[i+1:]))

Submission status: Accepted

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

for i in range(N):
  st[0][i][1] = int(st[0][i][1])
  
flag = 0

for i in range(N):
  if flag == 0:
    if st[0][i][0] == X:
      flag = 1
  else:
    ans += st[0][i][1]
    
print(ans)

Submission status: Accepted

Solution code:
from collections import OrderedDict as od

m1 = od()

n=int(input())

for i in range(n):
	l=input().split()
	s=l[0];t=int(l[1])
	m1[l[0]]=t

x=input()
flag=0;total=0
for key,value in m1.items():
	if key == x:
		flag=1
		continue
	if flag==1:
		total+=value

print(total)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
st = np.array([list(input().split()) for _ in range(N)])
X = input()

s = list(st[:, 0])
t = list(map(int, st[:, 1]))
index = s.index(X)
print(sum(t[index+1:]))

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

if S.index(X) == 0:
  time = sum(T) - T[S.index(X)]
else:
  time = sum(T[S.index(X) + 1:])

print(time)

Submission status: Accepted

Solution code:
n = int(input())
inlist=[]
for j in range(n):
  s, i = input().split()
  inlist.append(s+"."+i)
x = input()


result = 0
flag = False
for j in inlist:
  smoji,number = j.split(".")
  if flag:
    result += int(number)
  if smoji == x:
    flag = True

print(result)

Submission status: Accepted

Solution code:
N = int(input())
L = [0] * N
M = [0] * N
for i in range(N):
    L[i], M[i] = map(str, input().split())
K = [int(s) for s in M]
X = str(input())
t = L.index(X)
count = 0
for i in range(t + 1, N):
    count += K[i]
print(count)

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()
flag = False
time = 0
i = 0

while i < n:
  if list[i][0] == x:
    flag = True
    time = time - list[i][1]
  if flag == True:
    time = time + list[i][1]
  i = i + 1
print(time)

Submission status: Accepted

Solution code:
n = int(input())

s = []
t = []

sum = 0

for i in range(n):
    a,b = input().split()
    s.append(a)
    t.append(b)
x = input()

for i in range(n):
    if x == s[i]:
        for j in range(i+1,n):
            sum += int(t[j])
        break

print(sum)

Submission status: Accepted

Solution code:
N=int(input())
s=[]
t=[]
j=0
k=0
for i in range(N):
 a,b= input().split()
 s.append(a)
 t.append(int(b))
o=input()
for i in range(N):
 if j==1:
  k+=t[i]
 if s[i]==o:
  j+=1
print(k)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
t=[]
u=[]
for i in range(n):
    s_i,t_i=input().split()
    s.append(s_i)
    t.append(int(t_i))
x=input()
for i in range(n):
    if s[i]!=x:
        u.append(t[i])
    else:
        u.append(t[i])
        ans=sum(t)-sum(u)
        break
print(ans)

Submission status: Accepted

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

i = 0
while i < n:
    name, sec = input().split()
    playlist.append(name)
    seccond.append(int(sec))

    i += 1

x = input()
si = playlist.index(x)+1
cnt = 0

while si < n:
    cnt += seccond[si]

    si += 1


print(cnt)

Submission status: Accepted

Solution code:
N = int( input() )
p = {}
lengh = []
for i in range(N):
    s,t = map(str,input().split())
    t = int(t)
    p[s] = i
    lengh.append(t)

ans = p[input("")]
print(sum(lengh[ans:]) - lengh[ans])

Submission status: Accepted

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

start = 0
ans = 0
for i in range(n):
  if playlist[i][0] == x:
    start = i+1
for i in range(start,n):
  ans += int(playlist[i][1])
print(ans)

Submission status: Accepted

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

i = sl.index(x) + 1
print(sum(tl[i:]))

Submission status: Accepted

Solution code:
N=int(input())
slist=[input().split() for i in range(N)]
X=input()
sumT=0
flag=0
for j in range(len(slist)):
  if flag==1:
    sumT+=int(slist[j][1])
  if slist[j][0]==X:
    flag=1
print(sumT)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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])
    print(count)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print(time)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

N=int(input())

titles=[]
times=[]

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

X=input()


index=titles.index(X)

ans=0

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

print(ans)

Submission status: Accepted

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(names)):
  if not(t == names[i]):
    c += mins[i]
  else:
    c += mins[i]

    break
print(sum(mins)-c)

Submission status: Accepted

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

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

X = str(input())

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

print(x)

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


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


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


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


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


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

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

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

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

print(sum_time)

Submission status: Accepted

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

SleepingTime = 0

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

print(SleepingTime)

Submission status: Accepted

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

X = input()

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

name = []
time = []

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

x = input()
result = 0

num = name.index(x)

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

print(result)

Submission status: Accepted

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

# N=3
# s=["dwango","sixth","prelims"]
# t=[ 2, 5,25]
# X="prelims"

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

Submission status: Accepted

Solution code:
N = int(input())

s = []

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

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

print(t_sum);

Submission status: Accepted

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

num = int(input())

musics = []

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

sleep = input()

flg = False

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s_t = [input().split() for _ in range(N)]
X = input()
#print(s_t)
ans = 0
for i in range(N):
  if s_t[i][0] == X:
    for j in range(i + 1, N):
      ans+=int(s_t[j][1])
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

X = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(x+1,N):
    ans+=T[i]

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

X = input()

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

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

Submission status: Accepted

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

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))
X = input()
print(sum(ts[ss.index(X)+1:]))

Submission status: Accepted

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

Submission status: Accepted

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

m = s.index(x)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

spl = 0
ti = 0
flg = 0

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


print(ti)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

index=0
for i in range(N):
    if s[i]==X:
        index=i+1

ans=0
if index==N:
    print(0)
    exit()
else:
    for i in range(index,N):
        ans+= t[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
list = []
for i in range(n):
    a,b=input().split()
    list.append((a, int(b)))
    
s = input()
    
t = 0
for i in range(n):
  if list[i][0] == s:
    for j in range(i+1,n):
      t = t + list[j][1]
    break

print(t)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
    s_list.append(s)
    t_list.append(int(t))

X = str(input())

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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)

Submission status: Accepted

Solution code:
import sys

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

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

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

main()

Submission status: Accepted

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

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

kyoku = input()

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

result = 0

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

print(result)

Submission status: Accepted

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

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

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

Submission status: Accepted

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