Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e13
for i in range(n-k+1):
    l = x[i]
    r = x[i+k]
    ans = min(ans, abs(l)+abs(r-l))
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e13
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    ans = min(ans, abs(r)+abs(l-r))
    ans = min(ans, abs(l)+abs(r-l))
print(ans)
import numpy as np

a, b, x = map(float, input().split(" "))
print(np.arctan(2 / a * (b - x / (a ** 2)) / np.pi * 180)

### FIXED CODE ###

import math

def check(a, b, x, deg):
    theta = math.radians(deg)
    if b * math.cos(theta) >= a * math.sin(theta):
        return (a * a) * (b - a * math.tan(theta) / 2.0) >= x
    else:
        return (b * b * a) / (2.0 * math.tan(theta)) >= x


a, b, x = map(float, input().split(" "))
high, low = 90, 0   # [low, high)
while (high - low) > 1e-10:
    mid = (high + low) / 2
    if check(a, b, x, mid):
        low = mid
    else:
        high = mid
print(low)
class UnionFind:
    def __init__(self, NUM):
        self.p = [x for x in range(NUM)]
    def root(self, x):
        if self.p[x] == x:
            return x
        self.p[x] = self.root(self.p[x])
        return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx is ry:
            return
        self.p[rx] = ry
    def same(self, x, y):
        return self.root(x) == self.root(y)

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set([])
    for i in range(N):
        parent = u.root(i)
        rlist.add(parent)

    print(len(rlist))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.p[ry] = rx

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set()
    for i in range(N):
        rlist.add(u.root(i))

    print(len(rlist))

if __name__ == '__main__':
    main()
N=input()
if N%9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N=int(input())
if N%9 == 0:
    print("Yes")
else:
    print("No")
from math import gcd, gcd
n = int(input())
print(2*n // gcd(2,n))

### FIXED CODE ###

n = int(input())
print(n if n%2 == 0 else n*2)
n,m,l = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(i) for i in input().split()] for j in range(m)]
c = [[0 for i in range(n)] for j in range(l)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(l):
    print(' '.join(map(str,c[i])))

### FIXED CODE ###

n,m,l = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(i) for i in input().split()] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    print(' '.join(map(str,c[i])))
a,b = map(int(input().split()))
if b%a==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)
import itertools
S = input()
S = list(S)
l = max(list(sum(c) for c  in itertools.combinations(l, 3)))
print(adb(753-l))

### FIXED CODE ###

s = input()
t = 100000000000
for i in range(len(s)-2):
    t = min(abs(753 - int(s[i]+s[i+1]+s[i+2])), t)
print(t)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)a
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        data[C[i]] += data[B[i]]
        data[B[i]] = 0
    print(SUM)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        if C[i] in data:
            data[C[i]] += data[B[i]]
        else:
            data[C[i]] = data[B[i]]
        data[B[i]] = 0
    print(SUM)
n, t = map(int,input().split())
ans = []

for i in range(n):
  c, x = map(int,input().split())
  if x <= t:
    ans.append(c)
    
ans.sort()
print(ans[0])

### FIXED CODE ###

n, t = map(int,input().split())
ans = []

for i in range(n):
  c, x = map(int,input().split())
  if x <= t:
    ans.append(c)

if len(ans) == 0:
    print("TLE")
else:
    ans.sort()
    print(ans[0])
N = int(input())
s, t = input().split()

ans = ''
i = j = 0
flag = True
while j < N:
  if flag:
	  ans += s[i]
      i += 1
  else:
      ans += t[j]
      j += 1
  
  flag = not flag


### FIXED CODE ###

n = int(input())
s, t = input().split()

ans = ''
i = 0
flag = True

while i < n:
  if flag:
    ans += s[i]
  else:
    ans += t[i]
    i += 1
  flag = not flag
else:
  print(ans)
alph=input()
if(alpha.isupper()):
  print("A")
else:
  print("a")

### FIXED CODE ###

alpha=input()
if(alpha.isupper()):
  print("A")
else:
  print("a")
