Harryxun/stf_run huggingface dataset:
n,a,b = map(int,input().split())
def ten(i):
  wa = 0
  while i != 0:
     wa += i%10
     i = i//10
  print(wa)  

for i in range(n + 1):
  result = 0
  if a <= ten(i) and ten(i)<=b:
    result += i
print(result)    


### FIXED CODE ###

n,a,b = map(int,input().split())
def ten(i):
  wa = 0
  while i != 0:
     wa += i%10
     i = i//10
  return(wa)  

result = 0
for i in range(n + 1):
  if a <= ten(i) and ten(i)<=b:
    result += i
print(result)
S, T= input().split()
A, B= map(int, input().split())
U= input().split()

if (S==U):
    print(str(A-1) B)
else:
    print(A str(B-1))

### FIXED CODE ###

S, T= input().split()
A, B= map(int, input().split())
U= input()
if (S == U):
    print(A-1,B)
elif (T == U):
    print(A,B-1)
else:
    print(A,B)
s=input()
j=0
for i in "AKIHABARA":
    if i==s[j]:
        j+=1
    elif i=="A":
        continue
    elif j==len(s):
        break
    else:
        print("NO")
        exit()
print("YES") 

### FIXED CODE ###

a=["KIH","B","R",""]
ans=[]
aaa=[]
for i in range(16):
    b=""
    for j,k in enumerate(a):
        if ((i >> j) & 1):
            b+="A"
        b+=k
    ans.append(b)
print("YES" if input() in ans else "NO")
def fiv(n):
    return (((1+(5)**(1/2))/2)** (n + 1) - ((1-(5)**(1/2))/2)** (n + 1))/(5**(1/2))

n, m = map(int, input().split())
broken = []
for i in range(m):
	broken.extend(map(int, input()))

p = [0] * (m + 1) #broken間の登り方list

for i in range(m + 1):
    if i == 0: #a1 さいしょ
        if broken[0] == 1:
            p[0] = 1
        else:
            p[0] = fiv(broken[0] - 1)
    if i == m: #am さいご
        if broken[m - 1] == n - 1:
            p[m] = 1
        else:
            p[m] = fiv(n - broken[0] - 1)
    
    else:
        if broken[i] - broken[i - 1] - 1 == 0:
            print('0')
            exit()
        else:
            p[i] = fiv(broken[i] - broken[i - 1] - 1)

ans = 1
for i in range(m + 1):
    ans = ans * p[i] / 1000000007

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
mod = 10 ** 9 + 7
dp = [-1 for i in range(n + 1)]
dp[0], dp[1] = 1, 1
for _ in range(m):
    dp[int(input())] = 0
for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n])
a,b = int(input().split())
S = a*b
L = 2*(a+b)
print(S,end='')
print(L)

### FIXED CODE ###

a,b = map(int,input().split())
S = a*b
L = 2*(a+b)
print(S,end=" ")
print(L)
N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif D < C:
    pass

print('Yes' if flag else 'No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')
input()
d = Counter(map(int,input().split()))
input()
t = Counter(map(int,input().split()))
d.subtract(t)
if -d:
    print("NO")
else:
    print("YES")


### FIXED CODE ###

from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

input()
d = Counter(map(int,input().split()))
input()
t = Counter(map(int,input().split()))
d.subtract(t)
if -d:
    print("NO")
else:
    print("YES")
n,t=[int(s)for s in input().split()]
cost=[]
for _ in range(n):
  c,ti=[int(s)for s in input().split()]
  if ti<t:cost.append(c)
if len(cost)==0:print("TLE")
else:
  cs=cost.sorted()
  print(cs[0])

### FIXED CODE ###

n,t=[int(s)for s in input().split()]
cost=[]
for _ in range(n):
  c,ti=[int(s)for s in input().split()]
  if ti<=t:cost.append(c)
if len(cost)==0:print("TLE")
else:
  cs=sorted(cost)
  print(cs[0])
import math

def combination(n,r):
    return int ( math.factorial(n) / math.factorial(n-r) / math.factorial(r) )
def permutation(n,r):
    return int( math.factorial(n) / math.factorial(n-r) )

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)

