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

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

bridges = [list(map(int,input().split())) for i in range(M)]

roots = list(range(0,N))
a =int(N*(N-1)/2)
ans = [a]

for i in range(0,M)[::-1]:
    a =int(N*(N-1)/2)
    island0, island1 = bridges[i][0],bridges[i][1]
    if roots[island1-1] != island1: # merge
        min_i = min(roots[island0-1],roots[island1-1])
        max_i = max(roots[island0-1],roots[island1-1])
        roots = [min_i if root==max_i else root for root in roots]        
    else: # つなげる
        roots[island1-1] = roots[island0-1]
    
    unique_root = list(set(roots))
    for root in unique_root:
        b = roots.count(root)
        if b >=2:
            a -= b*(b-1)/2
    ans.append(int(a))

[print(ans[i]) for i in range(M)[::-1]]


### FIXED CODE ###


class UnionFindTree():
    # Union find tree
    # 2つの効率化　経路圧縮、ランク
    # つなげることはできるか分離することはできないので、木をつなげる方向に利用する
    # 
    def __init__(self, node_size):
        # node_num: 全体のノード数
        # parent: ノードがrootなら-1、親がいれば親の番号を入れる
        # size:
        # rank:  
        self.parent =[-1] * node_size 
        self.size = [1] * node_size
        self.rank = [1] * node_size
    
    def find_root(self,node):
        # node属する木のrootを探す
        # たどった経路に含まれるnodeの親をrootにつなぎ替える
        if self.parent[node] == -1:             # 自身がrootの場合
            root = node
        else:                                   # 自身がrootでない場合
            root = self.find_root(self.parent[node]) # 再帰的にrootを探す
            self.parent[node] = root            # たどった経路に含まれるnodeの親をrootにつなぎ替える(経路圧縮)
        return root

    def unite(self,node0, node1):
        # node0とnode1が含まれる木を結合する
        
        #node0 node1のrootを求める
        root0 = self.find_root(node0) 
        root1 = self.find_root(node1)

        if root0 != root1:
            # rankを比較しrankが小さい方の木を大きい方の木のrootにつなげる
            # rank is sameのときのみrankが増える
            rank0 = self.rank[root0]
            rank1 = self.rank[root1]

            if rank0 == rank1: # rank is same
                self.parent[root1] = root0
                self.size[root0] += self.size[root1]
                self.rank[root0] += 1
            elif rank0 > rank1:
                self.parent[root1] = root0
                self.size[root0] += self.size[root1]
            else:
                self.parent[root0] = root1
                self.size[root1] += self.size[root0]

            


N,M = map(int,input().split())
bridges = [list(map(int,input().split())) for i in range(M)]

UFT = UnionFindTree(N)

a = int(N*(N-1)/2) # 不便さ
ans = [a]

for i in range(1,M)[::-1]:
    island0_num, island1_num = bridges[i][0]-1, bridges[i][1]-1 
    root0 = UFT.find_root(island0_num)
    root1 = UFT.find_root(island1_num)
    if root0 != root1:
        size0 =  UFT.size[root0]
        size1 =  UFT.size[root1]
        UFT.unite(island0_num,island1_num)
        a -= size0 * size1
    ans.append(int(a))

[print(ans[i]) for i in range(M)[::-1]]
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
C = sorted(L)

def X(n,j):
    L1 = j+1
    L2 = N-1
    while L1 != L2:
        a = (L1+L2)//2
        if C[a] == n:
            return len(C[j+1:a])
        elif L2 - L1 <= 1:
            if C[L1] > n:
                return len(C[j+1:L1])
            elif C[L1] < n < C[L2]:
                return len(C[j+1:L2])
            else:
                return len(C[j+1:L2+1])
        elif C[a] < n:
            L1 = a
        else:
            L2 = a
    if C[L1] < n:
        return 1
    else:
        return 0
ans = 0
# print(C)
for i in range(N-2):
    for j in range(i+1,N-1):
        # print(X((C[i]+C[j]),j))
        ans += X((C[i]+C[j]),j)
