Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N,M=map(int,input().split())




count_WA=0

AC=[]
x=[]
for i in range(M):
    a=input().split()
    x.append(a)
    if a[1]=="AC" and not(a[0] in AC):
        AC.append(a[0])

count_AC=len(AC)

for i in x:
    if i[0] in AC:
        if i[1]=="AC":
            AC.remove(i[0])
        else:
            count_WA+=1




print(count_AC,count_WA,sep=" ")


### FIXED CODE ###

N,M=map(int,input().split())


ac = 0
wa = 0
aclist = {}
walist = {}

count_WA=0
for i in range(N):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(M):
    a,b=input().split()
    a=int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]




print(ac,wa,sep=" ")
### BUGGY CODE ###

l,r = [int(u) for u in input().split(" ")]

a = []
for i in range(l,r+1):
  p = [((i%2019)*j)%2019 for j in set([u%2019 for u in range(i+1,r+1)])]
  if len(p)>0:
    a.append(min(p))
print(min(a))

### FIXED CODE ###

import math

l,r = [int(u) for u in input().split(" ")]

if math.floor(l/2019)<math.floor(r/2019):
  print(0)
else:
  a = []
  for i in range(l,r+1):
    p = [((i%2019)*j)%2019 for j in set([u%2019 for u in range(i+1,r+1)])]
    if len(p)>0:
      a.append(min(p))
  print(min(a))
### BUGGY CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for i in range(m)]
hb = [0 for i in range(h)]
wb = [0 for j in range(w)]
M = [[0 for i in range(w)] for j in range(h)]

for i in range(m):
    hb[hw[i][0]-1] += 1
    wb[hw[i][1]-1] += 1
    M[hw[i][0]-1][hw[i][1]-1] = -1

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,hb[i]+wb[j]+M[i][j])
print(ans)

### FIXED CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for i in range(m)]
hb = [0] * h
wb = [0] * w

for i in range(m):
    hb[hw[i][0]-1] += 1
    wb[hw[i][1]-1] += 1

max_h = max(hb)
max_w = max(wb)
ans = max_h + max_w
count = hb.count(max_h) * wb.count(max_w)
for i in range(m):
    if hb[hw[i][0]-1] == max_h and wb[hw[i][1]-1] == max_w:
        count -= 1
if count <= 0:
    ans -= 1
print(ans)
### BUGGY CODE ###

from decimal import *
getcontext().prec = 40000
a,b,c=map(int,input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")


### FIXED CODE ###

from decimal import *
getcontext().prec = 39851
a,b,c=map(int,input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

n=int(input())
data=[int(aa) for aa in input().split()]
data.sort()
#print(data)
mydata=0
mylist=[0,0]
for aa in data:
    if data.count(aa) >3:
        mydata=aa
    if data.count(aa) >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))


### FIXED CODE ###

from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)
### BUGGY CODE ###

import math

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

print(max([math.floor(a * i / b) - a * math.floor(i / b) for i in range(1, n + 1)]))


### FIXED CODE ###

import math
 
a, b, n = map(int, input().split(" "))
i = min([b-1 , n])
print( math.floor(a*i / b) - a * math.floor(i / b) )
### BUGGY CODE ###

N, P = map(int, input().split())

if N == 1:
  d = P
else:
  d = 1
  i = 2
  while i**N <= P:
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)

### FIXED CODE ###

N, P = map(int, input().split())

if N == 1:
  d = P
else:
  d = 1
  i = 2
  while i <= round(pow(P, 1/N)):
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)
### BUGGY CODE ###

n, m = map(int, input().split())
list = [int(i) for i in input().split()]
while(m):
  list[list.index(max(list))] = max(list)//2
  m -= 1
print(sum(list))

### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(n):
  a[i] *= -1

heapq.heapify(a)
for i in range(m):
    heapq.heapreplace(a, int(a[0] / 2))

print(sum(a)*-1)
### BUGGY CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+2):
        for k in range(x_max*n+1):
            if k>= x[i]:
                dp[i+1][j][k] = dp[i][j-1][k-x[i]] + dp[i][j][k]
            elif k<x[i]:
                dp[i+1][j][k] = dp[i][j][k]
