Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
sorted_a = sorted(a, reverse = True)
max_a = sorted_a[0]
cnt = 0
ans = 0
for i in range(n - 1):
    if a[i] == max_a:
        cnt += 1
        max_a = sorted_a[cnt]
    for j in range(a[i] + i + 1, min(n, a[i] + i + max_a + 1)):
        if a[i] + a[j] == j - i:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [0] * n
ans = 0
for i, j in enumerate(a):
    if i + j < n:
        dp[i + j] += 1
    if 0 < i - j:
        ans += dp[i - j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
ans = 0
for i in range(n - 1):
    if a[i] == max_a:
        max_a = max(a[i + 1:])
    for j in range(a[i] + i + 1, min(n, a[i] + i + max_a + 1)):
        if a[i] + a[j] == j - i:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [0] * n
ans = 0
for i, j in enumerate(a):
    if i + j < n:
        dp[i + j] += 1
    if 0 < i - j:
        ans += dp[i - j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] >= n - 1:
        continue
    for j in range(a[i] + i + 1, n):
        if a[i] + a[j] == j - i:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [0] * n
ans = 0
for i, j in enumerate(a):
    if i + j < n:
        dp[i + j] += 1
    if 0 < i - j:
        ans += dp[i - j]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = list(map(int, list(input())))
    m = [0]*2019
    num = 0
    ans = 0
    n = len(s)
    ten = 1
    for i in range(n):
        num += s[n-i-1]*ten
        num %= 2019
        m[num] += 1 
        ten = (ten*10)
    for mi in m:
        if mi:
            ans += (mi*(mi-1))//2
    ans += m[0]
    print(ans)
        
if __name__ == "__main__":
    main()


Fixed submission:
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = 0
digit = 1
for i in range(n):
    tmp += int(s[n-i-1]) * digit
    tmp %= 2019
    amari[tmp] += 1
    digit = (digit * 10) % 2019

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = ""
for i in range(1, n + 1):
    tmp = s[-i] + tmp
    amari[int(tmp) % 2019] += 1

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Fixed submission:
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = 0
digit = 1
for i in range(n):
    tmp += int(s[n-i-1]) * digit
    tmp %= 2019
    amari[tmp] += 1
    digit = (digit * 10) % 2019

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1

for i in range(n):
    amari[int(s[n-i-1:]) % 2019] += 1

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Fixed submission:
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = 0
digit = 1
for i in range(n):
    tmp += int(s[n-i-1]) * digit
    tmp %= 2019
    amari[tmp] += 1
    digit = (digit * 10) % 2019

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1

for i in range(n):
    amari[int(s[n-i-1:]) % 2019] += 1

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

Fixed submission:
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = 0
digit = 1
for i in range(n):
    tmp += int(s[n-i-1]) * digit
    tmp %= 2019
    amari[tmp] += 1
    digit = (digit * 10) % 2019

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
flag = 0
    
def dfs(x, y, cnt):
    global flag
    if x == w - 1 and y == h - 1:
        flag = 1
        return 
    
    dx = [1, 0]
    dy = [0, 1]

    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]
        
        
        if 0 <= nx <= w - 1 and 0 <= ny <= h - 1:
            if maze[ny][nx] == ".":
                dfs(nx, ny, cnt)
            elif maze[ny][nx] == "#" and cnt > 0:
                dfs(nx, ny, cnt - 1)

ans = 0

while ans < h * w:
    dfs(0, 0, ans)
    if flag == 1:
        break
    ans += 1
    
if maze[0][0] == "#":
    ans += 1
    
print(ans)

Fixed submission:
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

dp = [[0] * w for i in range(h)]

if maze[0][0] == "#":
    dp[0][0] = 1
    
for i in range(h):
    for j in range(w):
        if i == j == 0:
            continue
                
        if i == 0:
            if maze[0][j] != maze[0][j - 1]:
                dp[0][j] = dp[0][j - 1] + 1
            else:
                dp[0][j] = dp[0][j - 1]
        
        if j == 0:
            if maze[i][0] != maze[i - 1][0]:
                dp[i][0] = dp[i - 1][0] + 1
            else:
                dp[i][0] = dp[i - 1][0]
        
        if i != 0 and j != 0:
            tmp1 = 0
            tmp2 = 0
            if maze[i][j] != maze[i - 1][j]:
                tmp1 = 1
            if maze[i][j] != maze[i][j - 1]:
                tmp2 = 1
        
            dp[i][j] = min(dp[i - 1][j] + tmp1, dp[i][j - 1] + tmp2)

if maze[h - 1][w - 1] == "#":
    dp[h - 1][w - 1] += 1

ans = dp[h - 1][w - 1] // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
q = int(input())

for i in range(q):
    t = input()
    if len(t) == 1:
        s.reverse()
    else:
        if t[2] == "1":
            s.appendleft(t[4])
        else:
            s.append(t[4])

print(*s, sep="")



Fixed submission:
from collections import deque
s = deque(input())
q = int(input())
rev = 0

