Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
strs = [sorted(str(input())) for _ in range(n)]

cnt = 0
for i in range(n):
  cnt += strs[i+1:].count(strs[i])
print(cnt)

Fixed submission:
n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
strs = [sorted(list(input())) for _ in range(n)]

cnt = 0
while len(strs) > 1:
  s = strs.pop()
  cnt += strs.count(s)
print(cnt)


Fixed submission:
n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
strs = [sorted(str(input())) for _ in range(n)]

cnt = 0
while len(strs) > 1:
  s = strs.pop()
  cnt += strs.count(s)
print(cnt)

Fixed submission:
n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
strs = [str(input()) for _ in range(n)]

cnt = 0
while len(strs) != 0:
  s = strs.pop()
  anagrams = set(["".join(a) for a in itertools.permutations(s)])
  for anag in anagrams:
    if anag in strs:
      cnt += 1

print(cnt)


Fixed submission:
n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
strs = [str(input()) for _ in range(n)]

cnt = 0
while len(strs) != 0:
  s = strs.pop()
  for anagram in set(itertools.permutations(s)):
    if "".join(anagram) in strs:
      cnt += 1
      
print(cnt)


Fixed submission:
n = int(input())
strs = ["".join(sorted(str(input()))) for _ in range(n)]

cache = {}
cnt = 0
for s in strs:
  if s in cache.keys():
    cnt = cnt + cache[s]
    cache[s] = cache[s] + 1
  else:
    cache[s] = 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):

ss = input()
l = [0 for i in range(len(ss))]

for i, s in enumerate(ss):
  p = i
  while ss[p] == ss[i]:
    p = p + (1 if ss[p] == "R" else -1)

  if (p-i)%2 == 0:
    l[p] = l[p] +1
  elif ss[p] == "L":
    l[p-1] = l[p-1] +1
  else:
    l[p+1] = l[p+1] +1

print(" ".join([str(c) for c in l]))

Fixed submission:

ss = input()
lr = [1]
ans = [0] * len(ss)

for s in ss[1:]:
  if lr[-1] > 0:
    if s == "R":
      lr[-1] += 1
    else:
      lr.append(-1)
  else:
    if s == "L":
      lr[-1] -= 1
    else:
      lr.append(1)

i = 0
for num in lr:
  is_r = (num > 0)
  num = abs(num)
  half = num // 2
  if is_r:
    i += num
    ans[i-1] += num - half
    ans[i] += half
  else:
    ans[i-1] += half
    ans[i] += num - half
    i += num

print(" ".join([str(c) for c in ans]))
Buggy python submission (verdict: Runtime Error):

inputs = [int(x) for x in input().split()]
n, k = inputs[0], inputs[1]
ls = [int(x) for x in input().split()]
s = sum(ls)

