Harryxun/stf_run huggingface dataset:
class UnionFind:
    def __init__(self, length):
        self.par = [_ for _ in range(length)]
        self.size_dict  = dict([(i,1) for i in range(length)])

    def root(self,x):
        if (self.par[x] == x):
             return x
        else:
            #change connection 
            self.par[x] =self.root(self.par[x])
            return self.par[x]
    
    def unite(self,x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        if (root_x==root_y):
            pass
        else:
            self.par[root_x] = root_y
            self.size_dict[root_y] += self.size_dict[root_x]
            self.size_dict[root_x] = -1
        
    def same(self,x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        return root_x == root_y 
    
    def size(self,x):
        root_x = self.root(x)
        return self.size_dict[root_x]

"""
uf = UnionFind(5)
uf.unite(3,4)
uf.unite(1,2)
uf.unite(1,4)
print(uf.size_dict)
"""


N,M = [ int(i) for i in input().split(" ")]
edges = [ tuple([ int(num)-1 for num in  input().split(" ")]) for _ in range(M) ]
score= N*(N-1)/2
outputs = [score]
uf = UnionFind(N)
for edge in edges[::-1]:
    if not uf.same(*edge):
        score -= uf.size(edge[0]) * uf.size(edge[1])
        uf.unite(*edge)
    outputs.append(score)
for i in range(M):
    print(int(outputs[M-i-1]))



### FIXED CODE ###

class UnionFind:
    def __init__(self, length):
        self.par = [-1 for _ in range(length)]
        self.rank = [0 for _ in range(length)]
 
    def root(self,x):
        if (self.par[x] < 0 ):
             return x
        else:
            #change connection
            root = self.root(self.par[x])
            self.par[x] = root
            return root
    
    def unite(self,x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        if (root_x==root_y):
            return 
        else:
            if self.rank[root_x] < self.rank[root_y]:
                self.par[root_y] += self.par[root_x]
                self.par[root_x] = root_y

            else:
                self.par[root_x] += self.par[root_y]
                self.par[root_y] = root_x
                if self.rank[root_x] == self.rank[root_y]:
                    self.rank[root_x]+=1
        
    def same(self,x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        return root_x == root_y 
    
    def size(self,x):
        return -self.par[self.root(x)]

"""
uf = UnionFind(5)
uf.unite(3,4)
uf.unite(1,2)

uf.unite(1,4)
print(uf.size_dict)
"""
def solve(edges,N,M):
 
    score= N*(N-1)//2
    outputs = [score]
    uf = UnionFind(N)
    for edge in edges[::-1]:
        if not uf.same(*edge):
            score -= uf.size(edge[0]) * uf.size(edge[1])
            uf.unite(*edge)
        outputs.append(score)
    for i in range(M):
        print(int(outputs[M-i-1]))

def get_input():
    N,M = map(int, input().split())
    edges = [tuple(map(lambda x:  int(x)-1, input().split())) for _ in range(M)]
    return N,M,edges

N,M,edges = get_input()
# = 10**6
#M=10**5
#import numpy as np
#edges = [(np.random.randint(N),np.random.randint(N)) for i in range(M)]
solve(edges,N,M)
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

# n 問題案数
# m 必要問題数
# d 難易度
# t 難易度

freq_of_val_in_d = dict()
freq_of_val_in_t = dict()

for v in d:
    if v in freq_of_val_in_d:
        freq_of_val_in_d[v] += 1
        continue
    freq_of_val_in_d[v] = 1

for v in t:
    if v in freq_of_val_in_t:
        freq_of_val_in_t[v] += 1
        continue
    freq_of_val_in_t[v] = 1

f = True
for v in t:
    if freq_of_val_in_t[v] > freq_of_val_in_d[v]:
        f = False

if f:
    print("YES")
else:
    print("NO")




### FIXED CODE ###

from collections import Counter
input()
c1 = Counter(map(int, input().split()))
input()
c2 = Counter(map(int, input().split()))
print("YES" if all(c1[k] >= v for k, v in c2.items()) else "NO")
n=int(input())
path=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    path[u-1].append((v-1,w%2))
    path[v-1].append((u-1,w%2))
ans=[0]+[-1]*(n-1)
def dfs(i):
    global n,path,ans
    for j in path[i]:
        if ans[j[0]]==-1:
            if j[1]:
                ans[j[0]]=1-ans[i]
                dfs(j[0])
            else:
                ans[j[0]]=ans[i]
                dfs(j[0])
dfs(0)
print("\n".join(map(str,ans)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n=int(input())
path=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    path[u-1].append((v-1,w%2))
    path[v-1].append((u-1,w%2))
ans=[0]+[-1]*(n-1)
def dfs(i):
    global n,path,ans
    for j in path[i]:
        if ans[j[0]]==-1:
            if j[1]:
                ans[j[0]]=1-ans[i]
                dfs(j[0])
            else:
                ans[j[0]]=ans[i]
                dfs(j[0])
dfs(0)
print("\n".join(map(str,ans)))
X = int(input())
fh = x // 500
f = (x - (500*fh)) // 5
pint(f*5+fh*1000)

### FIXED CODE ###

x = int(input())
fh = x // 500
f = (x - (500*fh)) // 5
sum = f*5+fh*1000
print(sum)
import functools
from math import gcd
N = int(input())
A = list(map(int, input().split()))
MAX = 10 * 6 + 10

if functools.reduce(gcd, A) == 1:
    print("setwise coprime")
    exit()

prime_list = [i for i in range(MAX + 1)]
p = 2
while p * p <= MAX:
    if prime_list[p] == p:
        for q in range(2*p, MAX+1, p):
            if prime_list[q] == q:
                prime_list[q] = p
    p += 1

prime = set()
for a in A:
    tmp = set()
    while a > 1:
        tmp.add(prime_list[a])
        a //= prime_list[a]
    for p in tmp:
        if p in prime:
            print("setwise coprime")
            exit()
        prime.add(p)
else:
    print("pairwise coprime")


### FIXED CODE ###

import functools
from math import gcd
N = int(input())
A = list(map(int, input().split()))
MAX = 10 ** 6 + 10

if functools.reduce(gcd, A) != 1:
    print("not coprime")
    exit()

prime_list = [i for i in range(MAX + 1)]
p = 2
while p * p <= MAX:
    if prime_list[p] == p:
        for q in range(2*p, MAX+1, p):
            if prime_list[q] == q:
                prime_list[q] = p
    p += 1

prime = set()
for a in A:
    tmp = set()
    while a > 1:
        tmp.add(prime_list[a])
        a //= prime_list[a]
    for p in tmp:
        if p in prime:
            print("setwise coprime")
            exit()
        prime.add(p)
else:
    print("pairwise coprime")
n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis={}
vis[0] = 0
vis[1] = 0
if n > 1:
  vis[2] = abs(arr[0]-arr[1])
if n == 2:
  print(vis[2])
for i in range(2, n+1):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-1]
    vis[i+1] = min(step_1, step_2)
   
print(vis[i])

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print(max(a * c, a * d, b * c, b * d))
n, k = map(int, input().split())
print(N*k)

### FIXED CODE ###

n, k = map(int, input().split())
print(n*k)
s = input().split()
t = input().split()
print(sum[s[i] == t[i] for i in range(3)])


### FIXED CODE ###

s = input()
t = input()
print(sum(s[i] == t[i] for i in range(3)))
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+1))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))

### FIXED CODE ###

import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))
import math
n = int(input())
nn = int(math.sqrt(n))
while n%nn != 0: nn-=1
ans = len(str(n/nn))
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())

