Harryxun/stf_run huggingface dataset:
import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

gcd=fractions.gcd(M,N)

if gcd==0:
  print(-1)
  sys.exit()

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//gcd
dl=lcm//N
for i in range(1,N):
  lst+=['-']*(dl-1)+[S[i]]

dl=lcm//M
for i in range(1,M):

  if len(lst)<(i*dl):
    lst+=['-']*(i*dl-len(lst))
  if lst[i*dl] == '-' or lst[i*dl] == T[i]:
    lst[i*dl]=T[i]
  else:
    print(-1)
    sys.exit()
print(lcm)


### FIXED CODE ###

import sys,fractions
N,M=map(int,input().split())
S=input()
T=input()

x=1

gcd=fractions.gcd(M,N)

if gcd==0:
  print(-1)
  sys.exit()

if S[0]!=T[0]:
  print(-1)
  sys.exit()

lst=[S[0]]


lcm=(M*N)//gcd
dn=lcm//N
dm=lcm//M

dlcm=(dn*dm)//fractions.gcd(dn,dm)

for i in range(lcm//dlcm):
  if S[dlcm*i//dn] != T[dlcm*i//dm]:
    print(-1)
    sys.exit()
print(lcm)
S,W = int(input().split())
if(S > W):
  print("safe")
else:
  print("unsafe")

### FIXED CODE ###

S,W = map(int,input().split())
if(S > W):
  print("safe")
else:
  print("unsafe")
n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])


for p in range(1,n+1):
    o = int(t[i])-int(t[i-1])
    p = int(x[i])-int(x[i-1])
    q = int(y[i])-int(y[i-1])
    if o >= p+q and (o - (p+q))%2 == 0:
        b += 1

if b == n:
    print('Yes')
else:

### FIXED CODE ###

n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])

for k in range(n):
    o = int(t[k+1])-int(t[k])
    p = int(x[k+1])-int(x[k])
    q = int(y[k+1])-int(y[k])
    if (o >= p+q) and ((o - (p+q))%2 == 0):
        b += 1
    else:
        b = b

if b == n:
    print('Yes')
else:
    print('No')
import math 

n=int(input())
l={}
  
# A function to print all prime factors of  
# a given number n 
def primeFactors(n): 
      
    # Print the number of two's that divide n 
    while n % 2 == 0: 
        if('2' in l):
            l['2']+=1
        else:
            l['2']=1
        n = n / 2
          
    # n must be odd at this point 
    # so a skip of 2 ( i = i + 2) can be used 
    for i in range(3,int(math.sqrt(n))+1,2): 
          
        # while i divides n , print i ad divide n 
        while n % i== 0:
            if(i in l):
                l[i]+=1
            else:
                l[i]=1
            n = n / i 
              
    # Condition if n is a prime 
    # number greater than 2 
    if n > 2: 
        if(n in l):
            l[n]+=1
        else:
            l[n]=1
        
primeFactors(math.factorial(n))
#print(l)
k=1
for i in l:
    k=k*(l[i]+1)
print(k)
    


### FIXED CODE ###

import math
n=int(input())
prime=[]


def expFactor(n, p): 
    x = p 
    exponent = 0
    while n // x > 0: 
      
        exponent += n // x 
        x *= p 
    return exponent 

ans=1

if(n>=2):
    prime.append(2)
for i in range(3,n+1):
    countt=0
    for j in range (1,int(math.sqrt(i))+1):
        if(i%j==0):
            countt+=1
    if(countt==1):
        prime.append(i)
#print(prime)
for i in prime:
    ans*=(expFactor(n,i)+1)
print(ans%(1000000007))
import math
n, x = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(x)
kotae = sorted(kotae)
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = math.gcd(t, kotae[i + 1] - kotae[i])
print(t)

### FIXED CODE ###

from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)
n = int(input())
data=[list(inout().split()) for _ in range(n)]
s = input()
ans = 0
c = False
for i in range(n):
  if c:
    ans += int(data[i][1])
  if data[i][0] == s:
    c = True
print(ans)

### FIXED CODE ###

n = int(input())
data=[list(input().split()) for _ in range(n)]
s = input()
ans = 0
c = False
for i in range(n):
   if c:
      ans += int(data[i][1])
   if data[i][0] == s:
      c = True