for k in range(x_max*n+1):
    for j in range(1,n+1):
        if a*j == k:
            ans += dp[n][j][k]
print(ans)

### FIXED CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+2):
        for k in range(x_max*n+1):
            if k>= x[i]:
                dp[i+1][j][k] = dp[i][j-1][k-x[i]] + dp[i][j][k]
            else:
                dp[i+1][j][k] = dp[i][j][k]
            
for k in range(x_max*n+1):
    for j in range(1,n+1):
        if a*j == k:
            ans += dp[n][j][k]
print(ans)
### BUGGY CODE ###

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

ans = 0

sum_list1 = np.zeros(n)
to_minus1 = np.zeros(n)
to_plus1 = np.zeros(n)
s = 0
for i in range(n):
    s += a[i]
    sum_list1[i] += s
    to_minus1[i] = sum_list1[i] + 1
    to_plus1[i] = sum_list1[i] - 1


def check(sum_list, to_minus, to_plus, t, ans):
    for i in range(n):
        if (i+t) % 2 == 0:
            if to_minus[i] <= 0:
                continue
            else:
                hiku = to_minus[i]
                to_minus[i::] -= hiku
                to_plus[i::] -= hiku
                ans += abs(hiku)
        else:
            if to_plus[i] >= 0:
                continue
            else:
                tasu = abs(to_plus[i])
                to_minus[i::] += tasu
                to_plus[i::] += tasu
                ans += abs(tasu)
    return ans

t = np.copy(to_minus1)
u = np.copy(to_plus1)

ans1 = check(sum_list1, to_minus1, to_plus1, 0, 0)
ans2 = check(sum_list1, t, u, 1, 0)

print(int(min(ans1, ans2)))


### FIXED CODE ###

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

def to_minus_one(num):
    return -1 - num

def to_plus_one(num):
    return 1 - num

s_list = np.zeros(n)
s = 0
for i in range(n):
    s += a[i]
    s_list[i] += s


def cal(sum_list, t, ans):
    hoge = 0
    for i in range(n):
        sum_list[i] += hoge
        if (i+t) % 2 == 0:
            if sum_list[i] >= 0:
                hiku = to_minus_one(sum_list[i])
                hoge += hiku
                ans += abs(hiku)
            else:
                continue
        else:
            if sum_list[i] <= 0:
                tasu = to_plus_one(sum_list[i])
                hoge += tasu
                ans += abs(tasu)
    return ans

q = np.copy(s_list)
w = np.copy(s_list)
num1 = cal(q, 0, 0)
num2 = cal(w, 1, 0)

print(int(min(num1, num2)))
### BUGGY CODE ###

import numpy as np
from collections import deque
 
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
 
dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
visited = np.zeros((h + 5, w + 5))
ans = 0
for i in range(h):
    for j in range(w):
        q = deque()
        q.append([i, j, 0])
        if s[i][j] == '#': continue
        visited[:, :] = 0
        while q:
            x, y, z = q.popleft()
            if z > ans: ans = z
            visited[x][y] = True
            for dx, dy in dirr:
                nx, ny = x + dx, y + dy
                if 0 <= nx < h and 0 <= ny < w:
                    if not visited[nx][ny] and s[nx][ny] == '.':
                        q.append([nx, ny, z + 1])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
from collections import deque

h, w = [int(item) for item in input().split()]
field = []
field.append("#" * (w + 2))
for i in range(h):
    field.append("#" + input().rstrip() + "#")
field.append("#" * (w + 2))


ans = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if field[i][j] == "#":
            continue
        dist = [[-1] * (w + 2) for _ in range(h + 2)]
        dist[i][j] = 0
        dq = deque()
        dq.append((i, j, 0))
        while dq:
            x, y, d = dq.popleft()
            if field[x+1][y] == "." and dist[x+1][y] == -1:
                dist[x+1][y] = d+1
                dq.append((x+1, y, d+1))
            if field[x][y+1] == "." and dist[x][y+1] == -1:
                dist[x][y+1] = d+1
                dq.append((x, y+1, d+1))
            if field[x-1][y] == "." and dist[x-1][y] == -1:
                dist[x-1][y] = d+1
                dq.append((x-1, y, d+1))
            if field[x][y-1] == "." and dist[x][y-1] == -1:
                dist[x][y-1] = d+1
                dq.append((x, y-1, d+1))
        for line in dist:
            ans = max(ans, max(line))
        
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
def main():
    n,k = map(int,input().split())
    h = tuple(int(i) for i in input().split())
    # dpの最小値を変更する関数

    # 無限大の値
    f_inf = 10 ** 9 
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    dp = [f_inf] * (10**5+10)
    # 初期条件
    dp[0] = 0
    # 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
    # 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
    for i in range(1, n):
        for j in range(1,k+1):
            if i-j < 0 :
                continue
            else:
                dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
    print(dp[n-1])

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
  
