Harryxun/stf_run huggingface dataset:
n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
#  for x,y in xy:
#    if [x+p,y+q] in xy:
#      cnt+=1
  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  ans=min(ans,n-cnt)
print(ans)

### FIXED CODE ###

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
        cnt+=1
  ans=min(ans,n-cnt)

print(ans)
N, K = map(int, input().split())
Const = []
pc = N
for i in range(1, 3200):
    c = N//i
    if pc>i-1:
        Const.append(pc - c)
    if i*i>N:
        sqrtN = i-1
        break
    pc = c
#if sqrtN*sqrtN!=N:
#    Const[-1] -= 1

len_dp = sqrtN + len(Const)
dp = [[0]*(len_dp) for _ in range(K)]
dp0 = dp[0]


for i in range(1, sqrtN+1):
    dp0[i] = 1
    if i<len(Const):
        dp0[-i] = Const[i]

cum_dp0 = []
c = 0
for v in dp0:
    c += v
    cum_dp0.append(c)
mod = 10**9+7
dp_old = cum_dp0
for _ in range(K-1):
    print(dp_old)
    dp = [0]*(2*sqrtN+2)
    for i in range(1,len_dp):
        dp[i] = dp_old[-i] + dp[i-1] % mod
        if i > sqrtN:
            dp[i] *= Const[-(i-sqrtN)]
            print(Const[-(i-sqrtN)])
            dp[i] %= mod
    dp_old = dp
print(dp)


### FIXED CODE ###

def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def sqrt_case_manager(N):
    # x ∈ [1, N] に対して、N//x の取りうる値と、その値を取るときの x の範囲（半開区間）を列挙
    # O(sqrt(N))
    l = 1
    while l <= N:
        r = N//(N//l) + 1
        yield N//l, l, r
        l = r

def solve(N, K, cases):
    # dp[k][n] := k 個目まで見て、k 個目に n を置く場合の数
    #           = sum( dp[k-1][N/n以下] )
    # dp[k][l,r] := k 個目まで見て、k 個目に [l, r) を置く場合の数
    #              ただし n' ∈ [l, r) について N/n' は同じ値を取る
    #             = sum( dp[k-1][N/l以下] )
    mod = 10**9+7
    dp = np.zeros((K+1, len(cases)), dtype=np.int64)
    dp[0, 0] = 1
    for k in range(1, K+1):
        cum = 0
        for n in range(len(cases)):
            cum = (cum + dp[k-1, n]) % mod
            _, l, r = cases[-n-1]
            dp[k, -n-1] = cum * (r-l) % mod
    print(dp[-1].sum() % mod)


numba_compile([
    [solve, "(i8,i8,i8[:,:])"],
])


def main():
    N, K = map(int, input().split())
    cases = np.array(list(sqrt_case_manager(N)), dtype=np.int64)
    solve(N, K, cases)

main()
from sys import stdin
a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
c = stdin.readline().rstrip()

A = int(a)
B = int(b)
C = int(c)


X = A + B - C
if X >= 0:
    print(X)
else:
    print(0)

### FIXED CODE ###

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

X = b + c - a
if X >= 0:
    print(X)
else:
    print(0)
from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
if gcd(n,m)==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  k=n//gcd(n,m)
  l=m//gcd(n,m)
  if len(s)<=len(t):
    for i in range(k):
      if s[i*k]!=t[i*l]:
        print(-1)
        exit()
    print(k*l*gcd(n,m))
  else:
    for i in range(l):
      if s[i*k]!=t[i*l]:
        print(-1)
        exit()
    print(k*l*gcd(n,m))

### FIXED CODE ###

from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
if gcd(n,m)==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  k=n//gcd(n,m)
  l=m//gcd(n,m)
  for i in range(gcd(n,m)):
    if s[i*k]!=t[i*l]:
      print(-1)
      exit()
  print(k*l*gcd(n,m))
from collections import defaultdict
readline = sys.stdin.buffer.readline
N = int(readline())

NUMBERS = defaultdict(bool)

for _ in range(N):
  n = int(readline())
  NUMBERS[n] = not NUMBERS[n]

