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())
playlist = []
playtime = []
for n in range(N):
  hoge = input().split()
  playlist.append(hoge[0])
  playtime.append(int(hoge[1]))
X = input()
print(sum(playtime[playlist.index(X)+1:]))

Submission status: Accepted

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 triger==1:
    A+=T[j]
  if i==X:
    triger=1
  j+=1
print(A)

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=str(input())
count=0
for i in S:
    count+=1
    if(X==i):
        break
    else:
        pass
print(sum(T[count:N]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    n = int(input())
    s = []
    t = []
    for _ in range(n):
        s_i, t_i = input().split()
        s.append(s_i)
        t.append(int(t_i))
    x = input()
    print(sum(t[s.index(x) + 1:]))
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(input())
    s = []
    t = []
    for i in range(n):
        tmp = input().split()
        if len(tmp):
            s.append(str(tmp[0]))
            t.append(int(tmp[1]))
    x = input()
    tmp = s.index(x.replace("\n", ""))
    res = 0
    for i in range(tmp+1, n):
        res += t[i]
    print(res)


if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Accepted

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

for i in range(N):
    if S[i] == X:
        if i == N:
            c=0
        else:
            c=sum(T[i+1:N+1])
            break

print(c)

Submission status: Accepted

Solution code:
n=int(input())
t=[""]*n
sec=[0]*n
for k in range(n):
  s=input().split()
  t[k]=s[0]
  sec[k]=int(s[1])
x=input()
p=t.index(x)
a=0
if p!=n:
  for l in range(p+1,n):
    a+=sec[l]
print(str(a))

Submission status: Accepted

Solution code:
import numpy as np

def solve_a():
    #
    N = int(input())

    # 
    list_S = []
    list_T = []

    for i in range(N):
        s, t = input().split()
        list_S.append(s)
        list_T.append(int(t))
    
    sentense = input()

    idx = list_S.index(sentense)

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

    print(sum_time)

def main():
    solve_a()

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
t=int(input())
name=[]
time=[]
for _ in range(t):
  args=list(input().split())
  name.append(args[0])
  time.append(int(args[1]))
s=input()
ind=name.index(s)
print(sum(time[ind+1:]))

Submission status: Accepted

Solution code:

n = int(input())
ts, tt = list(input().split())
s = [ts]
t = [int(tt)]
for i in range(1, n):
    ts, tt = list(input().split())
    s.append(ts)
    t.append(t[i-1] + int(tt))
x = input()

ans = 0
for i in range(n-1):
    if s[i] == x:
        ans = t[n-1] - t[i]
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):

    a = input().split(' ')
    _s = a[0]
    _t = int(a[1])

    s.append(_s)
    t.append(_t)

x = input()

idx_last = s.index(x)

playedsongs = sum(t[idx_last + 1:])

print(playedsongs)

Submission status: Accepted

Solution code:
N=input()
name=[]
sec=[]
for i in range(int(N)):
  p=input()
  plist=p.split(" ")
  name.append(plist[0])
  sec.append(plist[1])
X=input()
flag=0
sec_total=0
for i in range(int(N)):
  if(flag==1):
    sec_total+=int(sec[i])
  if(X==name[i]):
    flag=1
print(sec_total)

Submission status: Accepted

Solution code:
a = int(input())
b = []
c = 0
y = ""
for i in range(a):
    b.append(input().split(' '))
    #print(b)
x = input()
#print(x)
for i,j in b:
    if y == "x":
        c = c + int(j)
    #print(i)
    #print(j)
    if str(x) == str(i):
        y = "x"
print(c)

Submission status: Accepted

Solution code:
N = int(input())
s = []
t = []
for _ in range(N):
  st = input().split()
  s.append(st[0])
  t.append(int(st[1]))
X = input()
index = s.index(X)
print(sum(t[index+1:]))

Submission status: Accepted

Solution code:
n = int(input())
li = list(range(n))
lis = list(range(n))
for i in range(n):
    s_i, t_i = map(str, input().split())
    li[i] = s_i
    lis[i] = int(t_i)
x = input()
counter = 0
while x != li[counter]:
    counter = counter+1
    i = counter+1
counter=counter+1
su = 0
while counter != n:
    su = su+lis[counter]
    counter=counter+1
print(su)

Submission status: Accepted

Solution code:
N = int(input())
s = [0] * N
t = [0] * N
for i in range(N):
  s[i],t[i] = input().split()
X = input()
flg = 0
sum = 0
for i in range(N):
  if (s[i] == X) & (flg == 0):
    flg = 1
  elif flg == 1:
    sum += int(t[i])
print(sum)

Submission status: Accepted

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

from collections import OrderedDict

n = int(input())
dic = OrderedDict()

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: 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 = [int(s) for s in t]
x = input()

total_t = sum(t)
end = s.index(x)
total_ex = sum(t[0:end+1])

print(total_t - total_ex)

Submission status: Accepted

Solution code:
in1 = int(input())
in2 = [input().strip().rsplit(" ") for i in range(in1)]
in3 = input()
time = 0 

in2a = list(zip(*in2))

inde = in2a[0].index(in3)

for times in range(inde+1, in1):
    time += int(in2[times][1])
print(time)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
M=[]
for i in range(N):
  s,m=map(str,input().split())
  S+=[s]
  M+=[int(m)]
A=str(input())

answer=sum(M)
for i in range(N):
  answer -=M[i]
  if S[i]==A:
    print(answer)
    exit()
print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [[x for x in input().split()] for i in range(N)]
X = input()
B = [i[0] for i in A]
C = [i[1] for i in A]

ans = 0
for i in C[B.index(X)+1:]:
  ans += int(i)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for _ in range(n):
    l.append(input().split())
x=input()
ll=list(l[i][0] for i in range(n))
lll=list(int(l[i][1]) for i in range(n))
k=ll.index(x)
print(sum(lll[k+1:n]))

Submission status: Accepted

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

Submission status: Accepted

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

for r in s_t:
    r[1] = int(r[1])

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

Submission status: Accepted

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

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

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

ans = 0
if a != n:
	for i in range(a, n):
		ans += t[i]
else:
	ans = 0

print(ans)

Submission status: Accepted

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

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

sleep=0
for j in range(len(s_title)):
  if X == s_title[j]:
    sleep = j
    #print(sleep)
    break

sum = 0
for k in range(sleep+1, N):
  sum = sum + time[k]

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
s = []
t = []
for i in range (N):
  inin = input().split()
  s.append(str(inin[0]))
  t.append(int(inin[1]))
X = str(input())

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

Submission status: Accepted

Solution code:
N = int(input())
song = [0] * N
time = [0] * N
for i in range(N):
    song[i], time[i] = map(str, input().split())
time = [int (t) for t in time]
X = input()
res = 0
Sleep = song.index(X)
Played = time[Sleep+1::]
for time in Played:
    res = res + time
print(res)

Submission status: Accepted

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
s = []
t = []
for i in range(n):
    S,T = LS()
    s.append(S)
    t.append(int(T))
x = input()

idx = s.index(x)
if idx==n-1:
    print(0)
    exit()
print(sum(t[idx+1:]))

Submission status: Accepted

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

times = 0
flag = False
for i, s in enumerate(s_list):
    if flag:
        times += t[i]
    if X == s:
        flag = True

print(times)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
  input_line = input().split()
  s.append(str(input_line[0]))
  t.append(int(input_line[1]))
  #print(i,s[i],t[i])
x = input()

sum_bool = False
sum_song = 0
for j in range(n):
  if sum_bool == True:
    sum_song = sum_song + t[j]
  if x == s[j]:
    sum_bool = True
print(sum_song)

Submission status: Accepted

Solution code:
n = int(input())
s=[]
t=[]
for i in range(n):
    str = input().split()
    s.append(str[0])
    t.append(int(str[1]))
x=input()
total=0
if s.index(x)+1!=len(t):
    total=sum(t[s.index(x)+1:])
print(total)

Submission status: Accepted

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

N = int(input())

m = []
l = []

for _ in range(N):
    i = input().split()
    m.append(i[0])
    l.append(int(i[1]))

s = input().strip()
index = 0
for i, x in enumerate(m):
    if x == s:
        index = i + 1
        break

print(sum(l[index:]))

Submission status: Accepted

Solution code:
N = int(input())
play = list()
for i in range (N):
  play.append(input())
X = input()
j = 0
name = list()
time = list()
while j < N:
  kyoku = list(play[j].split())
  name.append(kyoku[0])
  time.append(int(kyoku[1]))
  j += 1

A = 0
k = name.index(X) + 1
while k < N:
  A += time[k]
  k += 1

print(A)

Submission status: Accepted

Solution code:
num=int(input()) 
song=[]
length=[]
for i in range(num):
  n, m = input().split()
  song.append(n)
  length.append(int(m))
last=str(input())
songindex=song.index(last)
print(sum(length[songindex+1:num]))

Submission status: Accepted

Solution code:
N = int(input())
mlist = [[]] * N
for i in range(N):
  mlist[i]  = list(map(str, input().split()))
X = str(input())
for j in range(N):
  if mlist[j][0] == X:
    mNo = range(j+1, N)
print(sum(int(mlist[k][1]) for k in mNo ))

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        n = int(lines[0])
        for i in range(n):
            lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])
    
    st = []
    for i in range(1, n+1):
        (s, t) = lines[i].split(" ")
        st.append((s, int(t)))
    x = lines[n+1]

    return (n, st, x)


