Harryxun/stf_run huggingface dataset:
import sympy as sym #sympyのインポート
def Fib(n):
    x = sym.symbols('x',nonnegative=True,integer=True) #変数xの宣言(非負の整数)
    Fib=1/sym.sqrt(5)*(((1+sym.sqrt(5))/2)**(n-1)-((1-sym.sqrt(5))/2)**(n-1)) #一般項の式
    result=Fib.subs(x,n) #xにnを代入
    result=result.evalf() #式を浮動小数点数として評価
    return int(result)

n, m = map(int, input().split())
a_i = []
for i in range(m):
    a_i.append(int(input()))

before = 0
total = 1
flag = False
for a in a_i:
    if a == before:
        flag = True
        break
    x = a - 1 - before
    fib = Fib(x+2)
    total = total*fib
    before = a + 1
if flag:
    print("0")
else:
    x = n - before
    total = total*Fib(x+2)
    print(total%1000000007)

### FIXED CODE ###

def Fib(num):
    """num番目のフィボナッチ数を返す
    """
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b

n, m = map(int, input().split())
a_i = []
for i in range(m):
    a_i.append(int(input()))

before = 0
total = 1
flag = False
for a in a_i:
    if a == before:
        flag = True
        break
    x = a - 1 - before
    fib = Fib(x+1)
    total = total*fib
    before = a + 1
if flag:
    print("0")
else:
    x = n - before
    total = total*Fib(x+1)
    print(total%1000000007)
if __name__=='__main__':
    while True:
        n,w=map(int,input().split())
        if n==w==0:
            break
        V=[]
        for _ in range(n):
            heappush(V,int(input()))
            maxV=V[-1]

        histnum=maxV//w
        hist=[]
        for i in range(histnum+1):
            hist.append([])
        vl=len(V)
        for i in range(vl):
            v=heappop(V)
            hist[v//w].append(v)

        highest=0
        for i in range(len(hist)):
            highest=max(highest,len(hist[i]))
        ink=0
        for i in range(len(hist)):
            ink+=(1-i/histnum)*(len(hist[i])/highest)
        print(ink)


### FIXED CODE ###

while 1:
    n,w=map(int,input().split())
    if n==w==0:break
    a=[0]*100
    s=h=int(0)
    while n:
        b=int(input())
        a[b//w]+=1
        s=max(s,b//w)
        h=max(h,a[b//w])
        n-=1
    ans=0.01
    for i in range(int(s)+1):
        ans+=a[i]/h*(s-i)/s
    print(ans)
s = '9' + input()
t = len(s) - 1
A = '9' + '01'*int(t/2) + '0'*int(t%2)
B = '9' + '10'*int(t/2) + '1'*int(t%2)

s = int(s)
A = int(A)
B = int(B)

sa = s^A
sa = sa.count('1')
sb = s^B
sb = sb.count('1')

if sa >= sb:
    print(sa)
else:
    print(sb)

### FIXED CODE ###

s = input()
t = len(s)
a = '01'*int(t/2) + '0'*int(t%2)
b = '10'*int(t/2) + '1'*int(t%2)
cta = 0
ctb = 0
for i in range(t):
    if s[i] == a[i]:
        cta += 1
    elif s[i] == b[i]:
        ctb += 1
if cta <= ctb:
    print(cta)
else:
    print(ctb)
a = list(input().split())
s = a[0]
t = a[1]

s = list(s)
t = list(t)
time = 0
for i in range(len(s)):
    if s[i] != t[i] :
        s[i] = t[i]
        time += 1

print(time)

### FIXED CODE ###

s = list(input())
t = list(input())

time = 0
for i in range(len(s)):
    if s[i] != t[i] :
        s[i] = t[i]
        time += 1
 
print(time)
import sys
sys.setrecursionlimit(1000000)
def P(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res)%p
    if bi[i]=="1":
      res=(res*a)%p
  return res
n,a,b=map(int,input().split())
a,b=min(a,n-a),min(b,n-b)
m=10**9+7
N=min(n,2*10**5)
inv=[0 for _ in range(max(a,b))]
inv[1]=1
if max(a,b)>1:
  for i in range(2,max(a,b)):
    inv[i]=m-inv[m%i]*(m//i)%m
def C(n,r,a):
  for i in range(r):
    a=a*(n-i)*inv[r-i-1]%m
  return a
A,B=C(n,a,1),C(n,b,1)
print((P(2,n,m)-int(A)-int(B)-1+m)%m)

### FIXED CODE ###

n,a,b=map(int,input().split())
c=d=1
e=0
m=10**9+7
for i in range(1,b+1):
    c=(c*(n+1-i))%m
    d=(d*i)%m
    if i==a or i==b:
        e+=c*pow(d,m-2,m)%m
print((pow(2,n,m)-e-1)%m)
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)

a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    x = b*k-1
    print(f(a,x,b) - a*f(x,b))

### FIXED CODE ###

import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)
a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    print(f(a, b-1, b))
for e in iter(input,'0 0'):
 H,W=map(int,e.split())
 s=[[*map(int,input().split())]for _ in[0]*H]
 print(max(sum(max(sum(c),H-sum(c))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H)))))for x in range(2**H)))


