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:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

S = [input().split() for _ in range(N)]

T = input()
flag = 0
cnt = 0
for i in range(N):
    if S[i][0] == T:
        flag = 1
    elif flag:
        cnt += int(S[i][1])
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
st = [list(input().split()) for nesya in range(n)]
x = input()
c = 0
for a in st:
  if x == a[0]:
    c = 0
  else:
    c += int(a[1])
print(c)

Submission status: Accepted

Solution code:
N = int(input())
T = 0
M = {}
for i in range(N):
  s, st = input().split()
  t = int(st)
  T += t
  M[s] = T
X = input()
r = T-M[X]
print(r)

Submission status: Accepted

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

flg = False
ans = 0
for x in X:
  if flg:
    ans += int(x[1])
  if S == x[0]:
    flg = True
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
s,t=zip(*[input().split() for i in range(N)])
X=input()
print(sum(list(map(int,t[s.index(X)+1:]))))

Submission status: Accepted

Solution code:
N=int(input())
playlist={}
time=0
for i in range(N):
    s,t=input().split()
    time+=int(t)
    playlist[s]=time
X=input()
print(time-playlist[X])

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()
print(sum(list(map(int,t[s.index(X)+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 i in range(N):
    s,t=input().split()
    S.append(s)
    T.append(int(t))
X=input()
print(sum(T[S.index(X)+1:N]))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split() for _ in range(n)]
s.reverse()
x = input()
ans = 0
for i in range(n):
    if s[i][0] == x:
        print(ans)
        exit()
    else:
        ans += int(s[i][1])

Submission status: Accepted

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

s,t = zip(*st)

print(sum(int(t[i]) for i in range(s.index(x)+1,n)))

Submission status: Accepted

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

ind = title.index(x)
print(sum(length[ind+1:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = [None] * N
t = [None] * N
for i in range(N):
  p, q = input().split()
  s[i] = p
  t[i] = int(q)
X = input()
print(sum(t[s.index(X)+1:]))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    s = [""] * N
    t = [0] * N
    for i in range(N):
        st = input().split()
        s[i] = st[0]
        t[i] = int(st[1])
    X = input().rstrip()

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ST = [input().split() for _ in range(N)]
X = input()
flag = False
ans = 0
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())
s,t = [0]*n,[0]*n
for i in range(n):
  s[i],t[i] = input().split()
t = list(map(int,t))
print(sum(t[s.index(input())+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))
print(sum(T[S.index(input())+1:]))

Submission status: Accepted

Solution code:
n = int(input())
movies = {}

summize = 0
for i in range(n):
  input_str = input().split()
  summize += int(input_str[1])
  movies.setdefault(input_str[0], summize)

title = input()
print(summize - movies[title])

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[list(input().split()) for i in range(n)]
    x=input()
    cnt=0
    flag=False
    for s,t in l:
        if s==x:
            flag=True
        if s!=x and flag:
            cnt+=int(t)
    print(cnt)
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[list(input().split()) for i in range(n)]
    x=input()
    cnt=0
    for s,t in l:
        if s!=x:
            cnt+=int(t)
        elif s==x:
            cnt+=int(t)
            break
    suml=0
    for i in range(n):
        suml+=int(l[i][1])
    print(suml-cnt)

resolve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N=int(input())
    
    A, B = [0] * N, [0] * N
    for i in range(N):
        A [i], x = map(str, input().split())
        B[i]=int(x)
    X=str(input())
    for i in range(N):
        if A[i]==X:
            print(sum(B[i+1:]))
            break
    

    

    

    
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

X = input()
idx = s.index(X)

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

Submission status: Accepted

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

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

f=S.index(X)
ans=0
if f==N-1:
    print(0)
else:
    for i in range(f+1,N):
        ans+=T[i]
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
t = [0]*n
for i in range(n):
    S,T = input().split()
    d[S] = i
    t[i] = int(T)
x = input()
idx = d[x]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
t = [0 for _ in range(n)]
for i in range(n):
    S,T = input().split()
    d[S] = i
    t[i] = int(T)
x = input()
idx = d[x]

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

Submission status: Accepted

Solution code:
line =int(input())

data = [list(map(str,input().split()))for i in range(line)]

sleep_song = input()
sleep_time=0

for s in range(line):
  if data[s][0] ==sleep_song:
    sleep_moment =s+1
for t in range(sleep_moment,line):
  sleep_time +=int(data[t][1])
print(sleep_time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())

st = [input().split() for _ in range(n)]
x = input()
s, t = zip(*st)
i = s.index(x)
print(sum(map(int, t[i+1:])))

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
s=[""]*n
t=[0]*n
for i in range(n):
    s[i],t[i]=input().split()
    t[i]=int(t[i])
x=input()
c=0
for i in range(n):
    if s[i]==x:
        c=i
        break
ans=0
for i in range(c+1,n):
    ans+=t[i]
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
st = [readline().rstrip().decode().split() for _ in range(n)]
x = readline().rstrip().decode()
cnt = 0
flag = False
for s, t in st:
    if flag:
        cnt += int(t)
    if x == s:
        flag = True
print(cnt)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    s,t=input().split()
    a.append([s,int(t)])
x=input()
sum1=0
for j in range(n):
    if a[j][0]!=x:
        sum1+=a[j][1]
    else:
        sum1+=a[j][1]
        break
sum2=0
for i in range(n):
    sum2+=a[i][1]
print(sum2-sum1)

Submission status: Accepted

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

Submission status: Accepted

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

X = input()

count = False
ans = 0
for i in range(N):
    if count:
        ans += x[i][1]
    if x[i][0] == X:
        count = True

print(ans)

Submission status: Accepted

Solution code:
# 1: O(N*digit(A))
if False:
    B=[int(i) for i in input().split()]
    N=int(input())
    rep={}
    for i,b in enumerate(B):
        rep[str(b)]=str(i)
    # print(rep)
    ans=[]
    for _ in range(N):
        a=input()
        num=''
        for d in a:
            num+=rep[d]
        ans.append((a,int(num)))
    ans.sort(key=lambda x: x[1])
    for i in range(N): print(ans[i][0])

# 2: 366**2
if False:
    N=int(input())
    S=[tuple(map(int,input().split('/'))) for _ in range(N)]
    if len(S)>=366: print(366)
    elif N==0: print(2)
    else:
        cal=[[] for m in range(12)]
        day=6 #0-6: 0-MON
        for m in range(12):
            if m+1==2: e=29
            elif m+1 in (4,6,9,11): e=30
            else: e=31
            for d in range(1,e+1):
                cal[m].append([d,day,day in (5,6)])
                day=(day+1)%7
        for m,d in S:
            m-=1
            d-=1
            while cal[m][d][2]:
                if d+1<len(cal[m]): d+=1
                else:
                    m+=1
                    m%=12
                    d=0
                if (m,d)==(11,30): break
            cal[m][d][2]=True
        ans=-1
        cnt=0
        for m in range(12):
            for d in range(len(cal[m])):
                if cal[m][d][2]:
                    cnt+=1
                else:
                    ans=max(ans,cnt)
                    cnt=0
        ans=max(ans,cnt)
        print(ans)
        # print(cal[11])

#ARC036-B
if False:
    N=int(input())
    H=[int(input()) for _ in range(N)]
    if N==1: print(1); exit()
    ans=0
    cnt=2
    prev=1 if H[0]<H[1] else 0 #1:<,0:>
    for i in range(1,N-1):
        tmp=1 if H[i]<H[i+1] else 0
        if prev<tmp:
            ans=max(ans,cnt)
            cnt=2
        else:
            cnt+=1
        prev=tmp
    ans=max(ans,cnt)
    print(ans)

#D2019PC-C
if False:
    N=int(input())
    S=[input() for _ in range(N)]
    ans=0
    cnt={'BA':0,'BX':0,'XA':0}
    for s in S: ans+=s.count('AB')
    for s in S:
        l=s[0]
        r=s[-1]
        if l=='B' and r=='A': cnt[l+r]+=1
        elif l=='B': cnt[l+'X']+=1
        elif r=='A': cnt['X'+r]+=1 
    if cnt['BA']:
        ans+=cnt['BA']-1
        if cnt['BX'] and cnt['XA']:
            ans+=min(cnt['BX']-1,cnt['XA']-1)+2
        else:
            ans+=int(bool(cnt['BX']))+int(bool(cnt['XA']))
    else:
        ans+=min(cnt['BX'],cnt['XA'])
    print(ans)

#6DQ-A
if True:
    N=int(input())
    M=[input().split() for _ in range(N)]
    X=input()
    for i,m in enumerate(M):
        s,t=m
        if s==X:
            I=i+1
            break
    print(sum(int(t) for s,t in M[I:]) if I!=N else 0)

Submission status: Accepted

Solution code:
n = int(input())
st = []
for _ in range(n):
  si, ti = input().split()
  st.append((si, int(ti)))
name = input()
count = 0
flag = False
for i in range(n):
  if flag:
    count += st[i][1]
  if st[i][0] == name:
    flag = True
print(count)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=[""]*n
    t=[0]*n
    for i in range(n):
        ss,tt=input().split()
        s.append(ss)
        t.append(int(tt))
    x=input()
    print(sum(t[s.index(x)+1:]))

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = list()
t = list()
ans = 0
for i in range(n) :
    addS,addT = input().split()
    s.append(addS)
    t.append(int(addT))
x = input()
for i in t :
    if t.index(i) > s.index(x) : 
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
music=[]
T=[]
ans=0
for i in range(N):
    s, t=input().split()
    t=int(t)
    music.append(s)
    T.append(t)
X=input()
num=music.index(X)
for j in range(num+1, N):
    ans+=T[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

j= s.index(X)
if X==s[-1]:
  ans=0
else:
  ans= sum(t[j+1:])

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

s = input()

cnt = 0
cnt_flag = 0
for i, j in a:
    if cnt_flag:
        cnt += j
    if s == i:
        cnt_flag = 1
print(cnt)

Submission status: Accepted

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

for i in range(N):
  if flg == True:
    ans += int(set_list[i][1])
  if set_list[i][0] == X:
    flg = True
    
print(ans)

Submission status: Accepted

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

yoroshiosu = 0
samu = 0

for i in range (0, N):
	if X == List[i][0]:
		yoroshiosu =1
	elif yoroshiosu == 0:
		continue
	else:
		samu+=int(List[i][1])
        
print(samu)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#######################################################################################################
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=input()
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

idx = 0
while idx < N:
  if s[idx] == X:
    idx += 1
    break
  idx += 1

ans = 0
for i in range(idx, N):
  ans += t[i]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
stri=[]
time=[]

for _ in range(n):
  s,t=input().split()
  stri.append(s)
  time.append(t)
x=input()

ind=stri.index(x)

ans=0

for i in range(ind+1,n):
  ans+=int(time[i])
  
print(ans)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
lis = ['0']*N
time = [0]*N
for i in range(N):
    lis[i],time[i] = input().split()
sing = input()
index = -1
for i in range(N):
    if lis[i] == sing:
        index = i
        break
ans = 0
for i in range(index+1,N):
    ans += int(time[i])
print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
music = []
length = []
for i in range(n):
    ti,leng = map(str,input().split())
    music.append(ti)
    length.append(int(leng))
x = input()

num = music.index(x)
print(sum(length[num+1::]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

time = None
for s, t in zip(S, T):
    if s == X:
        time = 0
    elif time is not None:
        time += t
    else:
        continue

print(time)

Submission status: Accepted

Solution code:
n = int(input())
li = [input().split() for _ in range(n)]
x = input()
flag = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n=input()
l=[]
m=[]
for i in range(n):
    x=raw_input().split()
    l.append(x[0])
    m.append(int(x[1]))
u=raw_input()
print sum(m[l.index(u)+1:])

Submission status: Accepted

Solution code:
n=input()
l=[]
m=[]
for i in range(n):
    x=raw_input().split()
    l.append(x[0])
    m.append(int(x[1]))
u=raw_input()
for i in range(n):
    if l[i]==u:
        print sum(m[i+1:])
        break

Submission status: Accepted

Solution code:
n = int(input())
songs = []
subs_total = 0
total = 0
for _ in range(n):
    s, t = input().split()
    total += int(t)
    songs.append([s,t])
x = input()
for i in range(n):
    subs_total += int(songs[i][1])
    if songs[i][0] == x:
        break
ans = total - subs_total
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
t = []
index = {}
for n in range(N):
    si, ti = input().split()
    ti = int(ti)
    index[si] = n
    t.append(ti)

X = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


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

Submission status: Accepted

Solution code:
n = int(input())
data=[list(input().split()) for _ in range(n)]
s = input()
ans = 0
c = False
for i in range(n):
   if c:
      ans += int(data[i][1])
   if data[i][0] == s:
      c = True
print(ans)

Submission status: Accepted

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

ans = 0
mode = 0
for s, t in st:
    if mode == 0:
        if s == x:
            mode = 1
    else:
        ans += int(t)

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

flag = 0
time = 0

for i, x in enumerate(s_list):
  if x == X:
    flag = 1
  
  elif flag == 1:
    time += t_list[i]
print(time)

Submission status: Accepted

Solution code:
N = int(input())
slist = []
tlist = []
from itertools import accumulate
for _ in range(N):
    s, t = input().split()
    slist.append(s)
    tlist.append(int(t))
cum = list(accumulate(tlist))
print(cum[-1]-cum[slist.index(input())])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, 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 input().split()
def S(): return 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)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    st = LSR(n)
    x = S()
    ans = 0
    te = 0
    for s, t in st:
        if te:
            ans += int(t)
        if s == x:
            te = 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:

n = int(input())
songs = []

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

for i in range(n):
    if songs[i][0] == x:
        number = i + 1
#print("number: " + str(number))

ans = 0
for j in range(number,n):
    ans += songs[j][1]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[list(input().split()) for _ in range(n)]
x=input()
ans=0
for i in range(n):
    s,t=l[i]
    t=int(t)
    ans+=t
    if s==x:
        c=ans
print(ans-c)

Submission status: Accepted

Solution code:
def main():
    musics = int(input())
    title = []
    time = []
    for _ in range(musics):
        s, t = input().split()
        title.append(s)
        time.append(int(t))
    last_song = input()
    for i in range(musics):
        if title[i] == last_song:
            print(sum(time[i + 1:]))
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ST = [list(map(str, input().split())) for _ in range(N)]
X = str(input())

ans = 0
flag = False
for s, t in ST:
    if flag:
        ans += int(t)
    else:
        if s == X:
            flag = True

print (ans)

Submission status: Accepted

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

ans = 0
f = False
for s, t in L:
    if f:
        ans += t
    if s == X:
        f = True
print(ans)