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())
mlst = []
ilst = []
for i in range(n):
    tmp = []
    a,b = input().split()
    c = int(b)
    tmp.append(a)
    tmp.append(c)
    mlst.append(tmp)
    ilst.append(a)
#print(mlst)
#print(ilst)
name = input()
idx = ilst.index(name)

total = 0
for j in range(idx+1, n):
    total += mlst[j][1]
print(total)

Submission status: Accepted

Solution code:
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

n = INT()
tune = {}
times = []
for i in range(n):
    title, time = input().split()
    time = int(time)
    tune[title] = i
    times.append(time)
x = input()
ind = tune[x]
print(sum(times[ind+1:]))

Submission status: Accepted

Solution code:
n=int(input())
listm=[]
listt=[]
ans=0
for i in range(n):
    m,t=input().split()
    listm.append(m)
    listt.append(t)
lastm=input()
index=listm.index(lastm)
for i in range((index+1),n):
    ans+=int(listt[i])
print(ans)

Submission status: Accepted

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

for i,st in enumerate(sT):
    T[i] = int(st)

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

Submission status: Accepted

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

time_t = 0
for k, l in st:
    time_t += int(l)

time = 0
for i, j in st:
    if i == x:
        time += int(j)
        break
    else:
        time += int(j)

print(time_t - time)

Submission status: Accepted

Solution code:
N=int(input())
s_ts=[]
for i in range(N):
    inp=input().split()
    s_ts.append((str(inp[0]),int(inp[1])))

X=str(input())

S=0
is_passed=False
for s_t in s_ts:
    s=s_t[0]
    t=s_t[1]

    if is_passed:
        S+=t
    
    if s == X:
        is_passed=True

print(S)

Submission status: Accepted

Solution code:
N = int(input())

ST = list()

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

X = input()

result = None

for s, t in ST:
    t = int(t)
    if result is None:
        if s == X:
            result = 0
    else:
        result += t

print(result)

Submission status: Accepted

Solution code:
import bisect
import itertools


N = int(input())
st = [input().split() for _ in range(N)]
s, t = list(zip(*st))
t = [int(i) for i in t]
X = input()

t_cumsum = list(itertools.accumulate(t))
sleep = s.index(X)
ans = t_cumsum[-1] - t_cumsum[sleep]
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()

switch = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
kyoku = [list(map(str,input().split())) for x in range(N)]
S = input()
Sum=0
i=0
for x in range(0,N):
    if kyoku[x][0]==S:
        AA=x
for x in range(AA+1,N):
    Sum=Sum+int(kyoku[x][1])
print(Sum)

Submission status: Accepted

Solution code:
N = int(input())

name = []
time = []
for i in range(N):
    a,b=input().split()
    name.append(a)
    time.append(int(b))
X = input()
for i in range(N):
    if X == name[i]:
        break
ans = sum(time[i+1:])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
L = []
for _ in range(N) :
  L.append(list(map(str, input().split())))
X = str(input())
#print (L)

sum = 0
Xt = 0
for i in range(N) :
  if Xt == 1 :
    sum += int(L[i][1])
  if L[i][0] == X :
    Xt = 1
print (sum)

Submission status: Accepted

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

X = str(input())
X_index = s_list.index(X) + 1

result = 0
for i in range(X_index, N):
    result += t_list[i]

print(result)

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

sum = 0

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

print(sum)

Submission status: Accepted

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

    sl = 0
    res = 0
    for i in s:
        if i[0] == x:
            sl = 1
            continue
        if sl == 1:
            res += int(i[1])
            continue
    print(res)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# DDCC A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(str, input().split()))
n=ni()
ST=[]
for i in range(n):
    st=nl()
    ST.append(st)
x=si()

idx=0
for i,sstt in enumerate(ST):
    if sstt[0]==x:
        idx=i
    ST[i][1]=int(ST[i][1])

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

Submission status: Accepted

Solution code:
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = num()
S,T = [],[]
for _ in range(N):
    si,ti = input().split()
    ti = int (ti)
    S.append(si)
    T.append(ti)
X = input()
idx = S.index(X)
print(sum(T[idx+1:]))

Submission status: Accepted

Solution code:
N = int(input())
l = []
ans = 0
flag = 0
for i in range(N):
  l.append(input().split())
x = str(input())
for i in l:
  if flag == 1:
    ans += int(i[1])
  if i[0] == x:
    flag = 1
print(ans)

Submission status: Accepted

Solution code:

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

    s.append(a)
    t.append(int(b))

x=str(input())
count=0
for i in range(n):
    if s[i]==x:
        count=i
        break
ans=0
count+=1

for i in range(count,n):
    ans+=t[i]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

