Harryxun/stf_run huggingface dataset:
import math
#from scipy.special import comb
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

N,A,B=map(int,input().split())
v=[int(i) for i in input().split()]
v.sort(reverse=True)
v=groupby(v)

if A<=v[0][1]:
    #こっちが間違ってる
    m=min(v[0][1],B)
    for i in range(A,m+1):
        co-=combinations_count(v[0][1],i)
    print(v[0][0])
    print(co)
else:
    al=0
    l=len(v)
    C=0
    for i in range(l):
        C+=v[i][1]
        if C<=A:
            al+=(v[i][0]*v[i][1])
        else:
            C-=v[i][1]
            al+=(v[i][0]*(A-C))
            k=combinations_count(v[i][1],A-C)
            break
    print(al/A)
    print(k)


### FIXED CODE ###

import math
#from scipy.special import comb
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

N,A,B=map(int,input().split())
v=[int(i) for i in input().split()]
v.sort(reverse=True)
v=groupby(v)

if A<=v[0][1]:
    #こっちが間違ってる
    m=min(v[0][1],B)
    co=0
    for i in range(A,m+1):
        co+=combinations_count(v[0][1],i)
    print(v[0][0])
    print(co)
else:
    al=0
    l=len(v)
    C=0
    for i in range(l):
        C+=v[i][1]
        if C<=A:
            al+=(v[i][0]*v[i][1])
        else:
            C-=v[i][1]
            al+=(v[i][0]*(A-C))
            k=combinations_count(v[i][1],A-C)
            break
    print(al/A)
    print(k)
S = sorted(input())
return S[0] == S[1] and S[2] == S[3] and S[1] != S[2]

### FIXED CODE ###

S = sorted(input())
if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]:
  print('Yes')
else:
  print('No')
import math
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)

### FIXED CODE ###

import math
def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(euclid(z[0],z[1]))))+1)
def solve():
    a,b = input().split()

    for i in range(101):
        if i * i == int(f'{a}{b}'):
            print('Yes')
            return
    print('No')
solve()


### FIXED CODE ###

def solve():
    a,b = input().split()

    for i in range(1000):
        if i * i == int('{}{}'.format(a,b)):
            print('Yes')
            return
    print('No')
solve()
N = R - L
A = []
A.append(10000)
if(L >= R):
    print(0)
elif(L == 0):
    print(0)
else:
    if(N = 1):
        print((L * R) % 2019)
    else:
        for i in range(L, R + 1):
            for j in range(i + 1, R + 1):
                A.append((i * j) % 2019)
        print(min(A))

### FIXED CODE ###

L, R = map(int, input().split())
ans = 10000
 
for i in range(L, min(R + 1, L + 2020)):
  for j in range(i,  min(R + 1, L + 2020)):
    if i < j:
      ans = min(ans, (i * j)%2019)
 
print(ans)
N=int(input())
dp=[10**7]*110000
dp[0]=0

pow6=[6**j for j in range(10) if 6**j <= N]
pow9=[9**j for j in range(10) if 9**j <= N]

for i in range(N):
    for p6 in pow6:
        dp[i+p6]=min(dp[i+p6], dp[i]+1)

    for p9 in pow9:
        dp[i+p9]=min(dp[i+p9], dp[i]+1)

print(dp[N])

### FIXED CODE ###

N=int(input())
dp=[10**7]*3000000
dp[0]=0

pow6=[6**j for j in range(10) if 6**j <= N]
pow9=[9**j for j in range(10) if 9**j <= N]

for i in range(N):
    for p6 in pow6:
        dp[i+p6]=min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9]=min(dp[i+p9], dp[i]+1)

print(dp[N])
n, m = map(int, input().split())

par = [i + 1 for i in range(n)]
rank = [0] * n
size = [1] * n

def find(x):
    if par[x - 1] == x:
        return x
    else:
        return find(par[x - 1])

