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

def locnt(s):
    index = 0
    lopair = 0
    while(index <= len(s)-2):
        if (s[index] != s[index+1]):
            lopair += 1
            index += 2
        else :
            index += 1
    return lopair

ans = 0
s = input()
lopair = locnt(s)
while(lopair):
    s = list(s)
    n = lopair
    i = 0
    while(n):
        if s[i] != s[i+1]:
            n -= 1
            ans += 2
            s[i] = '9'
            s[i+1] = '9'
            i += 2
        else:
            i += 1
    s = "".join(s).replace('9', "")
    lopair = locnt(s)
print(ans)

### FIXED CODE ###

s=input();f=s.count;print(2*min(f("1"),f("0")))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
a,b,k = map(int,input().split())

for i in range(a, b + 1):
    if a + k - 1 >= i or b - k + 1 <= i:
        print(i)


### FIXED CODE ###

# -*- coding: utf-8 -*-
a,b,k = map(int,input().split())

"""
for i in range(a, b + 1):
    if a + k - 1 >= i or b - k + 1 <= i:
        print(i)
"""
tmp = []
for i in range(k):
    if a + i <= b:
        print(a + i)
        tmp.append(a + i)
for i in range(k):
    i = k - i - 1
    if (b - i >= a) and (not((b - i) in tmp)):
        print(b - i)
### BUGGY CODE ###

from copy import deepcopy

N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
inf = 10**5
for n, dest in list(enumerate(passages))[::-1]:
    if len(dest) == 1:
        continue
    max_E = 0
    max_dest = 0
    for d in dest:
        if E[d] > max_E:
            max_E = E[d]
            max_dest = d
    E2 = deepcopy(E)
    E2[n] = ((E[n] - 1) * len(dest) - max_E) / (len(dest) - 1) + 1
    if n > 0:
        for n2, dest2 in list(enumerate(passages))[n-1::-1]:
            E2[n2] = sum(E2[d2] for d2 in dest2) / len(dest2) + 1
    min_E = min(min_E, E2[0])

print(min_E)


### FIXED CODE ###

N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

prob = [0] * N
prob[0] = 1
for n, dest in enumerate(passages):
    for d in dest:
        prob[d] += prob[n] / len(dest)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
for n, dest in enumerate(passages):
    if len(dest) == 1:
        continue
    new_E = ((E[n] - 1) * len(dest) - max(E[d] for d in dest)) / (len(dest) - 1) + 1
    min_E = min(min_E, E[0] - (E[n] - new_E) * prob[n])

print(min_E)
### BUGGY CODE ###

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

# 最初は全て繋がっているが、1本ずつ崩落していく。
# uniteし続けて、最終的に親が違うものは分離しているとみなせる？


parents = None


def root(x):
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x]


count = 0


def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x < root_y:
        parents[root_y] = root_x
    else:
        parents[root_x] = root_y


def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y)


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

# 1本ずつ崩落する
for i in range(1, M + 1):
    parents = [k for k in range(N)]
    for j, e in enumerate(es[i:]):
        a, b = e
        unit(a, b)
    uncertainly = 0
    # print('=======')

    for j in range(N):
        for k in range(j + 1, N):
            if not same(j, k):
                uncertainly += 1
    # print(parents)
    print(uncertainly)
    # print('=======')


### FIXED CODE ###

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

# 最初は全て繋がっているが、1本ずつ崩落していく。
# uniteし続けて、最終的に親が違うものは分離しているとみなせる？


parents = None


def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x]


count = 0


def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x


def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y)


def size(x):
    return -parents[root(x)]


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


parents = [-1] * N
ans = [0 for _ in range(M + 1)]
ans[M] = N * (N - 1) // 2
for i, e in enumerate(es[::-1]):
    # print('===========')
    a, b = e
    if root(a) != root(b):
        # print(size(a), size(b))
        x, y = size(a), size(b)
    else:
        x, y = 0, 0
    unit(a, b)
    ans[M - 1 - i] = ans[M - i] - (x * y)
    # print(parents)


# print(ans)
for num in ans[1:]:
    print(num)
### BUGGY CODE ###

