Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03712 (python)

Fixed submission:
h,w = map(int,input().split())
edges = '#' * (w+2)
ans = [edges]
for i in range(h):
  ans.append('#' + input() + '#')
ans.append(edges)
[print(i) for i in ans]

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
edges = '#' * (W+2)
ans = [edges]
for i in range(h):
  ans.append('#' + input() + '#')
ans.append(edges)
[print(i) for i in ans]
Problem p03729 (python)

Fixed submission:
A,B,C = input().split()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

Buggy submission (verdict: Runtime Error):
A,B,C = map(int, input().split())
print('YES' if A[-1] == B[0] and B[-1] == C[0] and C[-1] == A[0] else 'NO')
Problem p03732 (python)

Fixed submission:
from itertools import accumulate
n,w=map(int, input().split())
items = {}
for _ in range(n):
    u,v = map(int, input().split())
    if u not in items:
        items[u] = []
    items[u].append(v)
cost = 0
acc = []
minkey = min(items.keys())
for i in range(4):
    if minkey + i in items:
        items[minkey + i].sort(reverse=True)
        acc.append([0] + list(accumulate(items[minkey + i])))
    else:
        acc.append([0])

ans = 0
for i in range(len(acc[0])):
    a = (i) * minkey
    if w < a:
        continue
    for j in range(len(acc[1])):
        b = (j) * (minkey+1)
        if w < a + b:
            continue
        for k in range(len(acc[2])):
            c = (k) * (minkey+2)
            if w < a + b + c:
                continue
            for l in range(len(acc[3])):
                d = (l) * (minkey+3)
                if w < a + b + c + d:
                    continue
                cost = acc[0][i] + acc[1][j] + acc[2][k] + acc[3][l]
                if cost > ans :
                    ans = cost

print(ans)

Buggy submission (verdict: Runtime Error):
n,w=map(int, input().split())
lim = min(w,10**5)
dp = [0] * (lim+1)
items = []
mod = 10**5
for _ in range(n):
    ww,v = map(int, input().split())
    items.append((ww,v))
    if ww > mod:
        continue
    for i in range(ww,lim+1)[::-1]:
        # print(i)
        if dp[i-ww] + v > dp[i]:
            dp[i] = dp[i-ww] + v
    # print(dp)
if w <= 10**5:
    print(dp[-1])
    exit()
ll = w-mod
dd = [0] * (ll+1)
for ww,v in items:
    if ww <= mod:
        continue
    u = ww % mod
    for i in range(u,ll+1)[::-1]:
        if dd[i-u] + v > dd[i]:
            dd[i] = dd[i-u] + v
    # print(dp)
print(dp[-1] + dd[-1])

Buggy submission (verdict: Runtime Error):
n,w=map(int, input().split())
dp = [0] * (w+1)
ans = 0
for _ in range(n):
    ww,v = map(int, input().split())
    for i in range(ww,w+1)[::-1]:
        if dp[i-ww] + v > dp[i]:
            dp[i] = dp[i-ww] + v
            if ans < dp[i]:
                ans = dp[i]
    # print(dp)
print(ans)

Buggy submission (verdict: Runtime Error):
4 1
10 100
10 100
10 100
10 100
Problem p03760 (python)

Fixed submission:
print(''.join([o+e for o,e in zip(input(), input()+'\n')]))

Buggy submission (verdict: Runtime Error):
print(''.join([o+e for o,e in zip(input(), input()+[''])]))
Problem p03844 (python)

Fixed submission:
x,op,y = input().split()
x = int(x)
y = int(y)
print(x+y if op == '+' else x-y)

Buggy submission (verdict: Runtime Error):
x,op,y = int,input().split()
x = int(x)
y = int(y)
print(x+y if op == '+' else x-y)
Problem p03863 (python)

Fixed submission:
s = input()
print('Second' if (len(s) % 2 == 0) ^ (s[0] == s[-1]) else 'First')

Buggy submission (verdict: Runtime Error):
s = input()
print('Second' if len(s) % 2 == 0 ^ s[0] != s[-1] else 'First')
Problem p03919 (python)

Fixed submission:
h,w = map(int , input().split())
alf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(h):
  for j,s in enumerate(input().split()):
    if s == 'snuke':
      print(alf[j] + str(i+1))

Buggy submission (verdict: Runtime Error):
h,w = map(int , input().split())
alf = 'ABCDEFGHIJKLMN'
for i in range(h):
  for j,s in enumerate(input().split()):
    if s == 'snuke':
      print(alf[j] + str(i+1))
Problem p04019 (python)

Fixed submission:
dire = [0,0,0,0]
d = {c:i for i,c in enumerate('WENS')}
for c in input():
	dire[d[c]] = 1
