Problem:


Score: 500 points

Problem Statement

N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.

The preliminary stage consists of several rounds, which will take place as follows:

All the N contestants will participate in the first round.

When X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:

The organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.

For example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).

When X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.

The preliminary stage ends when 9 or fewer contestants remain.

Ringo, the chief organizer, wants to hold as many rounds as possible.
Find the maximum possible number of rounds in the preliminary stage.

Since the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \ldots, d_M and c_1, \ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \ldots, and the last c_M digits are all d_M.

Constraints

1 \leq M \leq 200000

0 \leq d_i \leq 9

d_1 \neq 0

d_i \neq d_{i+1}

c_i \geq 1

2 \leq c_1 + \ldots + c_M \leq 10^{15}

Input

Input is given from Standard Input in the following format:

M
d_1 c_1
d_2 c_2
:
d_M c_M

Output

Print the maximum possible number of rounds in the preliminary stage.

Sample Input 1

2
2 2
9 1

Sample Output 1

3

In this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:

229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.

Here, three rounds take place in the preliminary stage, which is the maximum possible number.  

Sample Input 2

3
1 1
0 8
7 1

Sample Output 2

9

In this case, 1000000007 will participate in the first round.  



Sample input:
2
2 2
9 1


Sample output:
3

Submission status: Wrong Answer

Solution code:
import sys
sys.stdin.readline

