Harryxun/stf_run huggingface dataset:
def calc(prepoint, nextpoint):
    return abs(nextpoint[0]-prepoint[0]) + abs(nextpoint[1]-prepoint[1])

def search(L,A,H):
    for h in range(H):
        if L in A[h]:
            return (h,A[h].index(L))
def main():
    H,W,D = map(int,input().split())
    A = [list(map(int, input().split())) for i in range(H)]
    Q = int(input())
    L_R_List = [list(map(int, input().split())) for i in range(Q)]

    temp = [(0,0) for i in range(H*W)]
    for L_R in L_R_List:
        L = L_R[0]
        R = L_R[1]
        ans = 0
        if temp[L] == (0,0):
            temp[L] = search(L,A,H)
            prepoint = temp[L]
        else:
            prepoint = temp[L]
        while(L != R):
            L += D
            if temp[L] == (0,0):
                temp[L] = search(L,A,H)
                nextpoint = temp[L]
            else:
                nextpoint = temp[L]
            ans += calc(prepoint, nextpoint)
            prepoint = nextpoint
        print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

def calc(prepoint, nextpoint):
    return abs(nextpoint[0]-prepoint[0]) + abs(nextpoint[1]-prepoint[1])

def main():
    H,W,D = map(int,input().split())
    index  = [(0,0) for i in range(H*W+1)]
    A = []
    for i in range(H):
        temp = list(map(int, input().split()))
        for t in temp:
            index[t] = (i,temp.index(t))
        A.append(temp)
    Q = int(input())
    L_R_List = [list(map(int, input().split())) for i in range(Q)]

    dp = [0 for i in range(H*W+1)]
    for i in range(D, H*W+1):
        dp[i] = dp[i-D] + calc(index[i], index[i-D])
    for L_R in L_R_List:
        L = L_R[0]
        R = L_R[1]
        print(dp[R]-dp[L])

if __name__ == '__main__':
    main()
a,b,c=map(int,input().split())
x=int(b/a)
if(x=<c):
  print(x)
else:
  print(c)


### FIXED CODE ###

a,b,c=map(int,input().split())
x=int(b/a)
if x<=c:
  print(x)
else:
  print(c)
#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    (n, w) = map(int, raw_input().split())
    if n == 0: break

    vcnt = [0]*10
    vr = 0
    for i in range(n):
        v = int(raw_input())
        if v/w > vr:
            vr = v/w
        vcnt[v/w] += 1
    
    vmax = max(vcnt)
    ans = 0
    for i in range(10):
        ans += ((vr-i)/float(vr))*(vcnt[i]/float(vmax))

    print ans+0.01

### FIXED CODE ###

#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    (n, w) = map(int, raw_input().split())
    if n == 0: break

    vcnt = [0]*11
    vr = 0
    for i in range(n):
        v = int(raw_input())
        if v/w > vr:
            vr = v/w
        vcnt[v/w] += 1
    
    vmax = max(vcnt)
    ans = 0
    for i in range(11):
        ans += ((vr-i)/float(vr))*(vcnt[i]/float(vmax))

    print ans+0.01
x,a,b=map(int,input().split())
if b<=a:
    print("delicious")
else:
    pass=b-a
    if pass<=x:
        print("safe")
    else:
        print("dangerous")


### FIXED CODE ###

x,a,b=map(int,input().split())
pass_day=b-a
if b<=a:
    print("delicious")
else:
    if pass_day<=x:
        print("safe")
    else:
        print("dangerous")
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

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

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s1] = s2
                self.table[s2] += self.table[s1]
            return True
        return False

N = ni()
a = []
b = []
for i in range(N):
    x, y = na()
    a.append((x, i))
    b.append((y, i))

a.sort()
b.sort()
t = []
for i in range(1, N):
    t.append((a[i][0]-a[i-1][0], a[i][1], a[i-1][1]))
    t.append((b[i][0]-b[i-1][0], b[i][1], b[i-1][1]))

t.sort()
ans = 0
uf = UnionFind(N)
for c, d, e in t:
    if uf.union(d,e):
        ans += c

print(ans)
    

### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
 
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]
 
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False
 
    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a
 