print(ans)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
C = sorted(L)
def X(n,j):
    L1 = j+1
    L2 = N-1
    while L1 != L2:
        a = (L1+L2)//2
        if C[a] == n:
            while C[a] == C[a-1]:
                a = a-1
            return len(C[j+1:a])
        elif L2 - L1 <= 1:
            if C[L2] < n:
                return len(C[j+1:L2+1])
            elif C[L1] < n <= C[L2]:
                return len(C[j+1:L2])
            while C[L1] == C[L1-1]:
                if j+1 <= L1-1:
                    L1 = L1-1
                else:
                    break
            if C[L1] > n:
                return len(C[j+1:L1])
            elif C[L1] == n:
                return len(C[j+1:L1])
        elif C[a] < n:
            L1 = a
        else:
            L2 = a
    if C[L1] < n:
        return 1
    else:
        return 0
ans = 0
# print(C)
for i in range(N-2):
    for j in range(i+1,N-1):
        # print(X((C[i]+C[j]),j))
        ans += X((C[i]+C[j]),j)
print(ans)
### BUGGY CODE ###

n, m, s = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(n)]


import math

M = 50 * n + 1

dp = [[float('inf')] * M for _ in range(n)]
s = min(s, M - 1)
dp[0][s] = 0

def inc(dp, i, j):
    c, d = cd[i][0], cd[i][1]

    for jj in range(j):
        dp[i][jj] = min(dp[i][jj], dp[i][j])

    for jj in range(j + 1, M):
        dp[i][jj] = min(dp[i][jj], dp[i][j] + math.ceil((jj - j) / c) * d)

    return dp

dp = inc(dp, 0, s)


while True:
    flag = False

    for i in range(m):
        u, v, a, b = uvab[i][0] - 1, uvab[i][1] - 1, uvab[i][2], uvab[i][3]
        for j in range(M):
            if j + a < M and dp[u][j + a] + b < dp[v][j]:
                dp[v][j] = dp[u][j + a] + b
                dp = inc(dp, v, j)
                flag = True

        u, v = v, u
        for j in range(M):
            if j + a < M and dp[u][j + a] + b < dp[v][j]:
                dp[v][j] = dp[u][j + a] + b
                dp = inc(dp, v, j)
                flag = True

    if flag == False:
        break

for t in range(1, n):
    print(min(dp[t]))


### FIXED CODE ###

n, m, s = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(n)]


import math

M = 50 * n + 1
s = min(s, M - 1)

dp = [[float('inf')] * M for _ in range(n)]

dp[0][s] = 0
c, d = cd[0][0], cd[0][1]
for jj in range(M):
    dp[0][jj] = min(dp[0][jj], dp[0][s] + max(math.ceil((jj - s) / c), 0) * d)

while True:
    flag = False

    for i in range(m):
        u1, v1, a, b = uvab[i][0] - 1, uvab[i][1] - 1, uvab[i][2], uvab[i][3]
        for u, v in [(u1, v1), (v1, u1)]:
            for j in range(M - a):
                tmp = dp[u][j + a] + b
                if tmp < dp[v][j]:
                    dp[v][j] = tmp
                    flag = True

            c, d = cd[v][0], cd[v][1]
            for jj in range(c, M):
                tmp = dp[v][jj - c] + d
                if tmp < dp[v][jj]:
                    dp[v][jj] = tmp
                    flag = True

    if flag == False:
        break

for t in range(1, n):
    print(min(dp[t]))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline


def solve():
    N = int(readline())

    anses = [0] * N

    for x in range(1, N):
        for y in range(1, N):
            for z in range(1, N):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if a > N:
                    break
                anses[a - 1] += 1
    
    for a in anses:
        print(a)

solve()

### FIXED CODE ###

import sys
readline = sys.stdin.readline


def solve():
    N = int(readline())

    anses = [0] * N

    for x in range(1, N):
        for y in range(x, N):
            for z in range(y, N):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if a > N:
                    break
                if x == y == z:
                    anses[a - 1] += 1
                elif x == y or y == z or z == x:
                    anses[a - 1] += 3
                else:
                    anses[a - 1] += 6
    
    for a in anses:
        print(a)

