Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
from collections import deque

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

n, k = na()
h = na()

inf = 10**10
dp = [inf] * n
dp[0] = 0
for i in range(n-1):
    for j in range(1, k+1):
        if i + j <= n - 1:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
#print(dp)
print(dp[n-1])

Fixed submission:
import sys
stdin = sys.stdin
from collections import deque

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

n, k = na()
h = na()

inf = 10**10
dp = [inf] * n
dp[0] = 0
for i in range(n-1):
    for j in range(1, k+1):
        if i + j <= n - 1:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
#print(dp)
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
na = lambda: list(map(int, stdin.readline().split()))
n, i = na()

print(n - i + 1)

Fixed submission:
import sys
stdin = sys.stdin

na = lambda: list(map(int, stdin.readline().split()))
n, i = na()

print(n - i + 1)
Buggy python submission (verdict: Runtime Error):
#create date: 2020-07-03 14:46

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    h, w = na()
    g = [[1] * (w+2)]
    white = 0
    for i in range(h):
        r = ns()
        white += r.count(".")
        g.append([1] + [1 if s=="#" else 0 for s in r] + [1])
    g.append([1] * (w+2))
    q = deque([[1,1]])
    move = ((1, 0), (-1, 0), (0, 1), (1, 0))
    while q:
        x, y = q.popleft()
        for dx, dy in move:
            nx, ny = x + dx, y + dy
            if g[nx][ny] > 0:
                continue
            g[nx][ny] = g[x][y] + 1
            q.append((nx, ny))
    if g[h][w] = 0:
        print(-1)
    else:
        print(white - g[h][w] - 1)



if __name__ == "__main__":
    main()

Fixed submission:
#create date: 2020-07-03 14:46

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    h, w = na()
    g = [[1] * (w+2)]
    white = 0
    for i in range(h):
        r = ns()
        white += r.count(".")
        g.append([1] + [1 if s=="#" else 0 for s in r] + [1])
    g.append([1] * (w+2))
    q = deque([[1,1]])
    move = ((1, 0), (-1, 0), (0, 1), (0, -1))
    while q:
        x, y = q.popleft()
        for dx, dy in move:
            nx, ny = x + dx, y + dy
            if g[nx][ny] > 0:
                continue
            g[nx][ny] = g[x][y] + 1
            q.append((nx, ny))
    if g[h][w] == 0:
        print(-1)
    else:
        print(white - g[h][w] - 1)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#create date: 2020-08-06 09:16

import sys
stdin = sys.stdin
from bisect import bisect_left

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    c = na()
    a.sort()
    b.sort()
    c.sort()
    cnt = 0
    for ci in c:
        i = bisect_left(b, ci)
        if i == 0:
            continue
        for bi in b[:i]:
            j = bisect_left(a, bi)
            cnt += j
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
#create date: 2020-08-06 09:16

import sys
stdin = sys.stdin
from bisect import bisect_left, bisect_right

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    c = na()
    a.sort()
    b.sort()
    c.sort()
    cnt = 0
    #print(a, b, c)
    for bi in b:
        i = bisect_left(a, bi)
        j = bisect_right(c, bi)
        cnt += i * (n-j)
        #print(bi, i, n-j)
    print(cnt)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        print(l[0] * l[1])
        quit()
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.apend(key)
print(0)


Fixed submission:
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        break
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(l[0] * l[1] if len(l) >= 2 else 0)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        break
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.apend(key)
print(l[0] * l[1])