ans = (a+b)%24

print(ans)
N = int(input())

a = [int(i) for i in input().split()]

i=0

c=0
max = 0
min = 0
for i in a[i]:
  if a[i] >= max:
    max = a[i]
  elif a[i] <= min:
    min = a[i]
  else
    i +=1
    
print (max - min)
  


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dist = []
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dist.append(abs(a[i]-a[j]))
print(max(dist))
# coding:utf-8
import math
array = map(int,raw_input().split())
x1 = array[0]
y1 = array[1]
x2 = array[2]
y2 = array[3]
answer = math.sqrt(math.pow(x2 - x1,2) + math.pow(y2 - y1,2))
print answer



### FIXED CODE ###

# coding:utf-8
import math
array = map(float,raw_input().split())
x1 = array[0]
y1 = array[1]
x2 = array[2]
y2 = array[3]
answer = math.sqrt(math.pow(x2 - x1,2) + math.pow(y2 - y1,2))
print answer
import bisect

N, M = map(int, input().split(" "))
As = list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
j = 0
for _ in range(M):
  if j >= As[-1-cnt]:
    i = j>>1
  else:
    i = As[-1-cnt]>>1
    
  j = i
  
  if i < As[-1-cnt-1]:
    cnt += 1
    bisect.insort_left(As,i)