solve()
### BUGGY CODE ###

N, A, B, C = [int(a) for a in input().split(" ")]
ls = [int(input()) for i in range(N)]

def solve(ls):
    n = len(ls)
    ans = float("inf")
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i!=j and j!=k and i!=k:
                    tmp = abs(ls[i]-A)+abs(ls[j]-B)+abs(ls[k]-C)
                    ans = min(ans, tmp)
    return ans

def dfs(ls):
    n = len(ls)
    if n < 3:
        return float("inf")
    ans = solve(ls)
    for i in range(n-1):
        for j in range(i+1,n):
            ls2 = ls[:i]+ls[i+1:]
            ls2[j-1] = ls[i]+ls[j]
            ans = min(ans, 10+dfs(ls2))
    return ans

print(dfs(ls))

### FIXED CODE ###

N, A, B, C = [int(a) for a in input().split(" ")]
ls = [int(input()) for i in range(N)]
tab = [([float("inf")]*N, ref) for ref in (A, B, C)]
INF = float("inf")
from heapq import heappush, heappop, heapreplace
maxtarg = max(A, B, C)

# O(n)
def solve(ls):
    n = len(ls)
    qs = [[(-INF, -1)]*3 for i in range(3)]
    # 3*n times
    for ref, q in zip((A, B, C), qs):
        for i in range(n):
            val = -abs(ref-ls[i])
            if q[0][0] < val:
                heapreplace(q, (val, i))
    ans = INF
    # 9 times
    for a, i in qs[0]:
        for b, j in qs[1]:
            for c, k in qs[2]:
                if i!=j and j!=k and k!=i:
                    ans = min(ans, -(a+b+c))
    return ans
dic = {}
def dfs(ls):
    key = tuple(sorted(ls))
    if key in dic:
        return dic[key]
    n = len(ls)
    if n < 3: return INF
    ans = solve(ls)
    for i in range(n-1):
        for j in range(i+1,n):
            tmp = ls[i]+ls[j]
            if min(maxtarg-ls[i], maxtarg-ls[j]) < 10:
                continue
            ls2 = ls[:i]+ls[i+1:]
            ls2[j-1] = tmp
            ans = min(ans, 10+dfs(ls2))
    dic[key] = ans
    return ans

print(dfs(ls))
### BUGGY CODE ###


from functools import lru_cache
import sys
sys.setrecursionlimit(10**9)
n = int(input())
arr = []
for i in range(n):
    arr.append([int(i) for i in input().split()])

@lru_cache(None)
def cal(i,action):
    if i>=len(arr):
        return 0

    if action==0:
        return max(cal(i+1,1)+arr[i][1],cal(i+1,2)+arr[i][2])

    elif action==1:
        return max(cal(i+1,0)+arr[i][0],cal(i+1,2)+arr[i][2]) 
    
    else:
        return max(cal(i+1,1)+arr[i][1],cal(i+1,0)+arr[i][0])
    

print(max(cal(0,0),cal(0,1),cal(0,2)))

### FIXED CODE ###


import sys
sys.setrecursionlimit(10**9)
n = int(input())
arr = []
for i in range(n):
    arr.append([int(i) for i in input().split()])

dp = [[-1 for i in range(n+2)] for i in range(3)]

def cal(i,action):

    if i>=len(arr):
        return 0

    if dp[action][i]==-1:
        if action==0:
            dp[action][i] = max(cal(i+1,1)+arr[i][1],cal(i+1,2)+arr[i][2])

        elif action==1:
            dp[action][i] = max(cal(i+1,0)+arr[i][0],cal(i+1,2)+arr[i][2]) 
        
        else:
            dp[action][i] = max(cal(i+1,1)+arr[i][1],cal(i+1,0)+arr[i][0])
        
    return dp[action][i]
print(max(cal(0,0),cal(0,1),cal(0,2)))
### BUGGY CODE ###