X = input()


idx = s_list.index(X)
ans = sum(t_list[idx+1:])
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 = str(input())

for i in range(N):
    if S[i] == X:
        sleep = i
time = 0

for i in range(sleep+1,N):
    time += T[i]

print(time)

Submission status: Accepted

Solution code:
n = int(input())

AB = [[i for i in input().split()] for _ in range(n)]
for i in range(n):
    AB[i][1] = int(AB[i][1])
X = input()
flag = False
ans = 0
for i in range(n):
    if flag:
        ans += AB[i][1]
    if AB[i][0] == X:
        flag=True
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ST = [list(input().split()) for _ in range(N)]
X = input()
for i,st in enumerate(ST):
  s=st[0]
  if X==s:
    r = i
    break
    
if r==(N-1):
  print(0)
  
else:
  ST=ST[r+1::]
  ans = 0
  for st in ST:
    ans += int(st[1])
    
  print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = []
for i in range(n):
    a.append([str(i) for i in input().split()])
x = str(input())

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

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())

s = ["" for i in range(N)]
t = [0 for i in range(N)]

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

X = input()

index = 0

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
X = []
music = []
time = []
for i in range(N):
  X.append(list(map(str,input().split())))
  music.append(X[i][0])
  time.append(int(X[i][1]))
S = input()

sleep_index = music.index(S)
print(sum(time[sleep_index+1:]))

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

Submission status: Accepted

Solution code:
N = int(input())
play = [input().split() for i in range(N)]
X = input()
music = [play[i][0] for i in range(N)] 
index = music.index(X)
zikan = [int(play[i][1]) for i in range(index + 1, N)]
print(sum(zikan))

Submission status: Accepted

Solution code:
from collections import OrderedDict
od = OrderedDict()

n = int(input())
for num in range(n):
  a, b = input().split()
  od[a] = b
  
s = input()

for k, v in od.items():
  if k != s:
    del od[k]
  else:
    del od[k]
    break

count = 0
for k, v in od.items():
  count += int(v)
  
print(count)

Submission status: Accepted

Solution code:
N = int(input())
li = []
for i in range(N):
  st = input().split()
  li.append([str(st[0]), int(st[1])])
X = str(input())
#print(N, X, li)

ans = 0
flag = 0

for i in range(len(li)):
  if flag == 1:
    ans += li[i][1]
  if X == li[i][0]:
    flag = 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[list(input().split()) for _ in range(n)]
b=[a[i][0] for i in range(n)]
c=[int(a[i][1]) for i in range(n)]
print(sum(c[b.index(input())+1:]))

Submission status: Accepted

Solution code:
all = int(input())
a = []
c = []
ans = []
f = False
for i in range(all):
    b = input().split()
    c.append(b[0])
    a.append(int(b[1]))
sleep = input()
for i in range(all):
    if not f:
        if c[i] == sleep:
            f = True
        continue
    else:
        ans.append(a[i])
ans = sum(ans)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li=[[0 for i in range(2)] for j in range(n)]
ans=0
for i in range(n):
    s,t=map(str,input().split())
    li[i][0]=s
    li[i][1]=t
    ans+=int(t)
x=str(input())
for j in range(n):
    if li[j][0]!=x:
        ans-=int(li[j][1])
    else:
        ans-=int(li[j][1])
        break
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        st = []
        for _ in range(N):
            tmp = list(input().split())
            st.append((tmp[0].rstrip(), int(tmp[1])))
        X = input().rstrip()

        f = False
        ans = 0
        for i in range(N):
            name, time = st[i]
            if f:
                ans += time
            if name == X:
                f = True

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
N = int(input())
S = [""] * N
T = [""] * N
Alltime = 0
for i in range(N):
    S[i], T[i] = input().split()
    T[i] = int(T[i])
    Alltime += T[i]
X = (input())
Waketime = 0
for i in range(N):
    Waketime += T[i]
    if S[i] == X:
        break
print(Alltime - Waketime)

Submission status: Accepted

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

idx = 0
ans = 0

for i in range(n):
    if ls[i][0] == x:
        idx = i
        break

for j in range(idx + 1, n):
    ans += int(ls[j][1])

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
  a,b = map(str,input().split())
  s.append(a)
  t.append(int(b))
x = str(input())
w = False
ans = 0
for j in range(n):
  if w:
    ans+=t[j]
  if s[j] == x:
    w = True
print(ans)

Submission status: Accepted

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

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

sleep_timing_music = input()
flag = False
sleep_time = 0

for j in music_list:
    if flag == True:
        sleep_time += int(j[1])
        
    if j[0] == sleep_timing_music:
        flag = True

print(sleep_time)