n,k = map(int,input().split())
h = [int(i) for i in input().split()]
# dpの最小値を変更する関数

# 無限大の値
f_inf = 10 ** 9 
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    for j in range(1,k+1):
        if i-j < 0 :
            continue
        else:
            dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[n-1])
### BUGGY CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,k = na()
f = [i for i in range(a,b+1)]
ans = f[:k]
ans_d = f[-k:]
ans += ans_d
for i in sorted(set(ans), key=ans.index):
    print(i)


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,k = na()
if (b-a+1) // 2 >= k:
    ans = list(range(a,a+k)) + list(range(b-k+1,b+1))
else:
    ans = list(range(a,b+1))
for i in ans:
    print(i)
### BUGGY CODE ###

K = int(input())
dicts = {}
for _ in range(K):
    string = str(sorted(input()))
    if string in dicts:
        dicts[string] += 1
    else:
        dicts[string] = 1

def calc_pairs(n):
    return n*(n-1)//2

answer = 0
for v in dicts.values():
    if v > 1:
        answer += calc_pairs(v)
    
print(answer)

### FIXED CODE ###

N = int(input())
dic = {}
for _ in range(N):
    IN = input()
    A = "".join(sorted(list(IN)))
    if A not in dic:
        dic[A] = 1
    else:
        dic[A] += 1
answer = 0
for k,v in dic.items():
    answer += v*(v-1)//2
print(answer)
### BUGGY CODE ###

import sys
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = rl()
max_ = 0
for i in range(n-k+1):
  max_ = max(max_, sum(a[i:i+k]))
print((max_+k)/2)

### FIXED CODE ###

import sys
from itertools import accumulate

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = [(i+1)/2 for i in rl()]
a = [0] + list(accumulate(a))
ans = 0
for i in range(n-k+1):
    ans = max(ans, a[i+k] - a[i])
print(ans)
### BUGGY CODE ###

N,M,K=map(int,input().split())
import math
def com(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
A=com(M*N-2, K-2)
MOD=10**9+7
ans=0
for d in range(1,N):
  ans+=d*(N-d)*M*M*A%MOD
for d in range(1,M):
  ans+=d*(M-d)*N*N*A%MOD
print(ans%MOD)

### FIXED CODE ###

N,M,K=map(int,input().split())
def cmb(x,y):
  X=1
  Y=1
  for i in range(1,y+1):
    X= X*(x+1-i)%MOD
    Y= Y*i%MOD
  return (X*pow(Y,MOD-2,MOD))%MOD
MOD=10**9+7
A=cmb(M*N-2, K-2)
ans=0
for d in range(1,N):
  ans+=d*(N-d)*M*M*A%MOD
for d in range(1,M):
  ans+=d*(M-d)*N*N*A%MOD
print(ans%MOD)
### BUGGY CODE ###

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*power_func(i-B+1, Mod-2,Mod)%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*power_func(i-W+1, Mod-2,Mod)%Mod]

p, q = 0, 0
inv = 1
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  inv *= magick
  p += consts_B[i]*inv
  q += consts_W[i]*inv

### FIXED CODE ###

B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

inv_t = [0]+[1]
inv_2 = [0]+[magick]
for i in range(2,B+W+1):
  inv_t += [inv_t[Mod % i] * (Mod - int(Mod / i)) % Mod]
  inv_2 += [inv_2[-1]*magick % Mod]

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*inv_t[i-B+1]%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*inv_t[i-W+1]%Mod]

p, q = 0, 0
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  p += consts_B[i]*inv_2[i+1]
  q += consts_W[i]*inv_2[i+1]
