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

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

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

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

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

songs = list()
times = {}
for i in range(0, N):
    
    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)

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

Solution (Python):


import sys



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

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

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

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)

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

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

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

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

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

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

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

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

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

Solution (Python):

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)

Solution (Python):


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

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

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

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

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

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

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


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

Solution (Python):


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

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

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

Solution (Python):

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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    s = [str()] * (N)  
    t = [int()] * (N)  
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  
    solve(N, s, t, X)

if __name__ == '__main__':
    main()

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




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)

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

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

Solution (Python):

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)

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

Solution (Python):


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

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

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

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

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

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

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

Solution (Python):
import sys

n = int(sys.stdin.readline().rstrip()) 
s, t = [], []
for _ in range(n):
    si, ti = sys.stdin.readline().split()
    s.append(si); t.append(int(ti))
x = sys.stdin.readline().rstrip()

def main():
    cum_t = t[1:n] + [0]
    for i in range(n-1, 0, -1):
        cum_t[i-1] += cum_t[i]
    
    return cum_t[s.index(x)]

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

Solution (Python):
n = int(input())
st = [list(map(str, input().split())) for _ in range(n)]
x = input()
ans = 0
sleep = 0
for i in range(n):
    if sleep == 1:
        ans += int(st[i][1])
    if st[i][0] == x:
        sleep = 1
print(ans)

Solution (Python):
n=int(input())
s=[input().split() for _ in range(n)]
x=input()
ans=0
for i in range(n):
  if x==s[i][0]:
    for a in range(i+1,n):
      ans+=int(s[a][1])
    break
print(ans)

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

Solution (Python):
n = int(input())
'''
lst = {}
for i in range(n):
    s, t = map(str, input().split())
    lst[s] = int(t)
print(lst)
'''
lst = []
for i in range(n):
    s, t = map(str, input().split())
    lst.append([s, int(t)])
title = input()

for i in range(n):
    if title == lst[i][0]:
        id = i
        break

time_cnt = 0
for i in range(id+1, n):
    time_cnt+=lst[i][1]
print(time_cnt)

Solution (Python):


def main():
    n = int(input())
    s = [0] * n
    t = [0] * n
    all_time_count = 0

    for i in range(n):
        s[i],t[i] = input().split()
        t[i] = int(t[i])
        all_time_count += t[i]
    x = input()
    time_count = 0
    for i in range(n):
        time_count += t[i]
        if s[i] == x:
            break
    print(all_time_count - time_count)




if __name__ == '__main__':
    main()

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

sleep = False
time = 0
for i in range(n):
  if sleep:
    time += t[i]
  elif s[i] == x:
    sleep = True

print(time)

Solution (Python):
import numpy as np

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

    idx = S.index(X)
    cumsum = np.cumsum(np.array(T))
    time = cumsum[-1] - cumsum[idx]
    print(time)

if __name__ == "__main__":
    resolve()

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

Solution (Python):


N=int(input())
pl=[]
tl=[]
for i in range(N):
    songname,time=input().split()
    pl.append(songname)
    tl.append(int(time))
    
X=input()

ind=pl.index(X)

if ind!=N:
    print(sum(tl[ind+1:]))
else:
    print(0)

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


L = [list(map(str,input().split())) for i in range(N)]
Last = input()
flag = 0
answer  =0
for j in L:
    if flag == 1:
        answer += int(j[1])
    if j[0] == Last:
        flag = 1
print(answer)

Solution (Python):
N=int(input())
music=[['', 0] for j in range(N)]
for i in range(N):
  s, t = map(str, input().split())
  music[i][0] = s
  music[i][1] = int(t)
X = input()

count = 0
flag=False
for i in range(N):
  if flag:
    count+=music[i][1]
  if music[i][0]==X:
    flag=True
print(count)

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

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

Solution (Python):
n = int(input())
lis = []
a = 0
b = 0
for _ in range(n):
  x,y = input().split()
  a += int(y)
  lis.append((x, int(y)))
x = input()
cnt = 0
for i in range(n):
    b += lis[i][1]
    if lis[i][0] == x:
        break
print(a-b)

Solution (Python):
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=input()
num=None
for i in range(N):
  if S[i]==X:
    num=i
    break
print(sum(T[(num+1):]))

Solution (Python):

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


X=input()

for i in range(N):
    if L[i][0]==X:
        flg=i
ans=0
for i in range(flg+1,N):
    ans+=L[i][1]
print(ans)

Solution (Python):
n=int(input())
l=[]
for i in range(n):
  l.append(input().split())
last=input()
ind=0
for i in range(n):
  if l[i][0]==last:
    ind=i
sum=0    
for i in range(ind+1,n):
  sum+=int(l[i][1])
print(sum)

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

x = input()

ans = 0
isSleep = False

for _st in st:
    
    if _st[0] == x:
        isSleep = True
        continue
    
    if isSleep==True:
        ans += int(_st[1])

print(ans)

Solution (Python):
N = int(input())
ST = []
for i in range(N):
    ST.append(input().split())
    ST[i][1] = int(ST[i][1])
