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:
def solve():
    N = int(input())
    s = []
    t = []
    for i in range(N):
        tmps, tmpt = input().split()
        tmpt = int(tmpt)
        s.append(tmps)
        t.append(tmpt)
    
    X = input()

    sleepi = 0
    for i in range(N):
        if X == s[i]:
            sleepi = i
    
    ans = sum(t[sleepi+1:])


    print(ans)

if __name__ == '__main__':
    solve()

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()
a = 0
for i in range(S.index(X)+1, N):
    a += T[i]
print(a)

Submission status: Accepted

Solution code:
n = int(input())

title = []
time = []

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

x = input()

flg = 0
cnt = 0
for i in range(n):
    if flg==0 and title[i] != x:
        continue
    elif flg==1:
        cnt += time[i]
    elif flg==0 and title[i] == x:
        flg = 1
print(cnt)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LS() for _ in range(n)]
  x=S()

  ans=0
  f=False
  for a,b in l:
    if f:
      ans+=int(b)
    if a==x:
      f=True

  return ans

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
songs = []
for i in range(N):
    s, t = map(str, input().split())
    songs.append((s, int(t)))
X = input().strip()
ans = 0
sleep = False
for s, t in songs:
    if sleep:
        ans += t
    if s == X:
        sleep = True
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()
ans=0
for i in range(n):
    if x==s[i]:
        ans=i
        break