### FIXED CODE ###

from operator import mul
from functools import reduce

def combination(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0
if m==0:
  print(0)
  exit()
for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if i==n-3:
      check+=1
    continue
print(check)
  
  
      
    

### FIXED CODE ###

import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0

for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if n==2:
      check+=1
    elif i==n-3:
      check+=1
    continue
print(check)
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else
    print(ans)


### FIXED CODE ###

N=int(input())
x=7%N
for i in range(1,N+1):
    if x==0:
        print(i)
        exit()
    x=(x*10+7)%N
print(-1)
list=sorted([int(x) for x in input().split()])
print(list[0]+" "+list[1]+" "+list[2])

### FIXED CODE ###

list=sorted([int(x) for x in input().split()])
print(str(list[0])+" "+str(list[1])+" "+str(list[2]))
a = int(input())
b = int(input())
c = int(input())
d = int(input())

num_listx = []
num_listy = []

for num in range(b):
  if num >= a:
    num_listx.append(num)
for nums in range(d):
  if nums >= c:
    num_listy.append(nums)
x = max(num_listx)
y = max(num_listy)
print(x*y)

### FIXED CODE ###

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

ans = max(a*c,a*d,b*c,b*d)

print(ans)
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r ==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

### FIXED CODE ###

from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  if M+1<i:
    red = 0
  else:
    red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))
N=input()
S=input()
print(S.count('ABC'))

### FIXED CODE ###

a,b = map(int,input().split())
sum=int(a)*500
if sum>=b:
    print("Yes")
else:
    print("No")
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
t = 0
a = 0
b = 0

while True:
    if not t + A[a] > K:
        t += A[a]
        a += 1
        # print(a, t, A[a-1])
        if a >= N:
            break
    else:
        break

flug = True     #全探索を行うか
while True:
    if not t + B[b] > K:
        t += B[b]
        b += 1
        # print(b, t, B[b-1])
        if b >= M:
            flug = False
            break
    else:
        break

# print(a, b, flug)
ans = a + b
flug2 = True    #処理を続けるか
if flug:
    while True:
        a -= 1
        t -= A[a]
        while True:
            if not t + B[b] > K:
                t += B[b]
                b += 1
                if b >= M:
                    flug2 = False
                    break
            else:
                break
        ans = max(ans, a + b)
        if not flug2:
            break
print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
t = 0
a = 0
b = 0

while True:
    if not t + A[a] > K:
        t += A[a]
        a += 1
        # print(a, t, A[a-1])
        if a >= N:
            break
    else:
        break

flug = True     #全探索を行うか
while True:
    if not t + B[b] > K:
        t += B[b]
        b += 1
        # print(b, t, B[b-1])
        if b >= M:
            flug = False
            break
    else:
        break

# print(a, b, flug)
ans = a + b
flug2 = True    #処理を続けるか
if flug:
    while True:
        a -= 1
        if a < 0:
            break
        t -= A[a]
        while True:
            if not t + B[b] > K:
                t += B[b]
                b += 1
                if b >= M:
                    flug2 = False
                    break
            else:
                break
        ans = max(ans, a + b)
        if not flug2:
            break