X = input()

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

sum = 0
for i in range(pt+1,N):
    sum += ST[i][1]

print(sum)

Solution (Python):
n = int(input())
st = []
for _ in range(n):
    a = input().split()
    a[1] = int(a[1])
    st.append(a)
x = input()

res = 0
s = False
for i in st:
    if i[0] == x:
        s = True
    elif s:
        res += i[1]

print(res)

Solution (Python):


n = int(input())
dict_name = {}
name_list = []
for i in range(0, n):
    name, t = input().split()
    dict_name[name] = int(t)
    name_list.append(name)
x = input()
flag = 0
total = 0
for i in range(0, n):
    if flag == 1:
        total += dict_name[name_list[i]]
    if name_list[i] == x:
        flag = 1
print(total)

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

names = []
minutes = []

for _ in range(0, num_input):
    name, minute = input().split()
    minute = int(minute)
    names.append(name)
    minutes.append(minute)

fall = input().strip()

i = names.index(fall)
print(sum(minutes[i+1:]))

Solution (Python):
import sys
from pprint import pprint

def solve(n, s, t, x):
    ans = 0
    slept = False
    for i in range(n):
        if slept:
            ans += t[i]
        if s[i] == x:
            slept = True
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    s = [""] * n
    t = [0] * n
    for i in range(n):
        s[i], tmp = sys.stdin.readline().strip().split(" ")
        t[i] = int(tmp)
    x = sys.stdin.readline().strip()
    solve(n, s, t, x)

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

print(sum(map(int,T[S.index(X)+1::]+['0'])))

Solution (Python):
N = int(input())
s = []
t = []
for i in range(N):
    st = [c for c in input().split()]
    s.append(st[0])
    t.append(int(st[1]))
X = input()
print(sum(t[s.index(X)+1:]))

Solution (Python):
N= int(input())
plList=['' for i in range(N)]
tmList=[0 for i in range(N)]

for i in range(N):
    pl,tm=input().split()
    plList[i]=pl
    tmList[i]=int(tm)

i=plList.index(input())
print(sum(tmList[i+1:]))

Solution (Python):
n = int(input())
s = [''] * n
t = [0] * n
for i in range(n):
    s[i], t_i = input().split()
    t[i] = int(t_i)
X = input()

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

Solution (Python):
n = int(input())
st = []
for _ in range(n):
    temp = input().split()
    s = temp[0]
    t = int(temp[1])
    st.append((s,t))
x = input()

ans = 0
flag = True
for y in st:
    if flag:
        if y[0] == x:
            flag = False
    else:
        ans += y[1]

print(ans)

Solution (Python):
n=int(input())
ST=[]
for i in range(n):
  s,t=map(str,input().split())
  ST.append((s,t))
chk=False
x=input()
ans=0
for s,t in ST:
  if chk:
    ans+=int(t)
  else:
    if s==x:
      chk=True
print(ans)

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    ST = [tuple(input().split()) for _ in [0] * N]
    X = input()

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


main()

Solution (Python):
n=int(input())
l=[]
for i in range(n):
  a,b=input().split()
  l.append([a,int(b)])
x=input()
s=0
cnt=0
for i in range(n):
  s+=l[i][1]
for i in range(n):
  if l[i][0]==x:
    print(s-cnt-l[i][1])
    exit()
  cnt+=l[i][1]

Solution (Python):
N = int(input())
S = list()
T = list()
for _ in range(N):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
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):
N = int(input())
music = []

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

    music.append((s, t))

X = input()
for i in range(N):
    if music[i][0] == X:
        music = music[i+1:]
        break

ans = 0
for i in music:
    ans += i[1]

print(ans)

Solution (Python):
N = int(input())
st = [input().split() for _ in range(N)]
X = input()
ans = 0
flg = 0
for i, ST in enumerate(st):
    s, t = ST

    if s == X:
        flg = 1
        continue

    if flg == 1:
        ans += int(t)

print(ans)

Solution (Python):
N = int(input())
s = ["a" for i in range(N)]
t = [0 for i in range(N)]

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

X = input()

p = s.index(X)

T=0
for i in range(p+1,N):
    T += int(t[i])

print(T)

Solution (Python):
N=int(input())
S,T=[None]*N,[None]*N
for i in range(N):
    s,t=input().split()
    S[i]=s
    T[i]=int(t)
X=input()
for i in range(N):
    if S[i]==X:
        a=i
        break
print(sum(T[a+1:]))

Solution (Python):
import sys
input = sys.stdin.buffer.readline


def gcd(a: int, b: int):
    while b: a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    N = int(input())
    mT = [tuple(input().decode().split()) for _ in [0,]*N]
    
    X = input().decode().rstrip()

    p = 0
    res = 0
    for s,t in mT:
        nt = int(t)
        if p:
            res += nt
        if s==X:
            p = 1

    print(res)
    
    
    
    
    
    
    


if __name__ == "__main__":
    main()

Solution (Python):