print('No' if (dire[0] ^ dire[1]) or (dire[2] ^ dire[3]) else 'Yes')

Buggy submission (verdict: Runtime Error):
dire = [0,0,0,0]
d = {c:i for i,c in numerate('WENS')}
for c in input():
	dire[d[c]] = 1
print('No' if (dire[0] ^ dire[1]) or (dire[2] ^ dire[3]) else 'Yes')
Problem p04047 (python)

Fixed submission:
num = int(input())
num_list = sorted(list(map(int, input().split())))
i = 0
sum = 0
while i < num * 2:
  sum += num_list[i]
  i += 2
print(sum)

Buggy submission (verdict: Runtime Error):
num = input()
num_list = list(map(int, input().split()))sort()
i = 0
sum = 0
while i < num * 2:
  sum += num_list[i]
  i += 2
print(sum)
Problem p02555 (python)

Fixed submission:
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    fac, finv = fact_and_inv(n+2000)

    length = 1
    ans = 0
    while True:
        if length * 3 > n:
            break
        distribution = n - length * 3
        ans += fac[length + distribution - 1] * finv[length-1] * finv[distribution]
        ans %= MOD
        length += 1
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    fac, finv = fact_and_inv(n)

    length = 1
    ans = 0
    while True:
        if length * 3 > n:
            break
        distribution = n - length * 3
        ans += fac[length + distribution - 1] * finv[length-1] * finv[distribution]
        ans %= MOD
        length += 1
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()
Problem p02706 (python)

Fixed submission:

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)
Problem p02778 (python)

Fixed submission:
print("x"*len(input().strip()))

Buggy submission (verdict: Runtime Error):
print(x*len(input().strip()))
Problem p02797 (python)

Fixed submission:
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10 ** 9 + 7
def solve():
    n, k, s = getList()
    if s > 10 ** 6:
        out = 1
    else:
        out = 10 ** 9
    ans = [out for i in range(n - k)] + [s for i in range(k)] #] + [0 for i in range(k-1)]

    print(*ans)

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()

Buggy submission (verdict: Runtime Error):
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10 ** 9 + 7
def solve():
    n, k, s = getList()
    fill = s // k
    if s > 10 ** 6:
        out = 1
    else:
        out = 10 ** 9
    ans = [out for i in range(n - k)] + [s for i in range(k)] #] + [0 for i in range(k-1)]

    print(*ans)

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()
Problem p02883 (python)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))

def check(mid, k, pairs):
    tmp = 0
    for pair in pairs:
        a,b = pair
        kari_a = mid // b
        tmp += max(a - kari_a, 0)

    if tmp <= k:
        return True
    else:
        return False


def solve():
    n, k = getList()
    cap = getList()
    foods = getList()
    cap.sort()
    foods.sort(reverse=True)
    h = []
    pairs = [(a, b) for a, b in zip(cap, foods)]
    ansmn = 0
    ansmx = 10**13
    # print(foods)
    # print(cap)
    # print([2046//p for p in foods])
    while(ansmx - ansmn > 1):
        mid = (ansmn + ansmx) // 2
        res = check(mid, k, pairs)
        if res:
            ansmx = mid
        else:
            ansmn = mid


    if check(ansmn, k, pairs):
        print(ansmn)
    else:
        print(ansmx)

def main():
    solve()


if __name__ == "__main__":
    main()


"""
10 10
95 38 9 26 36 10 69 25 44 83
6 42 33 74 75 31 73 20 70 93
"""

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))

def check(mid, k, pairs):
    tmp = 0
    for pair in pairs:
        a,b = pair
        kari_a = mid // b
        tmp += max(a - kari_a, 0)

    if tmp <= k:
        return True
    else:
        return False


def solve():
    n, k = getList()
    cap = getList()
    foods = getList()
    cap.sort()
    foods.sort(reverse=True)
    h = []
    pairs = [(-a * b, a, b) for a, b in zip(cap, foods)]
    ansmn = 0
    ansmx = 10**7
    while(ansmx - ansmn > 1):
        mid = (ansmn + ansmx) // 2
        res = check(mid, k, pairs)
        if res:
            ansmn = mid
        else:
            ansmx = mid


    if check(ansmx, k, pairs):
        print(ansmx)
    else:
        print(ansmn)

def main():
    t = getN()
    for times in range(t):
        solve()


if __name__ == "__main__":
    main()
Problem p02913 (python)

Fixed submission:
import sys
import math
import copy
import random
import itertools
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

dic = dict()

def zalg(s):
    n = len(s)
    ret = [0] * n
    ret[0] = n
    i, j = 1, 0
    while i < n:
        while i + j < n and s[j] == s[i+j]:
            j += 1
        ret[i] = j

        if j == 0:
            i += 1
            continue

        k = 1
        while k < j and k + ret[k] < j:
            ret[i + k] = ret[k]
            k += 1

        i += k
        j -= k

    return ret

