Harryxun/stf_run huggingface dataset:
#######################################
prime = 10**9+7

def sowa(num):
  return int((1+num)*num/2)
#######################################
n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime)))


### FIXED CODE ###

#######################################
prime = 10**9+7

def sowa(num):
  return int((1+num)*num//2)
#######################################
n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))
a,b,k = map(int,input().split())

nums = list(range(a,b+1))
n = len(nums)


if (k-1>=n-k):
    for ele in nums: print(ele)

else:
    for i in range(0,k): print(nums[i])
    for i in range(n-k,n): print(nums[i])


### FIXED CODE ###

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

n=b-a+1

if (k-1>=n-k):
    for i in range(a,b+1): print(i)

else:
    for i in range(a,a+k): print(i)
    for i in range(b-k+1,b+1): print(i)
s=input()
n=len(s)
ans=[0]*(n+1)
m=0
for i in range(1,n+1):
	if s[i]=='<':
		ans[i]=ans[i-1]+1
	else:
		ans[i]=ans[i-1]-1
	m=min(m,ans[i])
print(sum(ans)-m*n)
		


### FIXED CODE ###

s=str(input())
sl=len(s)+1
l,r=[0]*sl,[0]*sl
ss=[0]*sl
lcnt,rcnt=0,0
for i in range(sl):
  if i==0:
    l[0]=0
    r[sl-1]=0
  else:
    if s[i-1]=="<":
      lcnt+=1
    else:
      lcnt=0
    if s[sl-i-1]==">":
      rcnt+=1
    else:
      rcnt=0
    l[i]=lcnt
    r[sl-i-1]=rcnt
for i in range(sl):
  ss[i]=max(l[i],r[i])
print(sum(ss))
N=input()
a=0
for i in range(0,int(N),2):
    s=input()
    if s%2!=0:
        a=a+1
print(a)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
s=0
for i in range(0,N,2):
    if A[i]%2 !=0:
        s=s+1
print(s)
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

li = list(itertools.permutations(P,N))
li.sort()

a = 0
b = 0

for i in range(math.factorial(N)):
    if li[i] == P:
        a = i
    elif li[i] == Q:
        b = i
    else:
        a = a
        b = b
        
print(abs(a-b))


### FIXED CODE ###

import math
import itertools

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

li = list(itertools.permutations(P,N))
li.sort()

a = 0
b = 0

for i in range(math.factorial(N)):
    if li[i] == P:
        a = i
    else:
        a = a

for i in range(math.factorial(N)):
    if li[i] == Q:
        b = i
    else:
        b = b
        
print(abs(a-b))
import numpy as np
import math
A, B = map(int, input().split())

x_a = np.arange(math.ceil(12.5 * A), math.ceil(12.5 * (A + 1)))
x_b = np.arange(10 * B, 10 * (B + 1))

a_set = set(x_a)
b_set = set(x_b)
#aとbに共通するものを抽出
c_set = a_set & b_set
c = list(c_set)
x = min(c)
print(x)

if not c:
    print("-1")

else:
    continue

### FIXED CODE ###

import numpy as np
import math
A, B = map(int, input().split())

x_a = np.arange(math.ceil(12.5 * A), math.ceil(12.5 * (A + 1)))
x_b = np.arange(10 * B, 10 * (B + 1))

a_set = set(x_a)
b_set = set(x_b)
#aとbに共通するものを抽出
c_set = a_set & b_set
c = list(c_set)

if len(c) != 0:
    print(min(c))

else:
    print("-1")
# key not available ""
n = int(input())
matrix = []
for _ in range(n):
    matrix.append([int(i) for i in input().split()])
dp = [[0 for i in range(10)] for j in range(n+1)]


def go(i, j):
    if i < 0:
        return 0
    ans = 0
    if dp[i][j] > 0:
        return dp[i][j]
    dp[i][j] = max(ans, go(i-1, (j+1) % 3)+matrix[i][j], go(i-1, (j+2) % 3)+matrix[i][j])
    return dp[i][j]


print(max(go(n-1, 2),go(n-1,1),go(n-1,0)))



### FIXED CODE ###

# key not available ""
n = int(input())
matrix = []
for _ in range(n):
    matrix.append([int(i) for i in input().split()])
dp = [[0 for i in range(3)] for j in range(n)]
for i in range(3):
    dp[0][i] = matrix[0][i]
for i in range(1,n):
    for j in range(3):
        if j == 0:
            dp[i][j] = max(dp[i-1][j+1],dp[i-1][j+2])+matrix[i][j]
        elif j == 1:
            dp[i][j] = max(dp[i-1][j+1],dp[i-1][j-1])+matrix[i][j]
        else:
            dp[i][j] = max(dp[i-1][j-1], dp[i-1][j-2]) + matrix[i][j]