def union(x, y):
    x = find(x)
    y = find(y)
    if rank[x] < rank[y]:
        par[x] = y
        size[x] += size[y]
    else:
        par[y] = x
        size[y] += size[x]
        if rank[x] == rank[y]:
            rank[x] += 1

for i in range(m):
    a, b = map(int, input().split())
    union(a, b)

print(max(size))

### FIXED CODE ###

n, m = map(int, input().split())

par = [i + 1 for i in range(n)]
rank = [1] * n
size = [1] * n

def find(x):
    if par[x - 1] == x:
        return x
    else:
        return find(par[x - 1])

def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        par[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        par[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1

for i in range(m):
    a, b = map(int, input().split())
    union(a, b)

print(max(size))
A = input()
B = input()
print((int(A)-1)*(int(B)-1))

### FIXED CODE ###

i = input()
A = i.split(" ")[0]
B = i.split(" ")[1]
print((int(A)-1)*(int(B)-1))
s = input()
k = int(input())

i = 0

while s[i] == '1' and i < k:
  i += 1

print(s[i])

### FIXED CODE ###

s = list(map(int,list(input())))
k = int(input())

a = 0
i = 0

while a < k:
  a += min(s[i]**70, k)
  i +=1

print(s[i-1])
import sys

sys.setrecursionlimit(20000)
N, Q = list(map(int, input().split()))

points = [[] for _ in range(N)]
counters = [0 for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    points[a - 1].append(b)

operations = []
for _ in range(Q):
    operations.append(list(map(int, input().split())))

# print(points)
# print(operations)


def dfs(points, counters, i, count):
    counters[i - 1] += count
    for next_point in points[i - 1]:
        dfs(points, counters, next_point, count)


for operation in operations:
    dfs(points, counters, operation[0], operation[1])
# print(counters)

print(' '.join(map(str, counters)))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
graph = [[] for i in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

# print(graph)
v = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    v[p - 1] += x
# print(v)


seen_points = [True] * N
seen_points[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if seen_points[i]:
            seen_points[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)
x, y = input().split()

print(max(int(x), int(y)))

### FIXED CODE ###

x, y = input().split()

if (ord(x) > ord(y)):
  print('>')
elif (ord(x) < ord(y)):
  print('<')
else:
  print('=')
N = int(input())
P = list(map(int, input().split()))

count = 0

for i in range(N):
  if P[i] == i + 1:
    if i == N:
      P[i - 1], P[i] = P[i], P[i - 1]      
    else:
      P[i], P[i + 1] = P[i + 1], P[i]
    count += 1

print(count)    

### FIXED CODE ###

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

count = 0

for i in range(N):
  if P[i] == i + 1:
    if i + 1 == N:
      P[i - 1], P[i] = P[i], P[i - 1]      
    else:
      P[i], P[i + 1] = P[i + 1], P[i]
    count += 1

print(count)
a, b=map(input.split())
print(a*b)

### FIXED CODE ###

a, b=map(int, input().split())
print(a*b)
w, h, x, y = list(map(int, input().split(" ")))

if w == 0 or y == 0:
	print(0,"0")
else:
	S = w*h/2.0
	if w%x == 0 and h%y == 0:
		print(S, "1")
	else:
		print(S, "0")

### FIXED CODE ###

w, h, x, y = list(map(int, input().split(" ")))

if x*2 == w  and y*2 == h:
	print(w*h/2.0, "1")
else:
	print(w*h/2.0, "0")
from scipy.special import comb
import math
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
ans = 0
for j in range(min(K, N-K+1)):
    if j != N-K:
        tmp = (comb(N-K+1, j+1)) % MOD
    else:
        tmp = 1
    print(int((comb(K-1, j) * tmp) % MOD))
if min(K, N-K+1) == N-K+1:
    for i in range(N-K+1, K):
        print(0)


### FIXED CODE ###

def comb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n-r)
import math

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
ans = 0
for j in range(K):
    if N-K - j < 0:
        print(0)
        continue
    tmp = (comb(N-K+1, j+1)) % MOD
    print(int((comb(K-1, j) * tmp) % MOD))
N=int(input())
A=list(map(int,input().split()))
count=0
F=0
B=1
SUM=A[0]



while F<N:
    while True:
        SUMtest=SUM+A[B]
        XORtest=SUM^A[B]

        if SUMtest==XORtest:
            if B==N-1:
                for i in range(F,N):
                    count=count+(N-i)
                F=N
                break
                
            else:
                B+=1
                SUM=SUMtest

        else:
            count=count+(B-F)
            SUM=SUM-A[F]
            F+=1
            break


print(count)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
count=0
F=0
B=0
SUM=0



while F<N:
    while True:
        SUMtest=SUM+A[B]
        XORtest=SUM^A[B]

        if SUMtest==XORtest:
            if B==N-1:
                for i in range(F,N):
                    count=count+(N-i)
                F=N
                break
                
            else:
                B+=1
                SUM=SUMtest

        else:
            count=count+(B-F)
            SUM=SUM-A[F]
            F+=1
            break


print(count)
n = int(input())
d = list(range(1,n))
print(sum(d))

### FIXED CODE ###

n=int(input())
print(n*(n-1)//2)
a=list(input())
b=list(input())
d=""
for i in range(0,len(a)):
    c=a[i]+b[i]
    d=d+c
print("d")

### FIXED CODE ###

a=list(input())
b=list(input())
d=""
for i in range(0,len(b)):
    c=a[i]+b[i]
    d=d+c

if len(b)+1 == len(a):
    d = d+ a[len(a)-1]

print(d)
from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

memos = [False] * 102

for p in P:
    memos[p] = True

tgt = x
offset = 1
look_down = True
while True:

    if memos[tgt] == False:
        break
    if look_down:
        look_down = False
        tgt = tgt-offset
    else:
        look_down = True
        tgt = offset + offset
        offset += 1

print(tgt)


### FIXED CODE ###

from sys import stdin

a = [int(x) for x in stdin.readline().rstrip().split()]


for i, x in enumerate(a):
    i += 1
    if x == 0:
        print(i)
import numpy

N,M=map(int,input().split())
P=[]
Y=[]
for _ in range(M):
    data=[int(_) for _ in input().split()]
    P.append(data[0])
    Y.append(data[1])

y=[]
for x in range(1,N+1):
    for m in range(M):
        if P[m]==x:
            y.append(Y[m])

    ind=numpy.array(y)
    ind=ind.argsort()
    for i,k in enumerate(y):
        Y[Y.index(k)]=ind[i]+1
    y=[]

for x in range(M):
    xx=str(P[x])
    yy=str(Y[x])
    print(xx.zfill(6)+yy.zfill(6))


### FIXED CODE ###

N= int(input())
T,A=map(int,input().split())
H=[int(_) for _ in input().split()]

for i,h in enumerate(H):
    H[i]=abs(T-h*0.006-A)

print(H.index(min(H))+1)
import fractions
from functools import reduce

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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


# print(gcd_list(A))

max_A = max(A)
# エラトステネスの篩により素数を高速で求める
# そのかんにある数値がふるい落とされたその素数をメモしておく

D = [0] * (max_A + 1)
primes = list(range(2, max_A + 1))
prime = []
for i in range(max_A):
    if len(primes) == 0:
        break
    first = primes[0]
    prime.append(first)
    new_prime = []
    for j in range(len(primes)):
        if primes[j] % first == 0:
            D[primes[j]] = first
            continue
        else:
            new_prime.append(primes[j])

    primes = new_prime

# print(prime)
# print(D)

pairwise = True
check = [0] * (max_A + 1)
new_A = A[:]
for i in range(N):
    min_prime = D[new_A[i]]
    check[min_prime] += 1
    while True:
        new_A[i] //= min_prime
        if new_A[i] == 1:
            break

    if max(check) > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if gcd_list(A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')


### FIXED CODE ###

import math
from functools import reduce
from collections import deque

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


max_A = max(A)

if max_A == 1:
    print('pairwise coprime')
    exit()
# エラトステネスの篩により素数を高速で求める
# そのかんにある数値がふるい落とされたその素数をメモしておく

D = [0] * (max_A + 1)
is_prime = [True] * (max_A + 1)
is_prime[0] = False
is_prime[1] = False
prime = deque()
for i in range(2, int(max_A ** 0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, max_A + 1, i):
        is_prime[j] = False
        D[j] = i

for i in range(len(is_prime)):
    if is_prime[i]:
        D[i] = i

pairwise = True
check = [0] * (max_A + 1)
new_A = A[:]
for i in range(N):
    min_prime = D[new_A[i]]
    while True:
        if D[min_prime] == 0:
            break

        check[D[min_prime]] += 1
        while new_A[i] % min_prime == 0:
            new_A[i] //= min_prime

        min_prime = new_A[i]

        # print(check)


# print(D)
# print(check)

if max(check) > 1:
    pairwise = False
# print(check)
if pairwise:
    print('pairwise coprime')
else:
    if gcd_list(A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')
N = int(input())
a = set8int(input()) for i in range(N))
for i in range(len(list(a))):
  b = a.copy()
  del b[i]
  print((max(b)))

### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
amax = max(a)
amax2 = sorted(a)[-2]
for i in range(len(a)):
  if a[i]==amax:
    print(amax2)
  else:
    print(amax)
N = int(input())
L = [for i in range(N-1)]
if max(i) < sum(i) - max(i):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
if max(L) < (sum(L) - max(L)):
    print('Yes')
else:
    print('No')
a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
if a < k <= a + b:
    print(a)
ifa + b < k:
    d = 2*a + b - k
    print(d)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
if a < k <= a + b:
    print(a)
if a + b < k:
    d = 2*a + b - k
    print(d)
def main():
  r1,c1,r2,c2 = map(int,input().split())

  mod = 10**9+7

  fact = [1,1]
  finv = [1,1]
  inv = [0,1]

  for i in range(2,2*10**6+1):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)

  def nCr(n,r,mod):
      if (r < 0) or (n < r):
          return 0
      r = min(r, n - r)
      return fact[n]*finv[r]*finv[n-r]%mod

  print((nCr(r2+c2+2,r2+1,mod)+nCr(r1+c1,r1,mod)-nCr(c2+r1+1,r1,mod)-nCr(r2+c1+1,c1,mod))%mod)

if __name__ == "__main__":
  main()

### FIXED CODE ###

def main():
  r1,c1,r2,c2 = map(int,input().split())

  mod = 10**9+7

  fact = [1,1]
  finv = [1,1]
  inv = [0,1]

  for i in range(2,r2+c2+3):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)

  def nCr(n,r,mod):
      
      return fact[n]*finv[r]*finv[n-r]%mod

  print((nCr(r2+c2+2,r2+1,mod)+nCr(r1+c1,r1,mod)-nCr(c2+r1+1,r1,mod)-nCr(r2+c1+1,c1,mod))%mod)

if __name__ == "__main__":
  main()
import math

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

L = int(M*N/math.gcd(N, M))
X = 'A'*int(L)

for i, s in enumerate(S):
    j = int(L/N*i)
    if X[j] == 'A':
        X = X[:j]+s+X[j+1:]
    elif X[j] == s:
        continue
    else:
        print(-1)
        exit(0)

        
for i, t in enumerate(T):
    j = int(L/M*i)
    if X[j] == 'A':
        X = X[:j]+t+X[j+1:]        
    elif X[j] == t:
        continue
    else:
        print(-1)
        exit(0)

print(L)

        


### FIXED CODE ###

import math


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

if N>M:
    N,M = M,N
    S,T = T,S
    
def gcd(a, b):
    while b:
	    a, b = b, a % b
    return a
    
L = int(M*N/gcd(N, M))

for i in range(N):
    if (M*i)%N == 0:
        j = int((M*i)/N)
        if S[i] != T[j]:
            print(-1)
            exit(0)

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

if min(abs(a-b, a-c, b-c)) <= d:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

### FIXED CODE ###

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

if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)
from itertools import combinations
import math
n = int(input()
ans = 0
for r in range(1,4): 
    if r>n:
        break
    for x  in combinations([x+1 for x in range(n)],r):
        if len(x)==1:
            ans += x[0]
        elif len(x)==2:
            ans += math.gcd(x[0],x[1])*6
        else:
            tmp = math.gcd(x[0],x[1])
            ans += math.gcd(x[2],tmp)*6
print(ans)

### FIXED CODE ###

from itertools import combinations
import math
n = int(input())
ans = 0
for r in range(1,4): 
    if r>n:
        break
    for x  in combinations([x+1 for x in range(n)],r):
        if len(x)==1:
            ans += x[0]
        elif len(x)==2:
            ans += math.gcd(x[0],x[1])*6
        else:
            tmp = math.gcd(x[0],x[1])
            ans += math.gcd(x[2],tmp)*6
print(ans)
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
if n==1:
    print(x[-1]-x[0])
else:
    for i in range(n-1):
        d.remove(max(d))
    print(sum(d))

### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)
import collections
import numpy

def main():
    max_n = 10**18
    n = int(input())
    a = input_list()
    ans = 1
    if 0 in a:
        print(0)
        exit()

    ans = numpy.prod(a)
    if ans > max_n:
        print(-1)
    else:
        print(ans)

def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#import numpy
import math
import sys

def main():
    n = int(input())
    a = sorted(input_list())
    max_n = 10 ** 18
    ans = 1
    for v in a:
        ans *= v
        if ans > max_n:
            ans = -1
            break
        if ans == 0:
            break
    print(ans)


def yogen(a, b, angle):
    coss = math.cos((angle/180)*math.pi)
    return math.sqrt(a**2 + b**2 - 2*a*b*coss)


def get_angle(hour, minute):
    h = (hour * 360) / 12 + (minute * 360) / (12 * 60)
    m = (minute * 360) / 60
    angle = abs(h-m)
    return min(angle, 360-angle)

def has(v, l):
    for vl in l:
        if v == vl:
            return True
    return False

def input_list():
    return list(map(int, sys.stdin.readline().split()))


if __name__ == '__main__':
    main()
N = int(input())
n = N % 10

if n in [2, 4, 5, 7, 9];
  print("hon")
elif n in [0, 1, 6, 8];
  print("pon")
else;
  print("bon")


### FIXED CODE ###

N = int(input())
n = N % 10
 
if n in [2, 4, 5, 7, 9]:
  print("hon")
elif n in [0, 1, 6, 8]:
  print("pon")
else:
  print("bon")
S = input()
T = ''

S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]

i=0
while(1):
	for w in rev_words:
		s = S[i:i+len(w)]
		if s == w:
			flag = True
			T += w
			i += len(w)
			break
	if T == S:
		ans = "YES"
		break
	if flag == False:
		ans = 'NO'
		break
	flag = False

print(ans)

### FIXED CODE ###

#ABC 049 C
S = input()
T = ''
S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]

flag = False
i=0
while(1):
	for w in rev_words:
		s = S[i:i+len(w)]
		if s == w:
			flag = True
			T += w
			i += len(w)
			break
	if T == S:
		ans = "YES"
		break
	if flag == False:
		ans = 'NO'
		break
	flag = False

print(ans)
s=list(input())
cnt=0
now=''
for i in range(len(s)):
    now+=s[i]
    if buf!=now:
        buf=now
        now=''
        cnt+=1
print(cnt)


### FIXED CODE ###

s=list(input())
cnt=0
now=''
buf=''
for i in range(len(s)):
    now+=s[i]
    if buf!=now:
        buf=now
        now=''
        cnt+=1
print(cnt)
X = int(input())
check = false
ans = 100
count = 0
while ans < X:
  ans *= 1.01
  count += 1
print(count)
  
 

### FIXED CODE ###

X = int(input())
ans = 100
count = 0
while ans < X:
  ans = int(ans * 1.01)
  count += 1
print(count)
N,M=map(int,input().split())

par=[i for i in range(M)]
size=[1 for i in range(M)]

def find(X):
    if par[X]==X:
        return X
    else:
        return find(par[X])

def union(X,Y):
    if size[X]>=size[Y]:
        par[Y]=par[X]
        size[X]+=size[Y]
    elif size[Y]>size[X]:
        par[X]=par[Y]
        size[Y]+=size[X]
    
L=[]
for i in range(M):
    a,b=map(int,input().split())
    L.append([a-1,b-1])
    
L=L[::-1]

A=[]
for i in range(M):
    if find(L[i][0])==find(L[i][1]):
        A.append(0)
    else:
        A.append(size[find(L[i][0])]*size[find(L[i][1])])
        union(par[find(L[i][0])],par[find(L[i][1])])
        
A=A[::-1]
ans=0
for i in range(len(A)):
    ans+=A[i]
    print(ans)

### FIXED CODE ###

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

par=[i for i in range(N)]
size=[1 for i in range(N)]

def find(X):
    if par[X]==X:
        return X
    else:
        return find(par[X])

def union(X,Y):
    if size[X]>=size[Y]:
        par[Y]=par[X]
        size[X]+=size[Y]
    elif size[Y]>size[X]:
        par[X]=par[Y]
        size[Y]+=size[X]
    
L=[0 for i in range(M)]
for i in range(M):
    a,b=map(int,input().split())
    L[i]=[a-1,b-1]

L=L[::-1]

A=[]
for i in range(M):
    if find(L[i][0])==find(L[i][1]):
        A.append(0)
    else:
        A.append(size[find(L[i][0])]*size[find(L[i][1])])
        union(par[find(L[i][0])],par[find(L[i][1])])
        
A=A[::-1]
ans=0
for i in range(len(A)):
    ans+=A[i]
    print(ans)
N = int(raw_input())
s = [int(raw_input()) for _ in range(N)]

flag = True
for i in range(len(s)):
    if (s[i] % 10) != 0:
        flag = False
        break
if flag:
    print(0)
else:
    s.sort()
    s = s[::-1]
    Ncombination = 2**len(s)

    for c in range(Ncombination):
        SUM = 0
        combination = format(c, 'b').zfill(len(s))
        # print("combination", combination)
        for i in range(len(s)):
            # print("combination", i, combination[i])
            if combination[i] == "0":
                SUM += s[i]
        # print("SUM", SUM)
        if (SUM % 10) != 0:
            break
    print(SUM)

### FIXED CODE ###

N = int(raw_input())
s = [int(raw_input()) for _ in range(N)]

result = sum(s)
if (result % 10) != 0:
    print(result)
else:
    s.sort()
    for i in range(len(s)):
        if (s[i] % 10) != 0:
            result -= s[i]
            break
    if (result % 10) != 0:
        print(result)
    else:
        print(0)
a = 1
while True:
	b = int(raw_input())
	print('Case ' + str(a) + ': ' + str(b))
		a += 1
	if b != 0:
		continue
	else:
		break

### FIXED CODE ###

a = int(1)
b = int(1)
while True:
	b = int(raw_input())
	if b != 0:
		print('Case ' + str(a) + ': ' + str(b))
		a += 1
		continue
	else:
		break