N,K,Q = map(int,input().split())

import numpy as np



points=np.array([K]*N)

for i in range(Q):
    a = int(input())
    a=a-1
    points=points-1

    points[a]+=1


for j in points:
    if j>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N,K,Q = map(int,input().split())

import numpy as np

points=np.array([K]*N)
dis = np.array([0]*N)
for i in range(Q):
    a = int(input())
    a=a-1
    dis[a]+=1

points-=Q
points += dis

for j in points:
    if j>0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

ans = 0

for i in range(k):
  if a > 0:
    a = a-1
    ans +=1
  elif b > 0:
    b = b-1
  elif c > 0:
    ans = ans -1

print(ans)

### FIXED CODE ###

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

ans = 0

if k < a:
  ans = k

elif k <= a+b:
  ans = a
else:
  ans = a - (1 * (k - a -b) )
  


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

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
MAX_N = 2 * 10**6 + 1
 
# Construct factorial table
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD
 
fac_inv = [1] + [0] * MAX_N
# Femrmat's little theorem says a**(p-1) mod p == 1
# then, a * a**(p-2) mod p == 1
# it means that a**(p-2) is the inverse element
# Here, Get 1 / n! first
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD
 
def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD
 
def get_rect_sum(r, c):
    total = 0
    for i in range(1, c+2):
        total += mod_nCr(r + i, r)
    return total
 
r1, c1, r2, c2 = [int(item) for item in input().split()]
ans = get_rect_sum(r2, c2)
ans += get_rect_sum(r1 - 1, c1 - 1)
ans -= get_rect_sum(r2, c1 - 1)
ans -= get_rect_sum(r1 - 1, c2)
ans %= MOD
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
MAX_N = 2 * 10**6 + 1

# Construct factorial table
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD

fac_inv = [1] + [0] * MAX_N
# Femrmat's little theorem says a**(p-1) mod p == 1
# then, a * a**(p-2) mod p == 1
# it means that a**(p-2) is the inverse element
# Here, Get 1 / n! first
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

def get_rect_sum(r, c):
    total = 0
    for i in range(1, c+2):
        total += mod_nCr(r + i, r)
    return total

r1, c1, r2, c2 = [int(item) for item in input().split()]
ans = get_rect_sum(r2, c2)
ans += get_rect_sum(r1 - 1, c1 - 1)
ans -= get_rect_sum(r2, c1 - 1)
ans -= get_rect_sum(r1 - 1, c2)
ans %= MOD
print(ans)
### BUGGY CODE ###

S = input()
mod2019 = [0]*len(S)

for i in range(len(S)):
    mod2019[i] = int(S[i:])%2019

mod2019.extend([0])

answer = 0
count = [0 for _ in range(2020)]

for i in range(len(S)+1):
    answer += count[mod2019[i]]
    count[mod2019[i]] += 1
print(answer)

### FIXED CODE ###

S = input()
mod2019 = [0]*len(S)

mod2019[-1] = int(S[-1])
keta_mod = 1
for i in range(len(S)-2,-1,-1):
    keta_mod = (keta_mod*10)%2019
    mod2019[i] = (mod2019[i+1] + int(S[i])*keta_mod)%2019

mod2019.extend([0])

answer = 0
count = [0 for _ in range(2020)]

for i in range(len(S)+1):
    answer += count[mod2019[i]]
    count[mod2019[i]] += 1
print(answer)
### BUGGY CODE ###

#input
N, M = map(int, input().split())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

#output
import heapq

#点数配列の用意
point = [0] * M
hq = []
#M-i日目(1 <= i <= M)に働ける仕事の中で、Bが最大のものを選ぶ
for j in range(0, M):
    for i in range(N):
        if A[i] == j + 1:
            heapq.heappush(hq, -B[i])
    if len(hq):
        point[j] = -heapq.heappop(hq)

print(sum(point))

### FIXED CODE ###

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

