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

import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline

def chkprint(a):
	a_name = ''
	for k, v in globals().items():
		if id(v) == id(a):
			a_name = k
			break
	print(a_name+' = '+str(a), file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		print(e - s, 'sec', file=sys.stderr)
		return ret
	return wrap

@mt
def slv(N, A):
	a = min(A)
	flag = False
	while not flag:
		flag = True
		for i in A:
			if i % a == 0:
				i = a
			else:
				i = i % a
				flag = False
		a = min(A)
	return a
	
N = int(input())
A = [int(i) for i in input().split()]
#N = 4
#A = [2, 10, 8, 40]
print(slv(N, A))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline

def chkprint(a):
	a_name = ''
	for k, v in globals().items():
		if id(v) == id(a):
			a_name = k
			break
	print(a_name+' = '+str(a), file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		print(e - s, 'sec', file=sys.stderr)
		return ret
	return wrap

@mt
def slv(N, A):
	flag = True
	while len(A) > 1:
		m = min(A)
		A = [a % m for a in A if a % m != 0]
		A.append(m)
		print(A, file=sys.stderr)
	return m


N = int(input())
A = [int(i) for i in input().split()]
'''
N = 5
A = [13, 5, 18, 100000000]
'''
print(slv(N, A))
### BUGGY CODE ###

l=[]
n=int(input())
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            l.append(x**2+y**2+z**2+x*y+y*z+z*x)

for x in range(1,n+1):
    print(l.count(x))

### FIXED CODE ###

import collections

l=[]
n=int(input())
for x in range(1,10**2+1):
    if x**2>n:continue
    for y in range(1,10**2+1):
        if x**2+y**2>n:continue
        for z in range(1,10**2+1):
            if x**2+y**2+z**2>n:continue
            l.append(x**2+y**2+z**2+x*y+y*z+z*x)

c=collections.Counter(l)
for x in range(1,n+1):
    print(c[x])
### BUGGY CODE ###

a, b = map(int, input().split())
ans = 1

for i in range(a, b+1):
    ans *= i
if(ans != 0):
    print("Positive" if ans > 0 else "Negative")
else:
    print("Zero")

### FIXED CODE ###

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

if(a > 0):
    print("Positive")
elif(a < 0 and b >= 0):
    print("Zero")
elif(a < 0 and b < 0):
    if((abs(a-b)+1)%2 == 0):
        print("Positive")
    else:
        print("Negative")
### BUGGY CODE ###

n=int(input())
L=list(map(int,input().split()))
sumL=sum(L)
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    for j in range(i):
        tmp1+=L[j]
    tmp2=sumL-tmp1
    ans=min(ans,abs(tmp1-tmp2))
    tmp1=0
    tmp2=0
print(ans)

### FIXED CODE ###

n=int(input())
L=list(map(int,input().split()))
sumL=[0 for _ in range(n)]
S=sum(L)
for i in range(n):
    if i==0:
        sumL[i]=L[i]
    else:
        sumL[i]=sumL[i-1]+L[i]
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    tmp1=sumL[i]
    tmp2=S-sumL[i]
    ans=min(ans,abs(tmp1-tmp2))
print(ans)
### BUGGY CODE ###

S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
for i in range(N):
    now += int(S[-i-1])*(10**i)
    C[now%2019] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)




### FIXED CODE ###

S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
tenfactor = 1

for i in range(N):
    s = int(S[-i-1])
    now = (now + s*tenfactor)%2019
    tenfactor = tenfactor*10%2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)
### BUGGY CODE ###

ks = input()
count = 0
k, s = [int(x) for x in ks.split(" ")]
for i in range(s + 2):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

### FIXED CODE ###

ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
ans=0
A.sort()
for i in range(n):
  for j in range(i):
    ok=i ; ng=n
    while abs(ok-ng)>1:
      mid=(ok+ng)//2
      if A[mid]<A[i]+A[j]:
        ok=mid
      else: ng=mid
    ans+=ok-i
    
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
ans=0
A.sort()
from bisect import bisect_left as bi
for i in range(n):
  for j in range(i):
    index=bi(A,A[i]+A[j])
    ans+=index-1-i
    