print(ans)
s=sorted(s)
t=sorted(t)
if a>b:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s=input()
t=input()
s=sorted(s)
t=sorted(t,reverse=True)
if s<t:
  print('Yes')
else:
  print('No')
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  if j in a:
    dp[j] = 0
  else:
    dp[j] = dp[j-1]+dp[j-2]
  ans = dp[j]
  while ans >= 1000000007:
    ans -= 1000000007
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
#for i in range(m):
 # a[i] = int(input())
a = set([int(input()) for i in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  dp[j] = (dp[j-1]+dp[j-2])%1000000007
  if j in a:
    dp[j] = 0
print(dp[n])
a = 1
b = 0
while a != 0:
	a = raw_input()
	b += 1
	print('Case ' + b + ': ' + a)

### FIXED CODE ###

a = int(1)
b = int(1)
while True:
	b = int(raw_input())
	if b != 0:
		print('Case ' + str(a) + ': ' + str(b))
		a += 1
		continue
	else:
		break
from time import time
start = time()

# 解説放送の解法

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
def main():
  N,Q=map(int,input().split())
  *C,=map(int,input().split())

  # 重複度を数える。
  res=[]
  tmp_dict={}
  for i in range(N):
    if tmp_dict.get(C[i]) != None:
      #(クエリの種類、l, r）
      res.append((-1,tmp_dict[C[i]],i))
      del tmp_dict[C[i]]
    tmp_dict[C[i]] = i
    
  assert time() - start < 0.2

  # クエリと合わせてソート。
  X = []
  for i in range(Q):
    l,r = map(int,input().split())
    # (元のクエリの順番、l, r)
    X.append((i,l-1,r-1))

  assert time() - start < 0.5
    
  X.extend(res) 
  X = sorted(X,key=lambda x:(x[1],-x[0]))
  
  assert time() - start < 1.0

  # 平面走査
  bit = BIT(N)
  ans=[]
  for idx,l,r in reversed(X):
    if idx == -1:
      bit.add(r,1)
    else:
      ans.append((idx,r-l+1-bit.query(l-1,r)))

  # 元の順番にソートし直して出力
  print(*list(zip(*sorted(ans)))[1])
  
if __name__=="__main__":
  main()

### FIXED CODE ###

from time import time
start = time()

# 解説放送の解法

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
def main():
  N,Q=map(int,input().split())
  *C,=map(int,input().split())
  q = [tuple(map(int,input().split())) for _ in range(Q)]

  # 重複度を数える。
  res=[]
  tmp_dict={}
  for i in range(N):
    if tmp_dict.get(C[i]) != None:
      #(クエリの種類、l, r）
      res.append((tmp_dict[C[i]]<<40) | (Q<<20) | i)
      del tmp_dict[C[i]]
    tmp_dict[C[i]] = i

  # クエリと合わせてソート。
  X = []
  for i in range(Q):
    l,r = q[i]
    # (元のクエリの順番、l, r)
    X.append(((l-1)<<40) | (i<<20) | r-1)
    
  X.extend(res) 
  X = sorted(X)

  # 平面走査
  bit = BIT(N)
  ans=[0]*Q
  mask = (1<<20) - 1
  for l in reversed(X):
    r = l & mask
    l >>= 20
    idx = l & mask
    l >>= 20
    if idx == Q:
      bit.add(r,1)
    else:
      ans[idx] = r-l+1-bit.query(l-1,r)
      
  print(*ans)
  
if __name__=="__main__":
  main()
import numpy as np

n = int(input())

l = np.zeros(n)
l[:] = np.nan

k = 0
i = 1

while i <= n:
  if n % i == 0:
    l[k] = i + (n / i) - 2
    k += 1
  i += 1
print(int(np.nanmin(l)))

### FIXED CODE ###

n = int(input())

for i in range(int(n ** 0.5)):
  if n % (int(n ** 0.5) - i) == 0:
    j = n // (int(n ** 0.5) - i)
    break
    
print(int(n ** 0.5) - i + j - 2)
import math

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

num = 0
xh.sort(key=lambda xh:xh[0])
l = len(xh)
dam = [0]*n

for i in range(n):
    res = xh[i][1]-dam[i]
    if res > 0:
        nat = math.ceil(res/a)
        pos = xh[i][0]+d
        num += nat
        for j in range(n):
            if math.fabs(xh[j][0]-pos) <= d:
                ###dam[j] += a*nat

print(num)


### FIXED CODE ###

import math

n, d, a = map(int,input().split())
xh = [[0 for i in range(2)] for j in range(n)]
left = [i for i in range(n)]
for i in range(n):
    x,h = map(int,input().split())
    xh[i] = [x,h]

num = 0
xh.sort(key=lambda xh:xh[0])

for i in range(n):
    for j in range(left[i-1],i):
        if xh[j][0]+d >= xh[i][0]-d:
            left[i] = j
            break

dam = [0]*n

def dsum(k):
    if k == 0:
        return 0
    elif left[k] == 0:
        return dam[k-1]
    else:
        return dam[k-1]-dam[left[k]-1]

for i in range(n):
    res = xh[i][1]-dsum(i)
    nat = max([math.ceil(res/a),0])
    dam[i] = dam[i-1]+a*nat
    if res > 0:
        num += nat

print(num)
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
X = (K - num) % Y
print(B[C[place] + X] + 1)


### FIXED CODE ###

N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    elif num == K:
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
try:
    X = (K - num) % Y
    print(B[C[place] + X] + 1)
except:
    print(place+1)
a,b=[int(i) for i in input().split()] 
if( a/b === 0){
  print a + b
} else {
  print b -a 
}


### FIXED CODE ###

a, b = map(int, input().split())
if b % a == 0:
  print(a + b)
else:
  print(b - a)
N, M = map(int, input().split())
A = list(map(lambda x: int(x), input().split()))
Q = []

for i in range(M):
    Q.append(tuple(map(int, input().split())))

A.sort()

Q.sort(key=lambda x: x[1], reverse=True)

cur = 0
for i in range(M):
    cnt = Q[i][0]
    while A[cur] < Q[i][1] and cnt > 0:
        A[cur] = Q[i][1]
        cur += 1
        cnt -= 1
    
    if A[cur] >= Q[i][1]:
        break

print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(lambda x: int(x), input().split()))
Q = []

for i in range(M):
    Q.append(tuple(map(int, input().split())))

A.sort()

Q.sort(key=lambda x: x[1], reverse=True)

cur = 0
for i in range(M):
    cnt = Q[i][0]
    while cnt > 0 and cur < N:
        if A[cur] >= Q[i][1]:
            break
        A[cur] = Q[i][1]
        cur += 1
        cnt -= 1

print(sum(A))
N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
   
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
    x_sum=0
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)
N,x = input().split()
A = input().split()
a = []
for i in range(N):
  a.append(int(A[1]))