Fixed submission:
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        break
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(l[0] * l[1] if len(l) >= 2 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
from_one = []
to_n = []

for _ in range(m):
    a, b = na()
    if a == 1:
        from_one.append(b)
    if b == n:
        to_n.append(a)

p = False
for i in from_one:
    if i in to_n:
        print("POSSIBLE")
        p = True
if not p:
    print("IMPOSSIBLE")
        


Fixed submission:
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
from_one = [0] * n
to_n = [0] * n

for _ in range(m):
    a, b = na()
    if a == 1:
        from_one[b] = 1
    if b == n:
        to_n[a] = 1

p = False
for i, j in zip(from_one, to_n):
    if i == 1 and j ==1:
        print("POSSIBLE")
        p = True
        break
if not p:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    n = len(s)
    m = (n-1)//2 + 1
    for i in range(1, m, 2):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    n = len(s)
    m = (n-1)//2 + 1
    for i in range(1, m):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    for i in range(1, len(s)//2, 2):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                #print(s[:i], s[i:2*i])
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    n = len(s)
    m = (n-1)//2 + 1
    for i in range(1, m):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                for z in range(k+1):
                        if x + y + z == s:
                                ans += 1
                                break
print(ans)




Fixed submission:
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                z = s - x - y
                if z <= k and z >= 0:
                        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                for z in range(k+1):
                        if x + y + z == s:
                                ans += 1
print(ans)




Fixed submission:
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                z = s - x - y
                if z <= k and z >= 0:
                        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

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

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(A)
print(cnt)

Fixed submission:
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

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

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  if N == 1:
    break
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(MOD):
  if N == 1:
    break
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
if not N == 1:
  bai = res // cnt
  res = res %  cnt
  s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
print(s)

Fixed submission:
N,x,MOD = map(int, input().split())
s = x
flag = False
sflag = False
if N == 1:
  flag = True
  sflag = True
  print(s)
for i in range(1,MOD):
  x = (x*x) % MOD
  s += x
  if N == (i+1):
    flag = True
    break
if flag == True:
  if sflag == False:
    print(s)
else:
  t_s = 0
  cnt = 0
  init = x
  for i in range(MOD):
    x = (x*x) % MOD
    t_s += x
    cnt += 1
    if x == init:
      break
  bi = (N-MOD)//cnt
  res = (N-MOD)%cnt
  s += t_s * bi
  for i in range(res):
    x = (x*x) % MOD
    s += x
  print(s)

Buggy python submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(MOD):
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
bai = res // cnt
res = res %  cnt
s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
print(s)

Fixed submission:
N,x,MOD = map(int, input().split())
s = x
flag = False
sflag = False
if N == 1:
  flag = True
  sflag = True
  print(s)
for i in range(1,MOD):
  x = (x*x) % MOD
  s += x
  if N == (i+1):
    flag = True
    break
if flag == True:
  if sflag == False:
    print(s)
else:
  t_s = 0
  cnt = 0
  init = x
  for i in range(MOD):
    x = (x*x) % MOD
    t_s += x
    cnt += 1
    if x == init:
      break
  bi = (N-MOD)//cnt
  res = (N-MOD)%cnt
  s += t_s * bi
  for i in range(res):
    x = (x*x) % MOD
    s += x
  print(s)

Buggy python submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(0,MOD):
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
bai = res // cnt
res = res %  cnt
s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
else:
  pass
print(s)

Fixed submission:
N,x,MOD = map(int, input().split())
s = x
flag = False
sflag = False
if N == 1:
  flag = True
  sflag = True
  print(s)
for i in range(1,MOD):
  x = (x*x) % MOD
  s += x
  if N == (i+1):
    flag = True
    break
if flag == True:
  if sflag == False:
    print(s)
else:
  t_s = 0
  cnt = 0
  init = x
  for i in range(MOD):
    x = (x*x) % MOD
    t_s += x
    cnt += 1
    if x == init:
      break
  bi = (N-MOD)//cnt
  res = (N-MOD)%cnt
  s += t_s * bi
  for i in range(res):
    x = (x*x) % MOD
    s += x
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = [int(x) for x in input().split(' ')]
for i in range(1,N+1):
  print(line.count(i))

Fixed submission:
N = int(input())
line = [int(x) for x in input().split(' ')]
L = [0]*N
for i in line:
  L[i-1] += 1
for i in L:
  print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
mydict = {}
for i in range(N):
  t = input()
  if t in mydict:
    mydict[t]+=1
  else:
    mydict[t] = 1
max_k_list = [kv[0] for kv in mydict.items() if kv[1] == max(mydict.values())]
max_k_list.sort()
for i in max_k_list:
  print(i)

Fixed submission:
line = input().split(' ')
k = set(line)
if len(k) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
inport math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.ceil(M/N))


Fixed submission:
import math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.ceil(M/N))

Buggy python submission (verdict: Runtime Error):
inport math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.floor(M/N))

Fixed submission:
import math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.ceil(M/N))
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split(" "))
INF =  1e11
v = [INF]*100010
v[0] = 0
for i in range(N):
  weight,value = map(int,input().split(" "))
  for j in range(100001,0,-1):
    if j < value:
      break
    v[j] = min(v[j],v[j-value]+weight)

for i in range(100001,0,-1):
  if v[i] <= W:
    print(i)
    break



Fixed submission:
N,W = map(int,input().split(" "))
INF =  1e11
v = [INF]*100010
v[0] = 0
for i in range(N):
  weight,value = map(int,input().split(" "))
  for j in range(100001,0,-1):
    if j < value:
      break
    v[j] = min(v[j],v[j-value]+weight)

ans = 0
for i in range(100001,0,-1):
  if v[i] <= W:
    ans = i
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
j = {
    "-":-1,
    "+":1
    }
l =input()
n = input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)