if j > As[-1-cnt-1]:
  bisect.insort_left(As,j)
  cnt += 1

print(sum(As[:-cnt]))

### FIXED CODE ###

import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))
suuji = list(input())
count = 0
for i in range(0, len(suuji)):
  for j in range(i+3, len(suuji) + 1):
    if (int)(''.join(suuji[i:j])) % 2019 == 0:
      count += 1
print(count)

### FIXED CODE ###

s, w = map(int, input().split(" "))
print("safe" if s > w else "unsafe")
n,m=map(int,input().split())
ans=[0 for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  ans[a-1]+=1
  ans[b-1]+=1
for i in range(n):
  print(a[i])

### FIXED CODE ###

n,m=map(int,input().split())
ans=[0 for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  ans[a-1]+=1
  ans[b-1]+=1
for i in range(n):
  print(ans[i])
n = int(raw_input())
hs = raw_input()
print("20")

### FIXED CODE ###

a = int(input())


hs = [int(x) for x in input().split()]

if a == 1:
  print(0)
  exit()
dp = [0]* len(hs)


dp[0] = 0
dp[1] = abs(hs[1] - hs[0])

for i in range(2, a):
  dp[i] = min(abs(hs[i-1]- hs[i]) + dp[i-1], abs(hs[i-2]- hs[i]) + dp[i-2] )
  
print(dp[-1])
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

s=input()
t=input()
s=list(s)
t=list(t)
Ss=set(s)
St=set(t)
n=len(s)

alp=string.ascii_lowercase
di=dict([(i,j) for j,i in enumerate(alp)])
#print(di)
g=[{} for _ in range(n)]
fp=[-1 for i in range(26)]
lp=[-1 for i in range(26)]

for i,c in enumerate(s):
    fp[di[c]]=i
    for next_c in [di[l] for l in Ss]:
        g[i][next_c]=(min(g[i][next_c],fp[next_c]),1)

for i in range(n)[::-1]:
    lp[di[s[i]]]=i
    for next_c in [di[l] for l in Ss]:
        if lp[next_c]!=-1:
            g[i][next_c]=(lp[next_c],0)

m=[[] for i in range(n)]


#print(Ss,St,St-Ss)
if len(St-Ss)!=0:
    ans=-1
else:
    loop=0
    has=0
    st=di[t[0]]
    loop+=g[0][st][1]
    i_n=g[0][st][0]
    has=i_n
    for i in range(1,len(t)):
        ch=di[t[i]]
        loop+=g[i_n][ch][1]
        i_n=g[i_n][ch][0]
        has=g[i_n][ch][0]
        #print(loop,has,i_n,g[i_n][ch])
    ans=loop*n+has+1
print(ans)#,loop,has)
#print([[i,di[i]] for i in s])
'''
for i in g:
    print(sorted(list(i.items()),key=lambda x:x[0]))
'''


### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
alp=string.ascii_lowercase
d_al=dict([(i,j) for j,i in enumerate(alp)])

s=[d_al[i] for i in input()]
t=[d_al[i] for i in input()]
Ss=set(s)
St=set(t)
ns=len(s)
nt=len(t)
ss=s*2
#print(ss)

g=[{} for _ in range(ns)]
pos=[-1]*26
for i in range(ns*2)[::-1]:
    for j in Ss:
        if i<ns:
            g[i][j]=pos[j]-i
    pos[ss[i]]=i
#for i in range(len(g)):
#    print(g[i])

if len(St-Ss)!=0:
    ans=-1
else:
    cur=0
    cur+=g[-1][t[0]]-1
    #print(cur)
    for i in range(1,nt):
        #print(cur,s[cur%ns],'tg=',t[i],g[cur%ns][t[i]])
        cur+=g[cur%ns][t[i]]
    ans=cur+1
print(ans)
from collections import defaultdict

class Tree:
  def __init__(self):
    self.edges = defaultdict(set)
  
  def add(self, x, y, w):
    self.edges[x].add((y, w))
    self.edges[y].add((x, w))
  
  def traverse(self, start):
    return self._traverse(start, 0, set([start]), [])
  
  def _traverse(self, start, dist, already_visited, result):
    out_nodes = self.edges[start]
    for out_node, w in out_nodes:
      if out_node in already_visited:
        continue
      new_dist = dist + w
      result.append((out_node, new_dist))
      self._traverse(out_node, new_dist, already_visited | set([out_node]), result)
    return result
      
n = int(input())
tree = Tree()
for _ in range(n-1):
  xyw = list(map(int, input().split()))
  tree.add(*xyw)

node_dists = list(tree.traverse(1))
print(0)
"""
node_dists.append((1, 0))
node_dists = sorted(node_dists, key=lambda x: x[0])

for node, dist in node_dists:
  print(1 if dist % 2 == 0 else 0)
"""

### FIXED CODE ###

#!/usr/bin/env python
import bisect
from collections import defaultdict
import math

def main():
    #N = map(int, input().split())
    N = int(input())

    edges = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        edges[u-1].append((v-1, w))
        edges[v-1].append((u-1, w))

    colors = [None]*N
    colors[0] = 0
    colored = [(0, 0)]
    while colored:
        new_colored = []
        for n, d in colored:
            nodes = edges[n]
            for m, w in nodes:
                if colors[m] is None:
                    dist = d + w
                    if dist % 2 == 0:
                        colors[m] = 0
                    else:
                        colors[m] = 1
                    new_colored.append((m, dist))
        colored = new_colored

    for n in range(N):
        print(colors[n])

if __name__ == '__main__':
    main()
a=nums[0]
b=nums[1]
print a*b 2*(a+b)

### FIXED CODE ###

a,b=map(int, raw_input().split())
c=a*b 
d=2*(a+b)
print c,d
w,h,x,y = map(int,input().split())

print(w*h/2)
if x == w/2 and y == h/2:
        print(1)
else:
        print(0)


### FIXED CODE ###

x,a = map(int,input().split(" "))

if x < a:
    print(0)
else:
    print(10)
def dfs(i,s,res):
    if i==2:
        if res == 7:
            return s
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
print(dfs(0,S[0],int(S[0]))+"=7")


### FIXED CODE ###

def dfs(i, Str, res):
    if i==3:
        if res==7:
            print(Str+"=7")
            exit()
        return
    
    dfs(i+1,Str+"+"+s[i+1],res+int(s[i+1]))
    dfs(i+1,Str+"-"+s[i+1],res-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))
n = int(input())

if n < 105:
	print(0)
elif n == 105 or n == 106:
	print(1)
else:
	if n % 2 == 0:
		length = n / 2 - 1
	else:
		length = n / 2
	array = []
	answer = 1
	for i in range(53,length+1):
		number = i * 2 + 1
		for x in range(1,n+1):
			if number % x == 0:
				array.apped(x)
		if len(array) == 8:
			answer += 1
	print(answer)

### FIXED CODE ###

n = int(input())

if n < 105:
	print(0)
elif n == 105 or n == 106:
	print(1)
else:
	if n % 2 == 0:
		length = int(n / 2) - 1
	else:
		length = int(n / 2)
	array = []
	answer = 1
	for i in range(53,length+1):
		number = i * 2 + 1
		for x in range(1,n+1):
			if number % x == 0:
				array.append(x)
		if len(array) == 8:
			answer += 1
		array.clear()
	print(answer)
n=int(input())
v=list(map(int,input().split()))
v.sort(reverce=True)
for i in range(n-1):
    a=v.pop()
    b=v.pop()
    v.append((a+b)/2)
    v.sort(reverse=True)
print(v[0])

### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
v.sort(reverse=True)
for i in range(n-1):
    a=v.pop()
    b=v.pop()
    v.append((a+b)/2)
    v.sort(reverse=True)
print(v[0])
n=int(input())
    a = list(map(int,input().split()))
    even=[el for el in a if el % 2==0]
    try:
      for a in even:
        if a % 3 == 0 or a % 5 == 0:
          flg = 1
        else:
          raise
    except:
      print('DENIED')
    else:
      print('APPROVED')

### FIXED CODE ###

n=int(input())
a = list(map(int,input().split()))
even=[el for el in a if el % 2==0]
try:
  for a in even:
    if a % 3 == 0 or a % 5 == 0:
      flg = 1
    else:
      raise
except:
  print('DENIED')
else:
  print('APPROVED')
import collections
import math

MOD = 10**9 + 7


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = map(int, input().split())
mm = math.ceil(math.sqrt(m))
sieve = eratosthenes(mm)
primes = [i for i in range(mm) if sieve[i]]
counter = collections.Counter()
for p in primes:
    while m % p == 0:
        counter[p] += 1
        m //= p
    if m == 1:
        break
else:
    if m != 1:
        counter[m] += 1

me = max(counter.values())
factorials = [1]
for i in range(1, me + 1):
    factorials.append(factorials[-1] * i)

res = 1
for p, e in counter.items():
    for i in range(e):
        res *= e + n - 1 - i
    res //= factorials[e]
    res %= MOD
print(res)

### FIXED CODE ###

import collections
import math

MOD = 10**9 + 7


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = map(int, input().split())
mm = math.ceil(math.sqrt(m))
sieve = eratosthenes(mm)
primes = [i for i in range(mm) if sieve[i]]
counter = collections.Counter()
for p in primes:
    while m % p == 0:
        counter[p] += 1
        m //= p
    if m == 1:
        break
else:
    if m != 1:
        counter[m] += 1

me = max(counter.values()) if len(counter.values()) > 0 else 0
factorials = [1]
for i in range(1, me + 1):
    factorials.append(factorials[-1] * i)

res = 1
for p, e in counter.items():
    for i in range(e):
        res *= e + n - 1 - i
    res //= factorials[e]
    res %= MOD
print(res)
S = input()
T = input()
c = 0
l = []
for i in range(len(S)-len(T)):
    for j in range(len(T)):
        if (T[j] != S[i+j]):
            c += 1       
    l.append(c)
    c = 0
print(min(l))

### FIXED CODE ###

S = input()
T = input()
c = 0
l = []
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if (T[j] != S[i+j]):
            c += 1       
    l.append(c)
    c = 0
#print(l)
print(min(l))
A, op, B = str(input()).split()
A = int(A)
B = int(B)
op = str("+", "-")
if op =="+":
    print(A+B)
elif op == "-":
    print(A-B)

### FIXED CODE ###

A, op, B = input().split()

if op =="+":
    print(int(A) + int(B))
elif op == "-":
    print(int(A) - int(B))
import math
A, B, C, D = map(int, input().split())
U = B - A + 1


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st)//x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)


