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: Accepted

Solution code:
M = int(input())
DC = [tuple(map(int,input().split())) for i in range(M)]
s = k = 0
for d,c in DC:
    k += c
    s += d*c
ans = k-1 + (s-1)//9
print(ans)

Submission status: Accepted

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


def main():
    m = int(input())
    sum = 0
    digits = 0
    for _ in range(m):
        d, c = map(int, input().split())
        sum += d * c
        digits += c

    ans = digits - 1 + (sum-1) // 9

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


m = int(input())
s = 0
l = 0
for i in range(m):
    d,c = map(int, input().split())
    s += c*d
    l += c
val = s + 9*l
ans = (val-18)//9 + int((val-18)%9!=0)
print(ans)

Submission status: Accepted

Solution code:
M=int(input())
d,c=0,0
X=0
Y=0
for i in range(M):
  d,c=map(int,input().split())
  X+=c
  Y+=d*c
print(X-1+((Y-1)//9))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m=int(input())
dc=[]
for _ in range(m):
  d,c=map(int,input().split())
  dc.append([d,c])
ans=0
a=[]
for d,c in dc:
  ans+=c-1
  ans+=((d*c)-1)//9
  a.append((d*c)%9 if (d*c)%9!=0 else 9)
ans+=len(a)-1
ans+=((sum(a)-1)//9)
print(ans)

Submission status: Accepted

Solution code:
m=int(input())
n=0
ans=0
for i in range(m):
  x,y=map(int,input().split())
  n+=y
  ans+=x*y
n-=1
ans-=1
n+=ans//9
print(n)

Submission status: Accepted

Solution code:
#実験をすると順序によらず操作回数は一定そう
#...xy...でxとyに操作をすることを考える
#x+y<=9とx+y>=10で場合分けをすると、
#x+y<=9の時は、...xy... -> ...(x+y)... 1桁減る 総和は変わらない
#x+y>=10の時は、...xy... -> ...1(x+y-10)... 総和が9減る 桁数は変わらない
#最終的な状態は、1桁で、かつその数字が1~9になるので、
#桁数をn、総和をsとした時の答えはn-1+(s-1)/9になる
import sys
input = sys.stdin.readline

M = int(input())
s, n = 0, 0

for _ in range(M):
    d, c = map(int, input().split())
    s += d*c
    n += c
    
print(n-1+(s-1)//9)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
m = int(readline())
ans = 0
chk = -1
for i in range(m):
  d,c = map(int,readline().split())
  ans += c
  chk += d*c
  if chk > 8:
    ans += chk//9
    chk %= 9
print(ans-1)

Submission status: Accepted

Solution code:
M = int(input())

cur = 0

keta = 0
csum = 0
for _ in range(M):
  d,c = map(int,input().split())
  s = 0
  for i in str(d):
    s += int(i)
  csum += s * c
  keta += c

# 9をカウントしたくないため
print(keta-1 + (csum-1)//9)

Submission status: Accepted

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

moveup = (total-1)//9

print(digit + moveup - 1)

Submission status: Accepted

Solution code:
M = int(input())
Keta=0
Sum=0

for _ in range(M):
    d,c = map(int,input().split())
    Keta+=c
    Sum+=d*c
print(Keta-1 + (Sum-1)//9)

Submission status: Accepted

Solution code:
M = int(input())
S = 0 # 和
C = 0 # 桁数
for m in range(M):
    d, c= map(int, input().split())
    S += d*c
    C += c
print ((C-1)+(S-1)//9)

Submission status: Accepted

Solution code:
n = int(input())
d, d_sum = 0, 0
for _ in range(n):
    a, b = map(int, input().split())
    d += b
    d_sum += a * b

print(d - 1 + (d_sum - 1) // 9)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d

import sys
input=sys.stdin.readline

def main():
    M=int(input())
    dc=[tuple(map(int,input().split())) for i in range(M)]
    ans=0
    n=0
    for i in range(M):
        n+=dc[i][0]*dc[i][1]
        ans+=dc[i][1]
    ans-=1
    def aint(x):
        ret=0
        cnt=0
        while(x>0):
            cnt+=1
            ret+=x//10
            x//=10
        cnt-=1
        return int(ret)-cnt
            
    if n>=10:
        ans+=aint(n)
        

    while(n>=10):
        ns=str(n)
        n=0
        for i in range(10):
            c=ns.count(chr(i+ord("0")))
            n+=i*c
        ans+=len(ns)-1
        if n>=10:
            ans+=aint(n)
    print(ans)
        
    
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
M = int(input())

digit = 0
sum = 0

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

print(digit - (-(sum - 9) // 9) - 1)

Submission status: Accepted

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

# print(d)
# print(c)

D = 0
S = 0
for i in range(M):
    D += c[i]
    S += d[i] * c[i]

# print(D, S)
print((D - 1) + (S - 1) // 9)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    M = int(input())
    # d = [None]*M
    # c = [None]*M
    sumc = 0
    sumd = 0
    for i in range(M):
        td, tc = map(int, input().split())
        # d[i] = td
        # c[i] = tc
        sumc += tc
        sumd += td*tc
    # result = sumd%10+sumd//10
    # # print(sumd,c,d,result)
    # if result > 9:
    #     print(sum(c)+sumd//10)
    # else:
    print(sumc-1+(sumd-1)//9)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read


def main():
    M, *DC = map(int, read().split())

    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c

    print(digits - 1 + (total - 1) // 9)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c

    ans = digits - 1 + (total - 1) // 9

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

M = int(input())
dc = [list(mapint()) for _ in range(M)]
ans = 0
nowd = 0
for m in range(M):
    d, c = dc[m]
    s = nowd + d*c
    ans += c+s//10
    nowd = s%10+s//10
    while nowd>=10:
        ans += nowd//10
        nowd = nowd%10+nowd//10
print(ans-1)

Submission status: Accepted

Solution code:
n=int(input())
import sys
d=0
now=0
input=sys.stdin.readline
for i in range(n):
  a,b=map(int,input().split())
  now+=a*b
  d+=b
print((now-1)//9+d-1)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

m = int(input())
total = 0
ans = 0
for _ in range(m):
    d, c = map(int, input().split())
    total += d*c
    ans -= (d - 1)*c
while total > 9:
    temp = total%10
    total -= temp
    ans += total//10 * 10
    total = total//10 + temp
ans += total - 1
print(ans)

Submission status: Accepted

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

print(sum(c)-1+(sum([c[i]*d[i] for i in range(m)])-1)//9)

Submission status: Accepted

Solution code:
M = int(input())
S = 0
C = 0
for m in range(M):
    d, c= map(int, input().split())
    S += d*c
    C += c
print ((C-1)+(S-1)//9)

Submission status: Accepted

Solution code:
#桁数をNとし、各桁の数字の和をSとすると
#(N - 1) + (S - 1) // 9 が答え

M = int(input())
S = 0 #mod 9
N = 0
for i in range(M):
  d, c = map(int, input().split())
  N += c
  S += d * c
  
ans = (N - 1) + (S - 1) // 9
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.stdin.readline

def main():
    m = int(input())
    a = [list(map(int, input().split())) for _ in range(m)]
    wa = 0
    length = 0
    for i,j in a:
        wa += i*j
        length += j
    #print(wa,length)
    print(length-1+(wa-1)//9)
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
M = int(input())
ans = -1
S = 0
for i in range(M):
  d, c = map(int, input().split())
  ans += c
  S += d*c

ans += (S - 1) // 9
print(ans)

Submission status: Accepted

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-1)//9+di-1)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
m,*dc = map(int,open(0).read().split())
d = dc[::2]
c = dc[1::2]

dc_sum = sum(di*ci for di,ci in zip(d,c))
c_sum = sum(c)

ans = c_sum -1 + (dc_sum-1)//9
print(ans)

Submission status: Accepted

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) - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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())
    total = sum(d * c for d, c in zip(DC[::2], DC[1::2]))
    ans = sum(DC[1::2]) - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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))
    q, r = divmod(total, 9)
    ans = sum(C) - 1 + q - (r == 0)
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve():
    M = int(input())
    ans, s = 0, 0

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

    ans += (s-1)//9 - 1
    print(ans)

solve()

Submission status: Accepted

Solution code:
M = int(input())
ans, s = 0, 0

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

ans += (s-1)//9 - 1
print(ans)

Submission status: Accepted

Solution code:
M = int(input())
ans = 0

c1 = []
for _ in range(M):
    d, c = map(int, input().split())
    v1 = ((d*c)//9)-((d*c)%9==0 and d*c>0)
    v2 = c-1
    ans += v1+v2
    c1.append(d*c-9*v1)

ans += M-1
s = sum(c1)
ans += (s//9)-(s%9==0 and s>0)
print(ans)

Submission status: Accepted

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-1)//9)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    M = I()
    dc = [LI() for _ in range(M)]

    s = sum([i[0]*i[1] for i in dc])
    print((sum([i[1] for i in dc])-1)+(s-1)//9)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

if now==0:
    ans-=1

print(ans)

Submission status: Accepted

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

D,S=0,0
for d,c in DC:
    D +=c
    S +=d*c
print(D-1+(S-1)//9)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
digit = 0
d_sum = 0
for i in range(N):
    x,y = map(int, input().split())
    digit += y
    d_sum += x*y
print(digit-1+(d_sum-1)//9)

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    m=int(input())
    dc=[[0]*2 for i in range(m)]
    for i in range(m):
        dc[i]=list(map(int,input().split()))
elif icase==1:
    m=1
    dc=[[5,2]]

    
dsum=0
csum=0
for i in range(m):
    dsum+=dc[i][0]*dc[i][1]
    csum+=dc[i][1]

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

print(ans)

Submission status: Accepted

Solution code:
M = int(input())

s = 0
dig = 0
for i in range(M):
    d, c = map(int, input().split())
    s += d * c
    dig += c

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

Submission status: Accepted

Solution code:

import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline

def resolve():
    N = int(inp())

    S = 0
    D = 0
    for i in range(N):
        d, c = map(int, inp().split())
        S += d*c
        D += c

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:

def resolve():
    N = int(input())

    S = 0
    D = 0
    for i in range(N):
        d, c = map(int, input().split())
        S += d*c
        D += c

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    M,*cd = map(int, read().split())

    D = 0
    S = 0
    for d, c in zip(*[iter(cd)]*2):
        D += c
        S += c * d
    
    ans = (D - 1) + (S - 1) // 9
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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) // 9))

Submission status: Accepted

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-1)//9)

Submission status: Accepted

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-1)//9)

Submission status: Accepted

Solution code:
m = int(input())
a = 0
b = 0
for _ in range(m):
    d, c = [int(i) for i in input().split()]
    a += c
    b += d * c

print(a - 1 + (b - 1) // 9)

Submission status: Accepted

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 * c
    digit += c

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

print(ans)

Submission status: Accepted

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-1)//9)

if __name__ == '__main__':
    main()

Submission status: Accepted

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-1)//9)

main()

Submission status: Accepted

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 += c

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

Submission status: Accepted

Solution code:
def solve():
    m = int(input())
    s = 0
    d = 0
    for _ in range(m):
        a,b = map(int,input().split())
        d+=b
        s+=a*b
    print((s-1)//9 + d-1)
if __name__=='__main__':
    solve()

Submission status: Accepted

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*c
    sumc += c

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

Submission status: Accepted

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

M = int(readline())
DC = list(tuple(map(int, readline().split())) for _ in range(M))
res = sum(c*d for c, d in DC)
Z = sum(c for _, c in DC)
print((Z-1)+(res-1)//9)

Submission status: Accepted

Solution code:
m=int(input())
d=c=-1
for _ in range(m):
  dd,cc=map(int,input().split())
  d+=dd*cc
  c+=cc
print(c+d//9)

Submission status: Accepted

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 * c for d, c in X)
print(d - 1 + (s - 1) // 9)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    d = 0
    s = 0
    for _ in range(int(input())):
        a, b = map(int, input().split())
        s += a * b
        d += b
    print(d - 1 + (s - 1) // 9)

main()

Submission status: Accepted

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) // 9)

Submission status: Accepted

Solution code:
def main():
    M=int(input())
    DC=[list(map(int,input().split())) for _ in range(M)]
    D=sum([c for d,c in DC])
    S=sum([d*c for d,c in DC])
    print((D-1)+(S-1)//9)

main()

Submission status: Accepted

Solution code:
m=int(input())
dc=[[int(j) for j in input().split()] for i in range(m)]
s=0
k=0
for d,c in dc:
    s+=d*c
    k+=c
print((k-1)+(s-1)//9)

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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
ans += (m-1)//9-1
print(ans)

Submission status: Accepted

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)
else:
    print(digit-1+s//9)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
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():
    m = I()
    s,d = 0,0
    for i in range(m):
        a,b = LI()
        s += b
        d += a*b
    print(s-1+(d-1)//9)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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 = math.ceil(SUM / 9) - 1
print(sum(c) + times - 1)

Submission status: Accepted

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

    d_sum, c_sum = 0, 0
    for _ in range(M):
        d_, c_ = map(int, input().split())
        d_sum += d_ * c_
        c_sum += c_

    ret = ((d_sum - 9 + 8) // 9) + (c_sum - 1)
    print(ret)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

m = int(input())

sum_n = 0
len_n = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_n += d*c
    len_n += c

ans = len_n-1 + (sum_n-1)//9
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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, total = 0, 0

    for _ in range(m):
        d,c = map(int, input().split())
        total += d*c
        res += c
    res -= 1
    res += (total-1)//9
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    M = INT()

    SUM = 0
    keta = 0
    for _ in range(M):
        d,c = MAP()
        SUM += c*d
        keta += c
    
    print(keta-1+(SUM-1)//9)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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


x = sum([C[i] * D[i] for i in range(m)])
ans = sum(C) - 1 + (x - 1) // 9
print(ans)

Submission status: Accepted

Solution code:
M = int(input())
digit_num = 0
digit_sum = 0
for i in range(M):
    d, c = map(int, input().split())
    digit_num += c
    digit_sum += d * c
tmp = 0
if digit_sum % 9 == 0:
    tmp = digit_sum // 9 - 1
else:
    tmp = digit_sum // 9
print((digit_num - 1) + tmp)

Submission status: Accepted

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-1)//9))

Submission status: Accepted

Solution code:
import math
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 += math.ceil((s - 9)/9)
print(ans)

Submission status: Accepted

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-1)//9+keta-1)
        
if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
sums=0
digits=0
for _ in range(n):
  a,b=map(int,input().split())
  sums+=a*b
  digits+=b
ans=(digits-1)+(sums-1)//9
print(ans)

Submission status: Accepted

Solution code:
m = int(input())
dc = [list(map(int,input().split())) for i in range(m)]
digit = 0
dsum = 0
for i in range(m):
  digit += dc[i][1]
  dsum += dc[i][0]*dc[i][1]
print(digit-1+(dsum-1)//9)

Submission status: Accepted

Solution code:
m = int(input())
CD = [list(map(int, input().split())) for _ in range(m)]
count = 0
tmp = -1
total = 0
for c, d in CD:
  q, m = divmod(tmp + c * d, 9)
  count += q
  tmp = m
  total += d
print(total - 1 + count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = map(int,input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)

Submission status: Accepted

Solution code:
import sys

m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = map(int,input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)

Submission status: Accepted

Solution code:
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  c = [int(x) for x in input().split()]
  csum += c[1]
  dsum += c[0]*c[1]
print(csum-1 + (dsum-1) // 9)

Submission status: Accepted

Solution code:
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = (int(x) for x in input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)

Submission status: Accepted

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

from collections import deque

q = deque()

def calc(d, c):
    if c&1:
        q.append(d)
    if c == 1:
        return 0
    d *= 2
    c>>=1
    if d >= 10:
        return c * 2 + calc(1+d%10, c)
    return c + calc(d, c)
    

def main():
    M = int(input())
    ans = 0
    for i in range(M):
        d, c = map(int, input().split())
        ans += calc(d, c)
    
    num = q.popleft()
    while len(q) > 0:
        t = q.popleft()
        num += t
        if num >= 10:
            num = 1 + num%10
            ans += 1
        ans += 1
    
    print(ans)

if __name__ == "__main__":
    main()