print(ans)
import math
(A, B) = list(map(int, input().split()))
print((A * B) // math.gcd(A, B))

### FIXED CODE ###

import fractions
(A, B) = list(map(int, input().split()))
print((A * B) // fractions.gcd(A, B))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

def main():
    n = input()
    a =ord(n)
    if a>96:
        print("a")
    else:
        print("A")

if __name__ == "__main__":
    main()


### FIXED CODE ###


n = input()
a =ord(n)
if a>96:
    print("a")
else:
    print("A")
N, M = map(int, input().split())
A = list(map(int, input().split()))
daystofinish = sum(A)
print(N-daystofinish)
N, M = map(int, input().split())
A = list(map(int, input().split()))
daystofinish = sum(A)
if N-daystofinish < 0:
    print(-1)
else:
    print(N-daystofinish)

### FIXED CODE ###

import math
R = int(input(""))
C = 2 * math.pi * R
print(C)
n, m, p = map(int,input().split())
a = sorted([(int(input()) - p) % n for _ in range(m)])
print(min(a[-1], n - a[0], min([a[i] + n - a[i + 1] + min(a[i], n - a[i + 1]) for i in range(m - 1)])) * 100)


### FIXED CODE ###

n, m, p = map(int,input().split())
a = sorted([(int(input()) - p) % n for _ in range(m)])
print(min(a[-1], n - a[0], min([a[i] + n - a[i + 1] + min(a[i], n - a[i + 1]) for i in range(m - 1)])) * 100 if m > 1 else min(a[0], n - a[0]) * 100)
a,b,c,d,e,f=map(int,input().split())
x=set()
y=set()
m=f//(100*a)
for i in range(m+1):
  for j in range((m-i*a)//(100*b)+1):
    x1=i*100*a+j*100*b
    if x1<=f:
      x.add(x1)

m=int(f*(e/100))
for i in range(0,m+1,c):
  for j in range(0,m-i+1,d):
     y.add(i+j)
x.remove(0) 
z=[-1]
ans=[]
for i in x:
  for j in y:
    if i+j<=f and j*100/(i+j)<=e*100/(100+e):
      if j*100/(i+j)>max(z):
        z.append(j*100/(i+j))
        ans.append([i+j,j])
        
print(ans[-1][0],ans[-1][1])


### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
x=set()
y=set()
m=f//(100*a)
for i in range(m+1):
  for j in range(f//(100*b)+1):
    x1=i*100*a+j*100*b
    if x1<=f:
      x.add(x1)

m=int(f*(e/100))
for i in range(0,m+1,c):
  for j in range(0,m-i+1,d):
     y.add(i+j)
x.remove(0) 
z=[-1]
ans=[]
for i in x:
  for j in y:
    if i+j<=f and j*100/(i+j)<=e*100/(100+e):
      if j*100/(i+j)>max(z):
        z.append(j*100/(i+j))
        ans.append([i+j,j])
        
print(ans[-1][0],ans[-1][1])
N, T = map(int, input().split(" "))
roots = [tuple(map(int, input().split(" "))) for i in range(N)]
roots = sorted(roots, key=lambda x:x[1])

is_do = True
def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for i in range(len(roots)):
  csum = dfs(i, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False

if ans == 100000000:
    print('TLE')
else:
    print(ans)

### FIXED CODE ###

import sys
N, T = map(int, sys.stdin.readline().split(" "))
roots = [tuple(map(int, sys.stdin.readline().split(" "))) for i in range(N)]

from operator import itemgetter
#roots = sorted(roots, key=lambda x:x[1])
roots = (sorted(roots, key=itemgetter(1, 0)))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        if i+1 == N:
          return csum + roots[i][0]
        else:
          return dfs(i+1, csum+roots[i][0], tsum+roots[i][1])
    else:
        return 100000000 if csum == 0 else csum

ans = 100000000
for ii in range(N):
  csum = dfs(ii, 0, 0)
  if ans > csum:
    ans = csum
  if csum == 100000000:
    is_do = False
    break

if ans == 100000000:
    print('TLE')
else:
    print(ans)
a,b,c = map(int, input().split())
import.math

A = a+b+2*sqrt(a*b)

if A < c:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

a,b,c = map(int, input().split())
x = c-a-b

if x <= 0:
  print("No")
elif 4*a*b >= x**2:
  print("No")
else:
  print("Yes")
string = input()
a, b = string.split(' ')[0], string.split(' ')[1]
result = a * b - (a + b -1)
print(result)

### FIXED CODE ###

string = input()
a, b = int(string.split(' ')[0]), int(string.split(' ')[1])
result = a * b - (a + b -1)
print(result)
a, b, k = map(int, input().split())
ab = list(range(a, b+1))
ans = sorted(set(ab[:k]+ab[-k:]))
for i in ans:
  print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
if b-a+1 < k*2:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1 , b+1):
        print(k)
n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = s[len(s)-1]
a = [0 for i in range(l)]
for i in s:
    a[i] = 1

count = 0
for i in t:
    if i < l:
    count += a[i] 
print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
import sys
input =sys.stdin.readline 
number, weight = input().rstrip().split()
number = int(number)
weight = int(weight)

items = (tuple(map(int,input().rstrip().split())) for _ in range(number))
dp = [[0]*(weight+1) for _ in range(number+1)]

for i in range(number):
    for j in range(weight+1):
        if j < items[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-items[i][0]] + items[i][1])

print(dp[number][weight])

### FIXED CODE ###

import sys
 
input = sys.stdin.readline
 
 
def main():
    N, W = map(int, input().split())
    wv = [None] * N
    for i in range(N):
        wv[i] = tuple(map(int, input().split()))
 
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i, (w, v) in enumerate(wv, start=1):
        dp_i = dp[i]
        dp_im = dp[i - 1]
        for j in range(1, W + 1):
            if j < w:
                dp_i[j] = dp_im[j]
            else:
                a = dp_im[j - w] + v
                b = dp_im[j]
                if a > b:
                    dp_i[j] = a
                else:
                    dp_i[j] = b
 
    ans = dp[-1][-1]
    print(ans)
 
 
if __name__ == "__main__":
    main()
import math
a, b, c, d = map(int, input().split())

cnt = 0
s = b - a + 1
cd = (c*d) // math.gcd(c,d)

m1 = int((a-1) / c)
m2 = int((b+1) / c)
cnt += (m2-m1)

m1 = int((a-1) / d)
m2 = int((b+1) / d)
cnt += (m2-m1)

m1 = int((a-1) / cd)
m2 = int((b+1) / cd)
cnt -= (m2-m1)

#print(cnt)
print(s - cnt)

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())

cnt = 0
s = b - a + 1
cd = (c*d) // gcd(c,d)

m1 = int((a-1) // c)
m2 = int(b // c)
cnt += (m2-m1)
#print(cnt)

m1 = int((a-1) // d)
m2 = int(b // d)
cnt += (m2-m1)
#print(cnt)

m1 = int((a-1) // cd)
m2 = int(b // cd)
cnt -= (m2-m1)
#print(cnt)

#print(cnt)
print(s - cnt)
N = int(input())
x = list(map(int,input().split()))
middle = sum(x)/2
tol = 0
ans = []

for i in range(4):
  tol += x[i]
  re_new  =abs(tol-middle)
  ans.append(re_new)

t = ans.index(min(ans))
print(sum(x[0:t+1])-sum(x[t+1::]))
  

### FIXED CODE ###

N = int(input())
x = list(map(int,input().split()))
ans = []
for i in range(1,N):
  s1 = sum(x[0:i])
  s2 = sum(x[i::])
  ans.append(abs(s1-s2))
ans.sort()
print(ans[0])
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
c.sort()
DP=[[0 for j in range(b+1)]for i in range(a)]
for i in range(c[0][0],b+1):
  DP[0][i]+=c[0][1]
for i in range(1,a):
  for j in range(c[i][0]):
    DP[i][j]=DP[i-1][j]
  for j in range(c[i][0],b):
    DP[i][j]=max(DP[i-1][j-c[i][0]]+c[i][1],DP[i-1][j])
  DP[i][b]=max(DP[i-1][b-1]+c[i][1],DP[i-1][b])
print(max(DP[-1]))
    

### FIXED CODE ###

a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
c.sort()
DP=[[0 for j in range(b+1)]for i in range(a)]
for i in range(c[0][0],b+1):
  DP[0][i]+=c[0][1]
for i in range(1,a):
  for j in range(b):
    if j<c[i][0]:
      DP[i][j]=DP[i-1][j]
    else:
      DP[i][j]=max(DP[i-1][j-c[i][0]]+c[i][1],DP[i-1][j])
  DP[i][b]=max(DP[i-1][b-1]+c[i][1],DP[i-1][b])
print(max(DP[-1]))
n = int(input())

ans = 1
flag = [True] * (n + 1)
flag[2] = False
for i in range(2, n + 1):
    if flag[i]: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        flag[m] = False
        ans += m * (cnt + 1)
        m += i

print(ans)


### FIXED CODE ###

import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)
n,l=map(int,input.split())
if l<0:
  print(((n+2*l-1)*n)//2)
else:
  print((((n+2*l-1)*n)//2)-l)

### FIXED CODE ###

a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)
R = int(input())

if R < 1200:
    print("ABC"):
elif 1200 <= R and R < 2800:
    print("ARC")
else:
    print("AGC")

### FIXED CODE ###

R = int(input())

if R < 1200:
    print("ABC")
elif 1200 <= R and R < 2800:
    print("ARC")
else:
    print("AGC")
def solv():
    n = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    ans = 0

    for i in range(n+1):
        x = A[i] + A[i+1]
        ans += min(x,B[i])
        A[i+1] = min(A[i+1],max(x-B[i+1],0))
    print(ans)

solve()


### FIXED CODE ###

def solv():
    n = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    ans = 0

    for i in range(n):
        x = A[i] + A[i+1]
        ans += min(x,B[i])
        A[i+1] = min(A[i+1],max(x-B[i],0))
    return print(ans)

solv()
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
class UnionFind():
    def __init__(self,n):
        self.data = [-1] * n
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.data[x] < self.data[y]:
            x, y = y, x  # swap
        self.data[x] += self.data[y]
        self.data[y] = x
    
    def find(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.find(self.data[x])
        return self.data[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.data[self.find(x)]
        
# END CUT HERE

def ABC120_D():
    n, m = mi()
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = mi()
        
    uf = UnionFind(n)
    ans = [0] * (m + 1)
    ans[m] = n * (n - 1) // 2

    for i in range(m - 1, -1, -1):
        a[i] -= 1
        b[i] -= 1
        ans[i] = ans[i + 1]
        if uf.same(a[i], b[i]):
            continue
        
        x = uf.size(a[i])
        y = uf.size(b[i])
        ans[i] -= x * y
        
        uf.unite(a[i],b[i])
    
    for i in range(1, m + 1):
        print(ans[i])



if __name__ == '__main__':
    ABC120_D()


### FIXED CODE ###

A,B,C = map(int,input().split())

if B>= A*C:
    print(C)
else:
    print(B//A)
N = int(input())
H = list(map(int, input().split()))
result = 1

for i in range(N):
    dec = True
    for j in range(i-1):
        if H[i] <= H[j]:
            dec = False
            break
    if dec == True:
        result += 1
print(result)

### FIXED CODE ###

A, B = list(map(int, input().split()))
result = 0
A, B = max(A, B), min(A, B)
result += A + max(A-1, B)
print(result)
def main():
  array = []
  
  size = input()
  for i in range(size):
    array.append(int(input()))
    
  array.sort(reverse=True)
  
  result = 1
  for i in range(len(array)-1):
    if array[i] != array[i+1]:
      result+=1
  
  print(result)
    
    
main()
  

### FIXED CODE ###

def main():
  array = []
  
  size = int(input())
  for i in range(size):
    array.append(int(input()))
    
  array.sort(reverse=True)
  
  result = 1
  for i in range(len(array)-1):
    if array[i] != array[i+1]:
      result+=1
  
  print(result)
    
    
main()
from fraction import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
print(m)


### FIXED CODE ###

from fractions import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
if len(diffs) == 1:
  m = diffs[0]
print(m)
a=map(int,input().split())
b=list(map(int,input().split()))
def func(a,b):
    ab=set(b)
    return len(ab)


### FIXED CODE ###

a=int(input())
b=[input() for i in range(a)]
def func(b):
    return len(set(b))
print(func(b))
n = int(input())
print(int(n*(n-1)/2))

### FIXED CODE ###

s = input()
t = input()
cnt = 0
for i in range(3):
  if s[i] == t[i]:
    cnt += 1
print(cnt)
s = input()
ans = 'Yes'
for i in range(0, n, 2):
    if s[i] != 'h':
        ans = 'No'
for j in range(1, n+1, 2):
    if s[j] != 'i':
        ans = 'No'
print(ans)

### FIXED CODE ###

s = input()
if len(s)%2 == 0 and s == 'hi' * (len(s)//2):
    print('Yes')
else :
    print('No')