a.sort()
a.reverse()
X = int(x)

idx = 0
while X>0:
  X = X-a[idx]
  idx+=1
  
print(idx)

### FIXED CODE ###

N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
  a.append(int(A[i]))
  
a.sort()
X = int(x)
 
idx = 0
while X>0 and idx<int(N):
  X = X-a[idx]
  idx+=1

if X==0:
  idx+=1
  
print(idx-1)
import math

a,b,volume=map(int,input().split())
V=a*a*b
space=V-volume
if space>volume:
  high=x/a/b
  print(math.degree(math.atan(b/high)))
elif space<=volume:
  high2=space/a/a
  print(math.degree(math.atan(high2/a)))

### FIXED CODE ###

import math

a,b,volume=map(int,input().split())
V=a*a*b
space=V-volume
if space>volume:
  high=volume*2/a/b
  print(math.degrees(math.atan(b/high)))
elif space<=volume:
  high2=space*2/a/a
  print(math.degrees(math.atan(high2/a)))
n,x = map(int, input().split())
if 1 < x < (2*n - 1):
    print("Yes")
    if n == 2:
        ans = [-1 for i in range(2*n-1)]
        k = n//2
        ans[k-1] = x-1
        ans[k] = x
        ans[k+1] = x+1
        ans[k+2] = x-2
        used = set([x-1,x,x+1,x-2])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert
        for i in range(n*2-1):
            print(ans[i])
    else:
        for i in range(2*n-1):
            print(i+1)