ans = 0
for k,v in NUMBERS.items():
  if v:
    ans += 1

print(ans)

### FIXED CODE ###

import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
N = int(readline())

NUMBERS = defaultdict(bool)

for _ in range(N):
  n = int(readline())
  NUMBERS[n] = not NUMBERS[n]

ans = 0
for k,v in NUMBERS.items():
  if v:
    ans += 1

print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

if N - A.count(0) < K:
    print(0)
    exit(0)

plus = []
minus = []
for a in A:
    if a >= 0:
        plus.append(a)
    else:
        minus.append(a)


ans = 1
if K % 2 == 1 and len(plus) == 0:
    minus.sort(reverse=True)
    for i in range(K):
        ans *= minus[i]
        ans %= MOD
    print(ans)
    exit(0)

plus.sort(reverse=True)
minus.sort()

i = 0
j = 0

if K % 2 == 1 and len(plus) > 0:
    ans = plus[0]
    K -= 1
    plus = plus[1:]

for _ in range(K//2):
    if i+1 >= len(plus):
        ans *= (minus[j] * minus[j+1])
        ans %= MOD
        j += 2
        continue
    elif j+1 >= len(minus):
        ans *= (plus[i] * plus[i+1])
        ans %= MOD
        i += 2
        continue

    a = plus[i] * plus[i+1]
    b = minus[j] * minus[j+1]
    if a > b:
        ans *= a
        i += 2
    else:
        ans *= b
        j += 2
    ans %= MOD

print(ans)


### FIXED CODE ###

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 1
if N == K:
    for a in A:
        ans *= a
        ans %= MOD
    print(ans)
    exit(0)

if N - A.count(0) < K:
    print(0)
    exit(0)

plus = []
minus = []
for a in A:
    if a > 0:
        plus.append(a)
    else:
        minus.append(a)

if K % 2 == 1 and len(plus) == 0:
    minus.sort(reverse=True)
    for i in range(K):
        ans *= minus[i]
        ans %= MOD
    print(ans)
    exit(0)

plus.sort(reverse=True)
minus.sort()

if len(minus) == 0:
    for k in range(K):
        ans *= plus[k]
        ans %= MOD
    print(ans)
    exit(0)

i = 0
j = 0

if K % 2 == 1:
    ans = plus[0]
    K -= 1
    plus = plus[1:]

for _ in range(K//2):
    if i+1 >= len(plus):
        ans *= (minus[j] * minus[j+1])
        ans %= MOD
        j += 2
        continue
    elif j+1 >= len(minus):
        ans *= (plus[i] * plus[i+1])
        ans %= MOD
        i += 2
        continue

    a = plus[i] * plus[i+1]
    b = minus[j] * minus[j+1]
    if a > b:
        ans *= a
        i += 2
    else:
        ans *= b
        j += 2
    ans %= MOD

print(ans)
import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(n):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()

### FIXED CODE ###

import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(N):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()
import numpy as np 

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

ans = np.zeros(n)

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans[i] = min_cost

print(int(ans[-1]))

### FIXED CODE ###


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

ans = [0]

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans.append(min_cost)

print(int(ans[-1]))
a,b,c = map(int,input().split())
count = 0
for i in range(a,b+1) :
    d = c % i
        if d == 0 :
            count = count +1
print (count)

### FIXED CODE ###

a,b,c = map(int,input().split())
count = 0
for i in range(a,b+1):
    d = c % i
    if d == 0:
        count += 1
print (count)
import numpy as np

MOD = 1000000007
S = input()[::-1]

a = 10 ** np.arange(6) % 13
b = np.tile(np.arange(10),(6, 1))
c = a * b.T % 13
c = c.T
f = np.zeros((6, 13, 13), dtype=np.int64)
for i in range(6):
    f[i, 0, c[i]] = 1
    for j in range(12):
        f[i, j + 1] = np.roll(f[i, j], 1)

prev = np.zeros(13, dtype=np.int64)
prev[0] = 1
digit = 0

for i, c in enumerate(S):
    k = i % 6
    if c == '?':
        cur = prev @ f[k] % MOD
        prev, cur = cur, prev
    else:
        digit += a[k] * (ord(c) - ord('0'))

m = (5 - digit) % 13
print(prev[m])

### FIXED CODE ###

import numpy as np

MOD = 1000000007
S = input()[::-1]

a = 10 ** np.arange(6) % 13
b = np.tile(np.arange(10),(6, 1))
c = a * b.T % 13
c = c.T
f = np.zeros((6, 13, 13), dtype=np.int64)
for i in range(6):
    f[i, 0, c[i]] = 1
    for j in range(12):
        f[i, j + 1] = np.roll(f[i, j], 1)

prev = np.zeros(13, dtype=np.int64)
prev[0] = 1
digit = 0

for i, c in enumerate(S):
    k = i % 6
    if c == '?':
        cur = np.dot(prev, f[k]) % MOD
        prev, cur = cur, prev
    else:
        digit += a[k] * (ord(c) - ord('0'))

m = (5 - digit) % 13
print(prev[m])
import numpy as np

n, k = map(int, input())
ans = 0

for i in range(1, n):
  if i >= k:
    ans += 1.0 / n
    
  ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / n
  
print(ans)

### FIXED CODE ###

import numpy as np
 
n, k = map(int, input().split())
ans = 0
 
for i in range(1, n + 1):
  if i>= k:
    ans += 1 / n
  else:
    ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / n
    
print(ans)
choice = [1,2,3]
internal = list(map(int,input().split()))
choice.remove(internal[0])
choice.remove(internal[1])
print(choice[0])




### FIXED CODE ###

internal = [int(input()) for i in range(2)]

a = internal[0] + internal[1]
b = 6
c = b - a
print(c)
A,B,C,K=map(int, input().split())
num_list=[]

list1=[1]*A
list2=[0]*B
list3=[-1]*C

num_list.extend(list1)
num_list.extend(list2)
num_list.extend(list3)

print(sum(num_list[0:K]))


### FIXED CODE ###

S=input()
T=input()

if S==T[0:-1] and len(S)<=10:
    print('Yes') 
else:
    print('No')
s = [int(i) for i in input().split()]
print(s.swapcase)

### FIXED CODE ###

s = input()
print(s.swapcase())
s = list(map(int, list(input())))
k = int(input())

for i in range(len(s)):
    if s[i] == 1:
        continue
    else:
        print(s[i])
        f = False
        break
if f:
    print(1)

### FIXED CODE ###

s = list(map(int, list(input())))
k = int(input())

f = True
for i in range(k):
    if s[i] == 1:
        continue
    else:
        print(s[i])
        f = False
        break
if f:
    print(1)
import math

x1,y1,x2,y2 = tuple(int(n) for n in input().split())
D = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print("{:.8f}".format(D))


### FIXED CODE ###

import math

x1,y1,x2,y2 = tuple(float(n) for n in input().split())
D = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print("{:.8f}".format(D))
colors = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }

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

for a in A:
    colors[a // 400] += 1

min_clr = 0
for i in range(0, 8):
    if colors[i] > 0:
        min_clr += 1

print("{} {}".format(min_clr, min_clr + colors[8]))

### FIXED CODE ###

colors = [0 for i in range(9)]

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

for a in A:
    color = a // 400 if a < 3600 else 8
    colors[color] += 1

min_color = 0
for i in range(8):
    if colors[i] > 0:
        min_color += 1

if min_color > 0:
    print("{} {}".format(min_color, min_color + colors[8]))
else:
    print("{} {}".format(1, colors[8]))
K, N = int(input().split())
A = list(map(int, input().split()))
max = A[1] - A[0]
for i in range(1, N-1):
    if max < A[i+1] - A[i]:
        max = A[i+1] - A[i]
if max < K - A[N-1]:
    max = K - A[N+1]
print(K - max)

### FIXED CODE ###

K,N = map(int,input().split())
A = list(map(int, input().split()))
max = K + A[0] - A[N-1]
for i in range(N-1):
    if max < A[i+1] - A[i]:
        max = A[i+1] - A[i]
print(K - max)
from collections import defaultdict
from numba import jit


class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


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


@jit('void(i8, i8, i8)')
def solve(n, m, k):
    uf = UnionFind(n)

    friends = defaultdict(int)
    chain = defaultdict(int)

    for _ in range(m):
        a, b = map(int, input().split())
        friends[a] += 1
        friends[b] += 1
        uf.union(a, b)

    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if uf.find(i) == uf.find(j):
                chain[i] += 1

    for _ in range(k):
        c, d = map(int, input().split())
        if uf.find(c) == uf.find(d):
            friends[c] += 1
            friends[d] += 1

    ans = []
    for i in range(1, n + 1):
        ans.append(chain[i] - friends[i] - 1)

    print(*ans)


solve(n, m, k)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.ps = [-1] * (n + 1)

    def find(self, x):
        if self.ps[x] < 0:
            return x
        else:
            self.ps[x] = self.find(self.ps[x])
            return self.ps[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.ps[x] > self.ps[y]:
            x, y = y, x
        self.ps[x] += self.ps[y]
        self.ps[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        x = self.find(x)
        return -self.ps[x]


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


uf = UnionFind(n)

friends = [0] * (n + 1)
chain = [0] * (n + 1)

for _ in range(m):
    a, b = map(int, input().split())
    friends[a] += 1
    friends[b] += 1
    uf.union(a, b)

for _ in range(k):
    c, d = map(int, input().split())
    if uf.same(c, d):
        friends[c] += 1
        friends[d] += 1

ans = []
for i in range(1, n + 1):
    ans.append(uf.size(i) - friends[i] - 1)

print(*ans)
# coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
    order,data =input().split() 
    if order == "insert":
        output.append(int(data))
    elif order == "deleteFirst":
        output.pop()
    elif order == "deleteLast":
#        output.popleft()
        output.pop()
    elif order == "delete":
        try:
            output.remove(int(data))
        except:
            pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output)))

### FIXED CODE ###

import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
 
Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))
inf = float('inf')

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