def main():
    N = I()
    a = []
    b = []
    for i in range(N):
        x,y = LI()
        a.append((x,i))
        b.append((y,i))
    a.sort()
    b.sort()
    t = []
    for i in range(1,N):
        t.append((a[i][0]-a[i-1][0], a[i][1], a[i-1][1]))
        t.append((b[i][0]-b[i-1][0], b[i][1], b[i-1][1]))
    t.sort()
    r = 0
    uf = UnionFind(N)
    for c,d,e in t:
        if uf.union(d,e):
            r += c
 
    return r
 
print(main())
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(1,N+1):
    if all([i in range(l[k][0],l[k][1]+1) for k in range(m)]):
        ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
a=0
z=10**5
for i in range(m):
    a=max(a,l[i][0])
    z=min(z,l[i][1])
if a<=z:
    print(z-a+1)
else:
    print(0)
n = int(input())a = list(map(int, input().split(" ")))i = 0list = []for a_s in a:list.insert(0, x = a.index(n - i) + 1)i += 1print(*list)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
dic = {}
i = 0
for a_s in a:
    dic.setdefault(i, a_s)
    i += 1
for k, v in sorted(dic.items(), key=lambda x: x[1]):
    print(k + 1)
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(N):
    for j in range(j,N):
        if j-i==A[i]+A[j]:
            ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
L = []
for i in range(N):
    L.append(i-A[i])
R = []
for j in range(N):
    R.append(j+A[j])
from collections import Counter
LL = Counter(L)
RR = Counter(R)
ans = 0
for k,v in RR.items():
    ans += v*LL[k]
print(ans)
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [0]*M
y = [0]*M
z = [0]*M
for i in range(M):
  x[i],y[i],z[i] = map(int,input().split())
zsort = sorted(z)
ma = max(zsort)
ind = z.index(ma)
am = min(a)
bm = min(b)
mae = am + bm
indxy = a[ind-1] + b[ind-1] - ma


if mae < indxy:
  print(mae)
else:
  print(indxy)


### FIXED CODE ###

A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [0]*M
y = [0]*M
c = [0]*M
for i in range(M):
  x[i],y[i],c[i] = map(int,input().split())
ans = 10**10
ma = max(c)
#ind = c.index(ma)
am = min(a)
bm = min(b)
mae = am + bm #ここまで
#indxy = a[x[ind]-1] + b[y[ind]-1] - ma

for i in range(M):
  mai = a[x[i]-1] + b[y[i] -1] - c[i]
  if mai < ans:
    ans = mai
if mae < ans:
  print(mae)
else:
  print(ans)
class BIT:
    def __init__(self, a, func=int.__add__, one=0):
        self.n = len(a)
        self.func = func
        self.one = one
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        if i <= 0:
            a = 1/0
        i += 1
        while i <= self.n:
            self.a[i] = self.func(self.a[i], x)
            i += i & (-i)

    def get(self, i):
        if i<=0:
            a =1/0
        s = self.one
        i += 1
        while i != 0:
            s = self.func(s, self.a[i])
            i -= i & (-i)
        return s


n, q = map(int, input().split())
c = [int(i)-1 for i in input().split()]
que = [[i, [int(i)-1 for i in input().split()], 0] for i in range(q)]
que.sort(key=lambda x: x[1][1])
last = [-1] * n
bit = BIT([0]*(n+10))
j = 0
for i in range(n):
    if last[c[i]] >= 0:
        bit.update(last[c[i]]+5, -1)
    bit.update(i+5, 1)
    last[c[i]] = i
    while j < q and que[j][1][1] == i:
        que[j][2] = bit.get(i+5) - bit.get(que[j][1][0]+4)
        j += 1