m = int(input())
a = [list(map(int, input().split())) for _ in range(m)]
loop = [0]*10
rond = [0]*10
loop[0] = 1
for i in range(1,10):
    c = 1 #一塊
    r = 0
    now = 0
    if (2*i >= 10):
        now = 2*i
        r += 1
    else:
        now = 2*i
        c = 2
        r += 1
    while True:
        if (now==i):
            break
        r += 1
        if (len(str(now))==1):
            if (now*2 < 10):
                now = now*2
                c *= 2
            else:
                now = now*2
        else:
            now = (now//10 + now%10)
            c *= 2
    loop[i] = c
    rond[i] = r
#print(loop,rond)

ans = 0
main = []
for i,j in a:
    x = (j//loop[i]) + (j%loop[i])
    for k in range(x):
        main.append(i)
    
    ans += rond[i]*(j//loop[i])
#print(main,ans)

if (len(main)==1):
    print(ans)
    exit()
now = [0,0]
now[1] = main.pop()
now[0] = main.pop()
while len(main)>0:
    ans += 1
    x = now[0]+now[1]
    y = str(x)
    if (x>=10):
        now = [int(y[0]),int(y[1])]
    else:
        now[1] = x
        now[0] = main.pop()
    #print(now,ans)
if (now[0]+now[1]>=10):
    ans += 2
else:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

next_num = {
  0:(1, 0), 1:(1, 2), 2:(1, 4), 3:(1, 6), 4:(1, 8),
  5:(2, 1), 6:(2, 3), 7:(2, 5), 8:(2, 7), 9:(2, 9)
}
memo = {}
def rec_calc(d, c):
  global memo
  if (d, c) in memo:
    return memo[(d, c)]
  if c == 1:
    memo[(d, c)] = (0, d)
    return (0, d)
  elif c == 2:
    n = 2 * d
    if n <= 9:
      memo[(d, c)] = (1, n)
      return (1, n)
    else:
      a1 = d % 10
      a2 = d // 10
      memo[(d, c)] = (2, a1+a2)
      return (2, a1+a2)
  else:
    t, nn = next_num[d]
    time, n = rec_calc(nn, c//2)
    if c % 2 == 0:
      res = ((c//2)*t + time, n)
      memo[(d, c)] = res
      return res
    else:
      n += d
      if n <= 9:
        res = ((c//2)*t+time+1, n)
        memo[(d, c)] = res
      else:
        a1 = n % 10
        a2 = n // 10
        res = ((c//2)*t+time+2, a1+a2)
        memo[(d, c)] = res
      return res

M = int(input())
ans = 0
D = []
for i in range(M):
  d, c = map(int, input().split())
  time, n = rec_calc(d, c)
  ans += time
  D.append(n)

d1 = D.pop()
while D:
  d2 = D.pop()
  n = d1 + d2
  if n <= 9:
    ans += 1
    d1 = n
  else:
    ans += 2
    d1 = (n%10) + (n//10)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

next_num = {
  0:(1, 0), 1:(1, 2), 2:(1, 4), 3:(1, 6), 4:(1, 8),
  5:(2, 1), 6:(2, 3), 7:(2, 5), 8:(2, 7), 9:(2, 9)
}
memo = {}
def rec_calc(d, c):
  global memo
  if (d, c) in memo:
    return memo[(d, c)]
  if c == 1:
    memo[(d, c)] = (0, d)
    return (0, d)
  elif c == 2:
    n = 2 * d
    if n <= 9:
      memo[(d, c)] = (1, d)
      return (1, d)
    else:
      a1 = d % 10
      a2 = d // 10
      memo[(d, c)] = (2, a1+a2)
      return (2, a1+a2)
  else:
    t, nn = next_num[d]
    time, n = rec_calc(nn, c//2)
    if c % 2 == 0:
      res = ((c//2)*t + time, n)
      memo[(d, c)] = res
      return res
    else:
      n += d
      if n <= 9:
        res = ((c//2)*t+time+1, n)
        memo[(d, c)] = res
      else:
        a1 = n % 10
        a2 = n // 10
        res = ((c//2)*t+time+2, a1+a2)
        memo[(d, c)] = res
      return res

M = int(input())
ans = 0
D = []
for i in range(M):
  d, c = map(int, input().split())
  time, n = rec_calc(d, c)
  ans += time
  D.append(n)

d1 = D.pop()
while D:
  d2 = D.pop()
  n = d1 + d2
  if n <= 9:
    ans += 1
    d1 = n
  else:
    ans += 2
    d1 = (n%10) + (n//10)

print(ans)

Submission status: Wrong Answer

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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#2234
#import numpy as np

def main():
	m=II()
	di=0
	su=0
	for _ in range(m):
		d,c=MI()
		di+=c
		su+=d*c

	print(su//9+di-1)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    M, *DC = map(int, read().split())
    D = DC[::2]
    C = DC[1::2]

    total = sum(d * c for d, c in zip(D, C))
    ans = sum(C) + total // 9 - 1
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
m = int(input())

c, d = [],[]
s = 0
l = []
ans = 0
for i in range(m):
    di, ci = map(int, input().split())
    d.append(di)
    c.append(ci)
    ans = ans + (ci-1) + (ci*di)//10
    l.append(sum([int(d) for d in str(ci*di)]) % 10)
# print(l)
ans += len(l)-1+sum(l)//10
print(ans)

Submission status: Wrong Answer

Solution code:
m = int(input())

c, d = [],[]
s = 0
l = []
ans = 0
for i in range(m):
    di, ci = map(int, input().split())
    d.append(di)
    c.append(ci)
    ans = ans + (ci-1) + (ci*di)//10
    l.append(sum([int(d) for d in str(ci*di)]) //10)
ans += len(l)-1+sum(l)//10
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


m = readint()

a = 0
b = 0

for i in range(m):
    d,c = readints()
    a+=c
    b+=c*d

print(a-1+b//10)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
MOD = 10 ** 9 + 7
M = int(input())
ans = 0
li = deque([])
for i in range(M):
    d,c = map(int,input().split())
    ans += c-1
    x = c*d
    ans += (x-1) // 9
    if x == 0:
        ans += 1
        li.append(0)
    else:
        x = x%9
        if x == 0:
            li.append(9)
        else:
            li.append(x)
    ans = ans % MOD
while len(li) >= 2:
    ans += 1
    p = li.popleft()
    q = li.popleft()
    r = p+q
    if r < 10:
        li.appendleft(r)
    else:
        li.appendleft(r%10)
        li.appendleft(r//10)
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
m = int(input())
ans=-1
now=0
for i in range(m):
    d,c = map(int, input().split())
    ans+=c
    now+=d*c
    if now>9:
        ans+=now//9
        now%=9

print(ans)

Submission status: Wrong Answer

Solution code:
m = int(input())
ans=-1
now=0
for i in range(m):
    d,c = map(int, input().split())
    ans+=c
    now+=d*c
    ans+=now//9
    now%=9

print(ans)

Submission status: Wrong Answer

Solution code:

m=int(input())
dc=[[0]*2 for i in range(m)]
for i in range(m):
    dc[i]=list(map(int,input().split()))
    
dsum=0
csum=0
for i in range(m):
    dsum+=dc[i][0]
    csum+=dc[i][1]

ans=(dsum-1)//9+csum-1

print(ans)

Submission status: Wrong Answer

Solution code:

m=int(input())
dc=[[0]*2 for i in range(m)]
for i in range(m):
    dc[i]=list(map(int,input().split()))
    
dsum=0
csum=0
for i in range(m):
    dsum+=dc[i][0]
    csum+=dc[i][1]

ans=dsum//9+csum-1

print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
tmp, ans = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    tmp += d * c
    ans += tmp // 10 + c
    tmp = tmp // 10 + (tmp % 10)

print(ans-1)

Submission status: Wrong Answer

Solution code:
M = int(input())
tmp, ans = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    tmp += d * c
    ans += tmp // 10 + c
    tmp = tmp // 10 + tmp % 10

print(ans-1)

Submission status: Wrong Answer

Solution code:
M = int(input())
tmp, ans = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    tmp += d * c
    ans += tmp // 10 + c
    tmp %= 10

print(ans-1)

Submission status: Wrong Answer

Solution code:
M = int(input())
A = []
for i in range(M):
    d, c = map(int, input().split())
    for j in range(c):
        A.append(d)

tmp = 0
ans = 0
for a in A:
    tmp += a
    ans += 1
    if tmp >= 10:
        ans += 1
        tmp %= 10

print(ans-1)

Submission status: Wrong Answer

Solution code:
M = int(input())
A = []
for i in range(M):
    d, c = map(int, input().split())
    for j in range(c):
        A.append(d)

#print(A)
ans = 0
while len(A) > 1:
    ans += 1
    next_A = []
    la = len(A)
    m = 0
    for i in range(la-1):
        m = max(m, A[i]+A[i+1])
    if m < 10:
        i = 0
        A.append(0)
        while i < la:
            if m == A[i]+A[i+1]:
                next_A.append(m%10)
                i += 1
            else:
                next_A.append(A[i])
            i += 1
    else:
        i = la-1
        while i > 0:
            if m == A[i]+A[i-1]:
                next_A.append(m//10)
                next_A.append(m%10)
                i -= 1
            else:
                next_A.append(A[i])
            i -= 1
        next_A.append(A[0])
        next_A.reverse()
    A = next_A
    next_A = []

#print(A)
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
A = []
for i in range(M):
    d, c = map(int, input().split())
    for j in range(c):
        A.append(d)

print(A)
ans = 0
while len(A) > 1:
    ans += 1
    next_A = []
    la = len(A)
    m = 0
    for i in range(la-1):
        m = max(m, A[i]+A[i+1])
    if m < 10:
        i = 0
        A.append(0)
        while i < la:
            if m == A[i]+A[i+1]:
                next_A.append(m%10)
                i += 1
            else:
                next_A.append(A[i])
            i += 1
    else:
        i = la-1
        while i > 0:
            if m == A[i]+A[i-1]:
                next_A.append(m//10)
                next_A.append(m%10)
                i -= 1
            else:
                next_A.append(A[i])
            i -= 1
        next_A.append(A[0])
        next_A.reverse()
    A = next_A
    next_A = []

#print(A)
print(ans)

Submission status: Wrong Answer

Solution code:
m=int(input())
INF=10**9
sd=0
sc=0
for i in range(m):
    d,c=map(int,input().split())
    sd+=d
    sc+=c
print((sd-1)//9+sc-1)

Submission status: Wrong Answer

Solution code:
m = int(input())
s = 0
k = 0
for _ in range(m):
    d, c = map(int, input().split())
    s += c * d
    k += c

print(k - 1 + s // 9)

Submission status: Wrong Answer

Solution code:
m = int(input())
s = 0
k = 0
for _ in range(m):
    d, c = map(int, input().split())
    s += c * d
    k += c

print(k - 1 + s // 10)

Submission status: Wrong Answer

Solution code:
n = int(input())
dc=[list(map(int,input().split())) for i in range(n)]

sm=0
cnt=0
for tmp in dc:
    d,c=tmp
    cnt+=c
    sm+=d*c
print(cnt-1 + sm//10)

Submission status: Wrong Answer

Solution code:
m = int(input())
s = 0
t = 0
for i in range(m):
    d, c = map(int, input().split())
    s += d*c
    t += c

if s == 9 and t == 1:
    print(0)
    exit()

print(t-1+s//9)

Submission status: Wrong Answer

Solution code:
m = int(input())
s = 0
t = 0
for i in range(m):
    d, c = map(int, input().split())
    s += d*c
    t += c

print(t-1+s//9)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

M = int(input())
Dsum = 0
digit = 0

for _ in range(M):
    d, c = map(int, input().split())
    Dsum += d
    digit += c

ans = digit - 1
ans += (Dsum - 1) // 9

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

M = int(input())
Dsum = 0
digit = 0

for _ in range(M):
    d, c = map(int, input().split())
    Dsum += d
    digit += c

ans = digit - 1
ans += Dsum // 9

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

M = int(input())
Dsum = 0
digit = 0

for _ in range(M):
    d, c = map(int, input().split())
    Dsum += d
    digit += c

ans = digit - 1
div, mod = divmod(Dsum, 9)
if mod:
    ans += div
else:
    ans += div - 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def F(d, c):
    cnt = c - 1  # 桁減らし
    cnt += d * c // 10  # 数値減らし

    X = d * c
    while X >= 10:
        tmp = str(X)
        X = sum(int(x) for x in tmp)

    return X, cnt


M = int(input())
DC = [list(map(int, input().split())) for _ in range(M)]

ans = 0
digit = []
for d, c in DC:
    x, cnt = F(d, c)
    ans += cnt
    digit.append(x)

ans += len(digit) - 1
ans += sum(digit) // 10
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    M=int(input())
    DC=[tuple(map(int, input().split())) for _ in range(M)]
    Dsum=sum(d*c for d,c in DC)
    Csum=sum(c for d,c in DC)
    print(Csum-1 + Dsum//9)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    M=I()
    dig=0
    S=0
    for i in range(M):
        d,c=MI()
        dig+=c
        S+=d*c

    print(dig-1+(S)//9)

main()

Submission status: Wrong Answer

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    M=I()
    dig=0
    S=0
    for i in range(M):
        d,c=MI()
        dig+=c
        S+=d*c

    print(dig-1+(S)//10)

main()

Submission status: Wrong Answer

Solution code:
M = int(input())
dc = [list(map(int, input().split())) for _ in range(M)]

ans = 0
digit_final = []
for i, (di, ci) in enumerate(dc):
    ans += ci - 1
    tmp = di * ci
    while tmp > 10:
        tmp2 = tmp
        digit_sum = 0
        while tmp2 > 0:
            digit_sum += tmp2 % 10
            tmp2 //= 10
            ans += 1
        ans -= 1
        tmp = digit_sum
    #
    digit_final.append(tmp)

tmp = digit_final[0]
for i in range(1, M):
    ans += 1
    tmp += digit_final[i]
    while tmp > 10:
        tmp2 = tmp
        digit_sum = 0
        while tmp2 > 0:
            digit_sum += tmp2 % 10
            tmp2 //= 10
            ans += 1
        ans -= 1
        tmp = digit_sum

print(ans)

Submission status: Wrong Answer

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    M=I()
    dig=0
    S=0
    for i in range(M):
        d,c=MI()
        dig+=d
        S+=d*c

    print(dig-1+(S)//10)

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def F(d, c):
    cnt = c - 1  # 桁減らし
    cnt += d * c // 10  # 数値減らし

    X = d * c
    while X >= 10:
        tmp = str(X)
        X = sum(int(x) for x in tmp)

    return X, cnt


M = int(input())
DC = [list(map(int, input().split())) for _ in range(M)]

ans = 0
digit = []
for d, c in DC:
    x, cnt = F(d, c)
    ans += cnt
    digit.append(d)

ans += len(digit) - 1
ans += sum(digit) // 10
print(ans)

Submission status: Wrong Answer

Solution code:
def comp(d:int, c:int):
    """ srt(d) * c を圧縮する """
    res = 0
    while c > 1:
        c = c // 2
        if d + d >= 10:
            dd = str(d + d)
            d = int(dd[0]) + int(dd[1])
            res += c * 2
        else:
            d = d + d
            res += c
    return d, res # (数, 圧縮に要した回数)

M = int(input())
ans = 0
num = []
for _ in range(M):
    d, c = map(int, input().split())
    if c % 2 == 0:
        d, res = comp(d, c)
    else:
        num.append(d)
        c -= 1
        if c == 0: continue
        d, res = comp(d, c)
    num.append(d)
    ans += res

while len(num) != 1:
    d1 = num.pop()
    d2 = num.pop()
    
    if d1 + d2 >= 10:
        dd = str(d1 + d2)
        d = int(dd[0]) + int(dd[1])
        num.append(d)
        ans += 2
    else:
        num.append(d1 + d2)
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
DC = [tuple(map(int, input().split())) for _ in range(M)]

D = 0
C = 0
for d, c in DC:
    D += d
    C += c

ans = C - 1
ans += (D - 1) // 9
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
DC = [tuple(map(int, input().split())) for _ in range(M)]

D = 0
C = 0
for d, c in DC:
    D += d
    C += c

ans = C - 1
ans += -(-(D - 9) // 9)
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
DC = [tuple(map(int, input().split())) for _ in range(M)]

ans = 0
S = 0
for d, c in DC:
    ans += c
    S += d
ans -= 1

ans += S // 9
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
DC = [tuple(map(int,input().split())) for i in range(M)]

sumd = sumc = 0
for d,c in DC:
    sumd += d
    sumc += c

ans = sumc-1 + (sumd-1)//9
print(ans)

Submission status: Wrong Answer

Solution code:
d=c=0
for _ in range(int(input())):a,b=map(int,input().split());d+=a*b;c+=b
print(c-1+d//9)

Submission status: Wrong Answer

Solution code:
M = int(input())
X = [list(map(int, input().split())) for _ in range(M)]

d = sum(c for _, c in X)
s = sum(d for d, _ in X)
print(d - 1 + (s - 1) // 9)

Submission status: Wrong Answer

Solution code:
m = int(input())
d,c = [0]*m , [0]*m
for i in range(m):
    d[i],c[i] = map(int,input().split())
ans = sum(c) - 1
wa = sum(d) - 1
    
print(ans+wa//9)

Submission status: Wrong Answer

Solution code:
m = int(input())
d,c = [0]*m , [0]*m
for i in range(m):
    d[i],c[i] = map(int,input().split())
ans = sum(c) - 1
wa = sum(d)

if wa % 9 == 0:
    wa -= 1
    
print(ans+wa//9)

Submission status: Wrong Answer

Solution code:
m = int(input())
d,c = [0]*m , [0]*m
for i in range(m):
    d[i],c[i] = map(int,input().split())
ans = sum(c) - 1
wa = sum(d)
        
print(ans + wa//10)

Submission status: Wrong Answer

Solution code:
m = int(input())
d,c = [0]*m , [0]*m
for i in range(m):
    d[i],c[i] = map(int,input().split())
ans = sum(c) - 1
    
for i in range(m-1):
    if d[i] + d[i+1] >= 10:
        ans += 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
m = int(input())
ans = 0
sum_d = 0
for i in range(m):
  a, b = map(int, input().split())
  ans += b
  sum_d += a * b
print(ans + sum_d // 10 - 1)

Submission status: Wrong Answer

Solution code:
digit = 0
s = 0

M = int(input())
for _ in range(M):
    d, c = map(int, input().split())
    digit += c
    s += d * c

x = digit - 1
y = s // 9 + (s % 9 == 0)
print(x + y)

Submission status: Wrong Answer

Solution code:
M, *L = map(int, open(0).read().split())
m = 0
ans = 0
for d,c in zip(*[iter(L)]*2):
  m += d*c
  ans += c
x = len(str(m))
ans -= 1
for i in range(1,x):
  ans += m//(10**i)
print(ans)

Submission status: Wrong Answer

Solution code:
M=int(input())
c=[]
d=[]
for i in range(0,M):
    D,C=map(int,input().split())
    c.append(C)
    d.append(D)

s=sum(c[i]*d[i] for i in range(0,M))
digit=sum(c)
if s%9==0:
    print(digit-1+s//9-1)
elif s%9==1:
    print(digit-2+s//9)
else:
    print(digit-1+s//9)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

M = int(input())
d = [0] * M
c = [0] * M
for i in range(M):
    d[i], c[i] = map(int, input().split())  # dがc回続く
SUM = 0
for i in range(M):
    SUM += d[i] * c[i]
times = SUM // 9
print(sum(c) + times - 1)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    M = int(input())  # M[1,2*10**5]

    d, c = 0, 0
    for _ in range(M):
        d_, c_ = map(int, input().split())
        d += d_
        c += c_

    ret = ((d - 9 + 8) // 9) + (c - 1)
    print(ret)


if __name__ == '__main__':
    main()

# 桁が減って総和が変わらず
# 桁が変わらず総和が減る
# 桁が1で総和が10未満まで

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    M = int(input())  # M[1,2*10**5]

    d, c = 0, 0
    for _ in range(M):
        d_, c_ = map(int, input().split())
        d += d_
        c += c_

    ret = (d // 9) + (c - 1)
    print(ret)


if __name__ == '__main__':
    main()

# 桁が減って総和が変わらず
# 桁が変わらず総和が減る
# 桁が1で総和が10未満まで

Submission status: Wrong Answer

Solution code:
'''
https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    m = int(input())
    res = 0

    def digsum(n):
        res = 0
        while n:
            res += n%10
            n //= 10
        return res
    
    l = []
    for _ in range(m):
        d,c = map(int, input().split())
        res += c - 1 + d*c//10
        temp = d*c
        while temp >= 10:
            temp = digsum(temp)
        l.append(str(temp))
    a = int(''.join(l))
    while a >= 10:
        b = len(str(a))
        a = digsum(a)
        res += b - 1 + a//10
        a = digsum(a)
    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
'''
https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    m = int(input())
    res = 0

    def digsum(n):
        res = 0
        while n:
            res += n%10
            n //= 10
        return res
    
    l = []
    for _ in range(m):
        d,c = map(int, input().split())
        res += c - 1 + d*c//10
        temp = d*c
        while temp >= 10:
            temp = digsum(temp)
        l.append(str(temp))
    a = int(''.join(l))
    b = len(str(a))
    a = digsum(a)
    res += b - 1 + a//10
    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

M = int(input())
dc = [list(map(int,input().split())) for _ in range(M)]

#%%
ans = 0
memo_mod = [[0]*10 for _ in range(10)]
memo_num = [[0]*10 for _ in range(10)]


for i in range(10):
    for j in range(10):
        if i==0 and j==0:
            continue        
        num = 1
        mod = i+j
        while mod>=10:
            mod = mod%10 + mod//10
            num += 1
        memo_mod[i][j] = mod
        memo_num[i][j] = num
    
mod = 0
flag = True
for d,c in dc:
    ans += (c-1)
    amari_1 = d*c//10
    ans += amari_1 + amari_1//10
    new_mod = (d*c%10 + (d*c//10))%10
    if not flag:
        ans += memo_num[mod][new_mod]
    else:
        flag = False
    mod = memo_mod[mod][new_mod]
    print(ans,mod)
    
print(ans)

Submission status: Wrong Answer

Solution code:

M = int(input())
dc = [list(map(int,input().split())) for _ in range(M)]

#%%
ans = 0
memo_mod = [[0]*10 for _ in range(10)]
memo_num = [[0]*10 for _ in range(10)]


for i in range(10):
    for j in range(10):
        if i==0 and j==0:
            continue        
        num = 1
        mod = i+j
        while mod>=10:
            mod = mod%10 + mod//10
            num += 1
        memo_mod[i][j] = mod
        memo_num[i][j] = num
    
mod = 0
flag = True
for d,c in dc:
    ans += (c-1) + d*c//10
    new_mod = (d*c%10 + (d*c//10))%10
    if not flag:
        ans += memo_num[mod][new_mod]
    else:
        flag = False
    mod = memo_mod[mod][new_mod]
    
print(ans)

Submission status: Wrong Answer

Solution code:

M = int(input())
dc = [list(map(int,input().split())) for _ in range(M)]

#%%
ans = 0
memo_mod = [[0]*10 for _ in range(10)]
memo_num = [[0]*10 for _ in range(10)]


for i in range(10):
    for j in range(10):
        if i==0 and j==0:
            continue        
        num = 1
        mod = i+j
        while mod>=10:
            mod = mod%10 + mod//10
            num += 1
        memo_mod[i][j] = mod
        memo_num[i][j] = num
    
mod = 0
flag = True
for d,c in dc:
    ans += (c-1) + d*c//10
    new_mod = d*c%10
    if not flag:
        ans += memo_num[mod][new_mod]
    else:
        flag = False
    mod = memo_mod[mod][new_mod]

print(ans)

Submission status: Wrong Answer

Solution code:
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//9))

Submission status: Wrong Answer

Solution code:
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(d-1 + (c_sum//9))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_digit = ""
for i in range(m):
    d,c = map(int, input().split())
    ans += c-1
    cur_num = d*c
    ans += max(0,(cur_num//10)-1)
    sum_digit += str(cur_num)
#print(ans)
#print(sum_digit)
while len(sum_digit) >= 2:
    cur_sum = 0
    ans += len(sum_digit) - 1
    for i in range(len(sum_digit)):
        cur_sum += int(sum_digit[i])
    ans += max(0,(cur_sum//10)-1)
    sum_digit = str(cur_sum)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_digit = ""
for i in range(m):
    d,c = map(int, input().split())
    ans += c-1
    cur_num = d*c
    #桁上がりの数を足す
    sum_digit += str(cur_num)
while len(sum_digit) >= 2:
    cur_sum = 0
    ans += len(sum_digit) - 1
    for i in range(len(sum_digit)):
        cur_sum += int(sum_digit[i])
    sum_digit = str(cur_sum)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_digit = ""
for i in range(m):
    d,c = map(int, input().split())
    ans += c-1
    cur_num = d*c
    #桁上がりの数を足す
    ans += cur_num//10
    sum_digit += str(cur_num)
while len(sum_digit) >= 2:
    cur_sum = 0
    ans += len(sum_digit) - 1
    for i in range(len(sum_digit)):
        cur_sum += int(sum_digit[i])
    sum_digit = str(cur_sum)
print(ans)

Submission status: Wrong Answer

Solution code:
m = int(input())
ans = 0
sum_digit = ""
for i in range(m):
    d,c = map(int, input().split())
    ans += c-1
    cur_num = d*c
    #桁上がりの数を足す
    ans += cur_num//10
    sum_digit += str(cur_num)
while len(sum_digit) >= 2:
    cur_sum = 0
    ans += len(sum_digit) - 1
    for i in range(len(sum_digit)):
        cur_sum += int(sum_digit[i])
    sum_digit = str(cur_sum)
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())

ds = [list(map(int,input().split(" "))) for _ in range(M)]
ans = 0
s = 0
for d,c in ds:
    ans += c
    s += d * c
ans -= 1
ans += s//10
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())

ds = [list(map(int,input().split(" "))) for _ in range(M)]
ans = 0
s = 0
for d,c in ds:
    ans += c
    s += d
ans -= 1
ans += s//10
print(ans)

Submission status: Wrong Answer

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

def main():
    N = int(input())
    s,keta = 0,0
    for _ in range(N):
        a,b = map(int,input().split())
        s += a*b
        keta += b
        
    print(s//9+(keta-1))
        
if __name__ == "__main__":
    main()