### FIXED CODE ###

def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=max(c,r-c)
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()
A, B, K = map(int, input().split())
print((i for i in range(1, 101) if A % i + B % i < 1)[-K])

### FIXED CODE ###

integer1, integer2, term = map(int, input().split())
term_value = max(integer1, integer2)
largest_term = 0
while term_value <= 100:
    if integer1 % term_value == 0 and integer2 % term_value == 0:
        largest_term += 1
    if term == largest_term:
        break
    term_value -= 1
print(term_value)
import sys

for line sys.stdin:
    a,b,c,d,e,f = map(int, line.split())
    z = a * e - b * c
    if z != 0
        x=(c*e-b*f)/z
        y=(a*f-c*d)/z
    print("{0:.3f} {1:.3f}".format(x+0,y+0)

### FIXED CODE ###

while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break
n = int(input())

x = []
l = []
tls = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    l.append(tmp[1])
x, l = zip(*sorted(zip(x, l)))

m = {}
def solve(prev, idx):
    if idx == n:
        return 0
    key = (prev, idx)
    if key in m:
        return m[key]
    res_use = 0
    res_nouse = 0

    if x[idx] - l[idx] >= prev or prev == 0:
        res_use = 1
        res_use += solve(x[idx] + l[idx], idx + 1)
    res_nouse += solve(prev, idx + 1)

    ans = max(res_use, res_nouse)
    m[key] = ans
    return ans
print(solve(0, 0))

### FIXED CODE ###

def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()
n=int(input())
v=list(map(int,input().split()))
v1 = [v[2*i] for i in range(n//2)]

if len(set(v))==1:
    print(n//2)
    exit()
d1 = {}
for x in v1:
    if x in d1.keys():
        d1[x] = d1[x] + 1
    else:
        d1[x] = 1
d1 = sorted(d1.items(), key=lambda x:-x[0])

d2 = {}
v2 = [v[2*i+1] for i in range(n//2)]
ma2=0
for x in v2:
    if x in d2.keys():
        d2[x] = d2[x] + 1
    else:
        d2[x] = 1
d2 = sorted(d2.items(), key=lambda x:-x[0])
if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1) == 1:
        print(n-d1[0][1]-d2[1][1])
    elif len(d2) == 1:
        print(n-d1[1][1]-d2[0][1])
    else:
        raise UnicodeError
        # print(n-max(d1[0][1]+d2[1][1],d1[1][1]+d2[0][1]))

### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
v1 = [v[2*i] for i in range(n//2)]

if len(set(v))==1:
    print(n//2)
    exit()
d1 = {}
for x in v1:
    if x in d1.keys():
        d1[x] = d1[x] + 1
    else:
        d1[x] = 1
d1 = sorted(d1.items(), key=lambda x:-x[1])

d2 = {}
v2 = [v[2*i+1] for i in range(n//2)]
ma2=0
for x in v2:
    if x in d2.keys():
        d2[x] = d2[x] + 1
    else:
        d2[x] = 1
d2 = sorted(d2.items(), key=lambda x:-x[1])
if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1) == 1:
        print(n-d1[0][1]-d2[1][1])
    elif len(d2) == 1:
        print(n-d1[1][1]-d2[0][1])
    else:
        print(n-max(d1[0][1]+d2[1][1],d1[1][1]+d2[0][1]))
N = int(input())
D = list(map(int, input().split()))
if (D[0]!=0) or (0 in D[1:]):
  print(0)
else:
  mapping = dict()
  max_ = 0
  for n in D[1:]:
    if n in mapping:
      mapping[n]+=1
    else:
      mapping[n]=1
      if max_ < n :
        max_ = n
  ans=1
  for i in range(1,max_):
    if (i in mapping) and (i+1 in mapping):
      ans *= mapping[i]**(mapping[i+1])
    else:
      ans = 0
      break
  print(ans % 998244353)

### FIXED CODE ###

N = int(input())
print((N-1)//2)
S = input()
K = int(input())

con = 0

for i in S:
  if i == "1":
    con += 1
    


if S[0] == "1":
  print(int(S[1]))
else:print(int(S[0]))

### FIXED CODE ###

S = input()
K = int(input())

con = 0

for i in range(0,len(S)):
  if S[i] == "1":
    con += 1
  else:break

if K <= con:
  print(1)
else:
  if S[0] == "1":
    S = S.replace("1","")
    print(int(S[0]))
  else:
    print(int(S[0]))
a=input()
b=input()
c=input()
d=input()
if a<c:
    fast=c
else:
    fast=a
if b<d:
    last=b
else:
    last=d

if b<c:
    print("0")
else:
    print(last-fast)

### FIXED CODE ###

str=input()
if str[0]==str[2]:
    print("Yes")
else:
    print("No")
a, b = map(int, input().split())
if a and b == 1<= value < 10:
  print(a * b)
else:
  print('-1')

### FIXED CODE ###

a, b = map(int, input().split())
c = [1,2,3,4,5,6,7,8,9]
if a in c and b in c:
  print(a*b)
else:
  print('-1')
x = input()
def f(x):
    return sum(map(int, list(str(x))))
if x % f(x) == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

x = int(input())
def f(x):
    return sum(map(int, list(str(x))))
if x % f(x) == 0:
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n,m,k=map(int,input().strip("\n").split())
  A=list(map(int,input().strip("\n").split()))
  B=list(map(int,input().strip("\n").split()))
#  A.append(10**9+1)
#  B.append(10**9+1)

  def dfs(a,b,k,s):
    if k<0:
      return s-1
    if k==0:
      return s
    if a<n:
      ansA=dfs(a+1,b,k-A[a],s+1)
    else:
      ansA=s
    if b<m:
      ansB=dfs(a,b+1,k-B[b],s+1)
    else:
      ansB=s
    return max(ansA,ansB)

  ans=dfs(0,0,k,0)
  print(ans)


### FIXED CODE ###

import sys
from collections import deque
import copy
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
  n,m,k=map(int,input().strip("\n").split())
  A=list(map(int,input().strip("\n").split()))
  B=list(map(int,input().strip("\n").split()))
  t=sum(B)
  j=m
  ans=0
  for i in range(n+1):
    while j>0 and t>k:
      j-=1
      t-=B[j]
    if t>k:
      break
    ans=max(ans,i+j)
    if i==n:
      break
    t+=A[i]
  print(ans)
N, K = map(int, input().split())
L = list(map(int, input().split()))
XOR = 0
result = []
for i in range(K+1):
  for LINT in L:
     XOR += i ^ LINT
  result.append(XOR)
print(max(result))

### FIXED CODE ###

T, X = map(int, input().split())
print(T/X)
N, Q = map(int, input().split())
S = input()

ac = [0] * (N + 1)
for i in range(N):
    ac[i + 1] = ac[i] + (1 if S[i ] == 'A' and S[i + 1] == 'C' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])

### FIXED CODE ###

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

ac = [0] * (N + 1)
for i in range(N - 1):
    ac[i + 1] = ac[i] + (1 if S[i] == 'A' and S[i + 1] == 'C' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])
import sys
sys.setrecursionlimit(1000000)

h,w = map(int, input().split())
maze = [input() for i in range(h)]
route = [[0] * w for i in range(h)]
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            white += 1
 
 
class MyStack:
    def __init__(self):
        self.stack = []
    def push(self, item_1, item_2):
        self.stack.append([item_1,item_2])
    def pop(self):
        result = self.stack.pop(0)
        return result[0],result[1]
 
 
def min_route():
    global h,w
    stack = MyStack()
    stack.push(1,1)
    route[0][0] = 0
 
    while True:
        y,x = stack.pop()
        route_num = route[y-1][x-1] + 1
        if y != h:
            if maze[y][x-1] == '.' and route[y][x-1] == 0:
                stack.push(y+1,x)
                route[y][x-1] += route_num
        if y != 1:
            if maze[y-2][x-1] == '.' and route[y-2][x-1] == 0:
                stack.push(y-1,x)
                route[y-2][x-1] += route_num
        if x != w:
            if maze[y-1][x] == '.' and route[y-1][x] == 0:
                stack.push(y,x+1)
                route[y-1][x] += route_num
        if x != 1:
            if maze[y-1][x-2] == '.' and route[y-1][x-2] == 0:
                stack.push(y,x-1)
                route[y-1][x-2] += route_num
        if route[h-1][w-1]  != 0:
            return route[h-1][w-1]
 
ans = white - min_route() - 1
 
if ans < 0:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
maze = [input() for i in range(h)]
route = [[0] * w for i in range(h)]
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            white += 1
 
 
class MyStack:
    def __init__(self):
        self.stack = []
    def push(self, item_1, item_2):
        self.stack.append([item_1,item_2])
    def pop(self):
        result = self.stack.pop(0)
        return result[0],result[1]
 
 
def min_route():
    global h,w
    stack = MyStack()
    stack.push(1,1)
    route[0][0] = 0
    n = 0
    while len(stack.stack) >= 1:
        y,x = stack.pop()
        route_num = route[y-1][x-1] + 1
        if y != h:
            if maze[y][x-1] == '.' and route[y][x-1] == 0:
                stack.push(y+1,x)
                route[y][x-1] += route_num
        if y != 1:
            if maze[y-2][x-1] == '.' and route[y-2][x-1] == 0:
                stack.push(y-1,x)
                route[y-2][x-1] += route_num
        if x != w:
            if maze[y-1][x] == '.' and route[y-1][x] == 0:
                stack.push(y,x+1)
                route[y-1][x] += route_num
        if x != 1:
            if maze[y-1][x-2] == '.' and route[y-1][x-2] == 0:
                stack.push(y,x-1)
                route[y-1][x-2] += route_num
        if route[h-1][w-1]  != 0:
            return route[h-1][w-1]
        n += 1
    print(-1)
    exit()
 
ans = white - min_route() - 1
 
if ans < 0:
    print(-1)
else:
    print(ans)
s = input()
for i in range(1,len(s)//2):
  if s[:(n-2*i)//2] == s[(n-2*i)//2:n-2*i]:
    print(n-2*i)
    exit()

### FIXED CODE ###

s = input()
n = len(s)
for i in range(1,len(s)//2):
  if s[:(n-2*i)//2] == s[(n-2*i)//2:n-2*i]:
    print(n-2*i)
    exit()
import sys
 
input = sys.stdin.readline
 
ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

import sys
import numpy as np
import fractions
 
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    ans = 1
    for num in numbers:
        ans = ans * num // fractions.gcd(ans,num)
    return ans
 
def LI():
  return [int(s) for s in input().split()]
 
 
input = sys.stdin.readline
ri = lambda: int(input())
ril = lambda: list(map(int, input().split()))
 
N = ri()
A_s = ril()
mod = 10**9 + 7
 
#l = lcm_list(A_s)
l = 1
for num in numbers:
    ans = ans * num // fractions.gcd(ans,num)
return ans
 
print(sum(map(lambda x : l//x, A_s)) % mod)

### FIXED CODE ###

import fractions
 
N = int(input())

def LI():
  return [int(s) for s in input().split()]

A_s = LI()
mod = 10**9 + 7

#l = lcm_list(A_s)
l = 1
for num in A_s:
    l = l * num // fractions.gcd(l,num)

count = 0
for a in A_s:
  count+=l//a
  
print(count % mod)
N = int(input())
S = list(input())
cnt = 0
for i in range(i,N-2):
    if S[i] ='A' and S[i+1] == 'B' and S[i+2] == 'C':
        cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
S = list(input())
cnt = 0
for i in range(0,N-2):
    if S[i] =='A' and S[i+1] == 'B' and S[i+2] == 'C':
        cnt += 1

print(cnt)
N = int(input())
s = set()
for i in range(N):
    a = input()
    s.add(a)
if(len(s) == 3):
  print("Three")
else:
  print("Four")

### FIXED CODE ###

N = int(input())
a = list(input().split())

if("Y" in a):
  print("Four")
else:
  print("Three")
N=int(input())
cardlist=list(map(int,input().split())).sort(reverse=True)
Alist=cardlist[0:,2]
Blist=cardlist[1:,2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)

### FIXED CODE ###

N=int(input())
cardmap=map(int,input().split())
card=list(cardmap)
card.sort(reverse=True)
Alist=card[0::2]
Blist=card[1::2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)
N, M = map(int, input().split())
A = list(map(int, input().split()))
vote_sum = sum(A)
cnt = 0
y = "Yes"
n = "no"

for i in range(N):
	if (A[i]*4*M) >= T:
		cnt += 1

if cnt >= M:
	print(y)
else:
	print(n)

### FIXED CODE ###

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

total = sum(A)
def is_4M(x):
    a = total / (4*M)
    if x < a:
        return False
    return True

cnt = 0
for a in A:
    if is_4M(a):
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")
N = int(input())
S = input()
flag=(S[0]=="#")
count=0
for i in range(1,len(S)):
    if not flag:
        flag=(S[i]=="#" and S[i-1]==".")
    if flag:
        if S[i]=="." and S[i-1]=="#":
            count+=1
            s[i]="#"
print(count)

### FIXED CODE ###

N=int(input())
S=input()
use=[0 if S[i]=="." else 1 for i in range(N)]
now=[0 for i in range(N)]
count=sum(use)
lst=set()
lst.add(count)


for i in range(N-1,-1,-1):
    now[i]=1
    if use[i]:
        use[i]=0
        count-=1
    else:
        use[i]=1
        count+=1
    lst.add(count)
print(min(lst))
import math
from functools import reduce

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

N = int(input())
A = []
A = list(map(int, input().split()))
len = len(A)
gcd = 1

if gcd_list(A) > gcd:
    gcd = gcd_list(A)

if len > 2:
    for i in range(len):
        x = A.pop(i)
        if gcd_list(A) > gcd:
            gcd = gcd_list(A)
        A.insert(i, x)
print(gcd)


### FIXED CODE ###

import sys

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

n=int(input())
al=input().split()
al_i = [int(s) for s in al]

if (n == 2):
   print(max(al_i[0],al_i[1]))
   sys.exit()

fg = [0] * n
bg = [0] * n

for x in range(n):
   if (x == 0):
       fg[0] = al_i[0]
       y = 1
   else:
      while y <= x:
         fg[y] = gcd(fg[y-1], al_i[y])
         y += 1

for x in range(n):
   if (x == 0):
      bg[0] = al_i[n-1]
      y = 1
   else:
      while y <= x:
         bg[y] = gcd(bg[y-1], al_i[n-1-y])
         y += 1

m = 0
gm = 0

for x in range(n):
   if (x == 0):
      g = bg[n-2]
   elif (x == n-1):
      g = fg[n-2]
   else:
      g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(read())

def output(A):
    print('\n'.join(''.join(row) for row in A))

a = 'a'; b = 'b'; c = 'c'; d = 'd'; e = 'e'; f = 'f'; g = 'g'; h = 'h'; x = '.'

A3 = np.array([
        [a,a,x],
        [x,x,a],
        [x,x,a]
])

A4 = np.array([
    [a,a,c,d],
    [b,b,c,d],
    [e,f,g,g],
    [e,f,h,h]
])

A5 = np.array([
    [a,a,c,a,a],
    [b,b,c,x,c],
    [x,a,b,b,c],
    [b,a,x,x,a],
    [b,x,b,b,a]
])

A7 = np.array([
    [a,b,a,x,x,x,x],
    [a,b,a,x,x,x,x],
    [c,c,b,a,a,x,x],
    [x,a,b,c,c,x,x],
    [x,a,x,x,a,b,b],
    [a,x,x,x,a,c,c],
    [a,x,b,b,x,a,a]
])

def solve(N):
    if N <= 2:
        print(-1)
        return
    if N == 3:
        output(A3)
        return
    if N == 6:
        A = np.full((6,6),'.')
        A[:3,:3] = A3
        A[3:,3:] = A3
        output(A)
        return
    if N == 7:
        output(A7)
        return
    if N == 11:
        A = np.full((11,11),'.')
        A[:4,:4] = A4
        A[4:,4:] = A7
        output(A)
        return
    # 4,5,8,9,10,12以上
    # このときは、4x+5yと書ける
    x = 0
    while (N - 4 * x) % 5:
        x += 1
    y = (N - 4 * x) // 5
    A = np.full((N,N),'.')
    for i in range(x):
        A[4*i:4*i+4,4*i:4*i+4] = A4
    for j in range(y):
        A[4*x+5*j:4*x+5*j+5,4*x+5*j:4*x+5*j+5] = A5
    output(A)
    return

solve(N)

### FIXED CODE ###

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

import numpy as np

N = int(read())

def output(A):
    print('\n'.join(''.join(row) for row in A))

a = 'a'; b = 'b'; c = 'c'; d = 'd'; e = 'e'; f = 'f'; g = 'g'; h = 'h'; x = '.'

A3 = np.array([
        [a,a,x],
        [x,x,a],
        [x,x,a]
],dtype='U1')

A4 = np.array([
    [a,a,c,d],
    [b,b,c,d],
    [e,f,g,g],
    [e,f,h,h]
],dtype='U1')

A5 = np.array([
    [a,a,c,a,a],
    [b,b,c,x,c],
    [x,a,b,b,c],
    [b,a,x,x,a],
    [b,x,b,b,a]
],dtype='U1')

A7 = np.array([
    [a,b,a,x,x,x,x],
    [a,b,a,x,x,x,x],
    [c,c,b,a,a,x,x],
    [x,a,b,c,c,x,x],
    [x,a,x,x,a,b,b],
    [a,x,x,x,a,c,c],
    [a,x,b,b,x,a,a],
],dtype='U1')

def solve(N):
    if N <= 2:
        print(-1)
        return
    if N == 3:
        output(A3)
        return
    if N == 6:
        A = np.full((6,6),'.','U1')
        A[:3,:3] = A3
        A[3:,3:] = A3
        output(A)
        return
    if N == 7:
        output(A7)
        return
    if N == 11:
        A = np.full((11,11),'.','U1')
        A[:4,:4] = A4
        A[4:,4:] = A7
        output(A)
        return
    # 4,5,8,9,10,12以上
    # このときは、4x+5yと書ける
    x = 0
    while (N - 4 * x) % 5:
        x += 1
    y = (N - 4 * x) // 5
    A = np.full((N,N),'.','U1')
    for i in range(x):
        A[4*i:4*i+4,4*i:4*i+4] = A4
    for j in range(y):
        A[4*x+5*j:4*x+5*j+5,4*x+5*j:4*x+5*j+5] = A5
    output(A)
    return

solve(N)
import math
 
n, a, b = map(int, input().split())
 
sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += math.floor(m % 10)
        m /= 10
    if a <= sum_n <= b:
        sum_all += i
 
print(sum_all)

### FIXED CODE ###

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

if (a + b) > (c + d):
  print('Left')
elif (a + b) < (c + d):
  print('Right')
else:
  print('Balanced')
n=int(input())
arr=list(map(int, input().rstrip().split()))
arr.sort()

if arr[n//2-1] == arr[n//2]:
  print(0)
  return
print(arr[n//2]-arr[n//2-1])

### FIXED CODE ###

n=int(input())
arr=list(map(int, input().rstrip().split()))
arr.sort()

if arr[n//2-1] == arr[n//2]:
  print(0)
else:
  print(arr[n//2]-arr[n//2-1])
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
K = int(input())


count = 0
tmp = S[0]
for i in range(1, len(S)):
    if S[i] == tmp:
        count += 1
        tmp = ""
    else:
        tmp = S[i]

if S[0] == S[-1] and S[-2] != S[-1]:
    count += 1
print(count * K)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
K = int(input())

L = [i for i in S]


if len(S) == 1:
    if K == 1:
        print(0)
    else:
        print(K//2)
    sys.exit()

count = 0
tmp = S[0]
for i in range(1, len(S)):
    if S[i] == tmp:
        count += 1
        S[i] = "A"
        tmp = S[i]
    else:
        tmp = S[i]

count2 = 0
if S[0] == S[-1]:
    L[0] = "A"
    count2 += 1
    tmp = L[0]
    for i in range(1, len(L)):
        if L[i] == tmp:
            count2 += 1
            L[i] = "A"
            tmp = L[i]
        else:
            tmp = L[i]
    if L[-1] == "A":
        print((K//2)*count2 + (K//2+K%2)*count)
    else:
        print(count + (K-1)*count2)
else:
    print(count * K)