Harryxun/stf_run huggingface dataset:
import math
from collections import deque


def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0
    prev = s[0]
    for i in range(1, len(s)):
        if prev == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            prev = s[i]
            flg = 1
    lst.append(cnt)
    if flg == 0:
        ans = s * k // 2
    else:
        ans += sum(list(map(lambda x: x // 2, lst[1:len(lst)-1])))*k
        if s[-1] == s[0]:
            ans += (lst[0] + lst[-1]) // 2 * (k - 1)
            ans += lst[0] // 2 + lst[-1] // 2
        else:
            ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###



def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0
    prev = s[0]
    for i in range(1, len(s)):
        if prev == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            prev = s[i]
            flg = 1
    lst.append(cnt)
    if len(lst) == 1:
        ans = len(s) * k // 2
    else:
        ans += sum(list(map(lambda x: x // 2, lst[1:len(lst)-1]))) * k
        # for l in lst[1: len(lst) - 1]:
        #     ans += l // 2 * k
        if s[-1] == s[0]:
            ans += (lst[0] + lst[-1]) // 2 * (k - 1)
            ans += lst[0] // 2 + lst[-1] // 2
        else:
            ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()
N,x= map(int, input().split())
Alist = list(map(int, input().split())) 

if Alist[0] >x:
    res = Alist[0]-x
    Alist[0] = x
    
for i in range(0,N-1):    
    if Alist[i] + Alist[i+1] > x:
        de = Alist[i+1] + Alist[i] - x
        Alist[i+1] = Alist[i+1] - de
        res = res + de 

print(res)

### FIXED CODE ###

N,x= map(int, input().split())
Alist = list(map(int, input().split())) 
res = 0
if Alist[0] >x:
    res = Alist[0]-x
    Alist[0] = x
    
for i in range(0,N-1):    
    if Alist[i] + Alist[i+1] > x:
        de = Alist[i+1] + Alist[i] - x
        Alist[i+1] = Alist[i+1] - de
        res = res + de 

print(res)
import numpy as np


N = int(input())
a = list(map(int, input().split(' ')))
a.sort()

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1] and [j][2] < x[i][1] and x[i][2] > x[j][2]:
            x[j][2], x[i][1] = x[i][1], x[j][2]
            break
        else:
            break


res = 0

for n in range(N):
    res += x[n][1]

print(res)


### FIXED CODE ###

import numpy as np


N = int(input())
a = list(map(int, input().split(' ')))
a.sort()

res = 0
for i in range(len(a[N:])):
    if i % 2 == 0:
        res += a[N+i]

print(res)
a, b, c = list(map(int, input().split()))

hoge = {a, b, c}

if len(hoge) == 2:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

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

hoge = {a, b, c}

if len(hoge) == 2:
  print("Yes")
else:
  print("No")
a=int(input())
b=int(input())


    c=b-2*a
    d=c//4
    print(a+d)

### FIXED CODE ###

List=[int(j) for j in input().split()]
a=List[0]
b=List[1]

if b>2*a:
    c=b-2*a
    d=c//4
    print(a+d)
else:
    print(b//2)
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        l = LCM
    else:
        print(0)
        exit()
print((M//LCM+1)//2)

### FIXED CODE ###

import fractions
from functools import reduce
import numpy as np
import sys

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


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def listdivide(list):
    numpy = np.array(list)
    numpy = numpy//2
    return numpy.tolist()


def divide2(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res


# while gcd_list(an) % 2 == 0:
#     print(gcd_list(an))
an = listdivide(an)

t = divide2(an[0])
for i in range(1, N):
    if divide2(an[i]) != t:
        print(0)
        sys.exit()

for i in range(t):
    an = listdivide(an)
    M = M // 2

LCM = lcm_list(an)

if LCM > M == 0:
    print(0)
else:
    print(-(-(M // LCM)//2))
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=b[0]
B=b[1]

C=A+B
if C%3==0 or A%3==0 or B%3==0:
    print("Possible")
else:
    print("Impossible")


### FIXED CODE ###

# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=int(b[0])
B=int(b[1])

C=A+B
if C%3==0 or A%3==0 or B%3==0:
    print("Possible")
else:
    print("Impossible")
l=list(map(int,input().split()))
u=max(l)
d=0
while l[i]!max:
  if l[i]<l[i+1]:
    pass
  else:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)
a,b,c=[int(_) for _ in input().split()]
print('A'+b[0]+'C')

### FIXED CODE ###

a,b,c=[_ for _ in input().split()]
print('A'+b[0]+'C')
a,b,c=[int() for x in input().split]
if a<b:
 if b<c:
    print("Yes")
elif:
    print("No")


### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
if a<b<c:
    print("Yes")
else:
    print("No")
def main():
    N = int(input())

    if N in N==3 or N==5 or N==7:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__' :
    main()

### FIXED CODE ###

def main():
    N = int(input())

    if N in [7,5,3]:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__' :
    main()
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set([a, b, c]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###

import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set(['a', 'b', 'c']):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
def k(v, distance):  # distanceは0or1
    flag[v] = distance  # 最初は0

    for next_v, w in graph[v]:
        if flag[next_v] == 1 or flag[next_v] == 0:  # 到達済み（親）であればcontinue
            continue
        if w % 2 == 0:  # そのノードへの距離が偶数であればそのまま（最初は0なので）
            k(next_v, distance)
        else:
            k(next_v, 1-distance)


N = int(input())
graph = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append([v-1, w])
    graph[v-1].append([u-1, w])
# これによって木が定義できた
# print(graph)

flag = [None for _ in range(N)]  # まだどの頂点も探索していない

k(0, 0)  # 親を強制的に決めてよい, この場合は0のノードを親にしている
for i in range(N):
    print(int(flag[i]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    a[u-1].append((v-1,w))
    a[v-1].append((u-1,w))
b=[None for i in range(n)]
def k(v,dis):
    b[v]=dis
    for next_v,w in a[v]:
        if b[next_v]!=None:
            continue
        if w%2==0:
            k(next_v,dis)
        else:
            k(next_v,1-dis)
k(0,0)
for i in range(n):
    print(b[i])
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans='No'
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans='Yes'
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans='Yes'
if a[0][0]==a[1][1]==a[2][2]==0:
    ans='Yes'
if a[2][0]==a[1][1]==a[0][2]==0:
    ans='Yes'
print(ans)

### FIXED CODE ###

a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)
N = int(input())

A = [int(input()) for _ in range(N)]
allA=[]

for i in range(N):
    remA=A.pop(i)
    allA.append(max(A))
    A.insert(i, remA)

for i in range(N):
    print(allA[i])


### FIXED CODE ###

r = input()
Ans=3*int(r)**2

print(Ans)
n = int(input())

hints = []
for i in range(n):
    x, y, h = map(int, input().split())
    hints.append([x, y, h])

def height(center , point):
    if point[2] == 0:
        return 0
    else:
        return point[2] + abs(point[0] - center[0]) + abs(point[1] - center[1])

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0 or hmax == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break

print("{} {} {}".format(cent[0], cent[1], hmax))

### FIXED CODE ###

n = int(input())

if n == 1:
    print("Hello World")

else:
    a = int(input())
    b = int(input())

    print(a+b)
N = int(input())

if N<(10**6):
	a=(10**N)%(10**9+7)
	b=(9**N)%(10**9+7)
	c=(8**N)%(10**9+7)
	print((a+c-2*b)%(10**9+7))
else:
	print((a+c-2*b)%(10**9+7))
	




### FIXED CODE ###

N = int(input())
a=(10**N)%(10**9+7)
b=(9**N)%(10**9+7)
c=(8**N)%(10**9+7)
print((a+c-2*b)%(10**9+7))
import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())
ones = X.count('1')
intX = int(X, 2)
def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)

Xplus = intX % (ones + 1)
Xminus = intX % (ones - 1)
for i in range(N):
    if X[i] == '0':
        num = (Xplus + pow(2, N-1-i)) % (ones + 1)
    else:
        num = (Xminus - pow(2, N-1-i)) % (ones - 1)
    check(num, 1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())
ones = X.count('1')
intX = int(X, 2)
def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)

if ones > 1:
    Xplus = intX % (ones + 1)
    Xminus = intX % (ones - 1)
else:
    Xplus = intX % (ones + 1)
    Xminus = intX

for i in range(N):
    e = 1
    if X[i] == '0':
        num = (Xplus + pow(2, N-1-i, ones + 1)) % (ones + 1)
    elif X[i] == '1' and ones > 1:
        num = (Xminus - pow(2, N-1-i, ones - 1)) % (ones - 1)
    else:
        num = (Xminus - pow(2, N-1-i))
        e = 0
    check(num, e)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]

X = (H + W) * 80
# X点持った状態から始める
dp = [[0] * W for _ in range(H)]
d = abs(A[0][0] - B[0][0])
dp[0][0] = np.zeros(X+X+1,np.bool)
dp[0][0][X+d] = 1
for h in range(H):
    for w,(a,b) in enumerate(zip(A[h],B[h])):
        if h == w == 0:
            continue
        d = abs(a - b)
        x = np.zeros(X+X+1,np.bool)
        if h != 0:
            x[d:] |= dp[h-1][w][:-d]
            x[:-d] |= dp[h-1][w][d:]
        if w != 0:
            x[d:] |= dp[h][w-1][:-d]
            x[:-d] |= dp[h][w-1][d:]
        dp[h][w] = x

dp = dp[-1][-1]
can_make = np.where(dp)[0] - X

answer = np.abs(can_make).min()
print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]

X = (H + W) * 80
# X点持った状態から始める
dp = [[0] * W for _ in range(H)]
d = abs(A[0][0] - B[0][0])
dp[0][0] = (1 << (X - d))
for h in range(H):
    for w,(a,b) in enumerate(zip(A[h],B[h])):
        if h == w == 0:
            continue
        d = abs(a - b)
        x = 0
        if h != 0:
            x |= (dp[h-1][w] << d) 
            x |= (dp[h-1][w] >> d)
        if w != 0:
            x |= (dp[h][w-1] << d) 
            x |= (dp[h][w-1] >> d)
        dp[h][w] = x

dp = dp[-1][-1]

B = bin(dp)[2:]
can_make = [i - X for i,b in enumerate(B[::-1]) if b == '1']

answer = min(x if x >= 0 else -x for x in can_make)
print(answer)
x, y, z, k = map(int, input().split())
a_s = list(map(int, input().split()))
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))
a_s.sort(reverse=True)
bs.sort(reverse=True)
cs.sort(reverse=True)

list = []
i = 0
# flag = True
minlist = 0
for a in a_s:
    if minlist >= (a + bs[0] + cs[0]):
        break
    for b in bs:
        if minlist >= (a + b + cs[0]):
            break
        for c in cs:
            abc = a + b +c
            if i >= k:
            # if flag and i >= k:
                list.sort(reverse=True)
                minlist = list[k]
                # flag = False
            if minlist >= abc:
                break
            list.append(a + b + c)
            i += 1
list.sort(reverse=True)
for i in range(k):
    print(list[i])


### FIXED 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 = []
for ai in a:
  for bi in b:
    ab.append(ai + bi)
ab.sort(reverse = True)

abc = []

for abi in ab[:k]:
  for ci in c:
    abc.append(abi + ci)
abc.sort(reverse = True)

for abci in abc[:k]:
  print(abci)
#入力部
C= 998244353
N,M,K=map(int,input().split())

#定義部
F=[0]*max(N,K)
G=[0]*max(N,K)

F[0]=1
for i in range(1,N):
    F[i]=(F[i-1]*i)%C

G[i]=pow(F[-1],C-2,C)

for j in range(N-2,-1,-1):
    G[j]=(G[j+1]*(j+1))%C

def nCr(n,r):
    if r<0 or n<r:
        return 0
    else:
        return (F[n]*G[r]*G[n-r])

#メイン部
S=0
for k in range(0,K+1):
    S=(S+M*pow(M-1,N-k-1,C)*nCr(N-1,k))%C
    
print(S%C)


### FIXED CODE ###

#入力部
C= 998244353
N,M,K=map(int,input().split())

#定義部
U=max(N+1,K)
F=[0]*U
G=[0]*U

F[0]=1
for i in range(1,U):
    F[i]=(F[i-1]*i)%C

G[i]=pow(F[-1],C-2,C)

for j in range(U-2,-1,-1):
    G[j]=(G[j+1]*(j+1))%C

def nCr(n,r):
    if r<0 or n<r:
        return 0
    else:
        return (F[n]*G[r]*G[n-r])

#メイン部
S=0
for k in range(0,K+1):
    S=(S+M*pow(M-1,N-k-1,C)*nCr(N-1,k))%C
    
print(S%C)
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


s = input()
out = []
for i in range(len(s)):
    if s[i] == "0":
        out.append("0")
    elif s[i] == "1":
        out.append("1")
    else:
        out.pop()
print(listToString(out))

### FIXED CODE ###

def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


s = input()
out = []
for i in range(len(s)):
    if s[i] == "0":
        out.append("0")
    elif s[i] == "1":
        out.append("1")
    else:
        if len(out) > 0:
            out.pop()
print(listToString(out))
X,Y,A,B,C=map(int,input().split())

RO=list(map(int,input().split()))
GO=list(map(int,input().split()))
TO=list(map(int,input().split()))

RO.sort()
GO.sort()
TO.sort(reverse=True)

R=RO[A-X:A]
G=GO[B-Y:B]
ans=sum(R)+sum(G)

idxR=0
idxG=0
for t in TO:
    if idxR<A and idxG<B:
        mi=min(R[idxR],G[idxG],t)
        if mi==t:break
        elif mi==R[idxR]:
            ans=ans-R[idxR]+t
            idxR+=1
        elif mi==G[idxG]:
            ans=ans-G[idxG]+t
            idxG+=1
    elif idxR>=A and idxG<B:
        mi=min(G[idxG],t)
        if mi==t:break
        else:
            ans=ans-G[idxG]+t
            idxG+=1
    elif idxR<A and idxG>=B:
        mi=min(R[idxR],t)
        if mi==t:break
        else:
            ans=ans-R[idxR]+t
            idxR+=1
    elif idxR>=A and idxG>=B:break
print(ans)



### FIXED CODE ###

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

RO=list(map(int,input().split()))
GO=list(map(int,input().split()))
TO=list(map(int,input().split()))

RO.sort()
GO.sort()

R=RO[A-X:A]
G=GO[B-Y:B]

TO.extend(R)
TO.extend(G)

TO.sort(reverse=True)

T=TO[0:X+Y]

print(sum(T))
using namespace std;
 
typedef long long ll;
 
int main() {
    string str; getline(cin, str);
    for (int i = 0; i < str.size(); ++i) {
        char c = str[i];
        if ('a' <= c && c <= 'z') cout << (char)(c-'a'+'A');
        else if ('A' <= c && c <= 'Z') cout << (char)(c-'A'+'a');
        else cout << c;
    }
    cout << endl;
}

### FIXED CODE ###

import sys
print(sys.stdin.readline().strip().swapcase())
# E - Product of Arithmetic Progression

import sys
input = sys.stdin.buffer.readline

Q = int(input())
MOD = 10**6 + 3

# a//b (MOD p)
def div_mod(a, b, p = MOD):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1, 1]
for i in range(2, 10**5 + MOD):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

for _ in range(Q):
    x, d, n = map(int, input().split())
    if x == 0 and d == 0:
        print(0)
    elif x == 0:
        ans = factorial_memo[n-1]
        ans *= pow(d, n-1, MOD)
        ans %= MOD
        print(ans)
    elif d == 0:
        print(factorial_memo[x])
    else:
        ans = pow(d, n, MOD)
        x_divided_by_d = div_mod(x, d, MOD)
        ans *= factorial_memo[x_divided_by_d + (n-1)]
        ans %= MOD
        ans = div_mod(ans, factorial_memo[x_divided_by_d - 1], MOD)
        print(ans)

### FIXED CODE ###

# E - Product of Arithmetic Progression

import sys
input = sys.stdin.buffer.readline

Q = int(input())
MOD = 10**6 + 3

# a//b (MOD p)
def div_mod(a, b, p=MOD):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1, 1]
for i in range(2, MOD):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

def factorial(x, p=MOD):
    if x < p:
        return factorial_memo[x]
    else:
        return 0


for _ in range(Q):
    x, d, n = map(int, input().split())
    if x == 0 and d == 0:
        print(0)
    elif x == 0:
        ans = factorial(n-1)
        ans *= pow(d, n-1, MOD)
        ans %= MOD
        print(ans)
    elif d == 0:
        print(pow(x, n, MOD))
    else:
        ans = pow(d, n, MOD)
        x_divided_by_d = div_mod(x, d, MOD)
        ans *= factorial(x_divided_by_d + (n-1))
        ans %= MOD
        ans = div_mod(ans, factorial(x_divided_by_d - 1), MOD)
        print(ans)
while(True):
    a = int(input())
    b = a // 1000
    c = (a - 1000 * b) // 100
    d = a % 100 // 10
    e=a%10
    if (d == b == c or c==d==e):
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

a = int(input())
b = a // 1000
c = (a - 1000 * b) // 100
d = a % 100 // 10
e=a%10
if ( b == c and c==d ):
        print('Yes')
elif(c==d and d==e):
        print('Yes')
else:
        print('No')
# coding:utf-8
n = int(input())
v = list(map(int, input().split()))
k = [0] * 100000
g = [0] * 100000

num = 1
for i in v:
    if num % 2 == 1:
        k[i] += 1
    else:
        g[i] += 1
    num += 1

max_k = max(k)
max_g = max(g)
print(n - (max_k+max_g))

### FIXED CODE ###

from collections import Counter as C
n = int(input())
v = list(map(int, input().split()))

#偶数番と奇数番の同じ数字の数
evens = C(v[::2]).most_common()
odds = C(v[1::2]).most_common()
#[('数字', 出現数), ('数字', 出現数)...]

#偶数番と奇数番の数字が違うならそのままans
if evens[0][0] != odds[0][0]:
    ans = n - (evens[0][1] + odds[0][1])
#同じ時は各[0][1]と[1][1]の合計を比べて
# 出現数が多いほうがans
else:
    #oddsの長さが1より大きければ
    # rにevensの1番目の出現数とoddsの2番目の出現数の和を代入
    #  そうでなければevensの1番目の出現数を代入（oddsを全換えするため）
    r = evens[0][1] + odds[1][1] if len(odds) > 1 else evens[0][1]
    s = evens[1][1] + odds[0][1] if len(evens) > 1 else odds[0][1]
    if r > s:
        ans = n - r
    else:
        ans = n - s

print(ans)
l, r = map(int, input().split())
 
v = []
 
if l*r < 2019:
    print(l*r)
else:
    flag = True
    for a, i in enumerate(range(l, r+1)):
        for j in range(l+a+1, r+1):
            if i*j%2019 in v:
                break
            else:
                v.append(i*j%2019)
        else:
            continue
        break

    print(min(v))

### FIXED CODE ###

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

print(min(n*a, b))
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
m = a[0]
ans = a[0]
if a[0]%2 == 0:
    b = a[0]//2
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)

else:
    b = a[0]//2 + 0.5
    for i in a:
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
m = a[0]
ans = a[0]
if a[0]%2 == 0:
    b = a[0]//2
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)

else:
    b = a[0]//2 + 0.5
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)
s = input()
is s[::-1].translate(str.maketrans("bdpq","dbqp")) == s:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
if s[::-1].translate(str.maketrans("bdpq","dbqp")) == s:
  print("Yes")
else:
  print("No")
n,m=list(map(int, input().split()))
a=list(map(int,input().split()))
while m>0:
  a.sort(reverse=True)
  for _ in range(m):
    a[0] //= 2
    m -= 1
    if a[0] < a[1]:
      break
  if a[0] == 0:
    break
print(sum(a))

### FIXED CODE ###

n,m=list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort(reverse=True)
while m>0:
  a[0] //= 2
  m = m - 1
  for i in range(n-1):
    if a[0] < a[i+1] and m > 0:
      a[i+1] //= 2
      m = m - 1
    else:
      a.sort(reverse=True)
      break
print(sum(a))
# coding: utf-8
import sys
from functools import lru_cache

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
# 奇数の時と偶数の時、奇数の場合は真ん中を選ぶかどうか
INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if n == 0:
        return 0
    elif n == 1:
        return max(A[index:])
    ret = max(A[index] + F(index+2, n-1), F(index+1, n))
    return ret

answer = F(0, N//2)
print(answer)


### FIXED CODE ###

# coding: utf-8
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
# 奇数の時と偶数の時、奇数の場合は真ん中を選ぶかどうか
INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if N - index + 2 < 2 * n:
        return -INF
    if n == 0:
        return 0
    elif n == 1:
        return max(A[index:])
    ret = max(A[index] + F(index+2, n-1), F(index+1, n))
    return ret

answer = F(0, N//2)
print(answer)
n = int(input())
import sys
sys.setrecursionlimit(100000)
def fa(n, memo=dict()):
	if n==0 or n == 1:
		return 1
	elif n in memo.keys():
		return memo[n]
	else:
		temp = fa(n-1)*n
		memo[n] = temp
		return temp

print(fa(n))

### FIXED CODE ###

import math
n = int(input())
print(math.factorial(n)%int(10**9+7))