else:
    print("No")

### FIXED CODE ###

n,x = map(int, input().split())
if 1 < x < (2*n - 1):
    print("Yes")
    if n == 2:
        for i in range(3):
            print(i+1)
        exit()
    if x != 2:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) //2
        ans[k-1] = x-1
        ans[k] = x
        ans[k+1] = x+1
        ans[k+2] = x-2
        used = set([x-1,x,x+1,x-2])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
    else:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) // 2
        ans[k-1] = x+2
        ans[k] = x
        ans[k+1] = x-1
        ans[k+2] = x+1
        used = set([x+1,x,x+2,x-1])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
else:
    print("No")
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 1000
for n in range(2**N):
    n = bin(n)[2:]
    n = '0'*(N-len(n))+n
    l = []
    for i in range(N):
        if n[i]=='0':
            l.append([A[i],i,0])
        else:
            l.append([B[i],i,1])
    inversion = 0
    for i in range(N):
        if inversion>=ans:
            break
        for j in range(i+1,N):
            if l[i][0]>l[j][0]:
                inversion += 1
    if inversion>=ans:
        continue
    l.sort()
    d = defaultdict(list)
    for i in range(N):
        v,j,k = l[i]
        if (i-j+k)%2==1:
            d[v].append(i)
    possible = True
    for v in d:
        if len(d[v])%2==1:
            possible = False
        else:
            for i in range(len(d[v])//2):
                if (d[v][2*i+1]-d[v][2*i])%2==1:
                    inversion += d[v][2*i+1]-d[v][2*i]
                else:
                    possible = False
                    break
        if not possible:
            break
    if possible:
        ans = min(ans,inversion)

if ans == 1000):
    ans = -1
print(ans)

### FIXED CODE ###

from collections import defaultdict
from operator import itemgetter
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 1000
for n in range(2**N):
    n = bin(n)[2:]
    if n.count('1')%2!=0:
        continue
    n = '0'*(N-len(n))+n
    l = []
    for i in range(N):
        if n[i]=='0':
            l.append([A[i],i])
        else:
            l.append([B[i],i+1])
    inversion = 0
    for i in range(N):
        if inversion>=ans:
            break
        for j in range(i+1,N):
            if l[i][0]>l[j][0]:
                inversion += 1
    if inversion>=ans:
        continue
    l.sort(key=itemgetter(0))
    d = defaultdict(list)
    for i in range(N):
        v,j = l[i]
        if (i-j)%2==1:
            d[v].append(i)
    possible = True
    for v in d:
        if len(d[v])%2==1:
            possible = False
        else:
            for i in range(len(d[v])//2):
                if (d[v][2*i+1]-d[v][2*i])%2==1:
                    inversion += d[v][2*i+1]-d[v][2*i]
                else:
                    possible = False
                    break
        if not possible:
            break
    if possible:
        ans = min(ans,inversion)

if ans == 1000:
    ans = -1
print(ans)
N,H,W=[int(input()) in _ for range(3)]
print((N-H+1)*(N-W+1))

### FIXED CODE ###

N,H,W=[int(input()) for _ in range(3)]
print((N-H+1)*(N-W+1))
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

# print(a)
cnt = [0]*(10**5)
cnt2 = [0]*(10**5)#何回目に出てきたか
t = []
nxt = 0
loop = 0

for i in range(10**5):
    cnt[nxt] += 1
    if cnt[nxt] >= 2:
        # print("i: " + str(i))
        # print("nxt: " + str(nxt))
        loop = i - cnt2[nxt]
        modC = max(0, cnt2[nxt] - 2)
        break
    cnt2[nxt] = i
    t.append(nxt)
    nxt = a[nxt]

modK = (k-modC)%loop
# print("-------")
# print(t)
# print("modC: " + str(modC))
# print("modK: " + str(modK))
# print("loop: " + str(loop))
# print(modK)
# print(loop)
# print("-------")

print(t[modC + modK] + 1)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

cnt = [0]*(2*10**5)#何回出たか
cnt2 = [0]*(2*10**5)#何回目に出てきたか
t = []
nxt = 0
loop = 0

for i in range(2*10**5):
    cnt[nxt] += 1
    if cnt[nxt] >= 2:
        # print("i: " + str(i))
        # print("nxt: " + str(nxt))
        loop = i - cnt2[nxt]
        modC = cnt2[nxt]
        break
    cnt2[nxt] = i
    t.append(nxt)
    nxt = a[nxt]

modK = (k-modC)%loop
# print("-------")
# print(t)
# print("modC: " + str(modC))
# print("modK: " + str(modK))
# print("loop: " + str(loop))
# print(modK)
# print(loop)
# print("-------")

if k < modC:
    print(t[k] + 1)
else:
    print(t[modC + modK] + 1)

"""
発想はあってる
テストケース公開されたら試してみる！
"""
a,b,c,d = map(int, input().split())

print(map(a,b) + map(c,d))

### FIXED CODE ###

a,b,c,d = [int(input()) for i in range(4)]

print(min(a,b) + min(c,d))
s,t=input().split()
a,b=map(int,iinput().split())
u=input()
if u==s:
  a=a-1
if u==t:
  b=b-1
print(a+' '+b)

### FIXED CODE ###

s,t=input().split(' ')
a,b=map(int,input().split())
u=input()
if u==s:
    a=a-1
if u==t:
    b=b-1
print(str(a)+' '+str(b))
s = input()
<_cnt = 0
>_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)