def solve(n, st, x):

    index = None
    for i in range(n):
        (s, _) = st[i]
        if s == x:
            index = i
    
    st2 = st[index + 1:]
    result = sum([e[1] for e in st2])

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

#s[i][0] に曲名, s[i][1]に時間
s = [input().split() for i in range(N)]
X = input()
sleep_time = 0

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

for i in range(I + 1, N):
  sleep_time += s[i][1]

print(sleep_time)

Submission status: Accepted

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

start = s.index(X)
ans = 0
if start < N - 1:
    ans = sum(t[start + 1:])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s_list = []
t_list = []

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

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

print(sum(t_list))

Submission status: Accepted

Solution code:
def f(s):
  lst = s.split()
  return lst[0], int(lst[1])

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

X = str(input())

if X in S:
  index = S.index(X)
else:
  print(o)

sum = 0
for i in range(index+1, N):
  sum += int(T[i])

print(sum)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = ["" for i in range(N)]
    T = ["" for i in range(N)]

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

    X = input()

    total = 0
    sleep = False

    for i in range(N):
        if sleep:
            total += T[i]
        if not sleep and S[i] == X:
            sleep = True

    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(0, n):
    si, ti = map(str, input().split())
    s.append( si)
    t.append( int(ti) )

x = input()

sum = 0
sleeping = False
for i in range(0, n):
    if sleeping:
        sum += t[i]
    if s[i] == x:
        sleeping = True