def solve(n=None, s1=None, s2=None):
    n = getN()
    s = list(getS())
    ans = 0
    for i in range(n):
        ps = s[i:]
        z = zalg(ps)
        for i, zz in enumerate(z):
            if i >= zz:
                ans = max(ans, zz)
    print(ans)

def main():
    n = getN()
    for _ in range(n):
        solve()
    return


if __name__ == "__main__":
    # main()
    solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from bisect import bisect_left

def hantei(mid, s, suffix):
    # print(mid, s, suffix)
    for i in range(n - mid + 1):
        tmp = (s[i:i+mid], i)
        idx = bisect_left(suffix, tmp)
        flag = True
        while(flag):
            tgt = suffix[idx]
            # print(tgt)
            if tmp[0] == tgt[0]:
                if tgt[1] >= i + mid:
                    return True
                else:
                   idx += 1
            else:
                flag = False

n = getN()
s = input().strip()

suffix = []

for i in range(n):
    suffix.append((s[i:], i))

suffix.sort()

mn = 0
mx = n // 2
while(mx-mn>1):
    mid = (mx + mn + 1) // 2
    is_succ = hantei(mid, s, suffix)
    if is_succ:
        mn = mid
    else:
        mx = mid

if hantei(mx, s, suffix):
    print(mx)
else:
    print(mn)
Problem p02917 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
INF = 100000000000
nums = [INF] + getList() + [INF]
ans = 0
for i, j in zip(nums, nums[1:]):
    ans += min(i, j)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
    n = getN()
    a = getList()
    ans = 0
    for i, j in zip(a, a[1:]):
        ans += min(i, j)
    ans += a[0] + a[-1]

    print(ans)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
    n = getN()
    a = getList()
    ans = 0
    for i, j in zip(a, a[1:]):
        ans += min(i, j)
    ans += a[0] + a[-1]

    print(ans)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()
Problem p02928 (python)

Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(input())


def getList():
    return list(map(int, input().split()))


import math
MOD = 10 ** 9 + 7

n, k = getList()
anums = getList()

space = [[] for i in range(2002)]
remain = [1 for j in range(n)]
yet = n

for i, x in enumerate(anums):
    space[x].append(i)


ans = 0
for s in space:
    if s:
        jump = 0
        ls = len(s)
        yet -= ls
        for num in s:
            jump += sum(remain[:num])
            remain[num] = 0
            # print(jump)
        ans += ls * (yet * (k * (k-1))) // 2
        ans += jump * k
        # print(ans, jump, yet)
        # remain[num] = 0

        ans %= MOD
        # yet -= len(s)
        # yet -= 1
print(ans)
# print((43 * (998244353*998244354) // 2) % MOD)

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
class Segtree_op():
     def __init__(self, n):
         self.size = 1
         while(n >= 1):
             self.size = self.size << 1
             n = n//2
 
         self.arr = [self.unit() for i in range(self.size*2)]
 
     def op(self, lch, rch):
         # update min with holding index
         return lch + rch
 
     def unit(self):
         return 0
 
     def update(self, k, val):
         k += self.size - 1
         self.arr[k] = val
         while(k):
             k = (k - 1) // 2
             self.arr[k] = self.op(self.arr[k*2 + 1], self.arr[k*2 + 2])
 
     def query(self, l, r):
         L = l + self.size
         R = r + self.size
         s = self.unit()
         while L < R:
             if R & 1:
                 R -= 1
                 s = self.op(s, self.arr[R - 1])
 
             if L & 1:
                 s = self.op(s, self.arr[L - 1])
                 L += 1
             L >>= 1
             R >>= 1
         return s
 
 
     def show(self):
         idx = 1
         while(idx <= self.size):
             print(self.arr[idx - 1:idx * 2 - 1])
             idx *= 2
def tento(nums):
    n = len(nums)
    st = Segtree_op(n)
    ret = 0
    for i, num in enumerate(nums):
        st.update(num, st.query(num, num+1)+1)
        # st.show()
        ret += i - st.query(0, num+1) + 1

    return ret



def main():
    n, kk = getList()
    nums = getList()
    ten = tento(nums)
    oneset = 0
    for k, v in Counter(nums).items():
        oneset += n - v
    # print(ten, oneset)
    print((kk * ten + kk * (kk-1) * oneset // 4)% MOD)

if __name__ == "__main__":
    main()
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

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

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

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

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)
Problem p02945 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

a, b = getList()

print(max([a+b, a-b, a*b]))

# print(ans)

Buggy submission (verdict: Runtime Error):
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    a,b = getList()
    print(max([a+b, a - b. a * b]))
    return
def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()