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: Runtime Error

Solution code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Xml.Schema;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography;
using System.IO.Pipes;
using Microsoft.Win32;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.CodeDom;

namespace AtCoder
{
    public static class Ex
    {
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }
        public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
        public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
        public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
        public static int BuildBitCount(this int bits)
        {
            bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
            bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
            bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
            bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
            return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
        }
    }

    partial class AtCoder
    {
        public string GetStr() { return Console.ReadLine().Trim(); }
        public char GetChar() { return Console.ReadLine().Trim()[0]; }
        public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
        public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
        public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
        public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
        public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
        public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
        public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
        public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
        public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H).Select(s => Enumerable.Repeat(value, W).ToArray()).ToArray(); }
        public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetIntArray().ToArray()).ToArray(); }
        public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetLongArray().ToArray()).ToArray(); }
        public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetStr().ToCharArray()).ToArray(); }
        public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); }

        Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
        {
            var dic = new Dictionary<int, List<int>>();
            foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); }
            for (int i = 0; i < M; i++)
            {
                var input = GetIntArray();
                var a = isNode_0indexed ? input[0] : input[0] - 1;
                var b = isNode_0indexed ? input[1] : input[1] - 1;
                dic[a].Add(b);
                if (isDirected == false) dic[b].Add(a);
            }
            return dic;
        }
        Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
        {
            var dic = new Dictionary<int, List<Edge>>();
            foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<Edge>()); }
            for (int i = 0; i < M; i++)
            {
                var input = GetIntArray();
                var a = isNode_0indexed ? input[0] : input[0] - 1;
                var b = isNode_0indexed ? input[1] : input[1] - 1;
                var c = input[2];
                dic[a].Add(new Edge(b, c));
                if (isDirected == false) dic[b].Add(new Edge(a, c));
            }
            return dic;
        }

        bool eq<T, U>() => typeof(T).Equals(typeof(U));
        T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        void Multi<T>(out T a) => a = cv<T>(GetStr());
        void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
        }
        void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
        }
    }

    class Edge
    {
        public Edge(int to, long length)
        {
            To = to;
            Length = length;
        }
        public int To { get; set; }
        public long Length { get; set; }
    }

    class Comparable : IComparable<Comparable>
    {
        public Comparable(int value)
        {
            this.value = value;
        }

        public int value;
        public int CompareTo(Comparable c)
        {
            return this.value < c.value ? 1 : this.value == c.value ? 0 : -1;
        }
    }



    partial class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            new AtCoder().Solve();
            Console.Out.Flush();
            Console.Read();
        }
    }

    public partial class AtCoder
    {
        public void Solve()
        {
            var N = GetInt();
            var music = new int[N].Select(e =>
            {
                string s;
                int t;
                Multi(out s, out t);
                return (s, t);
            }).ToArray();
            var X = GetStr();
            var ans = music.SkipWhile(w => w.s != X).Skip(1).Sum(s => s.t);
            Console.WriteLine(ans);
        }
    }
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(sum(t[s.index(x):]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[list(map(input().split())) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
  if i[0]==x:
    cnt=0
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[list(map(input().split())) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
    if i[0]==x:
      cnt=0
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[list(map(input().split())) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
    if i[0]==x:
    cnt=0
print(cnt)

Submission status: Runtime Error

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

for _ in range(n):
    title, playtime = input().split()
    playlists.append([title, int(playtime)])

lastmusic = input()

print(sum([x[1] for x in playlists[playlists[0].index(lastmusic) + 1:]]))

Submission status: Runtime Error

Solution code:
n = int(input())
st = [list(input().split()) for nesya in range(n)]
x = input()
c = 0
for a in st:
  if x == st[0]:
    c = 0
  else:
    c += int(st[1])
print(c)

Submission status: Runtime Error

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

j= s.index(X)
if X==s[-1]:
  ans=0
else:
  ans= t[j+1:]

print(sum(ans))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
  x = a[i-1]
  for j in range(n+1):
    for t in range(min(n-j,x)+1):
      dp[i][j+t]=(dp[i][j+t]+dp[i-1][j]*cmb(n-j,t)*cmb(n-t,x-t))%mod
print(dp[k][n])

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
  x = a[i-1]
  for j in range(n+1):
    for t in range(min(n-j,x)+1):
      dp[i][j+t]=(dp[i][j+t]+dp[i-1][j]*fctr[n-j]*finv[n-j-t]*finv[t]*fctr[n-t]*finv[x-t]*finv[n-x])%mod
print(dp[k][n])

Submission status: Runtime Error

Solution code:
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=int(input())
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
s, t = [], []
for i in range(N):
  s_i, t_i = [input().split(" ")]
  t_i = int(t_i)
  s.append(s_i)
  t.append(t_i)
X = input()

idx = 0
while idx < N:
  if s[idx] == X:
    idx += 1
    break
  idx += 1

ans = 0
for i in range(idx, N):
  ans += t[i]
print(ans)

Submission status: Runtime Error

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
music = []
length = []
for i in range(n):
    ti,leng = map(str,input().split())
    music.append(ti)
    length.append(leng)
x = input()

num = music.index(x)
print(sum(length[x::]))

Submission status: Runtime Error

Solution code:
t = []
index = {}
for n in range(N):
    si, ti = input().split()
    ti = int(ti)
    index[si] = n
    t.append(ti)

X = input()

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

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
data=[list(inout().split()) for _ in range(n)]
s = input()
ans = 0
c = False
for i in range(n):
  if c:
    ans += int(data[i][1])
  if data[i][0] == s:
    c = True
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return input().split()
def S(): return input().rstrip()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    st = LSR(n)
    x = S()
    ans = 0
    te = 0
    for s, t in st:
        if te:
            ans += t
        if s == x:
            te = 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


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

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













if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
n =int(input())
s=[""]*n
t=[0]*n
for i in range(n):
  s[i],t[i] =[s,int(t) for s,t in input().split()]
r = [0] * (n+1)  
for i in range(1,n+1):
  r[i] = r[i-1] + t[i-1]
x=input()
ind = s.index(x)
print(r[n] - r[ind])

Submission status: Runtime Error

Solution code:
N = int(input())
music = []
for i in range(N):
    music.append(input().split())
X = str(input())
C = music.index('X')
D = int(C)
B = int(music[X][1])
A = B + 1
if music(X) == music[N]:
    print(0)
elif music[X] < music[N]:
    while music[D] == music[N]:
        s = music[X][1] + music[A][1]
        A += 1
        D += 1
print(s)

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
lines = input().readlines()

def toDigital(strs):
    return int("".join([s for s in strs if s.isdigit()]))
  
n = toDigital(lines[0])
l = lines[-1]
e = [i for i,s in enumerate(lines) if s.count(l)][0]
s = sum([toDigital(n) for n in lines.slice(e,-2)])

print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=['']*n
a=[0]*n
for i in range(n):
  s[i],v=input().split()
  a[i]=int(v)
x=input()
flg=False
ans=0
for i in range(n):
  if flg:
    ans+=a[i]
  if s[i]==x
    flg=True
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
factorials = [1] + list(accumulate(range(1,n + 1), mul))

combinations = dict()
def combination(i, j):
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    t = factorials[lt] * combination(n, gt) * factorials[gt]
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 0
s = [list(map(str(input().split()))) for i in range(n)]
key_s = str(input())
key = 0
for _ in range(n):
  for t,tt in s:
    if key == 1:
      ans += int(tt)
    if t == key_s:
      key = 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    playlist = dict()
    time = [0] * (N + 1)
    for i in range(N):
        s, t = map(str, input().split())
        playlist[s] = i
        time[i + 1] = time[i] + int(t)
    print(time[N] - time[playlist[input()] + 1])


    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

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

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(i):
    if i==1:
        return 1
    return calc(i-1)+(1.0/i)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(i)
    result.append(temp)
    
print(int(sum(result)*math.factorial(N-1)))

Submission status: Runtime Error

Solution code:
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力()
    曲名.append(入力された値)
    入力された値 = 入力()
    時間.append(入力された値)
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)

Submission status: Runtime Error

Solution code:
N = int(input())
i = 0
songs = []
result = 0

while N-i:
  songs.append(input().split())
  i+=1
X = input()
point = len(songs)

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

for i in range(point:N):
  result += songs[1]

print(result)

Submission status: Runtime Error

Solution code:
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    while s[i]!=X:
        c+=int(t[i])
        i+=1
    return sum(t)-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=input()
print(f(X,s,t))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
ST=[list(map(int,input().split())) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
ST=[list(map(int,input().split())) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=t
print(ans)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
n = int(input())
lx = list(map(int, input().split()))

from math import factorial as kj

d = 0
ans = 0

for i in range(1, n):
  d = (d * i + kj(i-1)) % mod
  ans = (ans * i + (lx[i] - lx[i-1]) * d) % mod

print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S = []
    T = []
    for i in range(N):
        S[i], T[i] = rip()
    X = ri()

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
n = int(input())
lx = list(map(int, input().split()))

from math import factorial as kj

d = 0
lk = [0] * n

for i in range(1, n):
  d += kj(n-1) // i
  lk[i] = (lx[i] - lx[i-1]) * d

print(sum(lk) % mod)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
	b = input().split()
	a+=[b]
x=input()
ans=0
for i　in range(n):
	if a[n-i-1][0]=x:
    	break
    ans+=a[n-i-1][1]
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = [input() for i in range(N)]
    S = input()
    print(sum(A[S.index():]))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(map(int, input().split()))

x_diff = []
for i in range(n-1):
    x_diff.append(x[i+1] - x[i])



def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

base = 1
for i in range(1, n):
    base *= i
    base %= 10**9+7

frac = []
for i in range(1, n):
    frac.append(base*modinv(i) % (10**9+7))

import itertools
frac = list(itertools.accumulate(frac))

ans = 0
for i in range(n-1):
    ans += frac[i]*x_diff[i]
    ans %= 10**9+7

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    X = tuple(map(int,input().split()))
    MOD = 10 ** 9 + 7
    goal = X[-1]
    ans = goal - X[0]
    x = 1
    count = 2
    for i in X[1:N-1]:
       tmp = goal - i
       ans = ((ans * count % MOD) + ((x*tmp)%MOD)) % MOD
       x *= count % MOD
       count += 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
s=[0]*N
t=[0]*N
title = [input().split()[0] for i in range (N)]
number = [int(input().split()[1]) for i in range (N)]
X=input()
Y=s.index(X)
print(sum(number([Y+1,N])))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(3000)
n = int(input())
x = list(map(int, input().split()))

dx = [0]*(n-1)
for i in range(n-1):
    dx[i] = x[i+1] - x[i]

def fact(n):
    if n <= 1:
        return n
    else:
        return n*fact(n-1)
    
r = fact(n-1)//2
res = 0
for j in range(n-1):
    if j == 0:
        res += dx[j]*fact(n-1)
    else:
        res += dx[j]*fact(n-1) + r
        r = r + r//(j+1)
        
ans = res%(10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
x,y = [list(map(int, input().split())) for i in range(n)]
x = input()
a = 0
b = 0
c = 0
while a <= n - 1:
  if s[a] == x:
     while b <= n - 1:
       c += int(t[b])
       b += 1
  else:
    a += 1
    b += 1
else:
  print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[input() for i in range(n)]
target_song = input()

total = 0

ff = False

for i in l:
    s, t = i.split(" ")

    if s == target_song:
        f = True
        continue
        
    if f == True:
        total +=  int(t)

print(total)

Submission status: Runtime Error

Solution code:
第六回ドワンゴからの挑戦状　A

N=int(input())

largelist=[]

for i in range(N):
    S=input().split()
    #print(S)
    largelist.append(S)

#print(largelist)

X=input()
answer=0

for i in range(N):
    if X==largelist[i][0]:
        for j in range(i+1,N):
            answer+=int(largelist[j][1])
        
    else:
        temp=0

print(answer)

Submission status: Runtime Error

Solution code:
input(s t)
if s1 = sN:
  print (t2+t3+...+tN);
else:
  print(0)

Submission status: Runtime Error

Solution code:

n = int(input())
x = [int(x) for x in input().split()]
inf = 10**9+7
a = 1
for i in range(n-1, 0, -1):
    a *= i
    a %= inf
key = 0
ans = 0
for i in range(n-1):
    key += a//(i+1)
    key %= inf
    ans += key*(x[i+1]-x[i])
    ans %= inf
    

print(ans)

Submission status: Runtime Error

Solution code:
'''--- input ---'''

# N is Amount of song
N:int = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X:str = input()
#print("X = " + X)
'''--- search ---'''
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        #print("mach is " + Song_List[i][0])
        #print("i is " + str(i))
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
                #print(str(i+1))
        else:
            continue
    else:
        continue
print(ans)

Submission status: Runtime Error

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

for i in range(n):
  a, b = input().split()
  b = int(b)
  lst.append([a, b])
x = input()
sum_time = 0
flag = false
for i in lst:
  if i[0] == x:
    flag = true
  if flag:
    sum_time += i[1]
print(sum_time)

Submission status: Runtime Error

Solution code:
#include<stdio.h>
int main(void){
  int N, A, B, sum, ans = 0;
  scanf("%d %d %d", &N, &A, &B);
  for(int i=0;i<=N;i++){
    int j=i;
    sum=0;
    while(j!=0){
      sum=sum+(j%10);
      j=j/10;
    }
    if(sum>=A && sum<=B){
      ans=ans+i;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Submission status: Runtime Error

Solution code:
n=int(input())
A=[[]for i in range(n)]
A[0].append(1)
for i in range(2,n+1):
  for j in range(i-1):
    A[i-1].append(A[i-2][j]*i)
  A[i-1].append(A[i-1][-1]+A[i-2][0])
X=list(map(int,input().split()))
Y=[X[1]-X[0]]
for i in range(2,n):
  Y.append(X[i]-X[i-1])
ans=0
for i in range(n-1):
  ans=(ans+A[n-2][i]*Y[i])%(10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(stdin.readline().rstrip())
a = np.array([stdin.readline().rstrip().split() for _ in range(n)])
x = [stdin.readline().rstrip() for _ in range(n)][0]

i = np.where(a[:,0] == x)[0][0]
b = a[i+1:,1]
b = [int(i) for i in b]
print(sum(b))

Submission status: Runtime Error

Solution code:
n=int(input())
t=[]*n
sec=[]*n
for k in range(n):
  s=input().split()
  t[k]=s[0]
  sec[k]=int(s[1])
x=input()
p=t.index(x)
a=0
if p!=n:
  for l in range(p+1,n):
    a+=sec[l]
print(str(a))

Submission status: Runtime Error

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

# N=3
# s=["dwango","sixth","prelims"]
# t=[ 2, 5,25]
# X="prelims"

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

Submission status: Runtime Error

Solution code:
n=int(input())
lst=[]
for i in range(n):
  s,t=input().split()
  T=int(t)
  lst.append([s,t])
x=input()
for j in range(n):
  if lst[j][0]==x:
    k=j
    break
totl=0
for j in range(k+1,n):
  totl+=lst[j][1]
print(totl)

Submission status: Runtime Error

Solution code:
n = int(input())
s1 = []
t1 = []
for in range(n):
  d = map(in,input().split())
  s1.append(d[0])
  t1.append(d[1])
print(sum(t1[s1.index(input()):]))

Submission status: Runtime Error

Solution code:
using System;
using System.Linq;

namespace DOWANGO006
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = new string[N];
            int[] t = new int[N];
            for (int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split().ToArray();
                s[i] = input[0];
                t[i] = int.Parse(input[1]);
            }
            string X = Console.ReadLine();
            int sum = 0;
            int total = t.Sum();
            for (int i = 0; i < N; i++)
            {
                sum += t[i];
                if (s[i] == X) break;
            }
            Console.WriteLine(total - sum);
        }
    }
}

Submission status: Runtime Error

Solution code:
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 += (tt)
  if ss==x:
    isis=True
print(ans)

Submission status: Runtime Error

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