Submission status: Accepted

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

Submission status: Accepted

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

X = input()

time = 0
sleeping = False
for s, t in s_t:
    if sleeping:
        time += t
    if s == X:
        sleeping = True

print(time)

Submission status: Accepted

Solution code:
n = int(input())
songs = []
for i in range(n):
    a,b = input().split()
    songs.append([a,b])
sleep = input()
s =0
r =0
for a,b in songs:
    if r ==1:
        s+=int(b)
    if a == sleep:
        r=1
print(s)

Submission status: Accepted

Solution code:
n = int(input())
music = [list(input().split()) for i in range(n)]
x = input()
#print(music)
ans=0
for i in range(n):
    if x in music[i]:
        ans = i
music = music[ans+1:]
#print(music)
total = 0
for j in music:
    total += int(j[1])
print(total)

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(s, t, x)

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 11 19:28:23 2020

@author: masat
"""

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

k = s_list.index(X)

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

print(time)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    tmps, tmpt = input().split()
    s.append(tmps)
    t.append(int(tmpt))
target = input()
sleep = s.index(target)
sum = 0
for i in range(sleep + 1, n):
    sum += t[i]
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

slist = []
tlist = []

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

X = input()

ind = slist.index(X)
if ind == len(tlist) - 1:
    print(0)
else:
    itlist = tlist[(ind+1):]
    print(sum(itlist))

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = []
t = []
for i in range(n):
    ss,tt = input().split()
    s.append(ss)
    t.append(int(tt))
x = input().strip()
onn = False
sm = 0
for i in range(n):
    if onn:
        sm += t[i]
    elif s[i]==x:
        onn = True
print(sm)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

x = input()

time = 0
for i in range(s.index(x)+1, len(t)):
    time += t[i]

print(time)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

songs = list()
times = {}
for i in range(0, N):
    # 2つの入力を空白で分割し、数値化
    s, t = input().split()

    songs.append(s)
    times[s] = int(t)

# そのまま入力文字列の入力
X = input()

sleeps = False
ans = 0
for song in songs:
    if song == X:
        sleeps = True
        continue

    if sleeps:
       ans += times[song]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
musics,minutes=[],[]

for i in range(N):
    music,minute = list(map(str, input().split()))
    musics.append(music)
    minutes.append(int(minute))

X = str(input())

Xidx=musics.index(X)
print(sum(minutes[Xidx+1:]))

Submission status: Accepted

Solution code:
# import numpy as np
# import math
import sys
# input = sys.stdin.readline().rstrip


def main():
    N = int(input())

    s = []
    t = []

    for i in range(N):
        temp = list(map(str,input().split()))
        s.append(temp[0])
        t.append(int(temp[1]))

    X = input()

    isSlept = False
    res = 0

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

    print(res)



main()

Submission status: Accepted

Solution code:
n = int(input())
li = [list(map(str, input().split()))for i in range(n)]
x = input()
ans = 0
after = False
for i, j in li:
  if after:
    ans += int(j)
  elif i == x:
    after = True
  else:
    continue
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
P = []
for i in range(N):
  s, t = input().split()
  S = [s, int(t)]
  if 0 < i:
    S[1] += P[-1][1]
  P.append(S)
D = {}
for s, t in P:
  D[s] = t
print(P[-1][1] - D[input()])

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [""]*n
t = [0]*n
for i in range(n):
    l = list(input().split())
    s[i] = l[0]
    t[i] = int(l[1])
x = input()
time_count = 0
for i in range(n):
    time_count += t[i]
    if s[i] == x:
        break
print(sum(t) - time_count)

Submission status: Accepted

Solution code:
n = int(input())
ls = []
lt = []

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

x = input()

ct = 0
for i in range(ls.index(x)+1, len(lt)):
    ct += lt[i]
    
print(ct)

Submission status: Accepted

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

x = input()

def solve():
    for i in range(n):
        if ls[i] == x:
            return sum(lt[i+1:])

print(solve())

Submission status: Accepted

Solution code:
N = int(input())

s = []
t = []

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

X = input()

ind = s.index(X)


if ind == len(s):
    print(0)
else:
    print(sum(t[ind + 1 : ]))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

M = int(input())
PList = [""] * M
Num = [0] * M

for i in range(M):
    s, t = input().split()
    t = int(t)
    PList[i] = s
    Num[i] = t

X = input()
x = PList.index(X)

print(sum(Num[x+1:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = [list(map(str, input().split())) for i in range(N)]
S = input()
i = 0
while A[i][0] != S:
  i += 1
print(sum(int(A[j][1]) for j in range(i + 1, N)))

Submission status: Accepted

Solution code:
#A
N = int(input())
playlist = []
timelist = []
for _ in range(N):
    s, t = input().split()
    playlist.append(s)
    timelist.append(int(t))

X = input()
last_played = playlist.index(X)

try:
    print(sum(timelist[last_played+1:]))
except:
    print(0)

Submission status: Accepted

Solution code:


def main():
    N = int(input())
    playlist = []
    for _ in range(N):
        tmp = input().split(' ')
        tmp[1] = int(tmp[1])
        playlist.append(tmp)

    X = input()

    titles = [x[0] for x in playlist]
    time = [x[1] for x in playlist]

    i = titles.index(X)
    if i + 1 >= N:
        print(0)
    else:
        print(sum(time[i + 1:]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np


n = int(input())
st = [tuple(input().split()) for i in range(n)]
x = input()
T = []

for i, (s, t) in enumerate(st):
    T.append(int(t))

    if s == x:
        fin = i

T = np.array(T)

ans = np.sum(T[fin+1:])

print(ans)

Submission status: Accepted

Solution code:
import sys

N=input()
st=[ sys.stdin.readline().split() for _ in range(N) ]
X=raw_input()

ans=float("-inf")
for s,t in st:
    if s==X:
        ans=0
    else:
        ans+=int(t)

print ans

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N = I()
    T = []
    S = []
    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[i] == X:
            for j in range(i+1,N):
                ans += T[j]
            print(ans)
            return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(input())
s = []
t = []

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

x = input()

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

Submission status: Accepted

Solution code:
n = int(input())

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

st = input()
print(num - d[st])

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N: int, s: "List[str]", t: "List[int]", X: str):

    ans = 0
    f = 0
    for i in range(N):

        if f == 1:
            ans += t[i]
        if s[i] == X:
            f = 1
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
n = int(input())
ls_st = [list(input().split()) for i in range(n)]
x = str(input())
ans = 0
for i in range(n):
    ls_st[i][1] = int(ls_st[i][1])
# print(ls_st.index(x))
# print(ls_st)
# arr = [["A", "B", "C"], ["D", "E", "F"], ["G", "H", "I"]]

for y, row in enumerate(ls_st):
    try:
        pos = (y, row.index(x))
        break
    except ValueError:
        pass
for i in range(pos[0]+1,n):
    ans += ls_st[i][1]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = []
for i in range(n):
  A.append(list(input().split()))
x = input()
b = 0
for i in range(n):
  if A[i][0] == x:
    b = i+1
ans = 0
for j in range(b, n):
  ans += int(A[j][1])
print(ans)

Submission status: Accepted

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

flg=-1
for i in range(n):
  if x==sl[i]:
    flg=i
    break

sum=0
for i in range(flg+1,n):
  sum+=tl[i]
print(sum)

Submission status: Accepted

Solution code:
# A - Falling Asleep : 2020/01/11
N = int(input())
s = [0 for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    l = input().split()
    s[i] = str(l[0])
    t[i] = int(l[1])
X = str(input())
for i in range(N):
    if s[i] == X:
        idx = i + 1
        break
time = 0
for j in range(idx, N):
    time = time + t[j]
print(time)

Submission status: Accepted

Solution code:
n = int(input())
st = [list(map(str, input().split())) for _ in range(n)]
totaltime = [0]*(n+1)
for i in range(n):
  totaltime[n-1-i] = totaltime[n-i]+int(st[n-1-i][1])
x = input()

k = 0
while x != st[k][0]:
  k+=1
print(totaltime[k+1])

Submission status: Accepted

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

N = int(input())
M = [input().split() for i in range(N)]
X = input()

def solver(M,X):
    result = 0
    flag = 0
    for m in M:
        if flag == 1:
            result += int(m[1])
        if m[0]==X:
            flag = 1
    return result

print(solver(M,X))

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    sc = Scan()
    N = sc.intarr()[0]
    T = []
    S = []
    for i in range(N):
        title, sec = sc.strarr()
        S.append(int(sec))
        T.append(title)
    X = sc.strarr()[0]
    idx = -1
    ans = 0
    for i in range(N):
        if idx != -1:
            ans += S[i]
        if T[i] == X:
            idx = i

    print(ans)


def perm(p):
    if len(p) == 1:
        return [p]
    else:
        s = []
        for i in range(len(p)):
            q = p[i]
            r = perm(p[:i]+p[i+1:])
            for t in r:
                s.append([q] + t)
        return s


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()

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

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

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

C = [0] * (N+1)
for i in range(N):
    C[i+1] = C[i] + T[i]

print(C[N] - C[S.index(x)+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()
X = input()
print(sum(list(map(int,t[s.index(X)+1:]))))