import itertools
import math
K = [i for i in range(1, int(input()) + 1)]
numbers = itertools.product(K, repeat=3)

sum_gcd = 0
for i in numbers:
    a = math.gcd(i[0], i[1])
    b = math.gcd(a, i[2])
    sum_gcd += b

print(sum_gcd)

### FIXED CODE ###

import itertools
import math
K = [i for i in range(1, int(input()) + 1)]
numbers = itertools.combinations_with_replacement(K, 3)

sum_gcd = 0
for i in numbers:
    a = math.gcd(i[0], i[1])
    b = math.gcd(a, i[2])

    if i[0] != i[1] != i[2]:
        sum_gcd += b * 6
    elif i[0] == i[1] == i[2]:
        sum_gcd += b
    else:
        sum_gcd += b * 3

print(sum_gcd)
### BUGGY CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def search_cd(a):
  common_div = 0
  for a_i in a:
    common_div = gcd(a_i, common_div)
  return common_div

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

m = max([search_cd(a[:i] + a[i+1:]) for i in range(n)])
  
print(m)

### FIXED CODE ###

# b = 0 のとき、aを返す
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
n = int(input())
a = [int(x) for x in input().split()]
reversed_a = list(reversed(a))

length = len(a)
left_gcd = [0] * length
right_gcd = [0] * length

for i in range(1, length):
  left_gcd[i] = gcd(a[i-1], left_gcd[i-1])
  right_gcd[i] = gcd(reversed_a[i-1], right_gcd[i-1])
  
right_gcd = right_gcd[::-1]
m = [gcd(r, l) for l, r in zip(left_gcd, right_gcd)]

# print(left_gcd)
# print(right_gcd)
# print(m)

print(max(m))
### BUGGY CODE ###

N = int(input())

print(sum(range(0,N)))

### FIXED CODE ###

N = int(input())
print(int((N*(N-1))//2))
### BUGGY CODE ###

n,k = (int(x) for x in input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0,i-k),i))

print(dp[-1])
                  



### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*n
    dp[1] = abs(h[1] - h[0])
    for i in range(2,n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0,i-k),i))
    print(dp[-1])

main()
### BUGGY CODE ###

N = int(input())

S = [list(input()) for i in range(N)]

for j in range(N):
  S[j].sort()
  S[j] = ''.join(S[j])

ans = 0  

for k in range(N):
  for l in range(k+1,N):
    if k < l:
      if S[k] == S[l]:
        ans += 1
  
print(ans)

### FIXED CODE ###

from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
  S[l] = ''.join(S[l]) 

S.sort()

X = []
p = 1

for j in range(N-1):
  if S[j] == S[j+1]:
    p +=1
  else:
    X.append(p)
    p = 1
X.append(p)


def comb(n):
  if n == 2: return 1
  else:
    return int(n*(n-1)/2)

ans = 0

for k in range(len(X)):
  ans += comb(X[k])

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

def main():

    s = input()
    q = int(input())

    query = [tuple(input().split()) for _ in range(q)]
    ctn = query.count(("1",))

    flag = 0
    for q in query:
        if q[0] == "1":
            if flag == 1:
                flag = 0
            else:
                flag = 1
        else:
            if flag == 0:
                if q[1] == "1":
                    s = q[2] + s
                else:
                    s = s + q[2]
            else:
                if q[1] == "1":
                    s = s + q[2]
                else:
                    s = q[2] + s

    if ctn % 2 == 1:
        print(s[::-1])
    else:
        print(s)

main()


### FIXED CODE ###

from collections import deque

def main():

    s = deque(input())
    q = int(input())

    flag = 0
    query = []

    for _ in range(q):
        temp = input().split()
        if len(temp) == 1:
            flag += 1
        else:
            query.append(temp + [flag%2])

    for q in query:
        if q[-1] == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])

    if flag % 2 == 1:
        print("".join(list(s)[::-1]))
    else:
        print("".join(s))

main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)