jobs = {}
for _ in range(N):
    A, B = map(int, input().split())
    if A > M :
        continue
    if A in jobs:
        jobs[A].append(B)
    else:
        jobs[A] = [B]

#output
import heapq

#点数配列の用意
point = 0
hq = []
#M-i日目(1 <= i <= M)に働ける仕事の中で、Bが最大のものを選ぶ
for A in range(1, M+1):
    if A in jobs:
        for B in jobs[A]:
            heapq.heappush(hq, -B)
    else:
        if len(hq) == 0:
            continue
    point += -heapq.heappop(hq)

print(point)
### BUGGY CODE ###

import fractions
from functools import reduce
import copy
N = int(input())
A=[int(i) for i in input().split()]
B=[]
def list_gcd(a):
    return reduce(fractions.gcd , a)
b = []
for i in range(N):
    if i>0 and i<N-1:
        a = A[:i]+A[i+1:]
    elif i == 0:
        a = A[1:]
    else:
        a = A[:N-1]
    b.append(list_gcd(a))
print(max(b))

### FIXED CODE ###

import fractions
N = int(input())
A=[int(i) for i in input().split()]
B=[]
L = [0]
R = [0]
for i in range(N):
    L.append(fractions.gcd(A[i],L[i]))
    R.append(fractions.gcd(A[N-i-1],R[i]))
for i in range(N):
    B.append(fractions.gcd(L[i],R[N-i-1]))
print(max(B))
### BUGGY CODE ###

s = input()
k = int(input())

sub_list = []
for i in range(0, len(s)):
    for j in range(1, len(s)-i+1):
        sub_list.append(s[i:j+i])
print(sorted(list(set(sub_list)))[k-1])

### FIXED CODE ###

s = input()
k = int(input())
ans = set()
r = len(s)

if r == 1:
    print(s)
else:
    for i in range(r):
        for j in range(k):
            ans.add(s[i:i+j+1])
    print(sorted(list(ans))[k-1])
### BUGGY CODE ###

n=int(input())
al=[int(input()) for _ in range(n)]
ans=[]
for a in al:
    for i in range(len(ans)):
        if max(ans[i])<a:
            ans[i].append(a)
            break
    else:
        ans.append([a])
print(len(ans))

### FIXED CODE ###

import bisect
n=int(input())
al=[-int(input()) for _ in range(n)]
ans=[al[0]]
for a in al[1:]:
    i=bisect.bisect(ans,a)
    if i==len(ans):
        ans.append(a)
    else:
        ans[i]=a
print(len(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy

#import numpy as np

import collections
n=int(input())
a = list(map(int, input().split()))
alis= collections.Counter(a)
ss=[]
for i in range(1,n+1):
    ss.append(alis[i]*(alis[i]-1)//2)

for i in range(n):
    ss[a[i]-1] = (alis[a[i]]-1)*(alis[a[i]]-2)//2
    print(sum(ss))
    ss[a[i]-1] = alis[a[i]]*(alis[a[i]]-1)//2


### FIXED CODE ###

import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
import collections

n = int(input())
a = list(map(int, input().split()))
alis = collections.Counter(a)
ss = []
for i in range(1, n+1):
    ss.append(alis[i]*(alis[i]-1)//2)
#print(ss,alis)

chinpo=sum(ss)
#print(chinpo)
for i in range(n):
    #ss[a[i]-1] = (alis[a[i]]-1)*(alis[a[i]]-2)//2
    print(chinpo-ss[a[i]-1]+(alis[a[i]]-1)*(alis[a[i]]-2)//2)
### BUGGY CODE ###

N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
counter = 0
i = 0
while i<N:
    for j in range(C):
        if i+(C-j-1)<N and T[i]+K >= T[i+(C-j-1)]:
            counter += 1
            i = i+(C-j-1)+1
            break
print(counter)



### FIXED CODE ###

N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort(reverse = True)
counter = 1
i = 0           #### whileの中のカウント（バス乗車数）
A = T.pop()     #####先頭
while T:
  a = T.pop()
  i+=1
  if i>=C or a>A+K:
    i=0
    A=a
    counter += 1
  
print(counter)
### BUGGY CODE ###

import sys
import math
import bisect
import heapq

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

### FIXED CODE ###

from collections import*
from bisect import*
s=input()
n=len(s)
t=input()
d=defaultdict(list)
for i,c in enumerate(s):
    d[c].append(i)
m=-1
o=0
for c in t:
    if not d[c]:
        print(-1)
        exit()
    i=bisect(d[c],m)
    if len(d[c])==i:
        o+=1
        m=d[c][0]
    else:
        m=d[c][i]
print(o*n+m+1)
### BUGGY CODE ###

ans=-1
x,y=map(int,input().split())
for i in range(10**18):
  if x*i%y>0:
    ans=x*i
    break
  if x*i>10**18:
    break
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
if a%b==0:
  print(-1)
else:
  print(a)
### BUGGY CODE ###

ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

while '*' in arrs:
    arrs.remove('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans)

### FIXED CODE ###

ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)
### BUGGY CODE ###

import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = [[a,i] for a,i in zip(A,range(1,N+1))]
A = sorted(A,reverse=True)
INF = float('inf')
dp = [[-INF] * (N+1) for _ in range(N+1)]
dp[0][0] = 0
for x_y in range(1,N+1):
  a = A[x_y-1]
  for x in range(x_y+1):
    y = x_y-x
    if x==0:
      dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])
    elif y==0:
      dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)
    else:
      dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))

