Harryxun/stf_run huggingface dataset:
import sys
S = input()
T = input()
ans = 'UNRESTORABLE'

if len(S) < len(T):
    print(ans)
    sys.exit()

if S.count(T) != 0:
    S = S.replace('?', 'a')
    print(S)
    sys.exit()

for i in range(len(S)):
    tmp = True
    s = i
    e = i + len(T)
    for j in range(len(T)):
        if S[i + j] != '?' and\
            S[i + j] != T[j]:
            tmp = False
            break

    if tmp:
        break
    else:
        s = -1
        e = -1
if s == -1:
    print(ans)
else:
    ans = S.replace('?', 'a')
    ans = ans[:s] + T + ans[e:]
    print(ans)


### FIXED CODE ###

import sys
S = input()
T = input()
ans = 'UNRESTORABLE'

if len(S) < len(T):
    print(ans)
    sys.exit()

if len(S) < len(T):
    print(ans)
    sys.exit()

tmp = True
anss = -1
anse = -1
for i in range(len(S) - len(T) + 1):
    tmp = True
    s = i
    e = i + len(T)
    for j in range(len(T)):
        if S[i + j] != '?' and\
            S[i + j] != T[j]:
            tmp = False
            break

    if tmp:
        anss = i
        anse = i + len(T)

if anss == -1:
    print(ans)

else:
    ans = S.replace('?', 'a')
    ans = ans[:anss] + T + ans[anse:]
    print(ans)
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

h, w = map(int, input().split())

m = math.inf
m = min(m, (1 if h % 3 else 0) * w)
m = min(m, (1 if w % 3 else 0) * h)
for _ in range(2):
    for i in range(1, h+1):
        v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)])
        m = min(m, max(v) - min(v))
    h, w = w, h

print(m)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

h, w = map(int, input().split())

m = 10000000000000000000000000
m = min(m, (1 if h % 3 else 0) * w)
m = min(m, (1 if w % 3 else 0) * h)
for _ in range(2):
    for i in range(1, h+1):
        v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)])
        m = min(m, max(v) - min(v))
    h, w = w, h

print(m)
N = int(input())
c = list(input())
ans = 0
#print(c)
for i in range(N):
    flag = 0
    if c[i] == "R":
        continue
    elif c[i] == "W":
        #print(c, ans, i, sep=" ",)
        for j in reversed(range(N)):
            if i == j:
                flag = 1
                break
            if c[j] == "R":
                c[i], c[j] = c[j], c[i]
                ans += 1
                print(c, ans, sep=" ")
                break
        else:
            continue
        if flag == 1:
            break

print(ans)

### FIXED CODE ###

N = int(input())
c = list(input())
ans = 0
cnt = c.count("W")
ans = c[N-cnt:].count("R")
if cnt != 0:
    print(ans)
else:
    print(0)
N, X = [int(i) for i in input().split()]
import math