Fixed submission:
j = {
    "-":-1,
    "+":1
    }
l =input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)

Buggy python submission (verdict: Runtime Error):
j = {
    "-":-1,
    "+":1
    }
l =input().split(" ")
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)

Fixed submission:
j = {
    "-":-1,
    "+":1
    }
l =input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        i = j
        break
      prev = line[j]
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        i = j
        break
      prev = line[j]
  prev = line[i]
  i+=1
print(count)


Fixed submission:
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)

Buggy python submission (verdict: Runtime Error):
def solve(ary):
  prev = ary[0]
  mem = "equal"
  for i in ary:
    if prev > i:
      mem = "minus"
      break
    elif prev < i:
      mem = "plus"
      break
  if mem == "minus":
    return M(ary)
  elif mem == "plus":
    return P(ary)
  else:
    return 1

def M(ary):
  prev = ary[0]
  for i in range(len(ary)):
    if ary[i] > prev:
      return solve(ary[i:])+1
    prev = ary[i]
  return 1
    
def P(ary):
  prev = ary[0]
  for i in range(len(ary)):
    if ary[i] < prev:
      return solve(ary[i:])+1
    prev = ary[i]
  return 1

N = int(input())
line = [int(x) for x in input().split(' ')]
print(solve(line))

Fixed submission:
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
line = input()
x = 0
t = 0
for i in range(N):
  if line[i] == 'I':
    t += 1
  else if line[i] == 'D':
    t -= 1
  x = max(t,x)
print(x)

Fixed submission:
N = int(input())
line = input()
x = 0
t = 0
for i in range(N):
  if line[i] == 'I':
    t += 1
  elif line[i] == 'D':
    t -= 1
  x = max(t,x)
print(x)
Buggy python submission (verdict: Runtime Error):
line = input().split(' ')
print(line[0],line[1],line[2])

Fixed submission:
line = input().split(',')
print(line[0],line[1],line[2])
Buggy python submission (verdict: Runtime Error):
ilne = input().split(' ')
print(int(line[0])*((int(line[0])-1)**(int(line[1])-1))

Fixed submission:
line = input().split(' ')
print(int(line[1])*((int(line[1])-1)**(int(line[0])-1)))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = list(map(int, input().split()))

anses = []
for x in range(a, b + 1):
  for y in range(c, d + 1):
    anses.append(x * y)

print(max(anses))


Fixed submission:
a, b, c, d = list(map(int, input().split()))

xs = [a, b]
if a < b and b == 0:
  xs.append(b - 1)
if a == 0 and a < b:
  xs.append(a + 1)

ys = [c, d]
if c < d and d == 0:
  ys.append(d - 1)
if c == 0 and c < d:
  ys.append(c + 1)

anses = []

for x in xs:
  for y in ys:
    anses.append(x * y)

print(max(anses))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

anses = []
for i in range(len(s) - len(t)):
  cnt = 0
  for c, d in zip(s[i:i + len(t)], t):
    if c != d:
      cnt += 1
  anses.append(cnt)

print(min(anses))


Fixed submission:
s = input()
t = input()

anses = []
for i in range(len(s) - len(t)+1):
  cnt = 0
  for c, d in zip(s[i:i + len(t)], t):
    if c != d:
      cnt += 1
  anses.append(cnt)

print(min(anses))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = input()

ar = c.count('R')
aw = c.count('W')

anses = []
for i in range(n + 1):
  rtow, wtor = 0, 0
  for j, e in enumerate(c):
    if j < i:
      if e != 'R':
        rtow += 1
    else:
      if e != 'W':
        wtor += 1

  ans = max(rtow, wtor)
  anses.append(ans)

print(min(anses))


Fixed submission:
n = int(input())
c = input()

rtow = c.count('R')
wtor = 0

anses = []
for i in range(n + 1):
  anses.append(max(rtow, wtor))
  if i == n:
    break
  if c[i] == 'W':
    wtor += 1
  else:
    rtow -= 1

print(min(anses))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = input()

ar = c.count('R')
aw = c.count('W')

anses = []
for i in range(n + 1):
  rtow, wtor = 0, 0
  for j, e in enumerate(c):
    if j < i:
      if e != 'R':
        rtow += 1
    else:
      if e != 'W':
        wtor += 1

  ans = max(rtow, wtor)
  anses.append(ans)

print(min(anses))


Fixed submission:
n = int(input())
c = input()

rtow = c.count('R')
wtor = 0

anses = []
for i in range(n + 1):
  anses.append(max(rtow, wtor))
  if i == n:
    break
  if c[i] == 'W':
    wtor += 1
  else:
    rtow -= 1

print(min(anses))