print(max(dp[-1]))
# d
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = np.array(list(input()))
point = 0
for i in range(k):
    if t[i] == 'r':
        point += p
    elif t[i] == 's':
        point += r
    else:
        point += s

for i in range(k, n):
    if t[i] != t[i-k]:
        if t[i] == 'r':
            point += p
        elif t[i] == 's':
            point += r
        else:
            point += s
    else:
        t[i] = ''

print(point)

### FIXED CODE ###

n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s
 
for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""
 
print(score)
# -*- 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
# 一方が他方の約数の時
if max(N, M) == lcm:
    for i in range(min(N, M)):
        if S[M_gap*i] != T[N_gap*i]:
            print(-1)
            exit()
# 互いに疎
elif N * M == lcm:
    # 先頭だけ気にすればいい
    if S[0] != T[0]:
        print(-1)
        exit()
else:
    for i in range(lcm//max(N, M)):
        if S[M_gap*i] != T[N_gap*i]:
            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)
n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    global memo
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

print(max([dp(n-1,a) for a in range(3)]))


### FIXED CODE ###

n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

import sys
sys.setrecursionlimit(1000000)
print(max([dp(n-1,a) for a in range(3)]))
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans*=[i]
ans.sort()
for i in ans:
  print(i)

### FIXED CODE ###

n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans+=[i]
ans.sort()
for i in ans:
  print(i)
H, W = map(str, input().split(' '))
h, w = map(str, input().split(' '))

print(H*W - (h*W + w*H - h*w))

### FIXED CODE ###

H, W = map(int, input().split(' '))
h, w = map(int, input().split(' '))

print(H*W - (h*W + w*H - h*w))
[a, b] = map(int, input().split())
if a*3==b:
    print(1)
elif b%3==0:
    print(b*3+1)
else:
    print(b*3)


### FIXED CODE ###

s = str(input())
s = s[:5] + " " + s[6:13] + " " + s[14:]
print(s)
import sys
sys.setrecursionlimit(12000)

depth = int(input()) 
leaves = list(map(int, input().split(" ")))
limited = []