print(sum(t[i+1:]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    st = tuple(input().split() for _ in range(N))
    X = input()
    f = False
    ans = 0
    for s, t in st:
        if f:
            ans += int(t)
        if X==s:
            f = True
    print(ans)




main()

Submission status: Accepted

Solution code:
#A
N = int(input())
ST = []
for i in range(N):
    s,t = input().split()
    ST.append([str(s),int(t)])
    
L = str(input())
rest = 0
ans = 0
flag = 0
for st in ST:
    s,t = st
    ans+=t
    if flag == 1:
        rest+=t
        
    if s == L:
        flag = 1
        
    
        
print(rest)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t_ = [x for x in input().strip().split()]
    t[i] = int(t_)
m = input().strip()
print(sum(t[s.index(m)+1:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    st = [input().split() for _ in range(n)]
    st = [(i,int(j)) for i,j in st]
    x = input()
    f = False
    ans = 0
    for i,j in st:
        if f:
            ans += j
        elif x == i:
            f = True
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(i):
    return i

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

sgn=0
ans=0
for i in range(n):
    if sgn==1: ans+=t[i]
    elif s[i]==x: sgn=1
print(ans)

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

count = 0
asleep = False
for i in range(n):
    if asleep:
        count += t[i]
    if s[i] == x:
        asleep = True

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for _ in range(n):
	ts,tt=map(str,input().split())
	s.append(ts)
	t.append(int(tt))
x = input()
cond = 0
ans = 0
for i in range(n):
	if s[i] == x:
		cond = 1
		continue
	if cond == 0:
		continue
	ans += t[i]

print(ans)

Submission status: Accepted

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

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

index = s.index(X)

answer = t[-1] - t[index]
print(answer)

Submission status: Accepted

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

X = input()

for i in range(N):
    if s_l[i]==X:
        break
ans = 0
for j in range(i+1,N):
    ans+=t_l[j]

print(ans)

Submission status: Accepted

Solution code:
N = int(input().strip())
plist = [input().strip().split(' ') for _ in range(N)]
ans = 0

x = input().strip()
found = False
for name,time in plist:
  if found:
    ans += int(time)
  else:
    if name == x:
      found = 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()
id = S.index(X)
ans = 0
for i in range(id+1,N):
    ans += T[i]
print(ans)

Submission status: Accepted

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

title=input()
flag=0
out=0
for i in arr:
    if flag==1:
        out+=int(i[1])
    if i[0]==title:
        flag=1 

print(out)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
f={}
s=0
for tc in range(int(input())):
    a=input().split()
    f[a[0]]=int(a[1])+s
    s+=int(a[1])
ss=input()
print(s-f[ss])

Submission status: Accepted

Solution code:
N = int(input())
lst = [input().split() for _ in range(N)]
X = input()
ans = 0
f = 0
for m in lst:
    if not f:
        if m[0] == X:
            f = 1
        continue    
    ans += int(m[1])
print(ans)

Submission status: Accepted

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

ind = lists.index(X) + 1
print(sum(listt[ind:]))

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())
    b = int(b)
    s[i], t[i] = a, b
k = input()

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

Submission status: Accepted

Solution code:
N = int(input())
sl, tl = [], []
for _ in range(N):
    s, t = input().split()
    sl.append(s)
    tl.append(int(t))
X = input()
ind = sl.index(X)
if ind == N - 1:
    print(0)
else:
    print(sum(tl[ind + 1:]))

Submission status: Accepted

Solution code:
N=int(input())
A=[]

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

X=str(input())
result=0
flg=0

for i in range(N):
    if flg==1:
        result+=A[i][1]

    if A[i][0]==X:
        flg=1

print(result)

Submission status: Accepted

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

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

ans = 0
for i in range(sub, n):
    ans += int(t[i])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = ["" for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    s_str, t_str = input().split()
    s[i] = s_str
    t[i] = int(t_str)
    
X = input()
ans = 0
count = False
for i in range(N):
    if count:
        ans += t[i]
    if s[i] == X:
        count = True
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())

s = []
t = []
for i in range(N):
    a, b = input().split()
    s.append(a)
    t.append(int(b))
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())
A=[list(input().split()) for i in range(n)]
m=input()
cnt,flag=0,0
for nam,time in A:
    if nam==m:
        flag=1
        continue
    if flag==1:
        time=int(time)
        cnt +=time
print(cnt)

Submission status: Accepted

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

awake = 0
for i in range(N):
    awake += t[i]
    if s[i] == X:
        break
    
print(total - awake)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    s = [0] * N
    t = [0] * N

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

    X = input()
    xi = 0

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

    ans = 0

    for i in range(N):
        if xi < i:
            ans += t[i]

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
title = []
time = []
for _ in range(N):
  x, y = input().split()
  title.append(x)
  time.append(int(y))

X = input()
id = title.index(X) + 1
print(sum(time[id:]))

Submission status: Accepted

Solution code:
def examA():
    N = I()
    S = [""]*N; T = [""]*N
    for i in range(N):
        S[i],T[i] = LSI()
        T[i] = int(T[i])
    X = SI()
    ans = 0
    flag = False
    for i in range(N):
        if flag:
            ans +=T[i]
        if S[i]==X:
            flag = True
    print(ans)
    return

def examB():
    return

def examC():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

Submission status: Accepted

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

t = False

c = 0

for i in s:
    if t:
        c += int(i[1])
    if i[0] == x:
        t = True

print(c)

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

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

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for z in range(N):
    a,b = input().split()
    lst.append([a, int(b)])
x = input()
idx = 0
for i in range(N):
    if lst[i][0] == x:
        idx = i
        break
s = 0
for i in range(idx+1,N):
    s += lst[i][1]
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=II()
    st=[input().split() for _ in range(n)]
    x=input()
    total=0
    flag=False
    for s,t in st:
        if flag:total+=int(t)
        if s == x: flag = True
    print(total)
main()

Submission status: Accepted

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


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    neta=False
    neteru=0
    for i in range(N):
        if neta:
            neteru+=t[i]
        if s[i]==X:
            neta=True
    print(neteru)
    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:
N = int(input())
st = [input().split() for i 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 = []
for _ in range(n):
    tmps, tmpt = map(str, input().split())
    s.append(tmps), t.append(int(tmpt))

x = input()

ans_li = []
count = False
for i in range(n):
    if count:
        ans_li.append(t[i])

    if s[i] == x:
        count = True

print(sum(ans_li))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = []
    for i in range(N):
        s, t = input().split()
        S.append([s,int(t)])
    X = input()
    ans = 0
    flag = False
    for i in range(N):
        if S[i][0] == X:
            flag = True
            continue
        if flag:
            ans += S[i][1]

    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = []
res = 0
for _ in range(N):
  s, t = input().split()
  t = int(t)
  a.append((s, t))
  res += t
s = input()[: -1]
for i in range(N):
  res -= a[i][1]
  if a[i][0] == s:
    break
print(res)

Submission status: Accepted

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

res = 0
flag = False
for i in range(n):
    s,t = st[i]
    if flag:
        res += t
    elif s==x:
        flag = True

print(res)

Submission status: Accepted

Solution code:
N = int(input())
L = [list(input().split()) for i in range(N)]
X = input()
j = 0
ans = 0
for i in range(N):
  if j != 0:
    ans += int(L[i][1])
  if L[i][0] == X:
    j = 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import accumulate

N = int(input())
title = []
time = []
for i in range(N):
    s, t = input().split()
    title.append(s)
    time.append(int(t))
time.append(0)
time = list(accumulate(time[::-1]))
X = input()
ind = title.index(X)
print(time[N-ind-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
st = [input().split() for _ in range(n)]
x = input()
flag = 0
res = 0
for i in range(n):
    if flag == 1:
        res += int(st[i][1])
    if st[i][0] == x:
        flag = 1
print(res)

Submission status: Accepted

Solution code:
def read():
    N = int(input().strip())
    S = list()
    T = list()
    for i in range(N):
        s, t = input().strip().split()
        s = str(s)
        t = int(t)
        S.append(s)
        T.append(t)
    X = str(input().strip())
    return N, S, T, X

def solve(N, S, T, X):
    start = S.index(X)
    return sum(T[start+1:])

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Accepted

Solution code:
N = int(input())
data = []

for _ in range(N):
	item = input().strip().split()
	data.append((item[0], int(item[1])))

X = input().strip()

i = 0
while X != data[i][0]:
	i += 1

i += 1
time = 0
while i < N:
	time += data[i][1]
	i += 1

print(time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

total = 0
p = 0
d = {}
for _ in range(N):
    s, t = input().split()
    t = int(t)
    total += t
    d[s] = total
print(total - d[input()])

Submission status: Accepted

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

S, T = [], []
for s, t in ST:
  S.append(s)
  T.append(int(t))
#print("S:", S)

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

Submission status: Accepted

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

    if flag:
        ans += t[i]

    if s[i]==x:
        flag = 1
print(ans)

Submission status: Accepted

Solution code:
# 2020/01/11

n=int(input())
s=[tuple(input().split()) for _ in range(n)]
w=input()

cnt=0
flag=False
for e in s:
    if flag:
        cnt+=int(e[1])
    if e[0]==w:
        flag=True
    
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
time=0
d={}
for i in range(N):
    si,ti=input().split()
    time+=int(ti)
    d[si]=time

print(time-d[input()])

Submission status: Accepted

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

ans = 0
is_sleep = False
for s, t in st:
    if is_sleep:
        ans += int(t)
    if s == X:
        is_sleep = True

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = []
T = []
for i in range(N):
    [stmp,ttmp] = list(input().split())
    S.append(stmp)
    T.append(int(ttmp))
X = input()
output = 0
flag = 0
for i in range(N):
    if flag == 1:
        output += T[i]
    if S[i]==X:
        flag += 1
print(output)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    s, t = [], []
    for _ in range(N):
        _s, _t = LS()
        _t = int(_t)
        s.append(_s)
        t.append(_t)
    X = S()
    for i, title in enumerate(s):
        if title == X:
            break
    i += 1
    cnt = 0
    for j in range(i, N):
        cnt += t[j]
    print(cnt)
main()

Submission status: Accepted

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

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

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



if __name__ == '__main__':
    main()

Submission status: Accepted

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

index = None
for i in range(N):
    if S[i] == X:
        index = i+1

ans = sum(T[index:])
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()
ans = 0
for i in range(N):
    ans += t_list[i]
    if x == s_list[i]:
        break
print(sum(t_list) -  ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
N = int(input())
cur = 0
dic = {}
for i in range(N):
    s,t = input().split()
    t = int(t)
    cur += t
    dic[s] = cur
q = input()
print(cur-dic[q])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

tar = 0

for i in range(n):
    if x == title[i]:
        tar = i
        break
ans = 0
for i in range(tar+1, n):
    ans += time[i]

print(ans)

Submission status: Accepted

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

ans = 0

f = 0
for i in range(N):
  s, t = st[i]
  if f:
    ans += int(t)
  if s == X:
    f = 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
arr1=[]
arr2=[]
for _ in range(N):
    x,y=input().split()
    arr1.append(x)
    arr2.append(int(y))
X=input()

print(sum(arr2[arr1.index(X)+1:]))

Submission status: Accepted

Solution code:
N=int(input())
M=[]
G=[]
for _ in range(N):
    a,b=input().split()
    G.append(a)
    M.append(int(b))
X=input()
flag = False
sum_=0
for i in range(N):
    if flag:
        sum_ += M[i]
    if G[i] == X:
        flag = True

print(sum_)

Submission status: Accepted

Solution code:
def main():

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

    ans = 0
    flag = False
    for s, t in a:
        if flag == True:
            ans += t
        if s == X:
            flag = True
    return ans

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ST = [list(map(str, input().split())) for _ in range(n)]
X = input()

ans = 0
flag = False
for st in ST:
    a, b = st
    b = int(b)
    if X == a:
        flag = True
        continue
    
    if flag is True:
        ans += b
print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())
playlist = []
playtime = []
for _ in range(n):
    s, t = input().split()
    playlist.append(s)
    playtime.append(int(t))
x = input()
i = playlist.index(x)
print(sum(playtime[i + 1:]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


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


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, T, X):
    i = S.index(X)
    return sum(T[i+1:])


def main():
    N = read_int()
    S, T = [], []
    for _ in range(N):
        s, t = read_str_n()
        t = int(t)
        S.append(s)
        T.append(t)
    X = read_str()
    print(slv(N, S, T, X))


if __name__ == '__main__':
    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 = input()

f = 0
ans = 0
for i in range(N):
    if f == 0 and S[i] == X:
        f = 1
    elif f == 1:
        ans += T[i]
        
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
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()
start = S.index(X)
ans = 0
for i in range(start+1, N):
    ans += T[i]
print(ans)

Submission status: Accepted

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

N = int(input())
P = [list(map(str, input().split())) for _ in range(N)]
S = input().rstrip()

ind = -1
for a, b in P:
    if a == S:
        ind = 0
    elif ind != -1:
        ind += int(b)

print(ind)