print(int(np.max(dp)))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A = [[a,i] for a,i in zip(A,range(1,N+1))]
A = sorted(A,reverse=True)
INF = float('inf')
dp = [[-INF] * (N+1) for _ in range(N+1)]
dp[0][0] = 0
ans = 0
for x_y in range(1,N+1):
  a = A[x_y-1]
  for x in range(x_y+1):
    y = x_y-x
    if x==0:
      dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])
    elif y==0:
      dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)
    else:
      dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))
    
    ans = max(ans,dp[x][y])
print(ans)
### BUGGY CODE ###

string=input()
length=len(string)
mod=[0]*2019
s=''
while length > 0:
  s=string[length-1]+s
  mod[int(s)%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod]))+mod[0])

### FIXED CODE ###

string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))
### BUGGY CODE ###

mod =1000000007
n = int(input())
a = list(map(int, input().split()))
sumpro = 0
x = 0
for i in range(n-1):
    x = 0
    for j in range(i+1, n):
        x += a[j]
    x = x%mod
    sumpro += (a[i]* x)%mod
    sumpro = sumpro%mod    
print(sumpro)

### FIXED CODE ###

MOD = 10 ** 9 + 7  # MODは変数に入れてしまったほうが打ち間違えなくていいです

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

S = sum(A) % MOD
ans = 0

# A_Nも含まれてしまいますが、そのときはs=0なので問題ありません
for x in A:
    S -= x  # 自分と自分自身を掛けないように、先に引く必要があります
    S %= MOD  # MODはいちいち取っておくといいです
    ans += S * x
    ans %= MOD

ans %= MOD  # この行は完全に不要ですが、最後だけMODを取り忘れてWAになるミスは非常によくあるので、必要以上に取っておくと安心できます
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
num = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
ans = {0: 0, 1: 0}
for i in range(2, N + 1):
    x = 0
    for j in A:
        k = num[j]
        if i - k < 0:
            continue
        if i == k:
            x = max(x, j)
            continue
        an = ans[i - k]
        if an == 0:
            continue
        x = max(x, an * 10 + j)
        x = max(x, j * 10 ** len(str(an)) + an)
    ans[i] = x
print(ans[N])

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
num = [2, 5, 5, 4, 5, 6, 3, 7, 6]
ans = {}
for i in range(N + 1):
    x = 0
    for j in A:
        k = num[j - 1]
        if i - k < 0:
            continue
        if i == k:
            x = max(x, j)
            continue
        an = ans[i - k]
        if an == 0:
            continue
        x = max(x, an * 10 + j)
    ans[i] = x
print(ans[N])