Problem p02856 (python)

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

M = ni()
D = [] ; C = []

for i in range(M):
    d, c = na()
    D.append(d)
    C.append(c)

D = np.array(D) ; C = np.array(C)
#桁数の9倍とそれぞれの数字の総和をx
x = C.sum() * 9 + (C * D).sum()
# 18以下で終了
answer = (x + 8) // 9 - 2
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 0

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = max(answer, count)
    else:
        i = -2
        sum = l[i] + l[i+1]
        result = l[:i] + [int(x) for x in list(str(sum))]
        #print(result)
        dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 0

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = max(answer, count)
    else:
        i = 0
        sum = l[i] + l[i+1]
        result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
        #print(result)
        dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 0

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = max(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 20

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    elif count > answer:
        return
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 15

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 30

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 100

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

Buggy submission (verdict: Runtime Error):
#dfs
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    elif count > answer:
        return
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

def main():
    global answer
    M = int(input())
    L = []
    for i in range(M):
        d, c = map(int, input().split())
        L.extend([d] * c)

    answer = 100
    dfs(0, L)
    print(answer)

if __name__ == '__main__':
    answer = 1000
    main()

Buggy submission (verdict: Runtime Error):
#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 100

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)