# https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
divisors = []
for i in range(1, int(s ** 0.5) + 1):
  if s % i == 0:
    divisors.append(i)
    if i != s // i:
      divisors.append(s // i)

divisors.sort(reverse=True)
ans = 1
for d in divisors:
  mods = sorted([l % d for l in ls if l % d != 0])
  opcnt = 0
  is_success = False
  # print("{}: {}".format(d, ", ".join([str(m) for m in mods])))
  while True:
    if mods[0] + mods[-1] < d:
      mods[-1] += mods[0]
      opcnt += mods[0]
      mods.pop(0)
    elif mods[0] + mods[-1] == d:
      opcnt += mods[0]
      mods.pop(0)
      mods.pop(-1)
    else:
      opcnt += (d - mods[-1])
      mods[0] -= (d - mods[-1])
      mods.pop(-1)
    # print("{}: {}".format(d, ", ".join([str(m) for m in mods])))

    if opcnt > k or len(mods) == 1:
      # print("opcnt: {}".format(opcnt))
      is_success = False
      break
    if len(mods) == 0:
      is_success = True
      ans = d
      # print("ans: {}, opcnt: {}".format(ans, opcnt))
      break

  if is_success:
    break

print(ans)

Fixed submission:
inputs = [int(x) for x in input().split()]
n, k = inputs[0], inputs[1]
ls = [int(x) for x in input().split()]
s = sum(ls)

# https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
divisors = []
for i in range(1, int(s ** 0.5) + 1):
  if s % i == 0:
    divisors.append(i)
    if i != s // i:
      divisors.append(s // i)

divisors.sort(reverse=True)
ans = 1
for d in divisors:
  mods = sorted([l % d for l in ls if l % d != 0])
  opcnt = 0
  is_success = False
  # print("{}: {}".format(d, ", ".join([str(m) for m in mods])))
  while True:
    if opcnt > k or len(mods) == 1:
      # print("opcnt: {}".format(opcnt))
      is_success = False
      break

    if len(mods) == 0:
      is_success = True
      ans = d
      # print("ans: {}, opcnt: {}".format(ans, opcnt))
      break

    if mods[0] + mods[-1] < d:
      mods[-1] += mods[0]
      opcnt += mods[0]
      mods.pop(0)
    elif mods[0] + mods[-1] == d:
      opcnt += mods[0]
      mods.pop(0)
      mods.pop(-1)
    else:
      opcnt += (d - mods[-1])
      mods[0] -= (d - mods[-1])
      mods.pop(-1)
    # print("{}: {}".format(d, ", ".join([str(m) for m in mods])))


  if is_success:
    break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = [int(input()) for _ in range(n)]
colors = {}
cnum = 0

colors[cnum] = arr[-1]
for a in arr[-2::-1]:
  for c in range(cnum + 1):
    if colors[c] > a:
      colors[c] = a
      break
  else:
    cnum += 1
    colors[cnum] = a

print(cnum+1)


Fixed submission:
import bisect

n = int(input())
arr = [int(input()) for _ in range(n)]
colors = []

colors.append(arr[-1])
cnum = len(colors)
for a in arr[-2::-1]:
  i = bisect.bisect_right(colors, a)
  if i < cnum:
    colors[i] = a
  else:
    colors.append(a)
    cnum += 1

print(cnum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cnt = {}
cnt2 = {}
check = []
for i in range(N):
  #print(cnt)
  if A[i] not in check:
    check.append(A[i])
    cnt[A[i]] = 0
    cnt2[A[i]] = 1
  else:
    cnt[A[i]] += cnt2[A[i]]
    cnt2[A[i]] += 1
ans = sum(cnt.values())
#print(ans, cnt, cnt2)
for i in range(N):
  print(ans - cnt2[A[i]]+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = {}
cnt2 = {}

for i in range(N):
  if A[i] in cnt2:
    cnt[A[i]] += cnt2[A[i]]
    cnt2[A[i]] += 1
  else:
    cnt[A[i]] = 0
    cnt2[A[i]] = 1
ans = sum(cnt.values())
#print(ans, cnt, cnt2)
for i in range(N):
  print(ans - cnt2[A[i]]+1)
Buggy python submission (verdict: Runtime Error):
s = int(input())
a = int(s**(1/2)) + 1
b = a**2 - s
if s = 10**18:
  print(" ".join(map(str, [0,0,10**9,0,0,10*9])))
else:
  print(" ".join(map(str, [0,0,a,1,b,a])))

Fixed submission:
s = int(input())
a = int(s**(1/2))
if s == a**2:
  b =0 
  print(" ".join(map(str, [0,0,a,1,b,a])))
elif a*(a+1) - s >= 0: 
  b = a*(a+1) - s
  print(" ".join(map(str, [0,0,a+1,1,b,a])))
else:
  b = (a+1)**2 - s
  print(" ".join(map(str, [0,0,a+1,1,b,a+1])))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
ans = 0
check = s.count("ABC")
while check > 0:
  ans += check
  s = s.replace("ABC","BCA")
  check = s.count("ABC")
print(ans)

Fixed submission:
s = str(input()).replace("BC", "D")

def f(s):
  ans = 0
  add = 0
  for i in range(len(s)):
    if s[i] == "A":
      add += 1
    if s[i] == "D":
      ans += add
  return ans

ans = 0
j = 0
for i in range(1, len(s)):
  if s[i] == "B" or s[i] == "C":
    ans += f(s[j:i])
    j = i
ans += f(s[j:])

print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
L = []
if n == 2:
  print(max(a))
else:
  for i in range(n):
    b = [_ for _ in a if _ != a[i]]
    L.append(gcd_list(b))

  print(max(L))

Fixed submission:
from functools import reduce
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
if n == 2:
  print(max(a))
else:
  p = gcd_list(a[:3])
  q = max([gcd(a[0], a[1]), gcd(a[0], a[2]), gcd(a[1], a[2])])
  for i in range(3, n):
    q = max([p, gcd(q, a[i])])
    p = gcd(p, a[i])
    
  print(q)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = str(input())
Sb = []
zero = 0
for i in range(n):
  if int(s[i]):
    if len(Sb) == 0 or Sb[-1][0] == 0:
      Sb.append([1, 1])
    else:
      Sb[-1][1] += 1
  else:
    if len(Sb) == 0 or Sb[-1][0]:
      Sb.append([0, 1])
      zero += 1
    else:
      Sb[-1][1] += 1
if zero <= k:
  print(n)
else:
  if Sb[0][0] != 1:
    Sb.insert(0, [1, 0])
  if Sb[-1][0] != 1:
    Sb.append([1, 0])
  tmp = ans
  for i in range(zero - k):
    tmp += Sb[2 * k + 2 * (i+1)][1] + Sb[2 * k + 2 * (i+1) - 1][1] - Sb[2 * i][1] - Sb[2 * i + 1][1]
    ans = max(ans, tmp)
  print(ans)

Fixed submission:
n, k = map(int, input().split())
s = str(input())
Sb = []
zero = 0
for i in range(n):
  if int(s[i]):
    if len(Sb) == 0 or Sb[-1][0] == 0:
      Sb.append([1, 1])
    else:
      Sb[-1][1] += 1
  else:
    if len(Sb) == 0 or Sb[-1][0]:
      Sb.append([0, 1])
      zero += 1
    else:
      Sb[-1][1] += 1
if zero <= k:
  print(n)
else:
  if Sb[0][0] != 1:
    Sb.insert(0, [1, 0])
  if Sb[-1][0] != 1:
    Sb.append([1, 0])
  ans = sum([Sb[i][1] for i in range(2 * k + 1)])
  tmp = ans
  for i in range(zero - k):
    tmp += Sb[2 * k + 2 * (i+1)][1] + Sb[2 * k + 2 * (i+1) - 1][1] - Sb[2 * i][1] - Sb[2 * i + 1][1]
    ans = max(ans, tmp)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(str(input()))
dp = [0] * n
for j in range(n-1):
  if s[j] == "A" and s[j+1] == "C":
      dp[j] = 0.4
      dp[j+1] = 0.6
for i in range(q):
  l, r = map(int, input().split())
  c = dp[l-1: r]
  if c[0] == 0.6:
    c[0] = 0
  if c[-1] == 0.4:
    c[-1] = 0
  print(int(sum(c)))

Fixed submission:
n, q = map(int, input().split())
s = list(str(input()))
dp = [0] * n
for j in range(n-1):
  if s[j] == "A" and s[j+1] == "C":
    dp[j+1] = 1 + dp[j]
  else:
    dp[j + 1] = dp[j]
for i in range(q):
  l, r = map(int, input().split())
  print(dp[r-1] - dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(str(input()))

for i in range(q):
  ans = 0
  l, r = map(int, input().split())
  c = s[l-1: r]
  for j in range(r-l):
    if c[j] == "A" and c[j+1] == "C":
      ans +=1
  print(ans)    

Fixed submission:
n, q = map(int, input().split())
s = list(str(input()))
dp = [0] * n
for j in range(n-1):
  if s[j] == "A" and s[j+1] == "C":
    dp[j+1] = 1 + dp[j]
  else:
    dp[j + 1] = dp[j]
for i in range(q):
  l, r = map(int, input().split())
  print(dp[r-1] - dp[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 10**9 + 7
def check(L4):
  for i in range(4):
    t = list(L4)
    if i > 0:
      t[i], t[i-1] = t[i-1], t[i]
    if "".join(t).count("AGC") >= 1:
      return False
  return True
def dfs(d, L3):
  if d >= n:
    return 1
  ret = 0
  for L in list("ACGT"):
    L4 = "".join([L3, L])
    if check(L4):
      ret += dfs(d + 1, L4[1:])
  return ret
    
  
  
print(dfs(0, "TTT"))

Fixed submission:
n = int(input())
p = 10**9 + 7
memo = [{} for _ in range(n+1)]
def check(L4):
  for i in range(4):
    t = list(L4)
    if i > 0:
      t[i], t[i-1] = t[i-1], t[i]
    if "".join(t).count("AGC") >= 1:
      return False
  return True
def dfs(d, L3):
  if L3 in memo[d]:
    return memo[d][L3]
  if d >= n:
    return 1
  ret = 0
  for L in list("ACGT"):
    L4 = L3 + L
    if check(L4):
      ret += dfs(d + 1, L4[1:]) 
    memo[d][L3] = ret
  return ret % p
    
  
  
print(dfs(0, "TTT"))
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())
ans = 0
for i in range(4*(a//4), a):
  ans = ans^i
for i in range(4*(b//4),b+1):
  ans = ans^i

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = []
b = []
c = []
for i in range(n):
  a_i, b_i = map(int,input().split())
  a.append(a_i)
  b.append(b_i)
  c.append(a_i+b_i)
c.sort(reverse=True)
k = int((n+1)/2)
print(np.sum(c[::2])-np.sum(b))

Fixed submission:
import numpy as np
n = int(input())
a = []
b = []
c = []
for i in range(n):
  a_i, b_i = map(int,input().split())
  a.append(a_i)
  b.append(b_i)
  c.append(a_i+b_i)
c.sort(reverse=True)
k = int((n+1)/2)
print(np.sum(c[::2])-np.sum(b))
Buggy python submission (verdict: Runtime Error):
n, p = map(int, input().split())
import sympy
import math
fac = sympy.factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
print(result)

Fixed submission:
n, p = map(int, input().split())
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

PS = primes(1000000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
if n == 1:
  result = p
print(result)
Buggy python submission (verdict: Runtime Error):
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(abs(d))   

Fixed submission:
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))

Buggy python submission (verdict: Runtime Error):
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [1] * x
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(d)    

Fixed submission:
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))

Buggy python submission (verdict: Runtime Error):
n, x =  map(int, input().split())
xi = list(map(int, input().strip().split()))
c = [1] * x
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(d)

Fixed submission:
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []
for i in range(m):
  ab.append(list(map(int, input().split())))
count = 0
while len(ab) > 0:
  c = float('inf')
  for i in range(len(ab)):
    if ab[i][1] < c:
      c = ab[i][1]
  count += 1
  tmp = []
  for i in range(len(ab)):
    if ab[i][0] >= c:
      tmp.append(ab[i])
  ab = tmp
print(count)

Fixed submission:
n, m = map(int, input().split())
ab = []
for i in range(m):
  ab.append(list(map(int, input().split())))
count = 0
while len(ab) > 0:
  c = float('inf')
  for i in range(len(ab)):
    if ab[i][1] < c:
      c = ab[i][1]
  count += 1
  tmp = []
  for i in range(len(ab)):
    if ab[i][0] >= c:
      tmp.append(ab[i])
  ab = tmp
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict

def main():
    N = int(input())
    As = [int(x) for x in input().split()]

    d = defaultdict(int)

    for i in range(N):
        d[As[i]] += 1
    
    for i in range(N):
        ans = 0
        for k in d.keys():
            j = d[k]
            if (k == As[i]):
                j -= 1
            if j > 1:
                ans += j*(j-1)//2
        print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc159","d",main)

Fixed submission:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict

def main():
    N = int(input())
    d = defaultdict(int)
    As = list(map(int, input().split()))
    for i in range(N):
        d[As[i]] += 1
    
    ans = 0
    for k in d.keys():
        j = d[k]
        if j > 1:
            ans += j*(j-1)//2

    for i in range(N):
        j = d[As[i]]
        print(ans+1-j)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc159","d",main)
Buggy python submission (verdict: Runtime Error):
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

import numpy as np

def main():
    N = int(input())
    Ds = np.array([int(d) for d in input().split()])

    Ds.sort()
    if Ds[Ds==0].size != 1:
        print(0)
        return
    Ds = Ds[1:]

    l = 0
    r = 1
    c = []
    while len(Ds) > 0:
        l = l + 1
        cnt = Ds[Ds==l].size
        c.append((r, cnt))
        r = cnt
        Ds = Ds[cnt:]
        
    ans = 1
    divider = 998244353
    for i, j in c:
        r = (i**j)%divider
        ans = (ans*r)%divider
    
    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("nikkei2019-2-qual","b",main)


Fixed submission:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

import math

def func(i, j, d):
    if i <= 1:
        return 1
    e = j
    b = int(math.log2(d)/math.log2(i))
    ret = 1
    while e > b:
        ret = ret*(i**b%d)
        e = e - b
    else:
        if e > 0:
            ret = ret*(i**e%d)
    return ret


def main():
    N = int(input())
    Ds = [int(d) for d in input().split()]

    if Ds[0] != 0:
        print(0)
        return

    Ds.sort()
    if Ds[1] == 0:
        print(0)
        return

    i = 1
    l = 1
    r = 1
    ans = 1
    divider = 998244353

    while i < N:
        cnt = 0
        while i < N and Ds[i] == l:
            cnt = cnt + 1
            i = i + 1
        if cnt == 0:
            print(0)
            return

        ans = ans*func(r, cnt, divider)%divider
        r = cnt
        l = l + 1
    
    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("nikkei2019-2-qual","b",main)
Buggy python submission (verdict: Runtime Error):
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    L, R = map(int, input().split())

    R_r = R%2019
    if (R - L) >= R_r :
        print(0)
    else:
        L_r = L%2019
        ans = (L_r*(L_r+1))%2019
        for l in range(L_r, R_r):
            for r in range(l+1, R_r+1):
                ans = min(ans, (l*r)%2019)
        print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","c",main)


Fixed submission:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())

    print(min(A*N, B))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","a",main)

Buggy python submission (verdict: Runtime Error):
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    L, R = map(int, input().split())

    R_r = R%2019
    if (R - L) > R_r :
        print(0)
    else:
        L_r = L%2019
        ans = L_r*(L_r+1)%2019
        for l in range(L_r, R_r):
            for r in range(l+1, R_r+1):
                ans = min(ans, l*r%2019)
        print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","c",main)

Fixed submission:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())

    print(min(A*N, B))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","a",main)
Buggy python submission (verdict: Runtime Error):
N=int(input())
AB=[list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[0]+x[1]),reverse=True)
print(sum([x for x in zip(*AB[::2])][0])-sum([x for x in zip(*AB[1::2])][1]))


Fixed submission:
N=int(input())
AB=[list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[0]+x[1]),reverse=True)

s=0
for i,v in enumerate(AB):
    if i%2:
        s = s - v[1]
    else:
        s = s + v[0]
print(s)
Buggy python submission (verdict: Runtime Error):
n=input()
t=map(int,raw_input().split())
l=[0]*(pow(10,5)+1)
for i in t:
    l[i]+=1
s=0
for x in l:
    s+=(x*(x-1))/2
for x in t:
    a=l[x]
    print s- (a*(a-1))/2 + (a-1)*(a-2)/2

Fixed submission:
n=input()
t=map(int,raw_input().split())
l=[0]*(2*pow(10,5)+4)
for i in t:
    l[i]+=1
s=0
for x in l:
    s+=(x*(x-1))/2
for x in t:
    a=l[x]
    print s- (a*(a-1))/2 + (a-1)*(a-2)/2
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(nm) for nm in input().split()]
A = [int(a) for a in input().split()]

for m in range(M):
  mx_A = max(A)
  A.remove(mx_A)
  A.append(mx_A // 2)

ans = sum(A)
print(ans)

Fixed submission:
N, M = [int(nm) for nm in input().split()]
A = [int(a) for a in input().split()]
A.sort(reverse = True)

while M >= 1:
  A[0] //= 2
  M -= 1
  
  i = 1
  while True:
    if N >= i*2 + 1:
      A1, A2, A3 = A[i-1], A[i*2 - 1], A[i*2]
    elif N == i*2:
      A1, A2, A3 = A[i-1], A[i*2 - 1], 0
    else:
      A1, A2, A3 = A[i-1], 0, 0

    if A1 < A2 or A1 < A3:
      if A2 >= A3:
        A[i-1], A[i*2 - 1] = A2, A1
        i = i*2
      else:
        A[i-1], A[i*2] = A3, A1
        i = i*2 + 1
    else:
      break

ans = sum(A)
print(ans)