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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):


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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n = int(input())

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:]))

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):

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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):


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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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])

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

MOD = 10 ** 9 + 7

import math

import itertools



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




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

Solution (Python):
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]))

Solution (Python):

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)

Solution (Python):
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)

Solution (Python):


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

x = input()

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

i = s.index(x)

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

Solution (Python):
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()

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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


for i in range(n-q-1):
    res+=b[q+1+i]
print(res)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):


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:]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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):]))

Solution (Python):
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]))

Solution (Python):
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()

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

for i in range(n):
    if x == lst1[i][0]:
        theindex = i
        break
ans = 0
for i in range(theindex+1,n):
    ans += int(lst1[i][1])

print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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


print(main())

Solution (Python):
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])

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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()

Solution (Python):

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)

Solution (Python):
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:]))

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:]))

Solution (Python):
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])