### BUGGY CODE ###

from scipy.misc import comb

MAX = 10**9 + 7

def man_comb(_N, _K):
    if _K > (_N/2):
        return comb(_N, _N - _K, exact=True)
    else:
        return comb(_N, _K, exact=True)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up *= (_N - i)
        low *= (i + 1)
    ret = up /low
    if ret >= MAX:
        ret %= MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = M*N* (M*(N+1)*(N-1) + N*(M+1)*(M-1)) / 6
    if disSum >= MAX:
        disSum %= MAX
    ret = disSum * combination(M*N-2, K-2)
    if ret >= MAX:
        ret %= MAX
    print ret

if __name__ == '__main__':
    solve()


### FIXED CODE ###

MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = (M*N* ((M*(N+1)*(N-1))%MAX + (N*(M+1)*(M-1)) % MAX)) % MAX
    disSum *= mod_inv(6, MAX) % MAX
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

if __name__ == '__main__':
    solve()
### BUGGY CODE ###

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

for i in range(a,b+1):
  if i % x ==0:
    c+=1

print(c)

### FIXED CODE ###

a,b,x = map(int, input().split())
 
print(b//x-(a-1)//x)
### BUGGY CODE ###

N=int(input())

A=list(map(int,input().split()))

S=0
for i in range(N):
    for j in range(i,N):
        if abs(i-j)==A[i]+A[j]:
            S+=1

print(S)

### FIXED CODE ###

def Binary_Search_Small_Count(A,x,equal=False,sort=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()

    if A[0]>x or ((not equal) and A[0]==x):
        return 0

    L,R=0,len(A)
    while R-L>1:
        C=L+(R-L)//2
        if A[C]<x or (equal and A[C]==x):
            L=C
        else:
            R=C

    return L+1

def Binary_Search_Equal_Count(A,x,sort=False):
    """2分探索によって,xの個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"を超える"がx"以上"になる
    """

    if sort:
        A.sort()

    if x<A[0] or A[-1]<x:
        return 0

    X=Binary_Search_Small_Count(A,x,equal=True)
    Y=Binary_Search_Small_Count(A,x,equal=False)
    return X-Y
#================================================
N=int(input())
A=["*"]+list(map(int,input().split()))

B=[0]*N
for j in range(1,N+1):
    B[j-1]=j-A[j]
B.sort()

K=0
del A[0]
for i in range(1,N+1):
    K+=Binary_Search_Equal_Count(B,i+A[i-1],False)
print(K)
### BUGGY CODE ###

MOD = 10 ** 9 + 7
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

# 前計算
for i in range(n - 1):
    x[i] = x[i + 1] - x[i]

for i in range(m - 1):
    y[i] = y[i + 1] - y[i]

N = [n - 1]
for i in range(n - 3, 0, -2):
    N.append(N[-1] + i)
    # N.append((N[i] + (n - 1 - 2 * (i + 1))) % MOD)

M = [m - 1]
for i in range(m - 3, 0, -2):
    M.append(M[-1] + i)
    # M.append((M[i] + (m - 1- 2 * (i + 1))) % MOD)

if N[0] % 2 == 0:
    N += N[::-1]
elif N[0] != 1:
    N += N[1::-1]

if M[0] % 2 == 0:
    M += M[::-1]
elif M[0] != 1:
    M += M[1::-1]

# print (x)
# print (y)
# print (N)
# print (M)

if len(x) - 1 > len(N):
    while True:
        pass

if len(y) - 1 > len(M):
    while True:
        pass


X_sum = 0
for i in range(n - 1):
    X_sum += x[i] * N[i]
    X_sum %= MOD

Y_sum = 0
for i in range(m - 1):
    Y_sum += y[i] * M[i]
    Y_sum %= MOD

print ((X_sum * Y_sum) % MOD)

### FIXED CODE ###

MOD = 10 ** 9 + 7
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

# 前計算
for i in range(n - 1):
    x[i] = x[i + 1] - x[i]

for i in range(m - 1):
    y[i] = y[i + 1] - y[i]

N = [n - 1]
for i in range(n - 3, 0, -2):
    N.append(N[-1] + i)
    # N.append((N[i] + (n - 1 - 2 * (i + 1))) % MOD)

M = [m - 1]
for i in range(m - 3, 0, -2):
    M.append(M[-1] + i)
    # M.append((M[i] + (m - 1- 2 * (i + 1))) % MOD)

if N[0] % 2 == 0:
    N += N[::-1]
elif N[0] != 1:
    N += N[-2::-1]

if M[0] % 2 == 0:
    M += M[::-1]
elif M[0] != 1:
    M += M[-2::-1]

# print (x)
# print (y)
# print (N)
# print (M)

if len(x) - 1 > len(N):
    while True:
        pass

if len(y) - 1 > len(M):
    while True:
        pass


X_sum = 0
for i in range(n - 1):
    X_sum += x[i] * N[i]
    X_sum %= MOD

Y_sum = 0
for i in range(m - 1):
    Y_sum += y[i] * M[i]
    Y_sum %= MOD

print ((X_sum * Y_sum) % MOD)
### BUGGY CODE ###

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True
    
  def all_group_numbers(self):
    return sum([-x*(-x-1)//2 for x in self.parents if x < -1])

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
uf=UnionFind(N)
ans=[]
ANS=N*(N-1)//2
flg=True
for i in range(M-1,-1,-1):
  if flg:
    ans.append(ANS-uf.all_group_numbers())
    if ans[-1]==0:
      ans.extend([0]*i)
      break
  else:
    ans.append(ans[-1])
  
  flg=uf.union(AB[i][0]-1,AB[i][1]-1)
for i in range(len(ans)-1,-1,-1):
  print(ans[i])

### FIXED CODE ###

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return False,0,0

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    nx=self.size(x)
    ny=self.size(y)
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    
    return True,nx,ny

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
    
  def all_group_numbers(self):
    return [-x for x in self.parents if x < -1]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
uf=UnionFind(N)
ans=[0]*(M+1)
ans[M]=N*(N-1)//2
i=M-1
for a,b in AB[::-1]:
  flg,na,nb=uf.union(a-1,b-1)
  if flg:
    ans[i]=ans[i+1]-na*nb
  else:
    ans[i]=ans[i+1]
  i-=1
for a in ans[1:]:
  print(a)
### BUGGY CODE ###

N=int(input())
B=list(map(int,input().split(' ')))
def dfs(n,B,ans):
    if n==0:
        return ans[::-1]
    else:
        for num,i in enumerate(B):
            if num+1==i:
                res = dfs(n-1,B[:num]+B[num+1:],ans+[i])
                if res:
                    return res
        return False
ans = dfs(N,B,[])
if not ans:
    print(-1)
else:
    for i in ans:
        print(i)

### FIXED CODE ###

N=int(input())
B=list(map(int,input().split(' ')))
ans = []
for i in range(N):
    for n,j in enumerate(B[::-1]):
        if N-i-n==j:
            ans.append(B.pop(N-i-n-1))
            break
if len(ans)==N:
    for i in ans[::-1]:
        print(i)
else:
    print(-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)

n, q = map(int, input().split())
ab = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
add = [0]*n
for _ in range(q):
    pp, xx = map(int, input().split())
    add[pp-1] += xx


def dfs(v, p, value):
    value += add[v]
    ans[v] = value
    for c in ab[v]:
        if c == p:
            continue
        dfs(c, v, value)


ans = [0]*n
dfs(0, -1, 0)
print(*ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

n, q = map(int, input().split())
ab = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
add = [0]*n
for _ in range(q):
    pp, xx = map(int, input().split())
    add[pp-1] += xx


def dfs(v, p, value):
    value += add[v]
    ans[v] = value
    for c in ab[v]:
        if c == p:
            continue
        dfs(c, v, value)


ans = [0]*n
dfs(0, -1, 0)
print(*ans)
### BUGGY CODE ###

n=int(input())
arr=[int(i) for i in input().split()]
f=1 
prod=1 
for i in arr:
    prod*=i 
if prod>10**18:
        f=0 
print(prod if f else -1)

### FIXED CODE ###

n=int(input())
arr=[int(i) for i in input().split()]
if 0 in arr:
    print(0)
    exit()
f=1 
prod=1 
for i in arr:
    prod*=i 
    if prod>10**18:
      f=0 
      break
        
print(prod if f else -1)