Buggy python submission (verdict: Runtime Error):
m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = map(int, input().split())
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) != 1:
            k = str(int(k[0]) + int(k[1])) + k[2:]
            ans += 1
        num += k
while len(num) != 1:
    num = str(int(num[0]) + int(num[1])) + num[2:]
    ans += 1
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))

Buggy python submission (verdict: Runtime Error):
from decimal import *

m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = input().split()
    d = int(d)
    if len(c) > 10:
        num += c[:10]
        c = int(c[10:])
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) > 1:
            if len(k) > 2:
                k = str(int(k[0]) + int(k[1])) + k[2:]
            else:
                k = str(int(k[0]) + int(k[1]))
            ans += 1
        num += k
while len(num) > 1:
    if len(num) > 2:
        num = str(int(num[0]) + int(num[1])) + num[2:]
    else:
        num = str(int(num[0]) + int(num[1]))
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))

Buggy python submission (verdict: Runtime Error):
from decimal import *

m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = input().split()
    d = int(d)
    if len(c) > 3:
        num += c[:10]
        c = int(c[10:])
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) > 1:
            if len(k) > 2:
                k = str(int(k[0]) + int(k[1])) + k[2:]
            else:
                k = str(int(k[0]) + int(k[1]))
            ans += 1
        num += k
while len(num) > 1:
    if len(num) > 2:
        num = str(int(num[0]) + int(num[1])) + num[2:]
    else:
        num = str(int(num[0]) + int(num[1]))
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))

Buggy python submission (verdict: Runtime Error):
m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = map(int, input().split())
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) > 1:
            if len(k) > 2:
                k = str(int(k[0]) + int(k[1])) + k[2:]
            else:
                k = str(int(k[0]) + int(k[1]))
            ans += 1
        num += k
while len(num) != 1:
    if len(num) > 2:
        num = str(int(num[0]) + int(num[1])) + num[2:]
    else:
        num = str(int(num[0]) + int(num[1]))
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))

Buggy python submission (verdict: Runtime Error):
m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = map(int, input().split())
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) != 1:
            k = str(int(k[0]) + int(k[1])) + k[2:]
            ans += 1
        num += k
while len(num) != 1:
    num = str(int(num[0]) + int(num[1])) + num[2:]
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))

Buggy python submission (verdict: Runtime Error):
m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = map(int, input().split())
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) != 1:
            if len(k) == 2:
                k = str(int(k[0]) + int(k[1]))
            else:
                k = str(int(k[0]) + int(k[1])) + k[:2]
            ans += 1
        num += k
while len(num) != 1:
    print(num)
    if len(num) == 2:
        num = str(int(num[0]) + int(num[1]))
    else:
        num = str(int(num[0]) + int(num[1])) + num[:2]
    ans += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))