Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
num_list = [s[:i].count("B") if s[i] == "W" else 0 for i in range(1, len(s))]
print(str(sum(num_list)))


Fixed submission:
s = list("BWBWBW" * 10000)

s = list(input())
ret, counter = 0, 0
for a in s:
    if a == "B":
        counter += 1
    else:
        ret += counter
print(str(ret))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
s = list(S)
if len(s) == 1:
    print("1")
else:
    num_list = [s[:i].count("B") if s[i] == "W" else 0 for i in range(1, len(s))]
    print(str(sum(num_list)))

Fixed submission:
s = list("BWBWBW" * 10000)

s = list(input())
ret, counter = 0, 0
for a in s:
    if a == "B":
        counter += 1
    else:
        ret += counter
print(str(ret))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
s = list(S)
num_list = [s[:i].count("B") if s[i] == "W" else 0 for i in range(1, len(s))]
print(str(sum(num_list)))


Fixed submission:
s = list("BWBWBW" * 10000)

s = list(input())
ret, counter = 0, 0
for a in s:
    if a == "B":
        counter += 1
    else:
        ret += counter
print(str(ret))
Buggy python submission (verdict: Runtime Error):
N, X = [int(a) for a in input().split()]
ans = 0
now_level = N
num_list = [2 ** (n + 2) - 3 for n in range(N + 1)]
while X > 0:
    if X == 1:
        break
    num_list = [2 ** (n + 2) - 3 for n in range(now_level + 1)]
    plus_base = [a + now_level - b for a, b in zip(num_list, range(now_level + 1))]
    eat_num = max([a for a in plus_base if a <= X])
    eat_level = plus_base.index(eat_num)
    now_level = eat_level
    ans += int((num_list[eat_level] + 1) / 2 + 0.1)
    X -= eat_num
    if X > 0:
        X -= 1
        ans += 1
print(str(ans))



Fixed submission:
N, X = [int(a) for a in input().split()]
ans = 0
now_level = N
num_list = [2 ** (n + 2) - 3 for n in range(N + 1)]
while X > 0:
    if X <= now_level:
        break
    num_list = [2 ** (n + 2) - 3 for n in range(now_level + 1)]
    plus_base = [a + now_level - b for a, b in zip(num_list, range(now_level + 1))]
    eat_num = max([a for a in plus_base if a <= X])
    eat_level = plus_base.index(eat_num)
    now_level = eat_level
    ans += int((num_list[eat_level] + 1) / 2 + 0.1)
    X -= eat_num
    if X > 0:
        X -= 1
        ans += 1
print(str(ans))
Buggy python submission (verdict: Runtime Error):
S = input()
l = len(S)
distance = 999
for i in range(l)
    num = int(S[i:i+3])
    if abs(num - 753) < distance:
        distance = abs(num - 753)
print(str(distance))

Fixed submission:
S = input()
l = len(S)
distance = 999
for i in range(l):
    num = int(S[i:i+3])
    if abs(num - 753) < distance:
        distance = abs(num - 753)
print(str(distance))
Buggy python submission (verdict: Runtime Error):
X, Y = [int(a) for a in input.split()]
ret = int(X + Y/2 + 0.1)
print(str(ret))


Fixed submission:
X, Y = [int(a) for a in input().split()]
ret = int(X + Y/2 + 0.1)
print(str(ret))

Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
ret = int(X + Y/2 + 0.1)
print(str(ret))

Fixed submission:
X, Y = [int(a) for a in input().split()]
ret = int(X + Y/2 + 0.1)
print(str(ret))
Buggy python submission (verdict: Runtime Error):
N = input()
A = input()
B = input()

if N == "1":
    print("Hello World")
else:
    print(str(int(A) + int(B)))


Fixed submission:
N = input()

if N == "1":
    print("Hello World")