print(ans)
### BUGGY CODE ###

# O(MN + 4^N) 解
# 参考: https://twitter.com/ei1333/status/1177951676818325504
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    dp = [float("inf")] * (1<<N)
    for _ in range(M):
        a, _ = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            s |= 1 << c-1
        dp[s] = min(dp[s], a)
    for i in range(1<<N):
        for j, dp_j in enumerate(dp):
            dp[i|j] = min(dp[i|j], dp[i]+dp_j)
    ans = dp[-1]
    print(ans if ans!=float("inf") else -1)

main()



### FIXED CODE ###

N, M = map(int, input().split())
A = []
C = []
for _ in range(M):
    a, _ = map(int, input().split())
    A.append(a)
    C_ = list(map(int, input().split()))
    c = 0
    for c_ in C_:
        c |= 1<<c_-1
    C.append(c)
dp = [float("inf")] * (1<<N)
dp[0] = 0
for a, c in zip(A, C):
    dp_new = dp[:]
    for s, d in enumerate(dp):
        dp_new[s|c] = min(d+a, dp_new[s|c])
    dp = dp_new
#print(dp)
ans = dp[(1<<N)-1]
print(ans if ans != float("inf") else -1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
if ans > 10**18:
    ans = -1
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
A.sort()
if A[0] == 0:
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit(0)
    print(ans)
### BUGGY CODE ###

from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[input() for _ in range(h)] #マップ
vi=[ [-1 for _ in range(w)] for _ in range(h)]#visit
st=deque()
st2=deque()
st.append([ch-1,cw-1])
vi[ch-1][cw-1]=1
c=0

d=[[0,1],[-1,0],[1,0],[0,-1]]
d2=[[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],
    [-1,-2],[-1,-1],[-1,1],[1,2],[0,-2],[0,2],
    [1,-2],[1,-1],[1,1],[1,2],
    [2,-2],[2,-1],[2,0],[2,1],[2,2]]

while st or st2:
  while st:
    s2=0
    h1,w1=st.popleft()
    if dh-1==h1 and dw-1 ==w1:
      print(c)
      exit()
    for m in d:
      x=w1+m[1]
      y=h1+m[0]
      if 0<=y<h and 0<=x<w:
        if s[y][x]=="." and vi[y][x]==-1:
          st.append([y,x])
        elif s[y][x]=="#":s2=1
        vi[y][x]=1
    if s2==1: st2.append([h1,w1])

  while st2:
    h1,w1=st2.popleft()
    for m in d2:
      x=w1+m[1]
      y=h1+m[0]
      if 0<=y<h and 0<=x<w and vi[y][x]==-1 and s[y][x]==".":
        vi[y][x]=1
        st.append([y,x])
  c+=1
print(-1)

### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[input() for _ in range(h)] #マップ
vi=[ [-1 for _ in range(w)] for _ in range(h)]#visit
st=deque()
st2=deque()
st.append([ch-1,cw-1])
vi[ch-1][cw-1]=1
c=0

d=[[0,1],[-1,0],[1,0],[0,-1]]
d2=[[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],
    [-1,-2],[-1,-1],[-1,1],[1,2],[0,-2],[0,2],
    [1,-2],[1,-1],[1,1],[1,2],
    [2,-2],[2,-1],[2,0],[2,1],[2,2]]

while st or st2:
  while st:
    s2=0
    h1,w1=st.popleft()
    if dh-1==h1 and dw-1 ==w1:
      print(c)
      exit()
    for m in d:
      x=w1+m[1]
      y=h1+m[0]
      if 0<=y<h and 0<=x<w:
        if s[y][x]=="." and vi[y][x]==-1:
          st.append([y,x])
        elif s[y][x]=="#":s2=1
        vi[y][x]=1
    if s2==1: st2.append([h1,w1])

  while st2:
    h1,w1=st2.popleft()
    for m in d2:
      x=w1+m[1]
      y=h1+m[0]
      if 0<=y<h and 0<=x<w and vi[y][x]==-1 and s[y][x]==".":
        vi[y][x]=1
        st.append([y,x])
  c+=1
print(-1)
### BUGGY CODE ###

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

list1 = []

for i in range(Q):
    l,r = input().split()
    list1.append([int(l)-1,int(r)])

for i in range(Q):
    print(S[list1[i][0]:list1[i][1]].count('AC'))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t=[0]*(N+1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

N,M = map(int,input().split())
P = list(map(int,input().split()))
L = [set(map(int,input().split())) for i in [None]*M]

LSET = L[:]
loop = True
while loop:
    loop = False
    LSET2 = []
    i = 0
    while i < len(LSET):
        j = i + 1
        tmp = LSET[i]
        if not tmp:
            i += 1
            continue
        while j < len(LSET):
            if  LSET[j] and not tmp.isdisjoint(LSET[j]):
                tmp |= LSET[j]
                loop = True
                LSET[j] = None
            j += 1
        LSET2.append(tmp)
        i += 1
    LSET = LSET2[:]

result = len([i for i in set(range(1,N+1)).difference(*LSET) if i == P[i-1]])
PSET = [{P[i-1] for i in s}for s in LSET]
result += sum([len(l&p) for l,p in zip(LSET,PSET)])
print(result)

### FIXED CODE ###

class UnionFind:
    def __init__(self,size):
        self.L = [{'parent':i,'rank':0} for i in range(size)]

    def find(self,x):
        if self.L[x]['parent'] != x:
            self.L[x]['parent'] = self.find(self.L[x]['parent'])
        return self.L[x]['parent']

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if x_root == y_root:
            return
        if self.L[x_root]['rank'] < self.L[y_root]['rank']:
            x_root,y_root = y_root,x_root

        self.L[y_root]['parent'] = x_root
        if self.L[x_root]['rank'] == self.L[y_root]['rank']:
            self.L[x_root]['rank'] += 1
    
    def __str__(self):
        return str([i['parent'] for i in self.L])

if __name__ == '__main__':
    N,M = map(int,input().split())
    P = list(map(int,input().split()))
    graph = UnionFind(N)
    for i in [None]*M:
        x,y = map(int,input().split())
        graph.union(x-1,y-1)
    count = 0
    for i,v in enumerate(P):
        if graph.find(i) == graph.find(v-1):
            count += 1
    print(count)
### BUGGY CODE ###

import bisect
n,m = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
right = l[-1]*2+1
left = 0

while right - left >1:
    mid = (right+left)//2
    
    x = 0
    for i in range(n):
        a = l[i]
        index = bisect.bisect_left(l,mid-a)
        x += n-index
   
    if x >= m:
        left = mid
    else:
        right = mid
ans = []
for i in range(n):
    a = l[i]
    for j in range(n):
        if a + l[j] >= left:
            ans.append(a+l[j])
ans.sort(reverse=True)

print(sum(ans[0:m]))



### FIXED CODE ###

def main():
    import bisect
    import numpy as np
    n,k = map(int,input().split())
    l = list(map(int,input().split()))
    l.sort()
    l1 = np.array(l)
    def bise(x):
        y = np.searchsorted(l1,x-l1)
        return n*n-y.sum()

    left = -1
    right = l[-1]*2+1

    while right > left+1:
        mid = (right+left)//2
        
        if bise(mid) >= k:
            left = mid
        else:
            right = mid
    ans = 0
    count = 0
    acc = [0]
    for i in l:
        acc.append(acc[-1]+i)
    for i in l:
        index = bisect.bisect_left(l,right-i)
        ans += i*(n-index) + acc[n]-acc[index]
        count += n-index

    print(ans-(count-k)*left)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

#ABC118C-MonstersBattleRoyale.py

from sys import stdin

input = stdin.readline

N = int(input())

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

A = set(A)
A = list(A)

a = 0

while len(A) != 1:
    A.sort()
    for i in range(1,len(A)):
        A[i] = A[i] - A[0]
    if A[0] == 0:
        A.pop(0)
    if len(A) <= N/100:
        break

i = 0
while True:
    if A[i] != 0:
        print(A[i])
        break
    i += 1


### FIXED CODE ###

#ABC118C-MonstersBattleRoyale.py

from sys import stdin
from functools import reduce
import fractions

input = stdin.readline

N = int(input())

A = list(set(map(int,input().split())))

answer = reduce(fractions.gcd, A)
print(answer)
### BUGGY CODE ###

k,s = map(int,input().split())
ans = 0
for a in range(k+1):
    for b in range(k+1):
        for c in range(k+1):
            if a + b + c == s:
                ans += 1

print(ans)


### FIXED CODE ###

k,s = map(int,input().split())
ans = 0
for a in range(k+1):
    for b in range(k+1):
        if 0 <= s - a - b <= k:
            ans += 1

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

import itertools


def check(a):
    if sum(a) > 2 * sum(a):
        return False
    else:
        return a[0] < a[1] + a[2] and a[1] < a[0] + a[2] and a[2] < a[0] + a[1]

N = int(input().strip())
L = [int(str) for str in input().split()]

# print(sum([1 if check(comb) else 0 for comb in itertools.combinations(L, 3)]))

ans = 0
for comb in itertools.combinations(L, 3):
    ans += 1 if check(comb) else 0

print(ans)

### FIXED CODE ###

N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

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

n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list
 
minpos= min(pos2)
divs=make_divisor_list(minpos)[::-1]
if divs[0]==1:ans=1
else:
  for j in divs:
    if all(x%j==0 for x in pos2):
        ans=j
        break
print(ans)

### FIXED CODE ###

n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list

if n==1: ans=pos2[0]
else:
    minpos= min(pos2)
    divs=make_divisor_list(minpos)[::-1]
    if divs[0]==1:ans=1
    else:
        for j in divs:
            if all(x%j==0 for x in pos2):
                ans=j
                break
print(ans)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1):
        if p[i] > p[j]:
            break
    else:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
mi = n+1
for i in range(n):
    mi = min(mi,p[i])
    if mi == p[i]:
        count += 1
print(count)
### BUGGY CODE ###

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
Q = int(input())
d = [[0] * (H*W+1) for i in range(H*W+1)]

# 全ての数字に対応する座標を格納
matrix = [[] for i in range(H*W+1)]
for i in range(H):
    for j in range(W):
        matrix[A[i][j]] = (i, j)

#print(matrix)
for i in range(1, H*W+1):
    for j in range(i, H*W+1, D):
        if i == j:
            d[i][j] = 0
        else:
            f = matrix[j-D]
            to = matrix[j]
            d[i][j] = d[i][j-D] + abs(f[0]-to[0]) + abs(f[1]-to[1])
    for j in range(i-D,0,-D):
        f = matrix[j+D]
        to = matrix[j]
        d[i][j] = d[i][j+D] + abs(f[0]-to[0]) + abs(f[1]-to[1])

for i in range(Q):
    l, r = map(int, input().split())
    print(d[l][r])



### FIXED CODE ###

H, W, D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]

