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

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

X = input()

s = 0
start = False
for ar in A:
    if start:
        s += int(ar[1])

    if ar[0] == X:
        start = True

print(s)

Submission status: Accepted

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

#print(st)
suma = 0

T = 0

for i in range(N):
    if T == 1:
        suma += int(st[i][1])
    if st[i][0] == X:
        T = 1

print(suma)

Submission status: Accepted

Solution code:
n = int(input())

m = []

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

s = input()

ret = 0
flag = False

for i in range(n):
    if flag:
        ret += m[i][1]
    if m[i][0] == s:
        flag = True

print(ret)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

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

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

def main():
    n = ri()
    lm = []
    mp = dict()
    c = 0
    for i in range(n):
        s, t = rl()
        lm.append((s, int(t)))
    x = input()
    c = 0
    for i in range(n):
        if lm[i][0] == x:
            c = i
            break
    ans = 0
    for i in range(c+1, n):
        ans += lm[i][1]

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

playlists = []
playlists_num = []
ans = 0

for i in range(n):
    a = input()
    a, b = a.split(' ')
    b = int(b)
    playlists.append(a)
    playlists_num.append(b)


s = input()

for i in range(n):
    if playlists[i] == s:
        break

for j in range(i+1, n):
    ans += playlists_num[j]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

play_list = []
for _ in range(N):
    music = input().split(" ")
    play_list.append((music[0], int(music[1])))

X = input()
result = 0
flag = False
for music in play_list:
    if flag:
        result += music[1]
        continue
    if music[0] == X:
        flag = True

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    n = int(input())
    s = list()
    t = list()

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

idx = S.index(x)
played = T[idx+1:]
time = sum(played)
print(time)

Submission status: Accepted

Solution code:
N = int(input())
cusum = {}
_sum = 0
for i in range(N):
    title, t = input().rstrip().split()
    _sum += int(t)
    cusum[title] = _sum
title = input().rstrip()
print(_sum - cusum[title])

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

for j in range(N):
    if S[j] == X:
        k = j
        break

if j < N-1:
    print(sum(T[j+1:N]))
else:
    print(0)

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

Submission status: Accepted

Solution code:
n=int(input())
ans=0
l1=[]
l2=[]
for i in range(n):
    li = input().split()
    l1.append(li[0])
    l2.append(int(li[1]))
x=input()
for i in range(n):
    if l1[n-i-1]==x:
        break
    else:
        ans+=l2[n-i-1]
print(ans)

Submission status: Accepted

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

res = 0
flg = False
for s, t in st:
    if(flg): res += int(t)
    if(s == x): flg = True
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
s = []
t = []
for _ in range(n):
    si, ti = stdin.readline().split(" ")
    s.append(si)
    t.append(int(ti))
x = ns()
index = s.index(x)
ans = sum(t[index+1:])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = []
for _ in range(n):
    s,t = input().split()
    tt = int(t)
    d.append([s,tt])
x = input()
ans = 0
flag = False
for a in d:
    if flag:
        ans += a[1]
    elif a[0] == x:
        flag = True
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))
X=input()
flag=0
ans=0
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())
ST=[list(input().split()) for _ in range(N)]
X=input()
ind=0
for i in range(N):
    if ST[i][0]==X:
        ind=i+1
        break
ST=ST[ind:]
ans=0
for st in ST:
    ans+=int(st[1])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
music = [list(input().split()) for _ in range(N)]
X = input()
X_after = False
ans = 0
for i in range(N):
    if X_after:
        ans += int(music[i][1])
    elif X == music[i][0]:
        X_after = True
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
T=[]
M=[]
for i in range(N):
    t,m=input().split()
    M.append(int(m))
    T.append(t)