else:
    A = input()
    B = input()
    print(str(int(A) + int(B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = -1
bef = -1
for i in range(N):
    now = int(data[input()])
    if now - bef > 1:
        ans = -1
        break
    elif now - bef == 1:
        ans += 1
        bef = now
    else:
        ans += now
        bef = now

print(str(ans))

Fixed submission:
N = int(input())
ans = -1
bef = -1
for i in range(N):
    now = int(input())
    if now - bef > 1:
        ans = -1
        break
    elif now - bef == 1:
        ans += 1
        bef = now
    else:
        ans += now
        bef = now
 
print(str(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

# import sys
# sys.stdout = open("e:/python/cp/output.txt","w")
# sys.stdin = open("e:/python/cp/input.txt","r")



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

count =0
for i in range(a,b+1):
    if i%c==0:
        count+=1
print(count)



Fixed submission:
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

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

# y = ((b/x) -((a-1)/x))
print(((b//x) -((a-1)//x)))
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

import sys
sys.stdout = open("e:/cp/output.txt","w")
sys.stdin = open("e:/cp/input.txt","r")



n,l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
result = ''.join(s)
print(s)


Fixed submission:
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7





n,l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
result ="".join(s)
print(result)
Buggy python submission (verdict: Runtime Error):
inport numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N , B

print(min(costs))


Fixed submission:
import numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N , B

print(min(costs))

Buggy python submission (verdict: Runtime Error):
inport numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N, B

return np.min(costs)


Fixed submission:
import numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N , B

print(min(costs))

Buggy python submission (verdict: Runtime Error):
inport numpy as np

N,A,B = map(int,input().split(" "))
i = np.arange(N+1)  # the number of people who use train
j = N-i  # the number pf people who use taxi
cost = A+i + B*j

return np.min(cost)

Fixed submission:
import numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N , B

print(min(costs))
Buggy python submission (verdict: Runtime Error):
ss = input()
set_ss = set(ss)
if len(set_ss) != 2 :
  print("No")
else:
	for s in set(ss):
    	if ss.count(s) != 2:
          print("No")
          break
    else:
    	print("Yes") 

Fixed submission:
ss = input()
set_ss = set(ss)
if len(set_ss) != 2 :
  print("No")
else:
  for s in set(ss):
    if ss.count(s) != 2:
      print("No")
      break
  else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
ss = input()

for i in range(3):
  if ss[i] = ss[i+1]:
    print("Good")
    break
else:
  print("Bad")


Fixed submission:
ss = input()

for i in range(3):
  if ss[i] == ss[i+1]:
    print("Bad")
    break
else:
  print("Good")

Buggy python submission (verdict: Runtime Error):
ss = input()

for i in range(3):
  if ss[i] = ss[i+1]:
    print("Good")
    break
else:
  print("Bad")

Fixed submission:
ss = input()

for i in range(3):
  if ss[i] == ss[i+1]:
    print("Bad")
    break
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
import numpy as np

A,B,C,D = map(int,input().split())

ns = np.arange(A,B+1)

print(((ns%C!=0)*(ns%D!=0)).sum())

Fixed submission:
import fractions

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

A,B,C,D = map(int,input().split())

AtoB =  B - (A-1)

div_C = (B//C) - ((A-1)//C)
div_D = (B//D) - ((A-1)//D)
div_CD = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

print(AtoB - div_C - div_D + div_CD)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
Ws = np.array(map(int,input().split()))

ret = []
for T in range(1,N):
  s1 = Ws[Ws<=T]
  s2 = Ws[Ws>T]
  ret.append(abs(s1-s2))
  
print(min(ret))

Fixed submission:
import numpy as np

N = int(input())
Ws = np.array(list(map(int,input().split())))

ret = []
for i in range(N):
  s1 = Ws[:i+1].sum()
  s2 = Ws[i+1:].sum()
  ret.append(abs(s1-s2))
  
print(min(ret))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

inp = input().split()
N = int(inp[0])
K = int(inp[1])

S = input()

ch:str = S[K - 1]


print(S[:K - 1] + ch.lower() + S[K:])



Fixed submission:
# coding: utf-8
# Your code here!

inp = input().split()
N = int(inp[0])
K = int(inp[1])

S = input()

ch = S[K - 1]

print(S[:K - 1] + ch.lower() + S[K:])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!


S:str = input()

a = int(S[:2])
b = int(S[2:])

if a > 12 and b <= 12 and b > 0:
    print("YYMM")
elif a <= 12 and b > 12 and a > 0:
    print("MMYY")
elif a <= 12 and b <= 12 and a > 0 and b > 0:
    print("AMBIGUOUS")
else:
    print("NA")



Fixed submission:
# coding: utf-8
# Your code here!


S = input()

a = int(S[:2])
b = int(S[2:])

if a > 12 and b <= 12 and b > 0:
    print("YYMM")
elif a <= 12 and b > 12 and a > 0:
    print("MMYY")
elif a <= 12 and b <= 12 and a > 0 and b > 0:
    print("AMBIGUOUS")
elif a == 0 and b <= 12 and b > 0:
    print("YYMM")
elif b == 0 and a <= 12 and a > 0:
    print("MMYY")
else:
    print("NA")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

inp: str = input()

input_list = inp.split()

a = int(input_list[0])
b = int(input_list[1])

count = 0

for i in range(2):
    if a < b:
        count += b
        b -= 1
    else:
        count += a
        a -= 1

print(count)



Fixed submission:
# coding: utf-8
# Your code here!

inp = input()

input_list = inp.split()

a = int(input_list[0])
b = int(input_list[1])

count = 0

for i in range(2):
    if a < b:
        count += b
        b -= 1
    else:
        count += a
        a -= 1

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int,input().split()))
m = sum(W)

for j in range(N-1):
    W1 = W[:j+1]
    W2 = W[j+1:N]
    s = abs(sum(W1) - sum(W2))
    m = min(m, s)

print(m)


Fixed submission:
P,Q,R = map(int, input().split())
A = [P+Q, P+R, R+Q]
print(min(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min = N
i = 0
for i in range(N + 1):
    b = S[:i]
    f = S[i:]
    T = b.count('#') + f.count('.')
    if T < min:
        min = T

print(min)

Fixed submission:
N = int(input())
S = input()
i = 0
b = S.count('.')
w = 0
min = b
for i in range(N):
    if S[i] == '#':
        w += 1
    else:
        b -= 1
    
    T = b + w
    if T < min:
        min = T

print(min)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min = N
i = 0
for i in range(N + 1):
    b = S[:i]
    f = S[i:]
    T = b.count('#') + f.count('.')
    if T < min:
        min = T

print(min)

Fixed submission:
N = int(input())
S = input()
i = 0
b = S.count('.')
w = 0
min = b
for i in range(N):
    if S[i] == '#':
        w += 1
    else:
        b -= 1
    
    T = b + w
    if T < min:
        min = T

print(min)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 0
i = 0
while S[i] == '.':
    i += 1

j = i

for i in range(N - j):
    if S[i] == '.':
        cnt += 1
        
print(cnt)

Fixed submission:
N = int(input())
S = input()
i = 0
b = S.count('.')
w = 0
min = b
for i in range(N):
    if S[i] == '#':
        w += 1
    else:
        b -= 1
    
    T = b + w
    if T < min:
        min = T

print(min)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 0
if S[0] == '#' and S[1] == '.':
    S.replace(S[0], '.')
    cnt += 1

i = 1
for i in range(N - 2):
    if S[i] == '#' and S[i + 1] == '.':
        if S[i - 1] == '.':
            S.replace(S[i], '.')
        else:
            S.replace(S[i + 1], '#')        
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
i = 0
b = S.count('.')
w = 0
min = b
for i in range(N):
    if S[i] == '#':
        w += 1
    else:
        b -= 1
    
    T = b + w
    if T < min:
        min = T

print(min)
Buggy python submission (verdict: Runtime Error):
import math
N,K=map(int,input().split())

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

for i in range(1,K+1):
    print((combinations_count(N-K+1,i)%1000000007)*(combinations_count(K-1,i-1)%1000000007)%1000000007)

Fixed submission:
import math
N,K=map(int,input().split())

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

for i in range(1,K+1):
    if i>min(K,N-K+1):print(0)
    else:print(((combinations_count(N-K+1,i))*(combinations_count(K-1,i-1)))%1000000007)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[]
for _ in [0]*M:
    a.append(int(input()))

stepsum=[1]   #k段目までの組み合わせ
if a[0]==1:   #1段目がNGなら
    stepsum.append(0)
else:
    stepsum.append(1)
    
for i in range(2,N+1):
    stepsum.append(((stepsum[i-1]+stepsum[i-2])*(not(i in a)))%1000000007)

ans=stepsum[N]%1000000007
print(ans)

Fixed submission:
N,M=map(int,input().split())
a=[]
for _ in [0]*M:
    a.append(int(input()))

a.append(N+1)    

step=[]

if a[0]==1:j=1
else:j=0

for i in range(2,N+1):
    if i <a[j]:
        step.append(i)
    else:
        step.append(0)
        j+=1

stepsum=[1]   #k段目までの組み合わせ
if a[0]==1:   #1段目がNGなら
    stepsum.append(0)
else:
    stepsum.append(1)
    
for i in step:
    if i==0:stepsum.append(0)
    else:stepsum.append(((stepsum[i-1]+stepsum[i-2]))%1000000007)


ans=stepsum[N]%1000000007
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[]
for _ in [0]*M:
    a.append(int(input()))

stepsum=[1]   #k段目までの組み合わせ
if a[0]==1:   #1段目がNGなら
    stepsum.append(0)
else:
    stepsum.append(1)
    
for i in range(2,N+1):
    stepsum.append((stepsum[i-1]+stepsum[i-2])*(not(i in a)))

ans=stepsum[N]%1000000007
print(ans)

Fixed submission:
N,M=map(int,input().split())
a=[]
for _ in [0]*M:
    a.append(int(input()))

a.append(N+1)    

step=[]

if a[0]==1:j=1
else:j=0

for i in range(2,N+1):
    if i <a[j]:
        step.append(i)
    else:
        step.append(0)
        j+=1

stepsum=[1]   #k段目までの組み合わせ
if a[0]==1:   #1段目がNGなら
    stepsum.append(0)
else:
    stepsum.append(1)
    
for i in step:
    if i==0:stepsum.append(0)
    else:stepsum.append(((stepsum[i-1]+stepsum[i-2]))%1000000007)


ans=stepsum[N]%1000000007
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
Sinput=input()
S=[]
for i in range(len(Sinput)):
    S.append(int(Sinput[i]))
Smax=0
human=[]
counter=1
if S[0]==0:
    human.append(0)
for i in range(1,len(S)):
    if S[i-1]!=S[i]:
        human.append(counter)
        counter=1
    else:
        counter+=1
human.append(counter)
if len(human)%2==0:
    human.append(0)

#奇数番目が０の個数、偶数番目が１の個数
if K>=len(human)//2:
    ans=len(S)
else:
    for i in range(len(human)//2-K+1):
        if sum(human[i*2:(i+K)*2+1])>=Smax:
            Smax=sum(human[i*2:(i+K)*2+1])
    ans=Smax
print(ans)

Fixed submission:
N,K=map(int,input().split())
Sinput=input()
S=[]
for i in range(len(Sinput)):
    S.append(int(Sinput[i]))
Smax=0
human=[]
humansum=[0]
counter=1
if S[0]==0:
    human.append(0)
for i in range(1,len(S)):
    if S[i-1]!=S[i]:
        human.append(counter)
        counter=1
    else:
        counter+=1
human.append(counter)
if len(human)%2==0:
    human.append(0)

#奇数番目が０の個数、偶数番目が１の個数
for i in range(len(human)):
    humansum.append(human[i]+humansum[i])

if K>=len(human)//2:
    ans=len(S)
else:
    for i in range(len(human)//2-K+1):
        Smax = max(Smax,humansum[(i+K)*2+1]-humansum[i*2])
    ans=Smax
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
ans=A
for i in range(A+1,B+1):
    ans=ans^i
print(ans)

Fixed submission:
A,B=map(int,input().split())

def func(n):
    ans=0
    if n>0:
        for i in range((n//4)*4,n+1):
            ans ^= i
        return ans
    else:return 0

print(func(A-1)^func(B))
Buggy python submission (verdict: Runtime Error):
import math

line = input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
temp = 0

for i, num in enumerate(num_list):
    if i+1 < len(num_list) -1:
        break
    temp = math.gcd(num, num_list[i + 1])


for num in num_list:
    ans += (temp-1) % num

print(ans)

Fixed submission:
line = input()
line= input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
for num in num_list:
    ans = ans + (num-1)

print(ans)
Buggy python submission (verdict: Runtime Error):
import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
n,d = R()
xs = [list(R()) for _ in range(n)]

def dist(y,z):
    return math.sqrt(sum([(y[i]-z[i])**2 for i in range(d)]))


count = 0
for i in range(n):
    for j in range(i+1,n):
        d = dist(xs[i],xs[j])
        if int(d)==d:
            count+=1
print(count)

Fixed submission:
# import atexit
# import io
# import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math

N, D = map(int, input().split())
Xs = [list(map(int, input().split())) for _ in range(N)]


def dist(y, z):
    return math.sqrt(sum([(y[i] - z[i]) * (y[i] - z[i]) for i in range(D)]))


count = 0
for i in range(N):
    for j in range(i + 1, N):
        d = dist(Xs[i], Xs[j])
        if int(d) == d:
            count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math
R = lambda : map(int,input().split())
n,d = R()
xs = [list(R()) for _ in range(n)]

def dist(y,z):
    return math.sqrt(sum([(y[i]-z[i])**2 for i in range(d)]))


count = 0
for i in range(n):
    for j in range(i+1,n):
        d = dist(xs[i],xs[j])
        if int(d)==d:
            count+=1
print(count)

Fixed submission:
# import atexit
# import io
# import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math

N, D = map(int, input().split())
Xs = [list(map(int, input().split())) for _ in range(N)]


def dist(y, z):
    return math.sqrt(sum([(y[i] - z[i]) * (y[i] - z[i]) for i in range(D)]))


count = 0
for i in range(N):
    for j in range(i + 1, N):
        d = dist(Xs[i], Xs[j])
        if int(d) == d:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
# import atexit
# import io
import sys
#
 _INPUT_LINES = sys.stdin.read().splitlines()
 input = iter(_INPUT_LINES).__next__
 _OUTPUT_BUFFER = io.StringIO()
 sys.stdout = _OUTPUT_BUFFER
#

 @atexit.register
 def write():
     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math
ans = sys.maxsize
n,k = R()
for i in range(n,k+1):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
          print(ans)
          exit()

print(ans)

Fixed submission:
import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import atexit
# import io
import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math
ans = sys.maxsize
n,k = R()
for i in range(n,k+1):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)

print(ans)

Fixed submission:
import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                break
    print(res)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                print(res)
                return
    print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappushpop


def main():
    x, y, z, k = map(int, input().split())
    aa = sorted(map(int, input().split()), reverse=True)
    bb = sorted(map(int, input().split()), reverse=True)
    cc = sorted(map(int, input().split()), reverse=True)

    heap = []
    for a in aa:
        if len(heap) == k and a + bb[0] + cc[0] < heap[0]:
            break
        for b in bb:
            if len(heap) == k and a + b + cc[0] < heap[0]:
                break
            for c in cc:
                v = a + b + c
                if len(heap) < k:
                    heappush(heap, v)
                    continue
                if v < heap[0]:
                    break
                heappushpop(heap, v)

    for v in sorted(heap, reverse=True):
        print(v)


if __name__ == "__main__":
    main()


Fixed submission:
from heapq import heappop, heappush


def main():
    x, y, z, k = map(int, input().split())
    aa = sorted(map(int, input().split()))
    bb = sorted(map(int, input().split()))
    cc = sorted(map(int, input().split()))
    v = aa[-1] + bb[-1] + cc[-1]
    t = (len(aa) - 1, len(bb) - 1, len(cc) - 1)
    q = [(-v, t)]
    vs = []
    ts = set()
    while len(vs) < k:
        nv, t = heappop(q)
        if t in ts:
            continue
        vs.append(-nv)
        ts.add(t)
        if t[0] > 0:
            heappush(q, (-(aa[t[0] - 1] + bb[t[1]] + cc[t[2]]), (t[0] - 1, t[1], t[2])))
        if t[1] > 0:
            heappush(q, (-(aa[t[0]] + bb[t[1] - 1] + cc[t[2]]), (t[0], t[1] - 1, t[2])))
        if t[2] > 0:
            heappush(q, (-(aa[t[0]] + bb[t[1]] + cc[t[2] - 1]), (t[0], t[1], t[2] - 1)))
    for v in vs:
        print(v)


if __name__ == "__main__":
    main()