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())
s=list()
t=list()
st=[]
for i in range(N):
    st.append(input().split())
X=input()
ans=0
count=False
for j in range(N):
    if count:
        ans+=int(st[j][1])
    if st[j][0]==X:
        count=True
print(ans)

Submission status: Accepted

Solution code:
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import itertools
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  S=[]
  T=[]
  for _ in [0]*N:
    s,t=pin().split()
    S.append(s)
    T.append(int(t))
  U=list(itertools.accumulate(T))
  X=pin()[:-1]
  print(sum(T)-U[S.index(X)])
  return 

main()

Submission status: Accepted

Solution code:
N = int(input())

lst = []

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

X = input()

index = 0

for i in range(N):
   if lst[i][0] == X:
      index = i
      break

ans = 0

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

print(ans)

Submission status: Accepted

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

c=input()
memo=0
ans=0
for i in range(n):
    if memo==1:
        ans+=l[i][1]
    if l[i][0]==c:
        memo=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
name=[""]*N
time=[0]*N
for i in range(N):
  a=input()
  name[i]=a.split()[0]
  time[i]=int(a.split()[1])
print(sum(time[name.index(input())+1:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

cnt = False
ans = 0
for s, t in S:
    if s == X:
        cnt = True
    elif cnt:
        ans += t

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    s, t = [list(i) for i in zip(*[input().split() for i in range(N)])]
    t = list(map(int, t))
    k = s.index(input())
    print(sum(int(t[i]) for i in range(k+1, N)))



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
st=[]
a=0
b=0
for i in range(N):
    st.append(list(map(str,input().split())))
X=str(input())
for i in range(N):
    if st[i][0]==X:
        a=i
for i in range(a+1,N):
    b+=int(st[i][1])
print(b)

Submission status: Accepted

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

insleep = s.index(x)
ans = sum(t[insleep+1:])
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N=int(input())

stlist=[]
for _ in range(N):
  s,t=input().split()
  stlist.append((s,t))
#print(stlist)

X=input()

answer=0
flg=False
for s,t in stlist:
  if s==X:
    flg=True
  else:
    if flg:
      answer+=int(t)
      
print(answer)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    title = defaultdict(int)
    cumsum = [0]
    for i in range(1, N + 1):
        s, t = readline().strip().decode('utf-8').split()
        title[s] = i
        cumsum.append(cumsum[-1] + int(t))
    X = readline().decode('utf-8').strip()
    ans = cumsum[-1] - cumsum[title[X]]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    stList = [list(map(str, readline().rstrip().split())) for _ in range(n)]
    x = readline().rstrip()
    sumT = 0
    flg = False

    for i in range(n):
        s, t = stList[i][0], int(stList[i][1])
        if flg != True:
            if s == x:
                flg = True
                continue
        if flg == False:
            continue
        sumT += t
    print(sumT)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
found = False
for s in l:
  if found:
    ans += s[1]
    continue
  if s[0] == X:
    found = True
    
print(ans)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s_ls = []
dic = collections.defaultdict(int)
for i in range(n):
    [s,t] = [j for j in input().split()]
    s_ls.append(s)
    dic[s] = int(t)
x = input()
f = 0
ans = 0
for i in range(n):
    if f:
        ans += dic[s_ls[i]]
    if x == s_ls[i]:
        f = 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
name = []
time = []
for i in range(n):
    a,b = input().split()
    name.append(a)
    time.append(b)
count = 0
for i in range(name.index(input()) + 1,n):
    count += int(time[i])
print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = ["" for i in range(n)]
t = [0 for i in range(n)]
for i in range(n):
    a, b = input().split()
    s[i], t[i] = a, int(b)
x = input()
ans = 0
flag = False
for i in range(n):
    if s[i] == x:
        flag = True
    elif flag:
        ans += t[i]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=['A']*N
T=[0]*N
for i in range(N):
    s,t=input().split()
    S[i]=s
    T[i]=int(t)
print(sum(T[S.index(input())+1:]))

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
st = [list(map(str,input().split())) for _ in range(n)]
x = input()
ch = 0
for i in range(n):
    if ch == 1:
        cnt += int(st[i][1])
    if st[i][0] == x:
        ch = 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
music = {}
for i in range(n):
    a, b = input().split()
    ans += int(b)
    music[a] = ans
print(ans-music[input()])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s, t = zip(*(input().split() for _ in range(N)))
t = list(map(int, t))
X = input()

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
sName = []
sTime = []
for i in range(n):
	m = input().split()
	sName.append(m[0])
	sTime.append(int(m[1]))
lsName = input()
lsInd = sName.index(lsName)
if lsInd == n - 1:
	result = 0
else:
	times = sTime[lsInd + 1:]
	result = sum(times)
print(result)

Submission status: Accepted

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

ans = 0
flag = False
for s, t in songs:
    if flag:
        ans += t
    if s == x:
        flag = True

print(ans)

Submission status: Accepted

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

X = input()

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

Submission status: Accepted

Solution code:
n = int(input())
l = []
flag = False
ans = 0

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

x = input()

for s, t in l:
    if flag == True:
        ans += t
    elif s == x:
        flag = True

print(ans)

Submission status: Accepted

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

x = input()

ans = 0
p = 0
for i in range(n):
    if p == 0 and lis[i][0] == x:
        p = 1
    elif p == 1:
        ans += lis[i][1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
time = []
for i in range(n):
  s, t = map(str, input().split())
  dic[s] = i + 1
  time.append(int(t))
ans = 0
song = input()
ans = sum(time[dic[song]:])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    name = []
    duration = []
    for _ in range(n):
        s, t = isp()
        name.append(s)
        duration.append(int(t))
    
    x = input()
    ind = name.index(x)
    print(sum(duration[ind+1:]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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[number+1:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
S=[]
T=[]
time=0
for i in range(n):
    s,t=map(str,input().split())
    S.append(s)
    T.append(int(t))
x=input()
for i in range(50):
    if S[i]==x:
        break
for j in range(i+1,n):
    time+=T[j]
print(time)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
total = 0
for _ in range(n):
    s, t = input().split()
    total += int(t)
    dic[s] = total
x = input()
total -= dic[x]
print(total)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    n = int(input())
    s_arr = []
    t_arr = []
    for _ in range(n):
        s, t = list(map(str, input().split()))
        t = int(t)
        s_arr.append(s)
        t_arr.append(t)
    x = input()[:-1]
    print(sum(t_arr[s_arr.index(x) + 1:]))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
a=[(input().split()) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
  if i[0]==x:
    cnt=0
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
clips = [input().split() for _ in range(N)]
X = input()
FLG = 0
ans = 0

for title,time in clips:
    if FLG:
        ans += int(time)
    if title == X:
        FLG = 1
    
print(ans)

Submission status: Accepted

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

for i,title in enumerate(clips):
    if X in title:
        for j in range(i+1, N):
            ans += int(clips[j][1])
        break

print(ans)

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

Submission status: Accepted

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

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

x = input()
y = s.index(x)
print(sum(t[y+1:]))

Submission status: Accepted

Solution code:
n = int(input())
s, t  = [], []
for i in range(n):
    ST = list(map(str, input().split()))
    s.append(ST[0])
    t.append(int(ST[1]))

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

Submission status: Accepted

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

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

titles, playtimes = list(zip(*playlists))
lastmusic = input()

lastmusic_timing = titles.index(lastmusic)
print(sum(playtimes[lastmusic_timing + 1:]))

Submission status: Accepted

Solution code:
N = int(input())

s = ['a']*N
t = ['a']*N

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

finish = input()

index = s.index(finish)

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
L = SLL(N)
Q = S()
flag = 0
sl = 0
for a,b in L:
  if flag == 1:
    sl += int(b)
  if a == Q:
    flag = 1
    
print(sl)

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    list =[]
    sumN=0
    for i in range(n):
        a = [str(i) for i in input().split()]
        list.append(a)
        sumN += int(a[1])
    x = input()

    for i in list:
        sumN -= int(i[1])
        if x == i[0]:
            break
    print(sumN)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
st = [LIST() for _ in range(N)]
X = input()
S = []
T = []
for s, t in st:
	S.append(s)
	T.append(int(t))

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

Submission status: Accepted

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

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

x=input()

a=s.index(x)

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

Submission status: Accepted

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

#入力
# s = input()
n = int(input())
# n,m = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


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

x = input()[0:-1]
     
def main():
    ans = 0
    flag = False

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ls = []
for i in range(N):
  s = input().split()
  ls.append(s)
X = input()
ans = 0
mode = 0
for i in range(N):
  if ls[i][0] == X:
    mode = 1
  else:
    if mode == 1:
      ans += int(ls[i][1])
print(ans)

Submission status: Accepted

Solution code:
from itertools import accumulate 

n = int(input())
song= []
time = [0]

for i in range(n):
    s, t = input().split()
    song.append(s)
    time.append(int(t) + time[i])

#time_acc = list(accumulate(time))
x = input()
print(time[n] - time[song.index(x) + 1])

Submission status: Accepted

Solution code:
from itertools import accumulate 

n = int(input())
song= []
time = []

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

time_acc = list(accumulate(time))
x = input()

print(time_acc[n - 1] - time_acc[song.index(x)])

Submission status: Accepted

Solution code:
n = int(input())
S = [None] * n
T = [None] * n
for i in range(n):
    S[i], T[i] = input().split()
x = input()
sleep_song_index = S.index(x)

counter = 0
for i in range(sleep_song_index+1, n):
    counter += int(T[i])
print(counter)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    word = []
    time = []
    for _ in range(N):
        a,b = input().split()
        word.append(a)
        time.append(int(b))
    X = input()
    s = -1
    for i in range(N):
        if word[i] == X:
            s = i + 1
    ans = sum(time[s:])
    print(ans)
if __name__ == '__main__':
    main()