### FIXED CODE ###

s = input()
right_cnt = 0
left_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and left_cnt == 0:
    right_cnt += 1
  elif s[i] == '<' and left_cnt > 0:
    k = max(right_cnt, left_cnt)
    l = min(right_cnt, left_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    right_cnt = 1
    left_cnt = 0
  elif s[i] == '>':
    left_cnt += 1
k = max(right_cnt, left_cnt)
l = min(right_cnt, left_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)
import sys
sys.setrecursionlimit(1000000000)
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def XOR(n):
    if n == 1:
        return 1
    else:
        return XOR(n-1)^n
    
A,B=map(int,input().split())
if A>1:
    print(XOR(B)^XOR(A-1))
else:
    if B > 0:
        print(XOR(B))
    else:
        print(0)


### FIXED CODE ###

#D問題
A,B = map(int,input().split())
def f(n):
    if n%2 == 0:
        if (n//2)%2 == 0:
            return n
        else:
            return n+1
    else:
        if ((n-1)//2)%2 == 0:
            return 1
        else:
            return 0
        
FB = f(B)
FA = f(A-1)
print(FB^FA)
n = int(input())
S = input()
b = 0
if n % 2 == 0:
  b = 1
  for i in range(n/2):
    if S[i] != S[i+n/2]:
      b = 0
print("Yes" if b = 1 else "No")
  

### FIXED CODE ###

n = int(input())
S = input()
b = 0
if n % 2 == 0:
  h = int(n/2)
  b = 1
  for i in range(h):
    if S[i] != S[i+h]:
      b = 0
print("Yes" if b == 1 else "No")
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
dum = prime_factorize(int(input()))
print(dum)
print(len(dum))
dum1 = 0
ans = 0
for i in range(len(dum)):
    if dum[i] == dum[i+1]:
        cnt += 1
    else:
        dum1 = 0
        cnt = 0
    if cnt > dum1:
        ans += 1
        cnt = 0
        dum1 += 1
print(ans)

### FIXED CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
dum = prime_factorize(int(input()))
dum_len = len(dum)

num = 0
ans = 0
cnt = 0
check = 0
for i in range(dum_len):
    if num == dum[i]:
        cnt += 1
        if cnt >= check:
            check += 1
            ans += 1
            cnt = 0
    else:
        num = dum[i]
        ans += 1
        cnt = 0
        check = 2
print(ans)
a = int(input())
sum = 0
for i in range(i+1):
    sum += i
print(sum)

### FIXED CODE ###

i = int(input())
sum = 0
for i in range(i+1):
    sum += i
print(sum)
while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
~                                                                               
~                            

### FIXED CODE ###

while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
for i in range(n):
    if max > ls[i]:
        print(maxnum)
    else:
        lstmp = ls[0:i] + ls[i+1:]
        print(max(lstmp))


### FIXED CODE ###

n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)