# 累積min/max
cmin = [0] * (N+1)
cmax = [0] * (N+1)
resmin = inf
resmax = -inf
for i, a in enumerate(A):
    resmin = min(resmin, a)
    resmax = max(resmax, a)
    cmin[i+1] = resmin
    cmax[i+1] = resmax

# 正負の境界を全探索 -[0,k) +[k, N)
for k in range(N):
    ans = []
    cnt = 0
    m = cmin[k]
    M = cmax[N] - cmax[k]
    flag = True

    if m > 0:
        for i, a in enumerate(A):
            res = max(-(a // m), 0)
            cnt += res
            if cnt > 2*N:
                flag = False
                break
            for _ in range(res):
                x = A.index(m)
                y = i
                ans.append((x, y))

    if not flag:
        continue

    if M > 0:
        for i, a in enumerate(A):
            res = max(-(a // M), 0)
            cnt += res
            if cnt > 2*N:
                flag = False
                break
            for _ in range(res):
                x = A.index(M)
                y = i
                ans.append((x, y))
    
    if not flag:
        continue

    for i in range(k-1, 0, -1):
        ans.append((i, i-1))
        cnt += 1
    
    for i in range(k, N-1):
        ans.append((i, i+1))
        cnt += 1
    
    if cnt < 2*N:
        print(cnt)
        print(*ans, sep="\n")
        exit()

### FIXED CODE ###

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

M = max(A)
Mi = A.index(M)
m = min(A)
mi = A.index(m)

cnt = 0
ans = []

if M > 0 and m < 0:
    if abs(m) <= abs(M):
        for i in range(N):
            if Mi == i:
                continue
            x = Mi
            y = i
            A[y] += A[x]
            ans.append((x, y))
            cnt += 1
    else:
        for i in range(N):
            if mi == i:
                continue
            x = mi
            y = i
            A[y] += A[x]
            ans.append((x, y))
            cnt += 1

M = max(A)
m = min(A)

if m >= 0:
    for i in range(N-1):
        x = i
        y = i+1
        A[y] += A[x]
        ans.append((x, y))
        cnt += 1
else:
    for i in range(N-1, 0, -1):
        x = i
        y = i-1
        A[y] += A[x]
        ans.append((x, y))
        cnt += 1

print(cnt)
for x, y in ans:
    print(x+1, y+1)
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    L = 5000
    base = [[None]*W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            base[h][w] = abs(A[h][w]-B[h][w])

    table = [[[False]*L for _ in range(W)] for _ in range(H)]
    table[0][0][base[0][0]] = True
    for h in range(H):
        for w in range(W):
            if h > 0:
                for i in range(L):
                    if table[h-1][w][i] == True:
                        table[h][w][abs(i-base[h][w])] = True
                        table[h][w][abs(i+base[h][w])] = True
            if w > 0:
                for i in range(L):
                    if table[h][w-1][i] == True:
                        table[h][w][abs(i-base[h][w])] = True
                        table[h][w][abs(i+base[h][w])] = True
    for i in range(L):
        if table[H-1][W-1][i] == True:
            print(i)
            return

    return


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
    A = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    base = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
    mx = (1 << 12800) - 1
    table = [[0]*W for _ in range(H)]
    table[0][0] = (1 << (6400 + base[0][0])) | (1 << (6400-base[0][0]))
    for h in range(H):
        for w in range(W):
            if h > 0:
                table[h][w] |= (table[h-1][w] << base[h][w])
                table[h][w] |= (table[h-1][w] >> base[h][w])
            if w > 0:
                table[h][w] |= (table[h][w-1] << base[h][w])
                table[h][w] |= (table[h][w-1] >> base[h][w])
            table[h][w] &= mx

    m = INF
    for j in range(12800):
        i = (table[H-1][W-1] >> j) & 1
        if i == 1:
            m = min(m, abs(j-6400))
    print(m)
    # print(table[H-1])

    return


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
    A = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)


if __name__ == '__main__':
    main()
N,M=map(int,input().split())
S=input()
T=input()
from math import gcd
g=gcd(N,M)
L=N*M//g
for i in range(g):
    if S[i*N//g]!=T[i*M//g]:
        print(-1)
        break
else:
    print(L)

### FIXED CODE ###

N,M=map(int,input().split())
S=input()
T=input()
from fractions import gcd
g=gcd(N,M)
L=N*M//g
for i in range(g):
    if S[i*N//g]!=T[i*M//g]:
        print(-1)
        break
else:
    print(L)
x,*y=map(int,open(0).read().split())
print(sum(y[0::2]-y[1::2])+x)

### FIXED CODE ###

x,*y=map(int,open(0).read().split())
print(sum(y[1::2])-sum(y[0::2])+x)
anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = 0;bsum = 0
ans = 0;a = 0;b = 0
while asum + alist[a] <= acc:
    asum += alist[a];a+=1
    if a == anum:
        break

while asum + blist[b] <= acc:
    bsum += blist[b];b += 1
    if b == bnum:
        break

if a == 0 and b == 0:
    pass
elif (a == anum and b == bnum) or a == 0:
    ans = a + b
else:
    ans = a+b
    for i in range(1,a):
        while asum - alist[a-i] + bsum + blist[b] <= acc:
            if b == bnum:
                break
            bsum += blist[b];b += 1
            if a + b > ans:
                ans = a + b

print(ans)


### FIXED CODE ###

anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = [0]
bsum = [0]
ans = 0
for i in range(anum):
    asum.append(asum[i]+alist[i])
for i in range(bnum):
    bsum.append(bsum[i]+blist[i])

b = bnum
for a in range(anum+1):
    if asum[a] > acc:
        break
    while asum[a] + bsum[b] > acc:
        b -=1
    ans = max(ans,a+b)

print(ans)
a,w=map(int,input().split())
b,y=map(int,input().split())
n=int(input())
print("YES") if abs(a-b)/(w-y)<=n else print("NO")

### FIXED CODE ###

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

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

n=int(input())

if w<=y:

  print("NO")

else:

  print("YES") if abs(a-b)/(w-y)<=n else print("NO")
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = input()
res = alphabet[alphabet.index(_) + n] for _ in s
print(res)

### FIXED CODE ###

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = list(input())
res = "".join([alphabet[alphabet.index(_) + n] for _ in s])
print(res)