### FIXED CODE ###


A, B, C, D = map(int, input().split())
U = B - A + 1

MofD = 0
MofCD = 0

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)


def sten(st, en, x):
    if x == 1:
        return en - st + 1
    st = st // x if st % x == 0 else st // x + 1
    en = en // x
    st *= x
    en *= x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
if C != D:
    MofD = sten(A, B, D)
    MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)
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 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))
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)


### FIXED CODE ###

import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

targetnum=999
minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)
N = int(split())
print(sum(range(1,N)))

### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
S = input()
gene = ['A','T','C','G']

length = len(S)
ans = 0
tmp = 0

for i in range(length):
  if s[i] in gene:
    tmp += 1
  else:
    tmp = 0
  if tmp >= ans:
    ans = tmp
print(ans)
      

### FIXED CODE ###

S = input()
gene = ['A','T','C','G']

length = len(S)
ans = 0
tmp = 0

for i in range(length):
  if S[i] in gene:
    tmp += 1
  else:
    tmp = 0
  if tmp >= ans:
    ans = tmp
print(ans)
import string
az = list(string.ascii_lowercase)
li = [0 for a in range(len(az))]

while True:
    a = raw_input()
    if a != '':
        for b in list(a):
            if b.lower() in az:
                tmp = az.index(b.lower())
                li[tmp] = li[tmp] + 1
    else:
        break

for c in range(len(az)):
    print az[c] + ' : ' + str(li[c])

### FIXED CODE ###

import string
az = list(string.ascii_lowercase)
li = [0 for a in range(len(az))]

while True:
    try:
        a = raw_input()
        for b in list(a):
            if b.lower() in az:
                tmp = az.index(b.lower())
                li[tmp] = li[tmp] + 1
    except:
        break

for c in range(len(az)):
    print az[c] + ' : ' + str(li[c])