gcd = math.gcd(N, X)
print(gcd*(N//gcd-1)*3)

### FIXED CODE ###

N, X = [int(i) for i in input().split()]
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
scale = gcd(N, X)
print(scale*(N//scale-1)*3)
count = 0
tmp = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        tmp += 1
    else:    
        tmp = 0
    count = max(tmp,count)
print(count)

### FIXED CODE ###

s = input()
count = 0
tmp = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        tmp += 1
    else:    
        tmp = 0
    count = max(tmp,count)
print(count)
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if (1.8)**(K//2) >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

### FIXED CODE ###

N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if K >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(x.index(min(z))+1)

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)
N = int(input())

if N == 1:
    print(1)
    sys.exit()

mylist = list(map(int, input().split()))


myans = 0
mymin = 99999999
for i in range(N):
    if mylist[i] < mymin:
        mymin = mylist[i]
        myans += 1
        
print(myans)

### FIXED CODE ###

N = int(input())


mylist = list(map(int, input().split()))


myans = 0
mymin = 9999999999
for i in range(N):
    if mylist[i] < mymin:
        mymin = mylist[i]
        myans += 1
        
print(myans)
N=int(input())
sum=0
for i range(N):
  l, r =map(int, input().split())
  sum+=(r-l+1)
print(sum)


### FIXED CODE ###

n=int(input())
sum=0
for i in range(n):
  l, r =map(int, input().split())
  sum+=(r-l+1)
print(sum)
N = input()
x = N % 10
#xはNを10で割ったあまり

if x == 2 or x == 4 or x == 5 or x == 7 or x == 9:
    k = 'hon'
elif x == 0 or x == 1 or x == 6 or x == 8:
    k = 'pon'
elif x == 3:
    k = 'bon'

print(k)


### FIXED CODE ###

N = int(input())
x = N % 10
#xはNを10で割ったあまり

if x == 2 or x == 4 or x == 5 or x == 7 or x == 9:
    k = 'hon'
elif x == 0 or x == 1 or x == 6 or x == 8:
    k = 'pon'
elif x == 3:
    k = 'bon'

print(k)
N = int(input())
t = N+1
for n in reversed(range(0, int(N**0.5))):
  if N%n==0:
    t = n+N//n
    break
print(t-2)

### FIXED CODE ###

N = int(input())
m = 100000000000000
for i in range(1, int(N**0.5)+1):
  if N%i == 0:
    m = min(m, i+N//i)
print(m-2)
from itertools import accumulate as ac
n=int(input())+2
t=[0]+list(map(int,input().split()))+[0]
v=[0]+list(map(int,input().split()))+[0]
s=[0]+list(ac(t))
def f(i,x):
    if s[i]<=x<=s[i+1]:return v[i]
    elif x<s[i]:return v[i]+s[i]-x
    else:return v[i]+x-s[i+1]
c=float("INF")
for i in range(n):
    c=min(c,f(i,0))
e=0
for i in range(1,2*s[-1]+1):
    i=i/2
    d=float("INF")
    for j in range(n):
        d=min(d,f(j,i))
    e+=0.25*(c+d)
    c=d
print(e)

### FIXED CODE ###

a=int(input())
b=int(input())
print(2*b-a)
a, b, c = map(int, input().split())
if b + c > a:
  print(c-(a-b))
elif b + c =< a:
  print(0)

### FIXED CODE ###

a, b, c = map(int, input().split())
if b + c > a:
  print(c-(a-b))
elif b + c <= a:
  print(0)
c5, c2 = (500, 5)
yens = int(input())
happiness = 0
if yens >= c5:
    noofc5 = yens // c5
    happiness += 1000 * noofc5
    yens -= (noofc5 * c5)
    
if yens >= c2:
    noofc2 = yens // c2
    happiness += 5 * noofc2
    yens -= (noofc5 * c2)
print(happiness)

### FIXED CODE ###

c5, c2 = (500, 5)
yens = int(input())
happiness = 0
if yens >= c5:
    happiness += (1000 * (yens // c5))
    yens %= c5
if yens >= c2:
    happiness += (5 * (yens // c2))

print(happiness)
a = input()
b = range(1, a + 1)
res = 0
max_cnt = 0

for index, bb in enumerate(b):
  cnt = 0
  while True:
    if bb % 2 == 0:
      bb /= 2
      cnt += 1
    else:
      break
  if cnt > max_cnt:
    max_cnt = cnt
    res = index + 1
    
print(res)

### FIXED CODE ###

a = int(input())
b = range(1, a + 1)
res = 1
max_cnt = 0

for index, bb in enumerate(b):
  cnt = 0
  while True:
    if bb % 2 == 0:
      bb /= 2
      cnt += 1
    else:
      break
  if cnt > max_cnt:
    max_cnt = cnt
    res = index + 1
    
print(res)
import math
N = int(input())
n = int(math.sqrt(N))
divisor = [i for i in range(1, n) if N % i == 0]
XY = [div + N // div - 2 for div in divisor]
print(min(XY))

### FIXED CODE ###

import math
N = int(input())
n = int(math.sqrt(N))
divisor = [i for i in range(1, n + 1) if N % i == 0]
XY = [div + N // div - 2 for div in divisor]
print(min(XY))
import math
A,B,C,D = map(int,input().split())
lcm = int( C * D / math.gcd(C,D) )
c_round = 0
ans = 0
for i in range(1, lcm + 1):
    if i % C != 0 and i % D != 0:
        c_round += 1

b = int( A / lcm )
start = A %lcm

for i in range(start, lcm + 1):
    if i % C != 0 and i % D != 0:
        ans += 1

c = int(  B  / lcm )
ans += ( c_round * (c-b-1) )
end = B % lcm

for i in range(1,end + 1):
    if i % C != 0 and i % D != 0:
        ans += 1
print(ans)

### FIXED CODE ###

A,B,C,D = map(int,input().split())
import fractions
lcm = int( C*D / ( fractions.gcd(C,D) ) )

first_c = ( A - 1) // C
first_d = ( A - 1) // D
first_cd = ( A - 1) // lcm 
first = ( A - 1 ) - ( first_c + first_d - first_cd )

end_c = B // C
end_d = B // D
end_cd = B // lcm 
end_ = B - ( end_c + end_d - end_cd )

print(end_ - first)
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=575000000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
import sys
lines = sys.stsin.readlines()
K, N = map(int, lines[0].srtip().split())
As = map(int, lines[1].strip().split())

diffs =[]
for base, switch in zip(arr[:-1], arr[1:]):
  diffs append(switch-base)

diffs append(arr[0]+K-arr[-1])

print(K-max(diffs))

### FIXED CODE ###

K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
diffs =[]
for base, switch in zip(As[:-1], As[1:]):
  diffs.append(switch-base)
diffs.append(As[0]+K-As[-1])
print(K-max(diffs))
h,w = int(input())
H = int((h+1)/2)
W = int((w+1)/2)
if w == 1:
    print(1)
elif w%2 == 0:
    print(H*(w/2))
else:
    print(H*W + (H-1)*(W-1))
    

### FIXED CODE ###

h,w = map(int,input().split())
if w == 1 or h == 1:
    print(1)
elif w%2 == 0 or h%2 == 0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))
def dfs(v, d):
	global D
	D[v] = d
	for u,dd in G[v]:
		if D[u] is not None:
			continue
		dfs(u, d+dd)

N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
	a, b, c = map(int, input().split())
	G[a].append([b, c])
	G[b].append([a, c])

Q, K = map(int, input().split())
D = [None]*(N+1)
dfs(K, 0)
for _ in range(Q):
	x, y = map(int, input().split())
	print(D[x] + D[y])


### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline


def dijkstra_heap(s, n, edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


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

    edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append([c,b])
        edge[b].append([c,a])
    
    Q, K = map(int, input().split())
    K -= 1
    D = dijkstra_heap(K, N, edge)

    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        print(D[x]+D[y])


if __name__ == '__main__':
    main()
n=input()
s=list(map(int,input().split())
sum=1
for i in s:
   sum=sum*i
if sum>10**18:
       print(-1)
else:
       print(sum)
       


### FIXED CODE ###

x,y=map(int, input().split())
print(x*y)
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)
	



### FIXED CODE ###

N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N+1):
	if (K - (a * A) < 0):
		break
	if (K - (a * A)) % B == 0 and ((K - (a * A))//B) <= N:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)
n = int(input())
a = list(map(int, input().split()))
color = [0]*8
for i in a:
  color[min(8,i//400)] += 1
kind = 0
for i in color[:7]:
  if i:
    kind += 1
if kind == 0 and color[7]:
  color[7] -= 1
  kind += 1
print(kind,kind+color[7])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
color = [0]*9
for i in a:
  color[min(8,i//400)] += 1
kind = 0
for i in color[:8]:
  if i:
    kind += 1
if kind == 0 and color[8]:
  color[8] -= 1
  kind += 1
print(kind,kind+color[8])
word = input()
print(len(word.("QWERYUIOPSDFHJKLZXVBNM")))

### FIXED CODE ###

word = input()
num = [0]
index = 0
for i in word:
  if i.strip("ATCG") == "":
    num[index] += 1
  else:
    index += 1
    num.append(0)
print(max(num))
list = ["haiku", "atcorder", "pytho"]
print(list.replace("," , " "))


### FIXED CODE ###

haiku = input()
print(haiku.replace("," , " "))
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

def calcM(A, B, x):
        return math.floor(A / B * x) - A * math.floor(x / B)    

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    if B < N:
        max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N-B, N+1))), default=N)
    # print('max_x:', max_x)
    return max(maxM, calcM(A, B, max_x))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)




### FIXED CODE ###

# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

def calcM(A, B, x):
        return math.floor(A / B * x) - A * math.floor(x / B)    

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    if k and B * k -1 <= N:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, k * B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))

    maxM = calcM(A, B, min(N, B - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)
# -*- coding: utf-8 -*-

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

a.sort()
l = 0
r = 0
ans = 0
cnt = [0, 0, 0]
while l < n and r < n:
    a_l = {a[l] - 1, a[l], a[l] + 1}
    a_r = {a[r] - 1, a[r], a[r] + 1}
    l_r = a_l & a_r

    if l_r:
        for ele in l_r:
            diff = ele - a[l]
            if diff == 0:
                cnt[1] += 1
            elif diff < 0:
                cnt[0] += 1
            else:
                cnt[2] += 1
        r += 1

    else:
        ans = max(ans, max(cnt))
        l += 1
        if l < n:
            diff = a[l] - a[l-1]
            if diff == 0:
                cnt = cnt
            elif diff == 1:
                cnt = cnt[1:] + [0]
            elif diff == 2:
                cnt = cnt[2] + [0, 0]
            else:
                cnt = [0, 0, 0]

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import Counter

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

c = Counter(a)
keys = c.keys()

st = set()
for key in keys:
    for i in (-1, 0, 1):
        st.add(key + i)

ans = 0
for x in st:
    cnt = c[x-1] + c[x] + c[x+1]
    ans = max(ans, cnt)

print(ans)
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):
    def chk_neighbor(i, j):
        if i < 0 or j < 0 or i >= H or j >= W:
            return "."
        else:
            return s[i][j]

    count = 0
    numofshirp = 0
    for s_ in s:
        numofshirp += s_.count("#")

    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                if "#" in [chk_neighbor(i - 1, j), chk_neighbor(i + 1, j), chk_neighbor(i, j - 1), chk_neighbor(i, j + 1)]:
                    count += 1

    if count == numofshirp:
        print(YES)
    else:
        print(NO)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):
    ans = YES
    for i in range(1, H-1):
        for j in range(1, W-1):
            if s[i][j] == "#" and s[i-1][j] == s[i+1][j] == s[i][j-1] == s[i][j+1] == ".":
                ans = NO
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W = map(int,input().split())  # type: int
    s = [input() for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
#素因数分解
def Prime_Factorization(n):
    R=[]
    N=n

    for k in range(2,int(-(-n**0.5//1))+1):
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])

    if N!=1:
        R.append([N,1])
        
    if not R:
        R.append([N,1])

    return R

#約数全部
from copy import copy
def Divisors(n):
    L=Prime_Factorization(n)
    U=[1]

    for (p,k) in L:
        T=copy(U)
        for t in T:
            r=t
            for _ in range(1,k+1):
                r*=p
                U.append(r)
    U.sort()
    return U

N=int(input())
L=Divisors(N)
L.remove(1)

K=0
for a in L:
    b=a-1
    if N//b==N%b:
        K+=b
print(K)

### FIXED CODE ###

#素因数分解
def Prime_Factorization(n):
    R=[]
    N=n

    for k in range(2,int(-(-n**0.5//1))+1):
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])

    if N!=1:
        R.append([N,1])
        
    if not R:
        R.append([N,1])

    return R

#約数全部
from copy import copy
def Divisors(n):
    if n==1:
        return [1]
    
    L=Prime_Factorization(n)
    U=[1]

    for (p,k) in L:
        T=copy(U)
        for t in T:
            r=t
            for _ in range(1,k+1):
                r*=p
                U.append(r)
    U.sort()
    return U


import sys
N=int(input())
if N==1:
    print(0)
    sys.exit()
    
L=Divisors(N)
L.remove(1)

K=0
for a in L:
    b=a-1
    if N//b==N%b:
        K+=b
print(K)
n = int(input())
for i in range(1,n+1):
  ans += i
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
  ans += i

print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 10**9
for i in range(1, 2**n, 2):
    if not i & 1 or k != sum([i >> j & 1 for j in range(n)]):
        continue
    pre = a[0]
    cost = 0
    for j in range(1, n):
        if i >> j & 1:
            tmp = max(pre - a[j] + 1, 0)
            pre = a[j] + tmp
            cost += tmp
    ans = min(ans, cost)
print(ans+'\n')


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 10**12
for i in range(1, 2**n, 2):
    if k != sum([i >> j & 1 for j in range(n)]):
        continue
    pre = a[0]
    cost = 0
    for j in range(1, n):
        if i >> j & 1:
            tmp = max(pre - a[j] + 1, 0)
            pre = a[j] + tmp
            cost += tmp
        else:
            pre = max(pre, a[j])
    ans = min(ans, cost)
print(ans)
(X,Y,Z,K) = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

delicious_list = []
for a in A[:min((1100,len(A)))]:
    for b in B[:min((1100,len(B)))]:
        for c in C[:min((1100,len(C)))]:
            delicious_list.append(a+b+c)
delicious_list.sort(reverse=True)
for i in range(K):
    print(delicious_list[i])

### FIXED CODE ###

lis = []
for i in range(5):
    lis.append(int(input()))
k = int(input())

flag_disconnectable = False
for i in range(5):
    for j in range(5):
        if i == j: continue
        if (lis[j]-lis[i]) > k:
            flag_disconnectable = True
            break

if flag_disconnectable:
    print(":(")
else:
    print("Yay!")
S = input()
K = int(input())
cnt = 0
for i in range(len(S)):
    if (S[i]==S[i+1])&(S[i]!=S[i-1]):
        cnt += K
print(cnt)


### FIXED CODE ###

s=input()
k=int(input())
l=len(s)
now=1
seq=[]
re=False
all=False
for i in range(l):
    if s[i%l]==s[(i+1)%l]:
        if i==l-1:
            re=True
            if len(seq)==0:
                all=True
            else:
                first=seq[0]//2
                end=now//2
                seq[0]=(seq[0]+now)
        now+=1
    else:
        seq.append(now)
        now=1
if all:
    ans=len(s)*k//2
else:
    seq=[i//2 for i in seq]
    if re:
        ans=sum(seq)*k-seq[0]+first+end
    else:
        ans=sum(seq)*k

print(ans)