for i in range(q):
    t = input()
    if rev == 0:
        if len(t) == 1:
            rev = 1
        else:
            if t[2] == "1":
                s.appendleft(t[4])
            else:
                s.append(t[4])
    else:
        if len(t) == 1:
            rev = 0
        else:
            if t[2] == "1":
                s.append(t[4])
            else:
                s.appendleft(t[4])

if rev == 1:
    s.reverse()
print(*s, sep="")

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    t = input()
    if len(t) == 1:
        s = s[::-1]
    else:
        if t[2] == "1":
            s = t[4] + s
        else:
            s = s + t[4]

print(s)



Fixed submission:
from collections import deque
s = deque(input())
q = int(input())
rev = 0

for i in range(q):
    t = input()
    if rev == 0:
        if len(t) == 1:
            rev = 1
        else:
            if t[2] == "1":
                s.appendleft(t[4])
            else:
                s.append(t[4])
    else:
        if len(t) == 1:
            rev = 0
        else:
            if t[2] == "1":
                s.append(t[4])
            else:
                s.appendleft(t[4])

if rev == 1:
    s.reverse()
print(*s, sep="")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
new_p = []
temp = 0
temp_max = 0
    
for i in range(len(p) - k + 1):
    if temp_max < sum(p[i:i + k]):
        temp_max = sum(p[i:i + k])
        temp = i

for i in p[temp:temp + k]:
    new_p.append(((i * (i + 1)) / 2) / i)

print(sum(new_p)) 

Fixed submission:
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

new_p = []
temp = []
for i in p:
    new_p.append(((i * (i + 1)) / 2) / i)
q = [0] + new_p
q = list(accumulate(q))

for i in range(len(q) - k):
    temp.append(q[i + k] - q[i])
print(max(temp))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
new_p = []
temp = []

for i in p:
    new_p.append(((i * (i + 1)) / 2) / i)
    
for i in range(len(p) - k + 1):
    temp.append(sum(new_p[i:i + k]))

print(max(temp))    

Fixed submission:
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

new_p = []
temp = []
for i in p:
    new_p.append(((i * (i + 1)) / 2) / i)
q = [0] + new_p
q = list(accumulate(q))

for i in range(len(q) - k):
    temp.append(q[i + k] - q[i])
print(max(temp))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
if nums[0] == 1:
    print("1")
else:
    cnt = 1
    for i in range(1, n):
        if nums[i] < min(nums[:i]):
            cnt += 1
            if nums[i] == 2:
                cnt += 1
                break
            if nums[i] == 1:
                break
    print(cnt)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
if nums[0] == 1:
    print("1")
else:
    cnt = 1
    for i in range(1, n):
        if nums[i] < min(nums[:i]):
            cnt += 1
            if nums[i] == 1:
                break
    print(cnt)


Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
if nums[0] == 1:
    print("1")
else:
    cnt = 1
    for i in range(n - 1):
        if nums[i + 1] < min(nums[:i + 1]):
            cnt += 1
            if nums[i + 1] == 1:
                break
    print(cnt)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
if nums[0] == 1:
    print("1")
else:
    cnt = 1
    for i in range(n - 1):
        if nums[i + 1] < min(nums[:i + 1]):
            cnt += 1
            if nums[i + 1] == 1:
                break
    print(cnt)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
for i in range(n - 1):
    if nums[i + 1] < min(nums[:i + 1]):
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
for i in range(n - 1):
    if nums[i + 1] < min(nums[:i + 1]):
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
cnt = 1
min = nums[0]
for i in range(1, n):
    if nums[i] < min:
        min = nums[i]
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())

def count_ab(start, end):
    l = len(str(n))
    if start == 0:
        return 0
    if l == 1:
        if start == end:
            if n >= start:
                return 1
            else:
                return 0
        else:
            return 0
    else:
        if start == end:
            cnt = 1
        else:
            cnt = 0
        if int(str(n)[0]) > start:
            for i in range(1, l):
                cnt += 10 ** i // 10
        if int(str(n)[0]) == start:
            for i in range(1, l - 1):
                cnt += 10 ** i //10
            cnt += int(str(n)[1:]) // 10
            if int(str(n)[-1]) >= end:
                cnt += 1
        if int(str(n)[0]) < start:
            for i in range(1, l - 1):
                cnt += 10 ** i //10
        return cnt

ans = 0
for i in range(10):
    for j in range(10):
        A = count_ab(i, j)
        B = count_ab(j, i)
        ans += A * B

print(ans)
Buggy python submission (verdict: Runtime Error):
C = input()
alphabet = {1:"a", 2:"b", 3:"d", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])

Fixed submission:
C = input()
alphabet = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a, b)

Fixed submission:
a, b, k = map(int, input().split())
if a - k > 0:
    c = a - k
elif a - k <= 0:
    c = 0
    if b - (k - a) > 0:
        b -= (k - a)
    elif b - (k - a) <= 0:
        b = 0
print(c, b)
Buggy python submission (verdict: Runtime Error):
import math
print(int(math.sqrt(x)))
for i in range(2, int(math.sqrt(x)) + 2):
    if x % i == 0:
        x += 1