n = int(input())
playlist = []
for i in range(n):
    playlist.append(input().split(" "))
    playlist[i][1] = int(playlist[i][1])


x = input()
s = 0

for i, p in enumerate(playlist):
    if p[0] == x:
        s = i
        break

sm = 0
for i in range(s+1, n):
    sm += playlist[i][1]

print(sm)

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

Solution (Python):
n=int(input())
s=list(input().strip().split() for _ in range(n))
x=input().strip()

ans=0
isis=False
for ss,tt in s:
  if isis:
    ans += int(tt)
  if ss==x:
    isis=True
print(ans)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    S,T = map(str,input().split())
    s.append(S)
    t.append(int(T))
x = str(input())
Sum = 0
for i in range(n):
    if s[i] == x:
        ind = i
for i in range(ind+1,n):
    Sum += t[i]
print(Sum)

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

last_music = input()

ans = 0
sleep_flg = False
for music in music_list:
    if(sleep_flg):
        ans += music[1]

    if(music[0] == last_music):
        sleep_flg = True

print(ans)

Solution (Python):
import collections as c
ip = lambda : map(int, input().split())

N = int(input())
l = [[],[]]
for i in range(N):
    s,t = input().split()
    l[0].append(s)
    l[1].append(int(t))
X = input()
ix = l[0].index(X)

print(sum(l[1][ix+1:]))

Solution (Python):
N=int(input())
kyoku=list(input().split() for i in range(N))
X=input()
time = 0
sousuu= 0
for i in range(N):
    sousuu += int(kyoku[i][1])

    if kyoku[i][0]==X:
        for j in range(i+1):
            time += int(kyoku[j][1])
print(sousuu-time)

Solution (Python):
n=int(input())
song=[]
time=[]
song_t=""
time_t=0
ans=0
for i in range(n):
    song_t,time_t=input().split()
    time_t=int(time_t)
    song.append(song_t)
    time.append(time_t)
ref=str(input())
judge=False
for i in range(n):
    if(judge):
        ans+=time[i]
    else:
        if(song[i]==ref):
            judge=True
print(ans)

Solution (Python):
import sys
hyperScan = sys.stdin.readline
n = int(hyperScan())
tSum = 0
tLi = {}
for i in range(n):
    s, t = map(str, hyperScan().strip('\n').split())
    tSum += int(t)
    tLi[s] = tSum

x = hyperScan().strip('\n')
print(tSum - tLi[x])

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


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

cnt = 0
for i in range(len(ans)):
    cnt += int(ans[i])

print(cnt)

Solution (Python):
n = int(input())
a = []
for _ in range(n):
    title, dur = input().split()
    a.append((title, int(dur)))
sleep = input().rstrip()

ret = 0
for i, (title, _) in enumerate(a):
    if sleep == title:
        for j in range(i + 1, n):
            ret += a[j][1]
print(ret)

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

S = list()
T = list()

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

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

Solution (Python):
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
import math
from functools import reduce
n = int(stdin.readline().rstrip())
name = []
span = []
for el in range(n):
    inputter = stdin.readline().rstrip().split()
    name.append(inputter[0])
    span.append(int(inputter[1]))
target = stdin.readline().rstrip()
pos = name.index(target) + 1
res = 0
for el in range(pos, len(span)):
    res += span[el]
print(res)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    a,b = input().split()
    l.append((a,b))
x = input()
count = 0
for i in range(n):
  if l[i][0] == x:
    f = i
    break
for i in range(f+1,n):
  count += int(l[i][1])
print(count)

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()
count=0

for j in range(N):
   if S[j]==X:
      for k in range(j+1,N):
         count+=T[k]
      break

print(count)

Solution (Python):
N = int(input())
s = []
t = []
for i in range(N):
    ss, tt = map(str, input().split())
    s.append(ss)
    t.append(tt)
X = input()

for i in range(N):
    t[i] = int(t[i])

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

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

print(time)

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

x = str(input())

index = -1
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)

Solution (Python):
n = int(input())
a = []
b = []
for i in range(n):
  x, y = map(str, input().split())
  if(i==0):b.append(int(y))
  else:b.append(b[-1] + int(y))
  a.append(x)
s = input()
print(b[-1] - b[a.index(s)])

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
st = []
for _ in range(N):
    st.append(input().rstrip().split())
X = input().rstrip()
s = []
t = []
for i in st:
    s.append(i[0])
    t.append(int(i[1]))
idx = s.index(X)
print(sum(t[idx+1:]))

Solution (Python):


def solve():
    N = int(input())
    d = {}
    T = []
    for i in range(N):
        s, t = input().split()
        d[s] = i
        T.append(int(t))
    X = input()
    return str(sum(T[d[X]+1:]))

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

Solution (Python):
N=int(input())
st=[input().split() for _ in range(N)]
X=input()
j=0
ans=0
for i in range(N):
  if j==1:
    ans+=int(st[i][1])
  else:
    if st[i][0]==X:
      j=1

print(ans)

Solution (Python):

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

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

print(ans)