def test(array, index, last_position, count, min_count):
    if index + 1 == len(array):
        # print("count:{}".format(count))
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]
    next = array[index + 1]

    # 前か次のと手がぶつかる場合は取り除く
    if last_position >= current[0] - \
            current[1] or current[0] + current[1] >= next[0] - next[1]:
        test(array, index + 1, last_position, count + 1, min_count)
    # 前のとぶつからない場合は取り除かないパターンも
    if last_position < current[0] - current[1]:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = sorted([list(map(int, input().split()))
                for i in range(N)], key=lambda x: x[0])
min_count = [-1]
test(array, 0, -1, 0, min_count)
print(len(array) - min_count[0])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)


def test(array, index, last_position, count, min_count):
    # 除去数が多いパターンは破棄する
    if min_count[0] != -1 and count >= min_count[0]:
        return
    if index + 1 == len(array):
        # print("count:{}".format(count))
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]

    # 前のと手がぶつかる場合は取り除く
    if last_position >= current[2]:
        test(array, index + 1, last_position, count + 1, min_count)
    # 前のとぶつからない場合は取り除かないパターンも
    else:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    # print(max_r)
    # print(current[2])
    if current[2] >= max_r:
        # print("残す")
        count += 1
        max_r = current[3]
# test(array, 0, -1, 0, min_count)
print(count)
### BUGGY CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
import numpy as np
N,W = list(map(int, input().split()))
wlist = [tuple(map(int, input().split())) for _ in range(N)]
suml = [0 for _ in range(W+1)]

V = [[0 for _ in range(W+1)] for _ in range(N+1)]
for e,item in enumerate(wlist,1):
    w,v = item
    for wpoint in range(W+1):
        if w <= wpoint:
            V[e][wpoint] = max(V[e-1][wpoint -w] + v,
                     V[e][wpoint])
        else:
            V[e][wpoint] = V[e-1][wpoint]

# print(V)
print(np.array(V).max())



# # w, v
# for i in range(W+1):
#     for w,v in wlist:
#         if not (i+w) <= W:
#             continue
#         suml[i+w] = max(
#             suml[i+w],
#             suml[i] + v
#         )
#         print("\tsuml[{}+{}]: {}".format(i,w,suml[i+w]))
#         print("\tsuml[{}]:{} + v:{}".format(i, suml[i], v))
#     print(suml)
# print(max(suml))


### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM :  https://atcoder.jp/contests/dp/submissions/4127921

import numpy as np
N,W = list(map(int, input().split()))

wvlist = sorted( [ [int(x) for x in input().split()] for _ in range(N)] ) 

dp = [0] * (W+1)
cnt = 0
for w,v in wvlist:
    cnt = cnt+w
    for i in range(min(cnt, W), w-1, -1):
        if dp[i] < dp[i-w]+v:
            dp[i] = dp[i-w] + v

print(max(dp))
### BUGGY CODE ###

n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = []
i = 1
j = 1
while(i not in t):
  t.append(i)
  i = d[i]
t_ = []
b = {}
while(i not in t_):
  t_.append(i)
  i = d[i]
i = 1
while(k>0):
  if i == t_[0]:
    k = k%len(t_)
    ans = t_[k]
    break
  else:
    i = d[i]
    ans = i
    k-=1
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = {}
t_ = {}
i = 1
j = 0
while(i not in t):
  t[i] = j
  t_[j] = i
  i = d[i]
  j += 1
a = 1
b = t[i]
if k < b+1:
  ans = t_[k]
else:
  k = (k-b)%(len(t.keys())-b)
  ans = t_[b+k]
print(ans)
### BUGGY CODE ###

import collections
import bisect
import copy
def main():

    N, M, Q = map(int, input().split())
    train = []
    for _ in range(M):
        l, r = map(int, input().split())
        train.append([l, r])
    train.sort()
    # print(train)

    end = []
    ends = []
    j = M-1
    for i in range(N, 0, -1):
        while j >= 0 and train[j][0] >= i:
            l, r = train[j]
            bisect.insort(end, r)
            j -= 1
        ends.append(copy.copy(end))
    ends.append([])
    ends = ends[::-1]
    # print(N)
    # print(ends)

    for _ in range(Q):
        p, q = map(int, input().split())
        j = bisect.bisect_right(ends[p], q)
        print(j)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():

    N, M, Q = map(int, input().split())
    train = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        l, r = map(int, input().split())
        train[l-1][r-1] += 1

    accum = [[0 for _ in range(N+1)]]
    for i in range(N):
        temp = [0]
        v = 0
        for j in range(N):
            v += train[i][j]
            temp.append(accum[-1][j+1]+v)
        accum.append(temp)
        # print(temp)

    for _ in range(Q):
        p, q = map(int, input().split())
        v = accum[q][q] - accum[p-1][q] - accum[q][p-1] + accum[p-1][p-1]
        print(v)

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

