Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
  a = list(input().split())
  if len(a)==1:
    S = S[::-1]
  else:
    if int(a[1]) == 1:
      S = a[2]+S
    else:
      S = S+a[2]
print(S)

Fixed submission:
from collections import deque
s=input()
q=int(input())
turn=0
ans=deque(s)
for i in range(q):
    query=input().split()
    if query[0]=="1":
        turn+=1
    if query[0]=="2":
        if query[1]=="1":
            if turn%2==0:
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
        elif query[1]=="2":
            if turn%2==0:
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
ans="".join(ans)
if turn%2==1:
    ans=ans[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
num = ["9"]*N
l = [list(map(int,input().split())) for i in range(M)]
l = sorted(l)
if N == 1 and l[0][0]==1 and l[0][1] == 0:
  print(0)
  exit()
for i in range(M):
  if l[i][0] == 1 and l[i][1] == 0:
    print(-1)
    exit()
  if i < M-1 and l[i][0] == l[i+1][0] and l[i][1] != l[i+1][1]:
    print(-1)
    exit()
  num[l[i][0]-1] = l[i][1]
for i in range(N):
  if num[i] == "9" and i != 0:
    num[i] = 0
  elif num[i] == "9" and i == 0:
    num[i] = 1
print("".join(map(str,num)))

Fixed submission:
N, M = map(int,input().split())
num = ["9"]*N
if M == 0:
  if N == 1:
    print(0)
    exit()
  for i in range(N):
    if i == 0:
      num[i] = 1
    else:
      num[i] = 0
  print("".join(map(str,num)))
  exit()
l = [list(map(int,input().split())) for i in range(M)]
l = sorted(l)
if N == 1 and l[0][0]==1 and l[0][1] == 0:
  print(0)
  exit()
for i in range(M):
  if l[i][0] == 1 and l[i][1] == 0:
    print(-1)
    exit()
  if i < M-1 and l[i][0] == l[i+1][0] and l[i][1] != l[i+1][1]:
    print(-1)
    exit()
  num[l[i][0]-1] = l[i][1]
for i in range(N):
  if num[i] == "9" and i != 0:
    num[i] = 0
  elif num[i] == "9" and i == 0:
    num[i] = 1
print("".join(map(str,num)))
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
A = [0]*n
for i in range(1, n+1):
    if i <= k:
        A[i] = s
    else:
        if s == 10**9:
          A[i] = 1
        else:
          A[i] = 10**9
print(*A)

Fixed submission:
H = int(input())
W = int(input())
N = int(input())
if N%max(H,W)==0:
  print(N//max(H,W))
else:
  print(N//max(H,W)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr)
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
for i in range(N):
  for j in range(i+1,N):
    if F[i]:
      if P[i][1] > P[j][0]:
        F[j] = False
      else:
        break
print(F.count(True))


Fixed submission:
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
P = sorted(P,key=lambda x:x[1])
ind = 0
for i in range(1,N):
  if P[i][0] < P[ind][1]:
    F[i] = False
  else:
    ind = i
print(F.count(True))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
for i in range(N):
  for j in range(i+1,N):
    if F[i]:
      if P[i][1] > P[j][0]:
        F[j] = False
      elif P[i][1] <= P[j][0]:
        break
print(F.count(True))


Fixed submission:
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
P = sorted(P,key=lambda x:x[1])
ind = 0
for i in range(1,N):
  if P[i][0] < P[ind][1]:
    F[i] = False
  else:
    ind = i
print(F.count(True))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
for i in range(N):
  for j in range(i+1,N):
    if F[i]:
      if P[i][1] > P[j][0]:
        F[j] = False
      elif P[i][1] <= P[j][0]:
        break
print(F.count(True))

Fixed submission:
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
P = sorted(P,key=lambda x:x[1])
ind = 0
for i in range(1,N):
  if P[i][0] < P[ind][1]:
    F[i] = False
  else:
    ind = i
print(F.count(True))
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
A = [0]*n
for i in range(1, n+1):
    if i <= k:
        A[i] = s
    else:
        if s == 10**9:
          A[i] = 1
        else:
          A[i] = 10**9
print(*A)


Fixed submission:
n, k, s = map(int, input().split())

for i in range(1, n+1):
    if i <= k:
        print(s)
    else:
        if s == 10**9:
            print(1)
        else:
            print(10**9)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
P = []
S = []
for i in range(M):
  p, s = input().split()
  P.append(int(p))
  S.append(s)
d = defaultdict(int)
d1 = defaultdict(int)
for i in range(M):
  if S[i] == "WA":
    if d[P[i]] != 1:
      d1[P[i]] += 1
  elif S[i] == "AC":
    d[P[i]] = 1
for i in range(M):
  if d[P[i]] == 0 and d1[P[i]] > 0:
    d1[P[i]] = 0
print(sum(d.values()), sum(d1.values()))

Fixed submission:
c=input()
l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(l)):
  if l[i] == c:
    print(l[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int,input().split())
A = [int(i) for i in input().split()]
ans = 0
for i in itertools.combinations(A, K):
  ans += max(i)-min(i)
print(ans%(10**9+7))

Fixed submission:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)  

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
ans = 0
for i in range(n-k+1):
    ans += (a[-1-i] - a[i]) * cmb(n-1-i, k-1, p)
    ans %= p
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
for i in range(n):
    if (x//a[i])%2==0:
        print(0)
        exit()
p = m//x
print(p//2 if p%2==0 else p//2+1)

Fixed submission:
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
for i in range(n):
    if (x//a[i])%2==0:
        print(0)
        exit()
p = m//x
print(p//2 if p%2==0 else p//2+1)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
def get_primenumber(N):
    if N == 2:
      return 2
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,10**6,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)
        if num >= N:
          return num
print(get_primenumber(X))
 

Fixed submission:
import math
X = int(input())
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
l = get_primenumber(10**6)
for i in range(X,10**6):
  if i in l:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = str(N)[0]+"0"
if N%2==1:
  print(0)
else:
  if N >= 24:
    print(int(a)**(len(str(N))-2)+25*10**(len(str(N))-4)-5)
  else:
    print(int(a)**(len(str(N))-2))

Fixed submission:
N = int(input())
num = 10
cnt = 0
if N%2!=0:
  print(0)
  exit()
for i in range(1, N+1):
  cnt += N//num
  num = num*5
  if num > N:
    break
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = str(N)[0]+"0"
if N%2==1:
  print(0)
else:
  if N >= 24:
    print(int(a)**(len(str(N))-1)+25*10**(len(str(N))-3)-5)
  else:
    print(int(a)**(len(str(N))-2))

Fixed submission:
N = int(input())
num = 10
cnt = 0
if N%2!=0:
  print(0)
  exit()
for i in range(1, N+1):
  cnt += N//num
  num = num*5
  if num > N:
    break
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
  s1 = s[:n/2+1]
  s2 = s[n/2+1:]
  if s1 == s2:
    print("Yes")
  else:
    print("No")

Fixed submission:
n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
  s1 = s[:(n//2)]
  s2 = s[(n//2):]
  if s1 == s2:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
X, Y = map(int,input().split())
ans = 0
start = [0, 0]
move = [[1, 2], [2, 1]]
queue = deque()
queue.append(start)
while queue:
  x, y = queue.popleft()
  for i in range(len(move)):
    nextX = x + move[i][0]
    nextY = y + move[i][1]
    if nextX == X and nextY == Y:
      ans += 1
    if nextX < X and nextY < Y:
      queue.append([nextX, nextY])
print(ans%(10**9+7))


Fixed submission:
X, Y = map(int,input().split())
n = int((2*Y-X)/3)
m = int((2*X-Y)/3)
if (X+Y)%3!=0:
  print(0)
  exit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print(cmb(n+m, n, p))

Buggy python submission (verdict: Runtime Error):
import math
X, Y = map(int,input().split())
n = (2*Y-X)//3
m = (2*X-Y)//3
if n < 0 or m < 0:
  print(0)
else:
  print((math.factorial(n+m)/(math.factorial(n)*math.factorial(m)))%(10**9+7))

Fixed submission:
X, Y = map(int,input().split())
n = int((2*Y-X)/3)
m = int((2*X-Y)/3)
if (X+Y)%3!=0:
  print(0)
  exit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print(cmb(n+m, n, p))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
X, Y = map(int,input().split())
ans = 0
start = [0, 0]
move = [[1, 2], [2, 1]]
queue = deque()
queue.append(start)
while queue:
  x, y = queue.popleft()
  for i in range(len(move)):
    nextX = x + move[i][0]
    nextY = y + move[i][1]
    #print(i,nextX, nextY)
    if nextX == X and nextY == Y:
      ans += 1
    if nextX < X and nextY < Y:
      queue.append([nextX, nextY])
print(ans%(10**9+7))

Fixed submission:
X, Y = map(int,input().split())
n = int((2*Y-X)/3)
m = int((2*X-Y)/3)
if (X+Y)%3!=0:
  print(0)
  exit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print(cmb(n+m, n, p))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
n1 = int(math.sqrt(n))
cnt = 10**18
for i in range(1, n1+1):
  if n % i == 0:
      j = (n/i) - 1
      ans = i-1
      cnt = min(cnt, j+ans)
  else:
    continue
print(int(cnt))

Fixed submission:
a, b = map(int,input().split())
if 1 <= a <= 9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
L = list(map(int,input().split()))
cnt = 0
for i in itertools.combinations(L, 3):
  if i[0] < i[1]+i[2] and i[1] < i[0]+i[2] and i[2] < i[0]+i[1]:
    cnt += 1
print(cnt)

Fixed submission:
import bisect
n = int(input())
L = sorted(((map(int,input().split()))))
#print(L)
cnt = 0
for i in range(n):
  for j in range(i+1,n):
    num = L[i] + L[j]
    b = bisect.bisect_left(L, num)
    #print(L[i], L[j], b, cnt)
    if b-1 > j:
      cnt += b-1-j
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(int(n*(n-1)/2))

Fixed submission:
s = input()
t = input()
cnt = 0
for i in range(3):
  if s[i] == t[i]:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n = int(input())
a = list(accumulate(range(n)))
print(a[-1])

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
m = n // 2
if n%2==1:
  for i in range(1, m+1):
    ans += (i%(i+1)+(m+i)%(m+i+1))
else:
  for i in range(1, m+1):
    ans += (i%(i+1)+(m+i)%(m+i+1))
    if i == m:
      ans -= m*2
print(ans) 

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(1,int(input()))))


Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
print(sum(range(1,int(input())))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
P = list(range(1,n+1))
for i in range(1, n+1):
  if i == n:
    break
  ans += i%(P[i])
print(ans)  

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
arr = [input() for _ in range(n)]
count = 0
for i in range(n-1):
  c1 = collections.Counter(arr[i])
  for j in range(i+1,n):
    c2 = collections.Counter(arr[j])
    if c1 == c2:
      count += 1
print(count)

Fixed submission:
n = int(input())
arr = []
for i in range(n):
  arr.append("".join(sorted(input())))
arr1 = sorted(arr)
count = 0
b1 = arr1[0]
l = []
for i in range(n-1):
  b2 = arr1[i+1]
  if b2 == b1:
    count += 1
    if i == n-2:
      l.append(count)
  else:
    l.append(count)
    count = 0
  b1 = b2
sums = 0
for j in l:
  for k in range(1,j+1):
    sums += k
print(sums)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
l = [False]*(sum(range(1, n)))
a = 0
for j in range(n):
  for i in range(j+1,n):
    if h[j] <= h[i]:
      l[a] = True
    else:
      if h[j]-1-h[i] < 1:
        l[a] = True
    a += 1
print("Yes" if l.count(False)==0 else "No")

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,-1,-1):
  if arr[i]>arr[i+1]:
    arr[i]-=1
    if arr[i]>arr[i+1]:
      print('No')
      break
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
l = [False]*(sum(range(1, n)))
a = 0
for j in range(n):
  for i in range(j+1,n):
    if h[j] <= h[i]:
      l[a] = True
    else:
      if h[j]-1-h[i] < 1:
        l[a] = True
      else:
        continue
    a += 1
if l.count(False) == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,-1,-1):
  if arr[i]>arr[i+1]:
    arr[i]-=1
    if arr[i]>arr[i+1]:
      print('No')
      break
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans, surplus = 0, 0
for i in range(N):
    tmp = min(A[i], surplus)
    ans += tmp
    A[i] -= tmp
    if B[i] > A[i]:
        ans += A[i]
        surplus = B[i] - A[i]
    else:
        ans += B[i]
        surplus = 0
tmp = min(A[N], surplus)
ans += tmp
print(ans)

Fixed submission:
a,b = map(int, input().split())
if (a+b) % 2 == 0:
  print(int((a+b)/2))
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = [int(i) for i in input().split()]
S = [0]*N
cnt = 0
for i in range(N-1, -1, -1):
  A = S[i::i+1]
  if sum(A)%2 == B[i]:
    continue
  elif sum(A)%2 == 0 and B[i] == 1:
    S[i] += 1
    cnt += 1
  elif sum(A)%2 == 1 and B[i] == 0:
    S[i] += 1
    cnt += 1
print(cnt)
for i in range(N):
  if S[i] == 1:
    print(i+1, end=" ")

Fixed submission:
a = int(input())
print(3*a**2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(input()) for i in range(n)]
for i in l:
  if i == max(l):
    print(sorted(l)[-2])
  else:
    print(max(l))


Fixed submission:
n = int(input())
l = [int(input()) for i in range(n)]
a = max(l)
b = sorted(l)[-2]
for i in l:
  print(b if i == a else a)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
l = [int(input()) for i in range(n)]
l1 = copy.copy(l)
for i in range(len(l1)):
  del l[i]
  print(max(l))
  l = copy.copy(l1)


Fixed submission:
n = int(input())
l = [int(input()) for i in range(n)]
a = max(l)
b = sorted(l)[-2]
for i in l:
  print(b if i == a else a)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
l = [int(input()) for i in range(n)]
l1 = copy.deepcopy(l)
for i in range(len(l1)):
  l.remove(l[i])
  print(max(l))
  l = copy.copy(l1)



Fixed submission:
n = int(input())
l = [int(input()) for i in range(n)]
a = max(l)
b = sorted(l)[-2]
for i in l:
  print(b if i == a else a)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int,input().split())
arr = []
if r-l < 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
  print(min(arr))
else:
  print(0)

Fixed submission:
l, r = map(int,input().split())
arr = []
if r-l < 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
    if 0 in arr:
      break
  print(min(arr))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int,input().split())
arr = []
if r-l <= 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
  print(min(arr))
else:
  print(0)

Fixed submission:
l, r = map(int,input().split())
arr = []
if r-l < 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
    if 0 in arr:
      break
  print(min(arr))
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int,input().split())
arr = []
if r-l <= 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
  print(min(arr))
else:
  for i in range(l,2019**2+l):
    for j in range(i+1, 2019**2+l+1):
      a = (i*j)%2019
      arr.append(a)
    if 0 in arr:
      break
  print(min(arr))

Fixed submission:
l, r = map(int,input().split())
arr = []
if r-l < 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
    if 0 in arr:
      break
  print(min(arr))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n, k = map(int, input().split())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
p = 10 ** 9 + 7
N = 10 ** 6 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)
for i in range(1, k+1):
  print(cmb(n-k+1, i, p) * comb(k-1, i-1)%p)

Fixed submission:
n, k = map(int, input().split())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)
for i in range(1, k+1):
  print(cmb(n-k+1, i, p) * cmb(k-1, i-1, p) % p)
Buggy python submission (verdict: Runtime Error):
import fractions
import math
def custom_round(number, ndigits=0):
    if type(number) == int:
        return number
    d_point = len(str(number).split('.')[1])
    if ndigits >= d_point:
        return number
    c = (10 ** d_point) * 2 
    return round((number * c + 1) / c, ndigits)
a, b, c, d = map(int,input().split())
c1 = a / c
c2 = b / c
d1 = a / d
d2 = b / d
e1 = custom_round(c2-c1)
e2 = custom_round(d2-d1)
lcm = c * d // fractions.gcd(c, d)
lcm1 = a / lcm
lcm2 = b / lcm
e3 = custom_round(lcm2-lcm1)
sum = e1+e2-e3
print(int(b-a+1-sum))

Fixed submission:
from functools import reduce
from fractions import gcd
def lcm(x,y):return x*y//gcd(x,y)
def lcmm(l):return reduce(lcm,l)
a,b,c,d = map(int,input().split())
l =[c, d]
num = a // c
if a%c==0:
  num -= 1
num1 = b // c
num2 = a // d
if a%d==0:
  num2 -= 1
num3 = b// d
e = lcmm(l)
num4 = a // e
if a%e==0:
  num4 -= 1
num5 = b // e
print((b-a+1)-((num1-num)+(num3-num2)-(num5-num4)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
a, b = map(int,input().split())
cnt = 0
for i in range(1, m):
  l, r = map(int,input().split())
  if (l > b and r > b) or (l < a and r < a):
    print(0)
    exit()
  if a<=l<=b:
    a = l
  if r <= b:
    b = r
print(b-a+1)

Fixed submission:
a, b = map(int,input().split())
if a <= 5:
  print(0)
elif 5 < a <= 12:
  print(int(b/2))
elif 13 <= a:
  print(b)