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 heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
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 NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()

input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

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

l=0
for i in range(n):
    ans+=l*T[i]
    if p[i]==x:
        l=1
        
    
    
print(ans)

Solution (Python):
n = int(input())
raw = []
for _ in range(n):
  a,b = input().split()
  b = int(b)
  raw.append([a,b])
t = input()
ans = 0
att = 0
for i in range(n):
  ans += att * raw[i][1]
  if raw[i][0] == t:
    att = 1
print(ans)

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

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

res = 0
flag = False
for a, b in l:
    if flag:
        res += b
    else:
        if a == s:
            flag = True
print(res)

Solution (Python):

N = int(input())

st = []
dic = {}

a = 0

for i in range(N):

    s,t = input().split()
    t = int(t)
    a += t
    dic[s] = a

X = input()
print (a - dic[X])

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

flag=False
ans=0
for s,t in ST:
  t=int(t)
  if flag: ans+=t
  if s==x: flag=True
print(ans)

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

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

    x = input()
    ret = 0
    flg = False
    for s, t in ms:
        if s == x:
            flg = True
        else:
            if flg:
                ret += t
    print(ret)


if __name__ == '__main__':
    main()

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

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

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

X = input()
count = 0
play = False
for i in range(1, N):
    if SS[i-1] == X: play = True
    if play: count += SD[i]

print(count)

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

ret = 0
flag = False
for s, t in st :
  t = int(t)
  if flag :
    ret += t
  
  if s == X:
    flag = True
    
print(ret)

Solution (Python):
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy


from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): 
    return int(input())
def inpm(): 
    return map(int,input().split())
def inpl(): 
    return list(map(int, input().split()))
def inpls(): 
    return list(input().split())
def inplm(n): 
    return list(int(input()) for _ in range(n))
def inpll(n): 
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n = inp()
    s = []
    for _ in range(n):
        t = inpls()
        t[1] = int(t[1])
        s.append(t)
    x = input()
    key = 0
    ans = 0
    for i in range(n):
        if key:
            ans += s[i][1]
        if s[i][0]==x:
            key = 1
    print(ans)          

if __name__ == "__main__":
    main()

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

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

ANS=0
flag=0

for s,t in ST:
    if flag==1:
        ANS+=int(t)
        
    if s==X:
        flag=1

print(ANS)

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

x = input()
flag = 0
for i in range(n):
    if flag == 1:
        ans += int(music[i][1])
    if music[i][0] == x:
        flag = 1

print(ans)

Solution (Python):
import sys
from collections import Counter
readline = sys.stdin.readline


N = int(readline())
C = Counter()

cnt = 0
for _ in range(N):
    s, t = readline().strip().split()
    C[s] = cnt + int(t)
    cnt += int(t)
print(cnt - C[readline().strip()])

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

s = input()
ans = 0
f = 0
for a, b in X:
    if f:
        ans += b
    if a == s:
        f = 1
print(ans)

Solution (Python):
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,t = (input().split())
    query.append((s,t))
  x = input()
  
  ans = 0
  sleep = False
  for i in range(n):
    s,t = query[i]
    if sleep:
      ans += int(t)
    if s == x:
      sleep = True
  print(ans)
solve()

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

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

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    st = [list(map(str, readline().rstrip().decode('utf-8').split())) for _ in range(n)]
    x = str(readline().rstrip().decode('utf-8'))
    b = True
    cnt = 0
    for s, t in st:
        if not b:
            cnt += int(t)
        if s == x:
            b = False
    print(cnt)


if __name__ == '__main__':
    solve()

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

sum_ = 0
flag = False
for i in range(n):
    if flag:
        sum_ += int(s[i][1])
    if s[i][0] == a:
        flag = True
print(sum_)

Solution (Python):
N = int(input())
st = [input().split() for _ in range(N)]
X = input()
a = 0
b = 0
for s, t in st:
    t = int(t)
    b+=t
    if s == X:
        a = b
print(b-a)

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

Solution (Python):
N = int(input())
song = [list(input().split()) for _ in range(N)]

X = input()
ans = 0

flag = False
for i in range(N):
    if song[i][0] == X:
        flag = True
    elif flag:
        ans += int(song[i][1])

print(ans)

Solution (Python):
n=int(input())
li=[]
li2=[]
for _ in range(n):
	a,b=input().split()
	li.append(a)
	li2.append(int(b))
print(sum(li2[li.index(input())+1:]))

Solution (Python):
import queue
import math
import copy
"""
N = int(input())



A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""

N = int(input())
A = [input().split() for i in range(N)]
S = input()
ans = -1
for a in A:
	if ans != -1:
		ans += int(a[1])
	if a[0] == S:
		ans = 0
print(ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    ans = 0
    sl = False
    S=[]
    for i in range(N):
        s,t = ST().split()
        t = int(t)
        S.append((s,t))
    X = ST()
    for s,t in S:
        if s==X:
            sl=True
        else:
            if sl:
                ans+=t
    print(ans)
if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):

import sys


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    index = s.index(X)
    print(sum(t[index+1:]))
    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):
n = int(input())
play = []
for i in range(n):
    s,t = input().split()
    t = int(t)
    play.append((s,t))
x = input()
flag = False
ans = 0
for s,t in play:
    if x == s:
        flag = True
    elif flag:
        ans += t
print(ans)

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

Solution (Python):
n = int(input())
a = [list(input().split()) for i in range(n)]
b = input()
flg = 0
ans = 0
for i in range(n):
  if a[i][0] == b:
    flg = 1
  elif flg:
    ans += int(a[i][1])
print(ans)

Solution (Python):



n = int(input())
C = [list(input().split()) for i in range(n)]
s = input()

ans = 0
a=0
for i in range(n):
    if a==1:
        ans += int(C[i][1])
    if s == C[i][0]:
        a = 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    s,t=['']*N,[0]*N
    for i in range(N):
        s[i],t[i]=input().split()
        t[i]=int(t[i])
    S=input()
    print(sum(t[s.index(S)+1:]))

if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = [input().split() for i in range(n)]
    d = defaultdict(lambda : 0)
    s = 0
    for pi,i in p:
        s += int(i)
        d[pi] += s
    print(s-d[input()])
    return


if __name__ == "__main__":
    solve()

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

N = int(readline())
ST = [readline().split() for _ in range(N)]
X = read().rstrip()

S,T = zip(*ST)

i = S.index(X)

answer = sum(map(int,T[i+1:]))
print(answer)

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    ret = 0
    flg = False
    for i in range(N):
        if flg:
            ret += t[i]
        if s[i] == X:
            flg = True
    print(ret)
    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()