from collections import Counter


N = int(input())
A=[]
for i in range(N):
    A.append(input())
    
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)

ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

### FIXED CODE ###

N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)
### BUGGY CODE ###

N=int(input())
ans=1
A=list(map(int,input().split()))
A.sort()
while ans<=10**18:
    for i in A:
        ans*=i
    break
if ans>10**18:
    print(-1)
else:
    print(ans)

   

### FIXED CODE ###

def kai():
    N=int(input())
    A=list(map(int,input().split()))
    
    if  0 in A:
        print(0)
        return
    
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return
kai()
### BUGGY CODE ###

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i,b in enumerate(a):
        if i==0: pass
        x = (x * b) // gcd(x, b)
    return x

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
gcd=lcm(a)
#print(gcd)
res=0
for b in a:
    res+=gcd//b
print(res%mod)



### FIXED CODE ###


from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
gcd=x
res = 0
for i in a:
    res += gcd//i
    #res%=mod
print(res%mod)
### BUGGY CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
AC = []
BC = []
for a in A:
    for b in B:
        AB.append(a+b)
    for c in C:
        AC.append(a+c)
for b in B:
    for c in C:
        BC.append(b+c)
AB.sort(reverse=True)
AC.sort(reverse=True)
BC.sort(reverse=True)

ABC = []
for x in AB[:K]:
    for c in C:
        ABC.append(x+c)
for x in BC[:K]:
    for a in A:
        ABC.append(x+a)
for x in AC[:K]:
    for b in B:
        ABC.append(x+b)
ABC.sort(reverse=True)
print(*ABC[::3][:K], sep='\n')

### FIXED CODE ###

import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
AC = []
BC = []
for a in A:
    for b in B:
        AB.append(a+b)
    for c in C:
        AC.append(a+c)
for b in B:
    for c in C:
        BC.append(b+c)
AB.sort(reverse=True)
AC.sort(reverse=True)
BC.sort(reverse=True)

hq = []
heapq.heapify(hq)
for a in A:
    for bc in BC[:K]:
        heapq.heappush(hq,-a-bc)
for b in B:
    for ac in AC[:K]:
        heapq.heappush(hq,-b-ac)
for c in C:
    for ab in AB[:K]:
        heapq.heappush(hq,-c-ab)

ans = []
for _ in range(K):
    ans.append(-heapq.heappop(hq))
    heapq.heappop(hq)
    heapq.heappop(hq)

print(*ans, sep='\n')
### BUGGY CODE ###

K,S = map(int,input().split())
count=0
for i in range(0,K+1):
  for j in range(0,K+1):
    for h in range(0,K+1):
      if i+j+h==S:
        count+=1
print(count)

### FIXED CODE ###

k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
### BUGGY CODE ###

n=int(input()) 
c=list(map(int, input().split()))

ans = 1
for i in range(n):
    ans *= c[i]
    
if ans > 1000000000000000000:
        print('-1')
else:
    print(ans)
 

### FIXED CODE ###

n=int(input()) 
c=list(map(int, input().split()))

ans = 1
if 0 in c:
    print('0')
    exit()

for i in range(n):
    ans *= c[i]
    if ans > 1000000000000000000:
        print('-1')
        exit()

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
while m > 0:
    tmp = a.index(max(a))
    #print(tmp)
    a[tmp] = a[tmp] // 2
    m -= 1
print(sum(a))


### FIXED CODE ###

import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))

pq = []
for a in A:
    heapq.heappush(pq, -a)#'-'にすることで最大値を考えることができる！