number_list = [[0] * 2 for _ in range(H*W+1)]
for h in range(H):
    for w in range(W):
        number_list[A[h][w]] = [h, w]

d = [0] * (H*W+1)
for idx in range(H*W+1):
    pre_idx = idx - D
    if pre_idx <= 0:
        continue
    diff = abs(number_list[idx][0] - number_list[pre_idx][0])
    diff += abs(number_list[idx][1] - number_list[pre_idx][1])
    d[idx] = d[pre_idx] + diff

for l, r in LR:
    cnt = 0
    print(d[r] - d[l])
### BUGGY CODE ###

n,x,m=map(int,input().split())

f=1
w=[]
d=set([])
t=[0]
chk=n
while 1:
    p=pow(x,f,m)
    if p in d: break
    d.add(p)
    w.append(p)
    t.append(t[-1]+p)
    f*=2
    chk-=1
    if chk==0:
        print(t[-1])
        exit()
ans=0
a=w.index(p)
ans+=t[a]
n-=a
loo=len(w)-a
if n%loo==0:
    ans+=(t[-1]-t[a])*(n//loo)
else:
    ans+=(t[-1]-t[a])*(n//loo)
    ans+=t[a+n%loo]-t[a]
print(ans)


### FIXED CODE ###

n,x,m=map(int,input().split())

f=1
w=[]
d=[0]*(m+2)
t=[0]
chk=n
p=x
for i in range(m+1):
    if i!=0: p=p*p%m
    if d[p]: break
    d[p]=1
    w.append(p)
    t.append(t[-1]+p)
    #f*=2
    chk-=1
    if chk==0:
        print(t[-1])
        exit()
ans=0
a=w.index(p)
ans+=t[a]
n-=a
loo=len(w)-a
if n%loo==0:
    ans+=(t[-1]-t[a])*(n//loo)
else:
    ans+=(t[-1]-t[a])*(n//loo)
    ans+=t[a+n%loo]-t[a]
print(ans)
### BUGGY CODE ###

N=int(input())
S=list(map(int,input().split( )))
tri=[]
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = [S[i],S[j],S[k]]
            a = sorted(a)
            if a[0] + a[1] > a[2]:
                tri.append(a)

for i in range(len(tri)):
    n=0
    for j in range(i+1,len(tri)):
        if tri[i] == tri[j-n]:
            tri.pop(j)
            n=n+1


print(len(tri))

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k = i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k-j-1
                if k == i+2:
                    k+=1
                break
            if k == N-1:
                tri_num = tri_num + k-j
                break
            k+=1
print(tri_num)
### BUGGY CODE ###

import sys

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    inp = sys.stdin.readlines()
    lis = []
    for i in range(n):
        com = inp[i].split()
        if com[0] == "insert":
            lis.append(com[1])
        elif com[1] in lis:
            print("yes")
        else:
            print("no")

### FIXED CODE ###

import sys

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    inp = sys.stdin.readlines()
    lis = set()
    for i in range(n):
        com = inp[i].split()
        if com[0] == "insert":
            lis.add(com[1])
        elif com[1] in lis:
            print("yes")
        else:
            print("no")
### BUGGY CODE ###

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

N, M = MAP()
S = input()
T = input()

lcm = lcm_base(N, M)
N_gap = lcm // N
M_gap = lcm // M
for i in range(lcm):
    if i % N_gap == 0 and i % M_gap == 0:
        if S[i//N_gap] != T[i//M_gap]:
            print(-1)
            exit()
print(lcm_base(N, M))


### FIXED CODE ###

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

N, M = MAP()
S = input()
T = input()

lcm = lcm_base(N, M)
N_gap = lcm // N
M_gap = lcm // M
for i in range(0, lcm, lcm//gcd(N, M)):
    if i % N_gap == 0 and i % M_gap == 0:
        if S[i//N_gap] != T[i//M_gap]:
            print(-1)
            exit()
print(lcm)
### BUGGY CODE ###

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

s = sum(a)
ans = 10**10
for i in range(1, n):
    ans = min(ans, abs(2*sum(a[:i]) - s))
print(ans)

### FIXED CODE ###

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

s = sum(a)
b = s
ans = 10**10
for i in range(1, n):
    b -= a[-i]
    tmp = abs(2*b - s)
    ans = min(ans, tmp)
print(ans)
### BUGGY CODE ###

a=int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans=0
for i in range(1,a+1):
  num=len(make_divisors(i))*i
  ans+=num
  
print(ans)
  
  

### FIXED CODE ###

n=int(input())

ans=0
for i in range(1,n+1):
  num=n//i
  ans+=i*num*(num+1)//2
  
print(ans)