def find( i, depth, cur) :
    if i == depth :
        limited.append(leaves[i])
        return ( leaves[i], (leaves[i]+1)//2 )
    _max, _min = find(i+1, depth, (cur-leaves[i])*2 )
    _max = min(cur, _max+leaves[i])
    _min += leaves[i]
    if _max < _min :
        return (-float('inf'), float('inf') )
    limited.append(_max)
    return ( _max, (_min+1)//2 )

find(0, depth, 1) 
if len(limited) != depth+1 :
    print(-1)
else :
    print(sum(limited))

### FIXED CODE ###

depth = int(input()) 
leaves = list(map(int, input().split(" ")))
limited = []
limited_a = []

def solve (depth) :
    cur = 1
    i = 0 
    while i <= depth :
        limited_a.append( cur )
        if cur <= 0 and leaves[i] != 0 :
            return False
        cur=(cur-leaves[i])*2
        i+=1 
    
    _min = _max = 0
    i = depth
    while i >= 0 :
        if i==depth: 
            if leaves[i] > limited_a[i] :
                return False
            limited.append(leaves[i])
            _max = leaves[i]
            _min = (leaves[i]+1)//2
        else :
            _max = min(limited_a[i], _max+leaves[i])
            _min = (_min+leaves[i]+1)//2
            if _max < _min :
                return False 
            limited.append(_max)
        i -= 1
    return True

if solve(depth) :
    print(sum(limited))
else :
    print (-1)
from fractions import gcd

n = int(input())
t = [int(input()) for _ in range(n)]
cm = []
t.sort()

def lcm(x, y):
    return (x * y) // gcd(x, y)

for i in range(n-1):
    cm.append(lcm(t[i], t[i+1]))

print(max(cm))

### FIXED CODE ###

from fractions import gcd

n = int(input())
t = [int(input()) for _ in range(n)]
result = 1


for i in range(n):
    num = t[i]
    result = result * num // gcd(result, num)

print(result)
Q = int(input())

import heapq
import sys
input = sys.stdin.readline

INF = 10**18
L = []
R = []
heapq.heappush(L,INF)
heapq.heappush(R,INF)
L_size = 0
R_size = 0
sum_b = 0
sum_L = 0
sum_R = 0

def f1(a,b):
  global sum_b,L_size,R_size,sum_L,sum_R
  sum_b += b
  L_max = -heapq.heappop(L)
  R_min = heapq.heappop(R)
  sum_L -= L_max
  sum_R -= R_min
  X = sorted([L_max,a,R_min])
  if L_size == R_size:
    heapq.heappush(L,-X[0])
    heapq.heappush(L,-X[1])
    heapq.heappush(R,X[2])
    L_size += 1
    sum_L += X[0] + X[1]
    sum_R += X[2]
  else:
    heapq.heappush(L,-X[0])
    heapq.heappush(R,X[1])
    heapq.heappush(R,X[2])
    R_size += 1
    sum_L += X[0]
    sum_R += X[1] + X[2]
  return

def f2():
  min_value = sum_b
  min_x = -heapq.nsmallest(L,1)[0]
  if L_size == R_size:
    min_value += sum_R - sum_L
  else:
    min_value += sum_R - sum_L + min_x
  print(min_x,min_value)

for _ in range(Q):
  q = [int(x) for x in input().split()]
  if q[0]&1:
    f1(q[1],q[2])
  else:
    f2()


### FIXED CODE ###

Q = int(input())

import heapq
import sys
input = sys.stdin.readline

INF = 10**18
L = []
R = []
heapq.heappush(L,INF)
heapq.heappush(R,INF)
L_size = 0
R_size = 0
sum_b = 0
sum_L = 0
sum_R = 0

def f1(a,b):
  global sum_b,L_size,R_size,sum_L,sum_R
  sum_b += b
  L_max = -heapq.heappop(L)
  R_min = heapq.heappop(R)
  sum_L -= L_max
  sum_R -= R_min
  X = sorted([L_max,a,R_min])
  if L_size == R_size:
    heapq.heappush(L,-X[0])
    heapq.heappush(L,-X[1])
    heapq.heappush(R,X[2])
    L_size += 1
    sum_L += X[0] + X[1]
    sum_R += X[2]
  else:
    heapq.heappush(L,-X[0])
    heapq.heappush(R,X[1])
    heapq.heappush(R,X[2])
    R_size += 1
    sum_L += X[0]
    sum_R += X[1] + X[2]
  return

def f2():
  min_value = sum_b
  min_x = -L[0]
  if L_size == R_size:
    min_value += sum_R - sum_L
  else:
    min_value += sum_R - sum_L + min_x
  print(min_x,min_value)

QUERY = [[int(x) for x in input().split()] for _ in range(Q)]
for q in QUERY:
  if q[0]&1:
    f1(q[1],q[2])
  else:
    f2()
a=input()
b=len(a)
i=0
j=0
while i <= b//2
	if a[i] != a[b-i]
	j +=1
else
	print(j)
    


### FIXED CODE ###

a=input()
b=len(a)
i=0
j=0
while i <= b//2-1 :
	if a[i] != a[b-i-1]: 
		j+=1
		i+=1
	else:
		i+=1
print(j)
s = list(input())
t = list(set(s))
if s.count(t[0]) == s.count(t[1]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = list(input())
t = list(set(s))
if len(t) == 2 and s.count(t[0]) == s.count(t[1]):
  print("Yes")
else:
  print("No")
import sys
sys.setrecursionlimit(10 ** 9)

class Union_Find:
    def __init__(self, n):
        self.root = [-1]*n
    
    def find(self, x):
        if self.root[x] < -1:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return root[x]

    def unite(self, x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return
        else:
            self.root[x] += self.root[y]
            self.root[y] = x

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


n, m = map(int, input().split())
uf = Union_Find(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

ans = 0
for i in range(n):
    size = uf.root[i]*(-1)
    ans = max(ans, size)

print(ans)

### FIXED CODE ###

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

root = [-1]*n
def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

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

ans = 0
for i in range(n):
    ans = max(ans, -root[i])

print(ans)
s = imput()
if s =="ABC":
    print("ARC")
else:
    print("ARC")

### FIXED CODE ###

s = input()
if s =="ABC":
    print("ARC")
else:
    print("ABC")
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print(ans%(10**9+7)
solve()

### FIXED CODE ###

def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print(ans%(10**9+7))
solve()
x = int(input())
count = 0

from math import sqrt

while count == 0:
	if x % 2 == 0:
      x += 1
	else:
      x += 2
    for i in range(1, round(sqrt(x)), 2):
      if x % i == 0:
        count = 1

### FIXED CODE ###

x = int(input())
count = 0

from math import sqrt

while count == 0:
  k = 0
  for i in range(1, x):
    if x % i == 0:
      k += 1
  if k == 1:
    print(x)
    count = 1
  else:
    if x % 2 == 0:
      x += 1
    else:
      x += 2
n, a = map(int,input().split())
x = list(map(int,input().split()))

dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)]
for i in range(n):
    for j in range(n * a + 1):
        for k in range(n):
            if i == 0:
                dp[0][x[0]][0] = 1
                break
            else:
                if j == 0:
                    if k == 0:
                        dp[i][x[i]][0] += 1
                    continue

                if dp[i - 1][j][k] == 0:continue
                dp[i][j][k] += dp[i - 1][j][k]
                if not(0 <= j + x[i] < n * a + 1):continue
                dp[i][j + x[i]][k + 1] += dp[i - 1][j][k]
cnt = 0
for i in range(n * a + 1):
    if i != 0 and i % a == 0:
        temp = i // a
        cnt += dp[-1][i][temp - 1]
print(cnt)


### FIXED CODE ###

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

dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)]
for i in range(n):
    for j in range(n * a + 1):
        for k in range(n):
            if i == 0 and x[0] < n * a + 1:
                dp[0][x[0]][0] = 1
                break
            else:
                if j == 0:
                    if k == 0 and x[i] < n * a + 1:
                        dp[i][x[i]][0] += 1
                    continue

                if dp[i - 1][j][k] == 0:continue
                dp[i][j][k] += dp[i - 1][j][k]
                if not(0 <= j + x[i] < n * a + 1):continue
                dp[i][j + x[i]][k + 1] += dp[i - 1][j][k]
cnt = 0
for i in range(n * a + 1):
    if i != 0 and i % a == 0:
        temp = i // a
        cnt += dp[-1][i][temp - 1]
print(cnt)
R = int(input())
G = int(input())

input(2G-R)




### FIXED CODE ###

R = int(input())
G = int(input())

print(2*G-R)
a = int(input())
s = int(input())

if a < 3200:
  print('red')
else:
  print(s)

### FIXED CODE ###

a = int(input())
s = input()

if a < 3200:
  print('red')
else:
  print(s)
N = int(input())
a = []
count = [1]
answer = 1
for _ in range(N):
    a.append(int(input()))

def search(A):
    answer += 1
    if A in count or answer > N:  # ループ処理
        print(-1)
        exit()
    count.append(A)
    print(count)
    if A == 2:
        print(len(count) - 1)
        exit()

    search(a[A-1])

search(a[0])

### FIXED CODE ###

N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
x = 1
visited = set([1])
answer = 0

while True:
    x = a[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)
N = int(input())
s = list(int(input().split())for i in range(N))
ans = sum(s)
if ans%10 == 0:
    for i in s:
        if i%10!=0:
            ans -= i
            break
print(ans)

### FIXED CODE ###

N = int(input())
s = list(int(input()) for i in range(N))
ans = 0
sum_s = sum(s)
if sum_s%10 != 0:
    ans = sum_s
for i in s:
    if (sum_s - i)%10 != 0:
        ans = max(ans,sum_s - i)
print(ans)
A,B,C = list(map(input()))
ans="NO"
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  ans = "YES"
print(ans)

### FIXED CODE ###

A,B,C = list(map(str,input().split()))
ans="NO"
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  ans = "YES"
print(ans)
import sys
sys.setrecursionlimit(10**7)
import copy

def main():
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)

    def lcm(a, b):
        return int(a / gcd(a, b)) * b
    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_ = A.pop()
    for a in A:
        a_lcm = lcm(a_, a)
        a_ = a_lcm
    for i in A_:
        if a_lcm / 2 % i == 0:
            print(0)
            exit()
    if a_lcm / 2 > m:
        print(0)     
    else:
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b-1) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)