#print(pq)
for _ in range(m):
    a = (-heapq.heappop(pq)) // 2
    heapq.heappush(pq, -a)
print(-sum(pq))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from sys import stdin

def main():
    ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

    N, W = ds_in()

    dp = [[0] * (W+1) for i in range(N+1)]
# dp[index][weight]:=valueとしてdp[n]での最大を求める.
    for i in range(N):
    # pre = values.copy()
        w, v = ds_in()  # [weight, value]
        for j in range(W+1):
            if (j-w>=0):
                dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
            else:
                dp[i+1][j] = dp[i][j]
    ans = 0
    for i in range(W+1):
        ans = max(ans, dp[N][i])
    print(ans)
    return 0
main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin

def main():
    ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

    N, W = ds_in()

    dp = [[0] * (W+1) for i in range(N+1)]
# dp[index][weight]:=valueとしてdp[n]での最大を求める.
    for i in range(N):
    # pre = values.copy()
        w, v = ds_in()  # [weight, value]
        for j in range(W+1):
            if (j-w>=0):
                dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
            else:
                dp[i+1][j] = dp[i][j]
    ans = 0
    for i in range(W+1):
        ans = max(ans, dp[N][i])
    print(ans)
    return 0
main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from collections import deque

N=int(input())
A = [deque(map(int, input().split())) for _ in range(N)]
lencount = 0
ans = 0
while lencount < N:
    update = False
    done = [0]*N
    for i in range(N):
        if len(A[i]) == 0 or done[i] == 1: continue
        tmp = A[i][0]-1
        if len(A[tmp]) == 0 or done[tmp] == 1: continue
        if A[tmp][0]-1 == i:
            update = True
            done[i] = 1
            done[tmp] = 1
            A[i].popleft()
            A[tmp].popleft()
            if len(A[i]) == 0:
                lencount+=1
            if len(A[tmp]) == 0:
                lencount+=1
    ans += 1
    if not(update):
        print(-1)
        sys.exit()
print(ans)
    







### FIXED CODE ###

import sys
input = sys.stdin.readline

from collections import deque

N = int(input())
A = [deque(map(int, input().split())) for _ in range(N)]
q = []
def check(x):
    if len(A[x]) == 0: return
    tmp = A[x][0]-1
    if A[tmp][0]-1 == x:
        if tmp < x: x,tmp=tmp,x
        q.append((x,tmp))
        return

for i in range(N):
    check(i)
day = 0
while len(q) > 0:
    day+=1
    q = list(set(q))
    prevQ=[]
    prevQ,q=q,prevQ
    for i in range(len(prevQ)):
        x,y=prevQ[i]
        A[x].popleft()
        A[y].popleft()
    for i in range(len(prevQ)):
        x,y=prevQ[i]
        check(x)
        check(y)
    
for i in range(N):
    if len(A[i]) != 0:
        print(-1)
        sys.exit()
print(day)
### BUGGY CODE ###

import itertools
N=int(input())
S=list(input())
answer=0

def is_unique(seq):
    return len(seq) == len(set(seq))

for i in range(N):
    C=list(itertools.combinations(S, i+1))
    C=[j for j in C if is_unique(j)]
    answer+=len(C)
print(answer%(7+10**9))

### FIXED CODE ###

N=list(range(int(input())))
S=list(input())
S=sorted(S)
answer=0

prev=S[0]
counts = []
counter=0

for k in S:
    if k==prev:
        counter+=1
    else:
        prev=k
        if counter!=0:
            counts.append(1+counter)
        counter=1
if counter!=0:
    counts.append(1+counter)

def soujou(li):
    atai=1
    for j in li:
        atai=j*atai
    return atai

answer=soujou(counts)-1
print(answer%(7+10**9))
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
t = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for l in range(1,K+1):
            t = t + gcd(i,j,l)
print(t)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
t = 0
t1 = 0
t2 = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for l in range(j,K+1):
            if i == j == l:
                t = t + i
            elif i == j or j ==l or l ==i:
                t = t + 3 * gcd(i, j,l)
            else:
                t = t + 6 * gcd(i,j,l)
             
           
           
print(t)