print(x)

Fixed submission:
n = int(input())
for i in range(n, 100004):
    flag = 0
    for j in range(2, int(i**0.5) + 1):
        if i % j == 0:
            flag = 1
            break
    if flag == 0:
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
pip install sympy 
x = int(input())
from sympy import nextprime
print(nextprime(x - 1))

Fixed submission:
n = int(input())
for i in range(n, 100004):
    flag = 0
    for j in range(2, int(i**0.5) + 1):
        if i % j == 0:
            flag = 1
            break
    if flag == 0:
        print(i)
        break

Buggy python submission (verdict: Runtime Error):
x = int(input())
from sympy import nextprime
print(nextprime(x - 1))

Fixed submission:
n = int(input())
for i in range(n, 100004):
    flag = 0
    for j in range(2, int(i**0.5) + 1):
        if i % j == 0:
            flag = 1
            break
    if flag == 0:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
c = min(a, b)
for i in range(c, a * b + 1):
    if i % a == 0 and i % b == 0:
        print(i)
        exit()

Fixed submission:
a, b = map(int, input().split())
c = a * b
d = min(a, b)
j = 1
for i in range(2, d + 1):
    j += 1
    if a % j == 0 and b % j == 0:
        c //= j
        a //= j
        b //= j
        j = 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
c = min(a, b)
for i in range(c, a * b + 1):
    if i % a == 0 and i % b == 0:
        print(i)
        exit()

Fixed submission:
a, b = map(int, input().split())
c = a * b
d = min(a, b)
j = 1
for i in range(2, d + 1):
    j += 1
    if a % j == 0 and b % j == 0:
        c //= j
        a //= j
        b //= j
        j = 1
print(c)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
if a > 9 or b > 9:
  print("-1")
else:
  print(a * b)

Fixed submission:
a, b = map(int, input().split())
if a > 9 or b > 9:
  print("-1")
else:
  print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
cnt = 0
l = list(map(int, input().split()))
for a, b, c in itertools.combinations(l, 3):
    if abs(b - c) < a < b + c:
        cnt += 1
print(cnt) 

Fixed submission:
import bisect
n = int(input())
cnt = 0
l = sorted(list(map(int, input().split())))
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        c_min = b + 1
        c_max = bisect.bisect_left(l, l[a] + l[b]) - 1
        cnt += c_max - c_min + 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
cnt = 0
l = list(map(int, input().split()))
for a, b, c in itertools.combinations(l, 3):
    if a < b + c and b < a + c and c < a + b:
        cnt += 1
print(cnt)

Fixed submission:
import bisect
n = int(input())
cnt = 0
l = sorted(list(map(int, input().split())))
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        c_min = b + 1
        c_max = bisect.bisect_left(l, l[a] + l[b]) - 1
        cnt += c_max - c_min + 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    del price[-1]
    m -= 1
    
print(sum(price))

Fixed submission:
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    price.pop(-1)
    m -= 1
    
print(sum(price))

Fixed submission:
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    price.pop(-1)
    m -= 1
    
print(sum(price))

Fixed submission:
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

if n == 1:
    price[0] //= (2 ** m)
else:
    while m >= 1:
        while price[-1] >= price[-2]:
            price[-1] //= 2
            m -= 1
        price.sort()
print(sum(price))

Fixed submission:
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    price[-1] //= 2
    m -= 1
    price.sort()
print(sum(price))

Fixed submission:
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 0
for i in range(n):
    ans += i

print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
lst = []
ans = 0

for i in range(n):
    s = input()
    c = sorted(collections.Counter(s).most_common())
    tmp_str = ""
    for i in c:
        tmp = str(i[1])
        tmp_str += i[0] + tmp
    lst.append(tmp_str)
    
d = collections.Counter(lst)
for i in d.values():
    if i >= 2:
        ans += combinations_count(i, 2)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
count_list = []
for i in range(n):
    s = input()
    c = sorted(Counter(s).items(), key = lambda x:x[0])
    tmp = ""
    for j in range(len(c)):
        tmp += c[j][0]
        tmp += str(c[j][1])
    count_list.append(tmp)

c = Counter(count_list)
ans = 0
for i in c.values():
    if i >= 2:
        ans += i * (i - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
lst = []
cnt = [0] * n
ans = 0

for i in range(n):
    s = input()
    c = collections.Counter(s)
    if c not in lst:
        lst.append(c)
    else:
        cnt[lst.index(c)] += 1

for i in cnt:
    if i != 0:
        ans += combinations_count(i+1, 2)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
count_list = []
for i in range(n):
    s = input()
    c = sorted(Counter(s).items(), key = lambda x:x[0])
    tmp = ""
    for j in range(len(c)):
        tmp += c[j][0]
        tmp += str(c[j][1])
    count_list.append(tmp)

c = Counter(count_list)
ans = 0
for i in c.values():
    if i >= 2:
        ans += i * (i - 1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            exit()
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
print(min(a * n, b))
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
    if ans == 0:
        break
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            break
print(ans)
            

Fixed submission:
# coding: utf-8
# Your code here!
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)