### FIXED CODE ###

a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b-2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)
N = int(input())
A = [int(input()) for i in range(N)]
for i in A:
    #if A.count(i) >= 1:
        if A.count(i)%2 == 0: 
            A.remove(i)   
print(B)

### FIXED CODE ###

N = input()
print('Yes' if '9' in N else 'No')
#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

my_value = int(input())
my_value_list_str = input().split()

my_value_list = [int(i) for i in my_value_list_str]
my_value_list.sort()

print("{} {} {}".format(my_value_list[my_value], my_value_list[0], sum(my_value_list)))

### FIXED CODE ###

#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

my_value = int(input())
my_value_list_str = input().split()

my_value_list = [int(i) for i in my_value_list_str]
my_value_list.sort()

print("{} {} {}".format(my_value_list[0], my_value_list[my_value-1], sum(my_value_list)))
S = input()

count = 0

for i in range(len(S)):
    for j in range(i + 3,len(S)):
       
        x = int(S[i:j+1])
        

        if x % 2019 == 0:
            count += 1

print(count)

### FIXED CODE ###

S, W = map(int, input().split())

if S>W:
    print("safe")
else:
    print("unsafe")
A, B = map(int, input().split())
print("{}".format((3A+b)/2))

### FIXED CODE ###

a, p = map(int, input().split())
c = int((3*a+p) / 2)
print("{}".format(c))
n, k = map(int, input().split())
h = list(map(int, input().split()))

h_ = sorted(h)

for i in range(k):
  h_.pop()

print(sum(h_))


### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
 
h_ = sorted(h)
 
for i in range(k):
    if len(h_) > 0:
        h_.pop()
    
s = [0]*(len(h_)+1)
for j in range(len(h_)):
    s[j+1] = s[j] + h_[j]

print(s[-1])