X=input()
a=T.index(X)
print(sum(M[a+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()

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

Submission status: Accepted

Solution code:
N = int(input())

SList = []
TList = []
for i in range(0, N):
    S, T = input().split()
    SList.append(S)
    TList.append(int(T))

X = input()

INDEX = SList.index(X)

result = 0
for i in range(INDEX + 1, N):
    result += TList[i]

print(result)

Submission status: Accepted

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

ans = 0
for s,t in ST:
  ans += t
  if s == X:
    ans = 0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
titles = []
times = []
for i in range(n):
    s, t = input().split()
    titles.append(s)
    times.append(int(t))
x = input()
ind = titles.index(x)
print(sum(times[ind+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()

flag = False
ans = 0

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

print(ans)

Submission status: Accepted

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

x = input()
a = s.index(x)

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

Submission status: Accepted

Solution code:
N = int(input())

play_list = []

for _ in range(N):
    s, t = map(str, input().split())
    play_list.append((s, int(t)))

sleep = input()

sleeped = False

ans = 0

for tup in play_list:
    s = tup[0]
    t = tup[1]
    if sleeped:
        ans += t
    if sleep == s:
        sleeped = True

print(ans)

Submission status: Accepted

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

for _ in range(N):
    si, ti = input().split()
    s.append(si)
    t.append(int(ti))

X = input()
ans = 0
flag = False

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

print(ans)

Submission status: Accepted

Solution code:


def main():
    N=int(input())
    name=[]
    time=[]
    for i in range(N):
        key, t =[i for i in input().split()]
        name +=[key]
        time +=[int(t)]

    X = input()
    ind = name.index(X)
    print(sum(time[ind+1:]))

main()

Submission status: Accepted

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

ind = S.index(X)
if ind < n-1:
    ans = sum(T[ind+1:])
if ind == n-1:
    ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

i = s_L.index(x)
print(sum(t_L[i+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()

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

Submission status: Accepted

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

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

X = input()

ans = 0
flag = False
for i, name in enumerate(S):
    if X == name:
        flag = True
        continue
    
    if flag:
        ans += T[i]

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


f=False
count=0

for i in range(n):

  if f:
    count+=t[i]
  if s[i]==x:
    f=True

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

X = str(input())

flag = False
Sum = 0

for i in range(N):

    if flag:
        Sum += t[i]
    elif s[i] == X:
        flag = True

print(Sum)

Submission status: Accepted

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

start = False
ans = 0
for i in range(N):
    if start:
        ans += int(st[i][1])
    if X == st[i][0] and not(start):
        start = True

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()
for idx, s in enumerate(ss):
    if s == X:
        last = idx
    
print(sum(ts[last+1:]))

Submission status: Accepted

Solution code:
N = int(input())
playlist = []
for i in range(N):
  playlist.append([x for x in input().split()])
M = input()
ans = 0
sleep = 0
for i in range(N):
  if sleep == 0:
    if playlist[i][0] == M:
      sleep = 1
  else:
    ans += int(playlist[i][1])
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=[input().split() for i in range(n)]
x=input()
kyo=0
ans=0

for i in range(n):
  if kyo!=0:
    ans+=int(s[i][1])
  if x==s[i][0]:
    kyo=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
T=[]
for i in range(N):
  temp=list(input().split())
  S.append(temp[0])
  T.append(int(temp[1]))
s=input()

ans=0
flag=False
for i in range(N):
  if flag:
    ans+=T[i]
  if s==S[i]:
    flag=True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

mymusic = []
mytime = []

for n in range(N):
    m, t = map(str,input().split())
    mymusic += [m]
    mytime += [int(t)]
    
music = input()

myindex = mymusic.index(music)

print(sum(mytime[myindex+1:]))

Submission status: Accepted

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

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

print(zenbu-minus)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())
liim = lambda: list(map(int, input().rstrip().split()))

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

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






if __name__ == "__main__":
    resolve()

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

for i, s in enumerate(S):
    if s == X:
        a = i

ans = sum(T[a + 1:])

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=0
sleep=False
for s,t in zip(S,T):
    ans+=t if sleep else 0
    if s==X:
        sleep=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)
partial_sum = 0
for s, t in zip(S, T):
    partial_sum += t
    if s == X:
        break
print(ans - partial_sum)

Submission status: Accepted

Solution code:
N = int(input())
s = ["" for i in range(N)]
t = ["" for i in range(N)]
for i in range(N):
    s[i], t[i] = map(str, input().split())
    t[i] = int(t[i])
X = str(input())
for i in range(N-1):
    if s[i] == X:
        print(sum(t[i+1:]))
        exit()
print(0)

Submission status: Accepted

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

sleep = False
total = 0
for s, t in zip(S, T):
    if s == X:
        sleep = True
        continue
    elif sleep:
        total += t
print(total)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
S=[]
T=[]

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = []
t = []
for i in range(N):
    si, ti = input().split()
    ti = int(ti)
    s.append(si)
    t.append(ti)
X = input()
ans = 0
for i in range(s.index(X)+1):
    ans += t[i]
print(sum(t) - ans)

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for _ in range(N):
  a,b=map(str,input().split())
  L.append([a, int(b)])
X=str(input())

count=0
know=0
for i in range(N):
  if know==1:
    count+=L[i][1]
  elif L[i][0]==X:
    know=1
    
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def main():
    N = int(input())
    musics = [input().split() for _ in range(N)]
    X = input()

    count_flag = False
    time = 0
    for i, m in enumerate(musics):
        if count_flag:
            time += int(m[1])
        if m[0] == X:
            count_flag = True

    print(time)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

flag=0;ans=0
for st in ST:
  s=st[0]
  t=int(st[1])
  
  if flag==1:
    ans+=t
  if X==s:
    flag=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
NT = []
for i in range(N):
    n,t = input().split()
    t = int(t)
    
    NT.append([n,t])
X = input()
flag = False
ans = 0
for a,b in NT:
    if flag:
        ans += b
    if a == X:
        flag = True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ST = []
for _ in range(N):
    s, t = input().split()
    ST.append((s, int(t)))
X = input()
ans = 0
sleep = False
for s, t in ST:
    if sleep: ans+=t
    if s==X: sleep=True
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

sm = 0
al = 0
d = {}

for i in range(n):
    s, t = input().split()
    t = int(t)
    al += t
    sm += t
    d[s] = sm

x = input()

print(al-d[x])

Submission status: Accepted

Solution code:
N = int(input())
d = {}
S = []
for i in range(N):
    s,t = map(str,input().split())
    d[s] = i
    r = int(t)
    S.append(r)
X = input()
x = d[X]
ans = 0
for i in range(x+1):
    ans += S[i]
ans = sum(S) - ans
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 1
for i in range(n):
    if l[i][0] == x:
        cnt = i+1
ans = 0

for i in range(cnt,n):
    ans += int(l[i][1])

print(ans)

Submission status: Accepted

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

X = input()

re = 0
for i in range(N):
    if Na[i]==X:
        re += T[i]
        break
    re += T[i]

print(sum(T)-re)

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()

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

Submission status: Accepted

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

k = 0
for i in range(n):
    s, t = st[i]
    if s == x:
        k = i
ans = 0
for i in range(k + 1, n):
    s, t = st[i]
    ans += int(t)

print(ans)

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n=int(input())
    s=[]
    t=[]
    for i in range(n):
        a,b=input().split()
        b=int(b)
        s.append(a)
        t.append(b)
    x=input()
    ind=s.index(x)
    print(sum(t)-sum(t[0:ind+1]))



if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
play_list = []
for _ in range(n):
    title, time = input().split()
    play_list.append((title, int(time)))
x = input()

sleep = 0
is_sleep = False
for title, time in play_list:
    if is_sleep:
        sleep += time
    else:
        is_sleep = title == x

print(sleep)

Submission status: Accepted

Solution code:
N = int(input())
s = [list(map(str, input().split())) for _ in range(N)]
X = input()
ans = 0
sleepf = False
for i in range(N):
    if sleepf == False:
        if s[i][0] == X:
            sleepf = True
            continue

    if sleepf:
        ans += int(s[i][1])

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())

s = []
t = []
for i in range(n):
    ss,tt = [i for i in readline().split()]
    s.append(ss)
    t.append(int(tt))
#b = tuple(int(i) for i in readline().split())
x = input()

from itertools import accumulate
t = list(accumulate(t))

i = s.index(x)

print(t[-1]-t[i])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    titles = []
    times = []
    for i in range(N):
        title, s_time = input().split()
        time = int(s_time)
        titles.append(title)
        times.append(time)
    target = input()
    started = False
    total = 0
    for i in range(N):
        if started:
            total += times[i]
        if titles[i] == target:
            started = True

    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
ST = []
D = {}
for i in range(N):
    s, t = input().split()
    t = int(t)
    ST.append((s, t))
    D[s] = i

X = input()
idx = D[X]
ans = 0
for i in range(idx+1, N):
    ans += ST[i][1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
from collections import defaultdict
dic = defaultdict(int)
ans = 0
flag = 0
l = []
for _ in range(n):
   s,t = map(str,input().split())
   l.append((s,t))


x = input()


for s,t in l:
   if flag:
      ans += int(t)
   if s == x:
      flag = 1
   
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

st = []
for i in range(N):
    a, b = input().split()
    st.append([a, int(b)])
X = input()

r = 0
flag = False
for i, sti in enumerate(st):
    s = sti[0]
    t = sti[1]
    if s == X:
        flag = True
    else:
        if flag:
            r += t
print(r)

Submission status: Accepted

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

    if f:
        ans += int(t)
    if s == x:
        f = 1
print(ans)

Submission status: Accepted

Solution code:
def solve(n, s_list, t_list, x):
    k = s_list.index(x)
    res = 0
    for i in range(k + 1, n):
        res += t_list[i]
    return res


def main():
    n = int(input())
    s_list = []
    t_list = []
    for _ in range(n):
        s, t_s = input().split()
        s_list.append(s)
        t_list.append(int(t_s))
    x = input()
    res = solve(n, s_list, t_list, x)
    print(res)


def test():
    assert solve(3, ["dwango", "sixth", "prelims"], [2, 5, 25], "dwango") == 30
    assert solve(1, ["abcde"], [1000], "abcde") == 0


if __name__ == "__main__":
    test()
    main()

Submission status: Accepted

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

x = input()
count = 0
counting = False
for i in range(n):
    if counting:
        count += songs[i][1]
    if songs[i][0] == x:
        counting = True
print(count)

Submission status: Accepted

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

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

index=-1
ans=0
for i in range(N):
    if index!=-1:
        ans+=int(t[i])
    if X==s[i]:
        index=i
print(ans)

Submission status: Accepted

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

ans = 0
sleeping = False
for title, time_str in play_list:
  if sleeping:
    ans += int(time_str)
  if title == x:
    sleeping = True


print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
b=[]
for i in range(n):
    c,d=input().split()
    a.append(c)
    b.append(int(d))
s=input()
q=a.index(s)
res=0
# print(q)
# print(a,s)
for i in range(n-q-1):
    res+=b[q+1+i]
print(res)

Submission status: Accepted

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

X = input()

ans = 0

flag = False
for s, t in zip(S, T):
    if flag:
        ans += t
    if s == X:
        flag = True

print(ans)

Submission status: Accepted

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

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

num = s.index(X) + 1

if N > num :
  print(sum(t[num:]))
else :
  print(0)

Submission status: Accepted

Solution code:
n = int(input())
st_lis = []
for i in range(n):
    s, t = input().split()
    st_lis.append([s, int(t)])
x = input()
cnt = 0
for s, t in st_lis:
    if s == x:
        cnt = 0
    else:
        cnt += t
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

s,t = [],[]
for _ in range(n):
    a,b = (i for i in 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())
S = []
T = []
for i in range(n):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
x = input()

idx = S.index(x)

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())

pl=[]
num=[]
for _ in range(N):
    temp=list(input().split())
    pl.append(temp[0])
    num.append(temp[1])

num=list(map(int,num))

start=int(pl.index(input()))
print(sum(num[start+1:]))

Submission status: Accepted

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

x = input()
ans = 0
p = 0
for i in ls:
    if p == 1:
        ans += int(i[1])
    if i[0]==x:
        p = 1
        
print(ans)

Submission status: Accepted

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

last = input()

trigger = 0
count = 0
for i in kyoku:
    if trigger == 1:
        count += int(i[1])

    elif i[0] == last:
        trigger = 1

print(count)

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
s=[]
t=[]
for i in range(N):
  x, y=input().split()
  s.append(x)
  t.append(int(y))
  
X=input()

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

Submission status: Accepted

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