print(sum)

Submission status: Accepted

Solution code:
import sys

f = sys.stdin
N = int(f.readline())
T = []
S = {}
for i in range(N):
    s, t = f.readline().split(' ')
    T.append(int(t))
    S[s] = i
X = f.readline()[:-1]
time = sum(T[S[X]+1:])
print(time)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


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


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    N = II()
    SS=[]
    T=[]
    for i in range(N):
        s, t = input().split()
        t=int(t)
        SS.append(s)
        T.append(t)
    X=input().rstrip()
    i=SS.index(X)+1
    ans=0

    while(1):
        if i>=(len(T)):
            break
        ans+=T[i]
        i+=1
    print(ans)

    return

# B


def B():
    S = input()
    S = S[:-1]
    count = 0
    for i in range(len(S)//2):
        if (S[i] != S[-1-i]):
            count += 1

    print(count)
    return

# C


def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def C():
    N = II()
    L = []
    for i in range(1, N+1):
        A = II()

        for j in range(A):
            x, y = LI()
            L.append([i, x, y])


# D


def D():

    a, b, x = LI()
    BIG = a*a*b/2
    if x > BIG:
        y = 2*b-(2*x/a/a)
        print(math.degrees(math.atan(y/a)))
    else:
        y = 2*x/a/b
        print(math.degrees(math.atan(b/y)))
    return

# E


def E():
    N, K = LI()
    A = LI()
    F = LI()
    A.sort(reverse=True)
    F.sort()
    cost = []
    for i in range(len(N)):
        cost.append(A[i]*F[i])

    a = F[cost.index(max(cost))]

    return

# F


def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    N = len(S)

    pass


# Solve
if __name__ == '__main__':

    A()

Submission status: Accepted

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

Submission status: Accepted

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

isSleep = False
ans = 0

for r in record:
    if isSleep:
        ans += int(r[1])
    if r[0] == x:
        isSleep = True

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

sl = []
nl = []

n = int(input())

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

index = sl.index(input())

cnt = 0

for i in nl[index+1:]:
    cnt += i

print(cnt)

Submission status: Accepted

Solution code:
n =int(input())
lista = [input().split() for i in range(n)]
x = input()
dicta = dict(lista)
rmnum = lista.index([x,dicta.get(x)])
lista[0:rmnum+1] =[]
ans = 0
for i in range(len(lista)):
    ans+=int(dicta.get(lista[i][0]))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

nalist=[]
nblist=[]
for i in range(N):
    na, nb = input().split()
    nalist.append(na)
    nblist.append(int(nb))
X = input()
a=nalist.index(X)
del nblist[0:a+1]
ans=sum(nblist)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    st = input().split()
    s.append(st[0])
    t.append(int(st[1]))
x = input()
check = 0
time = 0

for i in range(n):
    if check == 1:
        time += t[i]
    if s[i] == x:
        check += 1


print(time)

Submission status: Accepted

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

r = 0
f = False

for s, t in st:
    if f:
        r += int(t)
    if s == x:
        f = True

print(r)

Submission status: Accepted

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

for j in range(n):
	if songs[j][0] == x:
		break

answer = 0

for i in range(j+1,n):
	answer += int(songs[i][1])

print(answer)

Submission status: Accepted

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

for i,v in enumerate(s_t):
    if v[0] == x:
        sleep_i = i
cnt = 0
for i in s_t[sleep_i+1:]:
    cnt += int(i[1])

print(cnt)

Submission status: Accepted

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

ct = 0
for i in range(n):
    if (x == s[n-1 - i]):
        break
    else:
        ct += t[n-1 - i]

print(str(ct))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

mList = []
for i in range(n):
  mList.append(list(input().split()))

sleepM = input()

sleepIndex = 0
for i in range(n):
  if mList[i][0] == sleepM:
    sleepIndex = i
    break

result = 0
for i in range(sleepIndex+1,n):
  result += int(mList[i][1])

print(result)

Submission status: Accepted

Solution code:
num_of_songs = int(input())
all_list = [input().split() for _ in range(num_of_songs)]

song_name = input()
ind = 0

for i, tmp_list in enumerate(all_list):
  if tmp_list[0] == song_name:
    ind = i

if ind != len(all_list) - 1:
  print(sum([int(tmp_list[1]) for tmp_list in all_list[ind+1:]]))
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

playList = []
timeList = []
for cnt in range(N):
    ttl, scd=input().split()
    playList.append(ttl)
    timeList.append(int(scd))

key = input()
index = int(playList.index(key))

print(sum(timeList[index+1: N]))

Submission status: Accepted

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

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

X=input()

j=S.index(X)
sum=0

for k in range(j+1,N):
	sum+=int(T[k])

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
list = []
for i in range(N): #因数注意！
    n = input()    
    m = n.split()
    p = [i for i in m] #1列の数列をリスト化
    list.append(p)
x = input()
a = 0
A = 0
for i in list:
    if a == 0:
        if x == i[0]:
            a = 1
        else:
            pass
    else:
        A = A + int(i[1])
print(A)

Submission status: Accepted

Solution code:
n = int(input())
def f(s):
    list = s.split()
    return list[0],int(list[1])
play = [f(input()) for i in range(n)]
x = input()

s = []
t = []
for i in range(n):
    s.append(play[i][0])
    t.append(play[i][1])

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

print(ans)

Submission status: Accepted

Solution code:
class Music:
    def __init__(self, name, time):
        self.name = name
        self.time = int(time)


n = int(input())
data = [(input().split()) for _ in range(n)]
music_list = [Music(d[0], d[1]) for d in data]
x = input()

start_music = None
for music in music_list:
    if music.name == x:
        start_music = music
        break

if start_music is None:
    print(0)
else:
    index = music_list.index(start_music)
    skipped_list = music_list[index+1:]

    skipped_time = 0
    for music in skipped_list:
        skipped_time += music.time
    print(skipped_time)

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split() for i in range(n)]
x = input()
for i, ti in enumerate(s):
  #print(i, ti)
  s[i][1] = int(s[i][1])