N = int(input())
    A = list(map(int, input().split(' ')))
     
    B = []
    C = []
    D = []
     
    for a in A:
        if a in B:
            C[B.index(a)] += 1
        else:
            B.append(a)
            C.append(1)
     
    I = len(B)
     
    for i in range(I):
        D.append([B[i], C[i]])
     
    D = sorted(D, reverse=True)
     
    i = 0
    while i < I:
        x = D[i][0]
        d = D[i][1]
        if d > 1:
            if d > 3:
                print(x**2)
                exit()
            else:
                while i < I:
                    i += 1
                    y = D[i][0]
                    d = D[i][1]
                    if d > 1:
                        print(x*y)
                        exit()
        else:
            i += 1
     
    print(0)

### FIXED CODE ###

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

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)
n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]

es = [[] for i in range(n)]
for a,b in ab:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

#BFS
colors = {}
colors[(0,1)] = 0
color_parent = 0
k = 0
i = 0
queue = [0]
visited = [0]*n
while queue:
    v = queue.pop(0)
    visited[v] = 1
    color = 0

    color_parent = colors[(v, es[v][0])]

    for to in es[v]:
        if visited[to]: continue
        queue.append(to)

        if color == color_parent and v != 0:
            color += 1

        colors[(v,to)] = color
        colors[(to,v)] = color


        k = max(k, color)
        color += 1

print(k+1)

for a,b in ab:
    print(colors[(a-1, b-1)] + 1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]

es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append((b, i))
    es[b].append((a, i))

visited = [0]*n
ans_color = [0]*(n-1)

# DFS
def dfs(v, fromColor):
    color = 1
    visited[v] = 1
    for to, i in es[v]:
        if visited[to]: continue

        if color == fromColor:
            color += 1
        ans_color[i] = color
        dfs(to, color)
        color += 1

root = 0 # 頂点1が存在することが問題文中で保証されてるからここを根ノードとしよう
dfs(root, 0)

print(max(ans_color))
print(*ans_color, sep='\n')
A,B=map(int,input().split())
if 'A<9) and (B<9):
    print('Yay!')
else:
    print(':)')

### FIXED CODE ###

A,B=map(int,input().split())
if (A<9) and (B<9):
    print('Yay!')
else:
    print(':(')
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]


temp=0
z=0
for i in range(int((n+1)/2)):
    for j in range(i+1,n):
        temp=comb(a[i],a[j])
        if z<temp:
            z=temp
            x,y=a[i],a[j]

def comb(m, r):
    if m-r<r:
        k=m-r
    else:
        k=r
    x=1
    for i in range(m,m-k,-1):
        x*=i
    for j in range(1,k+1):
        x/=j
    return int(x)
print(x, y)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
x,a = a[-1],a[:-1]
temp = []
for i in a:
    temp.append(abs(x/2-i))
y=a[temp.index(min(temp))]
print(x,y)
N, K = map(int,input().split())

l = []

for i in range(N):
    a, b = map(int, input().split())
    l += [a] * b

print(sorted(l)[K-1])

### FIXED CODE ###

A,B,C = map(int,input().split())
if A <= C and C <= B:
  print('Yes')
else:
  print('No')
n = int(input())
h = [int(x) for x in input().split()]

dp_list = [-1]*(n)

def dp(n):
  if n == 0:
    dp_list[0] = 0
    return 0
  if n == 1:
    dp_list[1] = abs(h[1]-h[0])
    return dp_list[1]
  if dp_list[n] == -1:
    dp_list[n] = min([dp(n-1)+abs(h[n]-h[n-1]), dp(n-2)+abs(h[n]-h[n-2])])
  return dp_list[n]

ans = dp(n-1)
print(ans)

### FIXED CODE ###

n = int(input())
h = [int(x) for x in input().split()]
inf = 10**9+7

dp_list = [inf]*(n)

for i in range(n):
  if i == 0:
    dp_list[i] = 0
  elif i == 1:
    dp_list[i] = abs(h[1]-h[0])
  else:
    dp_list[i] = min([dp_list[i-1]+abs(h[i]-h[i-1]), dp_list[i-2]+abs(h[i]-h[i-2])])


print(dp_list[n-1])
import math
x,a,b=[int(input()) for i int range(3)]
print((x-a)%b)