que.sort()
for i in que:
    print(i[-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, a):
        self.n = len(a)
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.a[i] = self.a[i] + x
            i += i & (-i)

    def get(self, i):
        s = 0
        i += 1
        while i != 0:
            s = s + self.a[i]
            i -= i & (-i)
        return s


def inmin(x):
    return int(x)-1


if __name__ == "__main__":
    n, q = map(int, input().split())
    c = list(map(inmin, input().split()))
    que = [[i, list(map(inmin, input().split()))] for i in range(q)]
    que.sort(key=lambda x: x[1][1])
    ans = [0] * q

    last = [-1] * n
    bit = BIT([0]*(n+10))
    j = 0
    for i in range(n):
        if last[c[i]] >= 0:
            bit.update(last[c[i]]+5, -1)
        bit.update(i+5, 1)
        last[c[i]] = i
        while j < q and que[j][1][1] == i:
            ans[que[j][0]] = bit.get(i+5) - bit.get(que[j][1][0]+4)
            j += 1
    print(*ans)
import sys, math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, K = MAP()
    NK = N - K + 1
    for i in range(K):
        print(combinations_count(NK, i + 1) * combinations_count(K - 1, i) % mod)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, K = MAP()
    NK = N - K + 1
    for i in range(K):
        if NK < i + 1:
            print(0)
        else:
            print(combinations_count(NK, i + 1) * combinations_count(K - 1, i) % mod)

if __name__ == '__main__':
    main()
a = [int(i) for i in input().split()] 
if a[4]-a[0]<=a[5]:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a, b, c, d, e, k = [int(input()) for i in range(6)]
if e-a<=k:
  print('Yay!')
else:
  print(':(')
contest_name = [word for word in input.split()]
 
print('A' + contest_name[1][0] + 'C')

### FIXED CODE ###

contest_name = [word for word in input().split()]
 
print('A' + contest_name[1][0] + 'C')
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

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

l = lcm(N, M)

ans = ['.']*(l+1)
flag = True

for i in range(N):
    now = (l // N) * i + 1
    if ans[now] == '.':
        ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if ans[now] == '.':
        ans[now] = T[i]
    else:
        if ans[now] != T[i]:
            flag = False
            break

for i in range(1, l+1):
    if ans[i] == '.':
        ans[i] = 'a'

if flag:
    print(len("".join(ans[1:])))
else:
    print(-1)


### FIXED CODE ###

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

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

l = lcm(N, M)

ans = {}
flag = True

for i in range(N):
    now = (l // N) * i + 1
    ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if now in ans:
        if ans[now] != T[i]:
            flag = False
            break

if flag:
    print(l)
else:
    print(-1)
n, k = map(int, input().split()) 
a_list = list(map(int, input().split())) 

rireki = [0] * (n+10)
curr_c = 1
rireki[1] = 0

no_loop_count = k
loop_cnt = 0

mugen = False
for i in range(n):
    next_c = a_list[curr_c-1]
    # print(i, curr_c, next_c)
    if next_c == curr_c:
        if k-1 >= i:
            mugen = True
            mugen_num = next_c
    if next_c == 1:
        no_loop_count = 0
        loop_cnt = i + 1
        break
    elif rireki[next_c] == 0:
        rireki[next_c] = i+1
    else:
        # print(next_c)
        no_loop_count = rireki[next_c] -1
        loop_cnt = i - no_loop_count
        break
    curr_c = next_c

if loop_cnt ==0:
    loop_cnt = 1


if mugen:
    print(mugen_num)


if not mugen:
    if k <= no_loop_count or loop_cnt == 0:
        ans = rireki.index(k)
    else:
        # print('k',k)
        # print('no', no_loop_count)
        # print('lo', loop_cnt)
        ind = (k-1-no_loop_count)%loop_cnt +1
        rireki_fix = [i-no_loop_count for i in rireki]
        # print(ind, 'ind')
        ans = rireki_fix.index(ind)
        # print(rireki_fix)
        print(ans)

### FIXED CODE ###

def main():
    n, k = map(int, input().split()) 
    al = list(map(int, input().split())) 
    city_l = [1]
    city_s = set([1])
    loop_city_l = []
    curr_city = 1
    cnt = 0
    for i in range(1,k+1):
        next_c = al[curr_city-1]
        if next_c in city_s:
            cnt = i
            first_city = city_l.index(next_c)
            loop_city_l = city_l[first_city:]
            break
        else:
            city_s.add(next_c)
            city_l.append(next_c)
        curr_city = next_c
    else:
        print(curr_city)
        return

    # print(loop_city_l)
    remained = k-cnt
    last_pos = remained%len(loop_city_l)
    print(loop_city_l[last_pos])

if __name__ == "__main__":
    main()
from collections import deque

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

def is2power(n):
    if n==1:
        return True 
    if n%1==1:
        return False
    else:
        is2power(n//2)

noz=[x-a for x in cards].count(0)
pl=[x-a for x in cards if x-a>0]
nl=[a-x for x in cards if x-a<0]
sl=[pl,nl][len(nl)<=len(pl)]
ll=[pl,nl][len(pl)<len(nl)]

sl.sort()
ll.sort()

nsl=len(sl)
nll=len(ll)

sumsl=[]
for i in range(1,2**nsl):
    sumsl.append(sum([sl[x]*((i>>x)&1) for x in range(nsl)]))

count=0
for i in range(1,2**nll):
    s=sum([ll[x]*((i>>x)&1) for x in range(nll)])
    if is2power(i) and s>sumsl[-1]:
        continue
    count+=(s in sumsl)

print((count+1)*(2**noz)-1)


### FIXED CODE ###

import sys

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

integers=[x-a for x in cards]
cards.append(a)
f=max(cards)*n


dp=[[0 for i in range(n+1)] for j in range(2*f+1) ]

for y in range(n+1):
    for x in range(2*f+1):
        if y==0 and x==f:
            dp[x][y]=1
        elif y>0 and (x-integers[y-1]<0 or x-integers[y-1]>2*f):
            dp[x][y]=dp[x][y-1]
        elif y>0 and x-integers[y-1]>=0 and x-integers[y-1]<=2*f:
            dp[x][y]=dp[x-integers[y-1]][y-1]+dp[x][y-1]
        else:
            dp[x][y]=0
print(dp[f][n]-1)
if __name__ == '__main__':
    n =int(input())
    a = int(math.sqrt(n))

    max=1
    for i in range(2,a+1):
        now = i*i
        while now <= n:
            if max < now:
                max =now
            now = now*i
    print(max)

### FIXED CODE ###

import math

if __name__ == '__main__':
    n =int(input())
    a = int(math.sqrt(n))

    max=1
    for i in range(2,a+1):
        now = i*i
        while now <= n:
            if max < now:
                max =now
            now = now*i
    print(max)
print("ABC" ++ input())

### FIXED CODE ###

print("ABC" + input())
import numba


@numba.jit
def main(n,k,h):
    dp = [float('inf')] * n
    dp[0] = 0
    for i in range(n):
        for j in range(1, min(k, n - i - 1) + 1):
            dp[i + j] = min(
                dp[i + j],
                dp[i] + abs(h[i] - h[i + j]) )
    print(dp[-1])


if __name__ == "__main__":
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    main(n,k,h)


### FIXED CODE ###

import numpy as np


def main():
    n, k = map(int, input().split())
    height = np.fromstring(input(), 'int32', sep=' ')
    height = np.append(height, [0] * (k - 1))

    dp = np.full((n + k - 1), 10 ** 9, dtype='int')
    dp[0] = 0

    for i in range(n - 1):
        default_val = dp[i + 1:i + 1 + k]
        new_val = dp[i] + np.abs(height[i + 1:i + 1 + k] - height[i])
        dp[i + 1:i + 1 + k] = np.minimum(default_val, new_val)
    print(dp[n - 1])


if __name__ == "__main__":
    main()
def main():
    from functools import reduce
    from math import gcd
    from collections import deque

    n, *a = map(int, open(0).read().split())
    p = deque(a)
    edge1 = reduce(gcd, a[1:])
    edge2 = reduce(gcd, a[:-1])
    full = reduce(gcd, a)
    ans = max([edge1, edge2, full])
    gl = p.pop()
    tmp = gl
    for i in range(n - 2):
        tmp2 = p.pop()
        gr = reduce(gcd, p)
        gl = gcd(gl, tmp)
        tmp = tmp2
        g = gcd(gl, gr)
        ans = max(ans, g)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

a,b,t=map(int,input().split())
print(t//a*b)
s=set(input().sep())
a='abcdefghijklmnopqrstuvwxyz'
b=set()
for i in range(26):
    b.append(str(a[i]))
if s==b:
    print('None')
else:
    print(b-s)


### FIXED CODE ###

s=set(list(input()))
a=set(list('abcdefghijklmnopqrstuvwxyz'))

if s==a:
    print('None')
else:
    b=sorted(list(a-s))
    print(str(b[0]))
n = int(input())
a = [int(i) for i in input().split()]

val = []

for i in range(n):
    val.append(a[i]-i)

val.sort()
#print(val)

#idx = [(val[0],0)]
idx = []
cnt = 1
for i in range(n-1):
    if val[i] == val[i+1]:
        #cnt += 1
        if i == n-2:
            idx.append((val[i],i+2))
        continue
    else:
        if i == n-2:
            idx.append((val[i],i+1))
            idx.append((val[i+1],i+2))
        else:
           idx.append((val[i],i+1)) 
        #cnt = 1
        
ans_val = 0
ans2_val = 0
ans3_val = 0

flag2 = False
flag3 = False

for i in range(len(idx)):
    if idx[i][1] >= (n) // 2:
        ans_val = idx[i][0]
        
        #print(i-1)
        if i-1 >= 0:
            flag2 = True
            ans2_val = idx[i-1][0]
        
        if i+1 <= n-1:
            flag3 = True
            ans3_val = idx[i+1][0]
        
        break

#print(idx,ans_val,ans2_val)
#exit()
     
ans = 0
ans2 = 10**20
ans3 = 10**20
for i in range(n):
    ans += abs(a[i]-ans_val-i)
    if flag2 == True:
        ans2 += abs(a[i]-ans2_val-i)
    if flag3 == True:
        ans3 += abs(a[i]-ans3_val-i)
    


print(min(ans,ans2,ans3))

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]

if n == 1:
    print(0)
    exit()

val = []

for i in range(n):
    val.append(a[i]-i)

val.sort()
#print(val)

#idx = [(val[0],0)]
idx = []
cnt = 1
for i in range(n-1):
    if val[i] == val[i+1]:
        #cnt += 1
        if i == n-2:
            idx.append((val[i+1],i+2))
        continue
    else:
        if i == n-2:
            idx.append((val[i],i+1))
            idx.append((val[i+1],i+2))
        else:
           idx.append((val[i],i+1)) 
        #cnt = 1
        
ans_val = 0
ans2_val = 0
ans3_val = 0

flag2 = False
flag3 = False

for i in range(len(idx)):
    if idx[i][1] >= (n+1) // 2:
        ans_val = idx[i][0]
        """
        #print(i-1)
        if i-1 >= 0:
            flag2 = True
            ans2_val = idx[i-1][0]
        
        if i+1 <= len(idx)-1:
            flag3 = True
            ans3_val = idx[i+1][0]
        """
        break

#print(idx,ans_val,ans2_val)
#exit()
     
ans = 0
ans2 = 10**20
ans3 = 10**20
for i in range(n):
    ans += abs(a[i]-ans_val-i)
    if flag2 == True:
        ans2 += abs(a[i]-ans2_val-i)
    if flag3 == True:
        ans3 += abs(a[i]-ans3_val-i)
    


print(ans)
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
        return(a*b)//gcd(a, b)

    
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    A_ = copy.deepcopy(A)
    a_lcm = A.pop()
    # Aにまだ値が残っていれば
    if len(A) >= 1:
        for a in A:
            a_lcm = lcm(a_lcm, a)
    # 元のAの値とlcmの半分の値を割り切れるものがあったら終了
    for i in A_:
        if (a_lcm / 2) % i != 0:
            continue
        else:
            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()
import copy
n = int(input())
b = list(map(int,input().split()))
ans = 0
ls = copy.copy(b)

for i in range(n-1):
    if b[i] == 0:
        ls.remove(0)
        if i+1 < n-1:
            ls.remove(b[i+1])  

if n == 2:
    print(min(b)*2)
else:
    print(sum(ls)+min(ls))

### FIXED CODE ###

n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

print(ans+b[-1]+b[0])
n = int(input())
s = input()
result = []

for i in range(n):
    count = 0
    for j in range(n):
        if (i < j) and (s[j] == "E"):
            count += 1
        elif (i > j) and (s[j] == "W"):
            count += 1
    result.append(count)

pprint(min(result))


### FIXED CODE ###

a, b = map(int, input().split())
print(max([a+b, a-b, a*b]))