#print(n,s,x)
sum_t = 0
ind = 0

# xのindexを探索
for i, music in enumerate(s):
  #print(music)
  #print(x in music)
  if x in music:
    ind = i
    break
#print(ind)

# 経過時間計算
for i, music in enumerate(s):
  if i > ind:
    sum_t += music[1]
print(sum_t)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    input_s, input_t = input().split()
    s.append(input_s)
    t.append(int(input_t))
x = input()
c = 0
for i in range(n):
    if s[i] != x:
        c += 1
    else:
        print(sum(t[c+1:]))

Submission status: Accepted

Solution code:
N=int(input())
ls1=[]
for _ in range(N):
  title,time=input().split()
  ls1.append([title,int(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: Accepted

Solution code:
N = int(input())

P = [input().split() for i in range(N)]
last = input()

sleep_num = 0
sum_time = 0
for i,j in enumerate(P):
  if j[0] == last:
    sleep_num = i
  sum_time += int(j[1])
    


awake = 0
for i,j in enumerate(P):
  awake += int(j[1])
  if i == sleep_num:
    break

k = sum_time - awake

print(k)

Submission status: Accepted

Solution code:
n = int(input())

name = []
time = []
for _ in range(n):
    tmp = input().split()
    name.append(tmp[0])
    time.append(int(tmp[1]))

s = input()

i = name.index(s) + 1
ans = 0
while i < n:
    ans += time[i]
    i += 1

print(ans)

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:
n = int(input())
play_dict = {"_blank": 0}
old_s = "_blank"
for _ in range(n):
  s, t = input().split()
  play_dict[s] = play_dict[old_s] + int(t)
  old_s = s

print(max(play_dict.values()) - play_dict[input()])

Submission status: Accepted

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+1, n):
    total += int(t[i])
print(total)

Submission status: Accepted

Solution code:
N = int(input())
music =[]
time = []
count=0
for i in range(N):
  s,t = input().split()
  music.append(s)
  time.append(t)
S = input()
#print(S)
n = music.index(S)
for i in range(n+1,N):
  T = int(time[i])
  count +=T

print(count)

Submission status: Accepted

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

Submission status: Accepted

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 = -1

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

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

count = 0

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

Submission status: Accepted

Solution code:
n = int(input())
slist = []
tlist = []
dist = {}
sumt = 0
for i in range(n):
    s,t = input().split()
    t = int(t)
    slist.append(s)
    tlist.append(t)
for i in range(n):
      sumt += tlist[i]
for i in range(n):
  
    if i+1 <n:
      
      tlist[i+1] += tlist[i]  

        
    
    dist[slist[i]] = tlist[i]
x = input()
ans = sumt - dist[x] 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
title_list = []
time_list = []
for i in range(n):
    title,time = input().split(" ")
    time = int(time)
    title_list.append(title)
    time_list.append(time)

x = input()

total = 0
for i,j in enumerate(title_list):
    total += time_list[i]
  
time_res = 0
for i,j in enumerate(title_list):
    if j != x:
        time_res += time_list[i]
    else:
        time_res += time_list[i]
        break


        
print(total - time_res)

Submission status: Accepted

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

flag = False
ans = 0

for s_i, t_i in zip(s, t):
    if flag:
        ans += t_i
    if s_i == X:
        flag = True

print(ans)

Submission status: Accepted

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

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

    
print(ans)