### FIXED CODE ###

import math
x,a,b=[int(input()) for i in range(3)]
print((x-a)%b)
from demical import Demical
a,b,c=input().split()
a=Demical(a)
b=Demical(b)
c=Demical(c)
if a**0.5+b**0.5<c**0.5:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b, c=map(int,input().split())


if c>a+b and int(4*a*b)<int((c-a-b)**2):
    print('Yes')
else:
    print('No')
import collections

N = int(input())
li = list(map(int,input().split()))
even = [li[i] for i in range(N) if i%2==0]
odd =[ li[i] for i in range(N) if i%2!=0]

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

ec=e[0][1]
oc=o[0][1]

if e[0][0]==o[0][0]:
  if e[0][1] > o[0][1]:
    oc=o[1][1]
  else:
    ec=e[1][1]
    
ans = N-(ec+oc)
print(ans)


### FIXED CODE ###

from collections import Counter

ans = int(input())
V = [int(i) for i in input().split()]

v1 = []
v2 = []

for i, v in enumerate(V):
    if i % 2 == 0:
       v1.append(v)
    else:
        v2.append(v)

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

if k1 == k2:
    ans -= v2
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2

print(ans)
#D - Friends
N,M = map(int,input().split())
par = [i for i in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def size(x):
    return par.count(find(x))

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if par[x] > par[y]:
        x,y = y,x
    #par[x] += par[y]
    par[y] = x
#    par[x] = y

print(par)
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
    print(par)

group_count = 0

for i in range(N):
    group_count = max(group_count,size(i))

# 出力
print(group_count)


### FIXED CODE ###

#D - Friends
N,M = map(int,input().split())
par = [i for i in range(N)]
rank = [1] * (N)

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def size(x):
    return par.count(find(x))

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y : return 0
    if par[x] > par[y]:
        x,y = y,x
    par[y] = x
#    par[x] = x
    if par[x] == par[y]:
        rank[x] += rank[y]
#        rank[y] += rank[x]
#print(par)
#print(rank)
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
#    print(par)
#    print(rank)
group_count = 0

group_count = max(rank)

# 出力
print(group_count)
N = int(input())
headB=0
tailA=0 
both = 0
ans = 0
for j in range(N):
    t = input()
    if t[0] == "B":
        if t[-1] == "A":
            both += 1
        else:
            headB += 1
    elif t[-1] == "A":
        tailA += 1
    ans += t.count("AB")
if tailA > 0 or headB > 0:
    while both > 0:
        tmp = min(tailA+headB,both)
        ans += tmp
        both -= tmp
else:
    ans += both-1
ans += min(headB,tailA)
print(ans)

### FIXED CODE ###

print((lambda x,y:x-y+1)(*map(int,input().split())))
l = raw_input().split()
    f = int(l[0])
    r = int(l[1])

    a = f-r+1

    print(a)

### FIXED CODE ###

# -*- coding: utf-8 -*-
f, r = map(int, raw_input().split())
print(f - r + 1)
from sympy import sieve

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

ans = 0

if len(A) > 2:
    for i in range(len(A)):
        if A[i] in sieve:
            ans += 1
            continue
        for j in range(i+1):
            if A[i] % A[j] == 0:
                if j != i:
                    break
        else:
            ans += 1

print(ans)

### FIXED CODE ###

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

dp = [True]*(A[-1]+1)

ans = 0

for i in range(len(A)):
    if dp[A[i]]:
        if (i == len(A)-1) or (A[i] != A[i+1]):
            ans += 1
    try:
        k = 1
        while(True):
            dp[k*A[i]] = False
            k += 1
    except:
        pass

print(ans)
N = input()
n = int(N)
s =0
while N:
  s+= N%10
  N=N//10
if n%2==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import sys
import math

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = input()
    n = int(N)
    s = 0

    while n:
        s += n % 10
        n = n // 10
    if int(N) % s == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
a =int(input())
b =int(input())
if a & 2 ==0 or a % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2 ==0 :
  print("Even")
else:
  print("Odd")
s=str(input())
flag=True
n=len(s)
if s!=s.reversed():
    flag=False
if s[:(n-1)/2]!=s[:(n-1)/2].reversed():
    flag=False
if s[(n+3)/2-1:]!=s[(n+3)/2-1:].reversed():
    flag=False
print("Yes" if flag else "No")



### FIXED CODE ###


s=input()
flag=True
n=len(s)
if s!=s[::-1]:
    flag=False
if s[:(n-1)//2]!="".join(list(reversed(s[:(n-1)//2]))):
    flag=False
if s[(n+3)//2-1:]!="".join(list(reversed(s[(n+3)//2-1:]))):
    flag=False
print("Yes" if flag else "No")
N = int(input())
S = input()
min_num = 10**6


for i in range(0, N):
    num = 0
    num = sum(x == 'W' for x in S[:i]) + sum(x == 'E' for x in S[i+1:])    
    if num < min_num:
        min_num = num
        
print(min_num)

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A+B, A-B, A*B))
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = il()
    for n in range(1, N):
        A[n] *= A[n - 1]
        if n == K:
            A[n] //= A[n - K]
        elif n > K:
            A[n] //= A[n - K] // A[n - K - 1]
    for k in range(K, N):
        if A[k - 1] < A[k]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = il()

    for k in range(K, N):
        if A[k - K] < A[k]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()
N = str(input())
A = 0
for i in N:
    A += int(i)
return "Yes" if N%A == 0 else "No"  

### FIXED CODE ###

N = str(input())
A = 0
for i in N:
    A += int(i)
print("Yes" if int(N)%A == 0 else "No")
N, X, M = map(int, input().split())
table = [0]*M

table[X] = 1
pre = X
seq = [X]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        fir = table[A]
        sec = cnt
        break
    
ans = 0
for i in range(fir + (N-fir)%(sec-fir)):
    ans += seq[i]
mul = (N-fir)//(sec-fir)
for i in range(fir, sec):
    ans += seq[i]*mul

print(ans)

### FIXED CODE ###

N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 0
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        f = table[A]
        s = cnt
        break
    
ans = 0
for i in range(f + (N-f)%(s-f)):
    ans += seq[i]
m = (N-f)//(s-f)
for i in range(f, s):
    ans += seq[i]*m

print(ans)
N, M = map(int, input().split())
s = [list(map(int, list(input().split()))) for i in range(M)]

ans = [-1] * M
for i in s:
    if ans[i[0] - 1] != -1 and ans[i[0] - 1] != i[1]:
        print(-1)
        exit()
    ans[i[0] - 1] = i[1]

ans = [int(str(a).replace('-1', '0')) for a in ans]
res = ''.join((map(str, ans)))
if int(res) != 0 and len(res) == N:
    print(int(res))
else:
    print(-1)

### FIXED CODE ###

N, M = map(int, input().split())
s = [list(map(int, list(input().split()))) for i in range(M)]

ans = [-1] * N

for i in s:
    if ans[i[0] - 1] != -1 and ans[i[0] - 1] != i[1]:
        print(-1)
        exit()
    ans[i[0] - 1] = i[1]

if M == 0 and N != 1:
    ans[0] = 1
tmp = int(''.join((map(str, [int(str(a).replace('-1', '0')) for a in ans]))))
if N >= 2 and ans[0] == -1:
    ans[0] = 1

ans = [int(str(a).replace('-1', '0')) for a in ans]

res = ''.join((map(str, ans)))
if int(res) >= 0 and len(str(int(res))) == N:
    print(int(res))
else:
    print(-1)
h, k = map(int, input().split())
a = []
b = []
for i in range(k):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
dp = [0 for _ in range(h+1)]

for i in range(1, h+1):
    m0 = dp[i-a[0]] + b[0]
    for j in range(1, len(a)):
        m = dp[i-a[j]] + b[j]
        m0 = min(m, m0)
    dp[i] = m0

print(dp[h])

### FIXED CODE ###

h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
maxa = max(a for a,b in ab)
dp = [0 for i in range(h+maxa)]
for i in range(1, h+maxa):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(min(dp[h:]))
import sys
sys.setrecursionlimit(10**5)

def my_factorial(n):
    if n == 0:
        return 1

    else:
        return n * my_factorial(n-1)

N,M = map(int,input().split())
if abs(N-M) >= 2:
    print(0)
elif abs(N-M) == 1:
    print(my_factorial(N) * my_factorial(M))
else:
    print(2*my_factorial(N)*my_factorial(M))

### FIXED CODE ###

import math
n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print(math.factorial(n)*math.factorial(m)%mod)
else:
    print(2*math.factorial(n)*math.factorial(m)%mod)
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

def mul(n):
  s=1
  for t in range(1,n+1):
    s=s*t
  return s

def f(x):
  result=0
  M=len(x)
  for i in range (x):
    k=0
    for j in range(i,M):
      if x[i]>x[j]:
        k=k+1
      result=result+k*mul(M-i-1)
  return result

print(f(P)-f(Q))


### FIXED CODE ###

K,X=map(int,input().split())
if K*500>=X:
  print("Yes")
else:
  print("No")
def main(a,op,b):
  if op=='+':
    return int(a)+int(b)
  elif op=='-':
    return int(a)-int(b)

  
if __init__=='__main__':
  a,op,b=input().split()
  print(main(a,op,b))

### FIXED CODE ###

def main(a,op,b):
  if op=='+':
    return int(a)+int(b)
  elif op=='-':
    return int(a)-int(b)
 
  
if __name__=='__main__':
  a,op,b=input().split()
  print(main(a,op,b))
a=input()
if a>=30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=input()
if int(a)>=30:
  print("Yes")
else:
  print("No")
a, b = map(int, imput().split())
if (a + b) % 2 == 0:
  print("Even")
else:
  print("Odd")
      

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2 == 0:
  print("Even")
else:
  print("Odd")
N, K = input().split()
d = []
A = []
for _ in K:
    d.append(int(input()))
    num = d[-1]
    for i in num:
        A.append(int(input()))

for j in max(d)+1:
    if j+1 in A:
        pass
    else:
        print(j+1)

### FIXED CODE ###

N, K = map(int, input().split())
uid_list = []
for _ in range(K):
   input()
   for uid in [int(i) for i in input().split()]:
       uid_list.append(uid)
print(N - len(set(uid_list)))
def min(a,i):
  for t in range(0, i):
    if a[0] > a[t]:
      a[0] = a[t]
  return a[0]

def max(a,i):
  for t in range(0, i):
    if a[0] < a[t]:
      a[0] = a[t]
  return a[0]

def sum(a,i):
  for t in range(1, i):
    a[0] += a[t]
  return a[0]

i = int(raw_input())
a = map(int, raw_input().split())
print min(a,i) max(a,i) sum(a,i)

### FIXED CODE ###

def min(a,i):
  x = a[0]
  for t in range(0, i):
    if x > a[t]:
      x = a[t]
  return x

def max(a,i):
  y = a[0]
  for t in range(0, i):
    if y < a[t]:
      y = a[t]
  return y

def sum(a,i):
  s = 0
  for t in range(0, i):
    s += a[t]
  return s

i = int(raw_input())
a = map(int, raw_input().split())
print "%d %d %d" % (min(a,i), max(a,i), sum(a,i))
n=str(N)
if n.find("7")!= -1:
   print("Yes")
else:
   print("No")


### FIXED CODE ###

n=str(input())
if n.find("7")!= -1:
   print("Yes")
else:
   print("No")
lang:reverse.py
result = 0
str = input()
--文字数
str_length = len(str)
rev_str = str[::-1]
count = 0

if str_length % 2 == 1:
    count = (str_length -1)/2
else:
    count = str_length / 2


for i in range(count):
    if str[i] != rev_str[i] :
        result = result + 1

print(result)


### FIXED CODE ###

#lang:reverse.py

result = 0
str = input()
#文字数
str_length = len(str)
rev_str = str[::-1]
count = 0

if str_length % 2 == 1:
    count = (str_length -1)/2
else:
    count = str_length / 2


for i in range(int(count)):
    if str[i] != rev_str[i] :
        result = result + 1

print(result)