Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
P = list(map(int, input().split()))[::-1]
p = Counter(P)

cnt = 0
for i in range(n):
    flag = True
    p[P[i]] -= 1
    if p[P[i]] == 0: p.pop(P[i])
    for x,y in p.items():
        if x < P[i]:
            flag = False
            break
    if flag: cnt += 1
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

n = P[0]
count = 1
for i in range(1, N):
  if P[i] <= n:
    count += 1
    n = P[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
# X = []
# L = []
# for _ in range(N):
#   x, l = map(int, input().split()))
#   X.append(x)
#   L.append(l)

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


A = []
B = []
for _ in range(N):
  x, l = map(int, input().split())
  A.append(x - l)
  B.append(x + l - 1)

l = []
ans = 0
for i in range(N):
  count = 0
  for j in range(N):
    if i == j:
      continue
    else:
      if A[i] <= A[j] <= B[i] or A[i] <= B[j] <= B[i]:
        count += 1
  l.append(count)
print(N - l.count(max(l)) if max(l) != 0 else N)

Fixed submission:
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l - 1
  b = x - l
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)

robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])

print(len(robot_count))
Buggy python submission (verdict: Runtime Error):
n,k,s = map(int, input().split())

ans = [1] * n
if k * 2 <= n:
    i = 0
    while k > 0:
        ans[i], ans[i+1] = 1, s-1
        k -= 1
        i += 2
else:
    if s % 2 == 0:
        i = 0
        while k > 0:
            ans[i] = ans[i+1] = s//2
            k -= 1
            i += 1
    else:
        i = 0
        while k-1 > 0:
            ans[i], ans[i+1] = 1, s-1
            k -= 1
            i += 2
        ans[i] = s
print(" ".join(map(str, ans)))

Fixed submission:
n,k,s = map(int, input().split())
if s < 10 ** 9:
    ans = [s+1] * n
else:
    ans = [1] * n
ans[:k] = [s] * k
print(" ".join(map(str, ans)))

Buggy python submission (verdict: Runtime Error):
n,k,s = map(int, input().split())

ans = [1] * n
ans[0] = s
if k % 2 == 0:
    i = 1
    while k > 1:
        ans[i], ans[i+1] = 1, s-1
        i += 2
        k -= 1
else:
    for i in range(1,k+1):
        ans[i] = s//2
print(" ".join(map(str, ans)))

Fixed submission:
n,k,s = map(int, input().split())
if s < 10 ** 9:
    ans = [s+1] * n
else:
    ans = [1] * n
ans[:k] = [s] * k
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print((A * B) // math.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
def lcm(x, y):
  return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

import math

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

print(lcm(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print((A * B) // fractions.gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = []
for x in range(len(s)-2):
  for y in range(x+1, len(s)-1):
    Z = list(set(s[y+1:]))
    for z in Z:
      ans.append(s[x]+s[y]+z)
print(len(list(set(ans))))

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

cnt = 0
for i in range(1000):
  x = str(i).zfill(3)
  a = s.find(x[0])
  b = s[a+1:].find(x[1])
  c = s[a+b+2:].find(x[2])
  if -1 not in (a,b,c):
    cnt += 1
print(cnt)

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

ans = []
for x in range(len(s)-2):
  for y in range(x+1, len(s)-1):
    Z = list(set(s[y+1:]))
    for z in Z:
      ans.append(s[x]+s[y]+z)
print(len(list(set(ans))))

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

cnt = 0
for i in range(1000):
  x = str(i).zfill(3)
  a = s.find(x[0])
  b = s[a+1:].find(x[1])
  c = s[a+b+2:].find(x[2])
  if -1 not in (a,b,c):
    cnt += 1
print(cnt)

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

ans = []
for x in range(len(s)-2):
  for y in range(x+1, len(s)-1):
    for z in range(y+1, len(s)):
      ans.append(s[x]+s[y]+s[z])
print(len(list(set(ans))))

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

cnt = 0
for i in range(1000):
  x = str(i).zfill(3)
  a = s.find(x[0])
  b = s[a+1:].find(x[1])
  c = s[a+b+2:].find(x[2])
  if -1 not in (a,b,c):
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
for i in range(N):
  if n < m:
    n += A[i]
  elif n >= m and i != N-1:
    a = i
    break
  elif n >= m and i == N - 1:
    a = i
if a == 0:
  print(abs(A[a]-sum(A[a:])))
elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
  print(abs(sum(A[:a]) - sum(A[a:])))
else:
  print(abs(sum(A[:a-1]) - sum(A[a-1:])))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
if N > 2:
  for i in range(N):
    if n < m:
      n += A[i]
    elif n >= m and i == N - 1:
      a = i
    elif n >= m and i != N - 1:
      a = i
      break
  if a == 0:
    print(abs(A[a]-sum(A[a:])))
  elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
    print(abs(sum(A[:a]) - sum(A[a:])))
  else:
    print(abs(sum(A[: a - 1]) - sum(A[a - 1 :])))
else:
  print(abs(A[0]-A[1]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
for i in range(N):
  if n < m:
    n += A[i]
  elif n >= m:
    a = i
    break

if abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
  print(abs(sum(A[:a]) - sum(A[a:])))
else:
  print(abs(sum(A[:a-1]) - sum(A[a-1:])))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
if N > 2:
  for i in range(N):
    if n < m:
      n += A[i]
    elif n >= m and i == N - 1:
      a = i
    elif n >= m and i != N - 1:
      a = i
      break
  if a == 0:
    print(abs(A[a]-sum(A[a:])))
  elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
    print(abs(sum(A[:a]) - sum(A[a:])))
  else:
    print(abs(sum(A[: a - 1]) - sum(A[a - 1 :])))
else:
  print(abs(A[0]-A[1]))
Buggy python submission (verdict: Runtime Error):
h,w,k = map(int, input().split())
s = [input() for _ in range(h)]
now = 1
flag = False
Ans = []
for i in range(h):
    if s[i] == "." * w:
        if i > 0: 
            Ans.append(Ans[-1])
        continue
    ans = []
    if i%2==0: x = s[i]
    else: x = s[i][::-1]
    for j in range(w):
        if x[j] == "#":
            if flag: now += 1
            else: flag = True
        ans.append(now)
    if i%2!=0: ans = ans[::-1]
    for _ in range(i+1-len(Ans)): Ans.append(ans)
for x in Ans:
    print(" ".join(list(map(str, x))))

Fixed submission:
h,w,k = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = []
n = 1
cnt = 0
for i in range(h):
    if "#" in S[i]:
        ans = []
        for j in range(w):
            if S[i][j] == "#":
                for _ in range(j+1-len(ans)):
                    ans.append(str(n))
                n += 1
        if len(ans) < w:
            x = ans[-1]
            for _ in range(w-len(ans)):
                ans.append(x)
    if ans:
        for _ in range(i+1-cnt):
            print(" ".join(ans))
            cnt += 1

Buggy python submission (verdict: Runtime Error):
h,w,k = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = []
n = 1
cnt = 0
for i in range(h):
    if "#" in s[i]:
        ans = []
        for s[i][j] == "#":
            for _ in range(j+1-len(ans)):
                ans.append(str(n))
            n += 1
        if len(ans) < w:
            x = ans[-1]
            for _ in range(w-len(ans)):
                ans.append(x)
    if ans:
        for _ in range(i+1-cnt):
            print(" ".join(ans))
            cnt += 1

Fixed submission:
h,w,k = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = []
n = 1
cnt = 0
for i in range(h):
    if "#" in S[i]:
        ans = []
        for j in range(w):
            if S[i][j] == "#":
                for _ in range(j+1-len(ans)):
                    ans.append(str(n))
                n += 1
        if len(ans) < w:
            x = ans[-1]
            for _ in range(w-len(ans)):
                ans.append(x)
    if ans:
        for _ in range(i+1-cnt):
            print(" ".join(ans))
            cnt += 1
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
n = 0
l = [S[0]]
if N > 1:
  for i in range(N):
    if not S[i+1] in l:
      l.append(S[i + 1])
    else:
      n = i + 1
      break
  if S[0:n] == S[n:]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Fixed submission:
N = int(input())
S = input()
if N > 1:
  if S[0: N // 2] == S[N // 2 :]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
    divisors.sort()
  return divisors
l = make_divisors(N)
if len(l) % 2 == 0:
  x = l[len(l) // 2 - 1]
  y = l[len(l) // 2]
  print(x + y - 2)
else:
  x = l[len(l) // 2]
  print(2 * (x-1))

Fixed submission:
N = int(input())
import math

n = math.sqrt(N)
if n.is_integer():
  x = round(n) - 1
  print(2 * x)
else:
  def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
      if n % i == 0:
        divisors.append(i)
        if i != n // i:
          divisors.append(n // i)
    divisors.sort()
    return divisors
  l = make_divisors(N)
  if len(l) % 2 == 0:
    x = l[len(l) // 2 - 1]
    y = l[len(l) // 2]
    print(x + y - 2)
Buggy python submission (verdict: Runtime Error):
s = list(input())
k = int(input())

cnt = 0
c = 0
if s[0] == s[-1]:
  if s[-1] == s[-2]: cnt +=1
  else: c +=1
  s[-1] = ""

for i in range(len(s)-1):
  if s[i] == s[i+1]:
    s[i+1] = ""
    cnt += 1
print(k*cnt + (k-1)*c)

Fixed submission:
s = list(input())
k = int(input())

if len(set(s)) == 1:
    print((len(s)*k)//2)
    exit()

def n_change(sss):
    s = sss.copy()
    x = 0
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            s[i] = "X"
            x += 1
    return x

print(n_change(s) + (k-1) * (n_change(2*s) - n_change(s)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())
         
ans = [0] * N
for i in range(N):
         ans[A[i] - 1] = i + 1
    
print(" ".join(map(str, ans)))
         

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
         
ans = [0] * N
for i in range(N):
         ans[A[i] - 1] = i + 1
    
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

import math
def prime(n):
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

ans = 0
for i in range(1, min(a, b)+1):
  if a % i == 0 and b % i == 0:
    if prime(i): ans += 1
print(ans)

Fixed submission:
from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)

from collections import Counter
#最大公約数を素因数分解する
def factorize(n):
  d = Counter()
  m = 2
  while m*m <= n:
    while n%m == 0:
      n //= m
      d[m] += 1
    m += 1
  if n > 1:
    d[n] += 1
  return d

fs = factorize(g) # "1"以外の公約数
print(len(fs) + 1) # 公約数"1"を足す
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))
a = list(set(A))
if Q >= K:
  ans = ["No"] * N
  for i in range(len(a)):
    if K - (Q - A.count(a[i])) > 0:
      ans[a[i]-1] = "Yes"
else:
  ans = ["Yes"] * N

for x in ans:
  print(x)

Fixed submission:
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

score = [0] * N
for i in range(Q):
  score[A[i] - 1] += 1
 
ans = []
for j in range(N):
  if K - Q + score[j] <= 0:
    ans.append("No")
  else:
    ans.append("Yes")
 
for a in ans:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

a = list(set(A))
ans = []
for i in range(N):
  if i + 1 in a:
    if Q - A.count(i + 1) < K:
      ans.append("Yes")
    else:
      ans.append("No")
  elif Q < K:
    ans.append("Yes")
  else:
    ans.append("No")

for x in ans:
  print(x)

Fixed submission:
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

score = [0] * N
for i in range(Q):
  score[A[i] - 1] += 1
 
ans = []
for j in range(N):
  if K - Q + score[j] <= 0:
    ans.append("No")
  else:
    ans.append("Yes")
 
for a in ans:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

def minus(n):
  return n - 1

score = [0] * N
for i in range(Q):
  score[A[i] - 1] += 1

ans = []
for j in range(N):
  if K - sum(score) + score[j] <= 0:
    ans.append("No")
  else:
    ans.append("Yes")

for a in ans:
  print(a)

Fixed submission:
N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

score = [0] * N
for i in range(Q):
  score[A[i] - 1] += 1
 
ans = []
for j in range(N):
  if K - Q + score[j] <= 0:
    ans.append("No")
  else:
    ans.append("Yes")
 
for a in ans:
  print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = [int(x) for x in input().split()]

ans = []
c = 0
for i in range(N - 1):
  if H[i] >= H[i + 1]:
    c += 1
    if i == N - 2:
      ans.append(c)
  elif H[i] < H[i + 1]:
    ans.append(c)
    c = 0
  
print(max(ans))

Fixed submission:
N = int(input())
H = [int(x) for x in input().split()]

if N == 1:
  print(0)
else:
  ans = []
  c = 0
  for i in range(N - 1):
    if H[i] >= H[i + 1]:
      c += 1
      if i == N - 2:
        ans.append(c)
    elif H[i] < H[i + 1]:
      ans.append(c)
      c = 0
  print(max(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(range(1, N+1))

ans = 0
for i in range(N):
  if i == N-1:
    ans += l[i] % 1
  else: ans += l[i] % (l[i] + 1)
print(ans)

Fixed submission:
N = int(input())
print((N * (N-1)) //2)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

list = [a + b, a - b, a * b]

if a > 0:
  if b > 0:
    print(list[2])
  else:
    print(list[1])

else:
  if b > 0:
    print(list[0])
  else:
    print(list[2])

Fixed submission:
A, B = (int(x) for x in input().split() )

print(max(A+B, A-B, A*B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [sorted(input()) for _ in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1, n):
    if s[i] == s[j]: ans += 1
print(ans)

Fixed submission:
N = int(input())
s = {}
for _ in range(N):
  a = "".join(sorted(input()))
  if a not in s:
    s[a] = 0
  else: s[a] += 1

import math
ans = 0
for v in s.values():
  if v < 2: ans += v
  if v > 1: ans += v*(v+1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for _ in range(N):
  s = list(input())
  s.sort()
  S.append("".join(s))

s = list(set(S))
ans = 0
for i in range(len(s)):
  a = S.count(s[i])
  if a == 1: continue
  ans += a * (a-1) // 2
print(ans)

Fixed submission:
N = int(input())
s = {}
for _ in range(N):
  a = "".join(sorted(input()))
  if a not in s:
    s[a] = 0
  else: s[a] += 1

import math
ans = 0
for v in s.values():
  if v < 2: ans += v
  if v > 1: ans += v*(v+1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [sorted(input()) for _ in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    if s[i] == s[j]: ans += 1
print(ans)

Fixed submission:
N = int(input())
s = {}
for _ in range(N):
  a = "".join(sorted(input()))
  if a not in s:
    s[a] = 0
  else: s[a] += 1

import math
ans = 0
for v in s.values():
  if v < 2: ans += v
  if v > 1: ans += v*(v+1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A =[int(input()) for _ in range(N)]
M = max(A)

for i in range(N):
  if A[i] != M:
    print(M)
  else:
    a = A[:i] + A[i+1:]
    print(max(a))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(set(A))
max_count = A.count(a[-1])

for i in range(N):
  if len(a) > 1:
    if A[i] != a[-1]:
      print(a[-1])
    else:
      if max_count > 1:
        print(a[-1])
      else:
        print(a[-2])
  else:
    print(a[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = max(A)
for i in range(N):
  if A[i] == ans:
    a = A[:i] + A[i+1:]
    print(max(a))
  else:
    print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(set(A))
max_count = A.count(a[-1])

for i in range(N):
  if len(a) > 1:
    if A[i] != a[-1]:
      print(a[-1])
    else:
      if max_count > 1:
        print(a[-1])
      else:
        print(a[-2])
  else:
    print(a[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
  a = A[:i] + A[i+1:]
  print(max(a))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(set(A))
max_count = A.count(a[-1])

for i in range(N):
  if len(a) > 1:
    if A[i] != a[-1]:
      print(a[-1])
    else:
      if max_count > 1:
        print(a[-1])
      else:
        print(a[-2])
  else:
    print(a[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(set(a)[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int, input().split()))
ok = False
for v in itertools.permutations(a):
    v = v+v[:2]
    for i in range(n):
        if int(bin(v[i] ^ v[i+1] ^ v[i+2]), 2) != 0: break
        elif i == n-1 and int(bin(v[i] ^ v[i+1] ^ v[i+2]), 2) == 0: ok = True
    if ok: break
print("Yes" if ok else "No")

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int, input().split()))
ok = False
for v in itertools.permutations(a):
    v = v+v[:2]
    for i in range(n):
        if v[i+1] != int(bin(v[i] ^ v[i+2])[2:], 2): break
        if i == n-1:
            if v[i+1] == int(bin(v[i] ^ v[i+2])[2:], 2):
                ok = True
    if ok: break
print("Yes" if ok else "No")

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
if l >= 2019: 
  i = l
  j = l+1
elif r <= 2019:
  i = r - 1
  j = r
print((i*j) % 2019)

Fixed submission:
l,r = map(int, input().split())
ans = 10**10

for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j) % 2019
        if a == 0:
            print(0)
            exit()
        elif a < ans:
            ans = a
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
e = (c*d)//math.gcd(c,d)
A = (a-1)//c + (a-1)//d - (a-1)//e
B = b//c + b//d - b//e
print((b-a+1)-(B-A))

Fixed submission:
from fractions import gcd
a,b,c,d = map(int, input().split())
x = (c*d) // gcd(c,d)
c1, d1, cd1 = b // c, b // d, b // x
c2, d2, cd2 = (a-1) // c, (a-1) // d, (a-1) // x
ans = (c1+d1-cd1) - (c2+d2-cd2)
print(b-a+1-ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(input().split())
D = 1
l = [0]
if N == 1:
  print(1)
else:
  while max(l) < X:
    if int(l[-1]) + int(L[D - 1]) <= X:
      l.append(int(l[-1]) + int(L[D - 1]))
      D += 1
    else:
      break
  print(len(l))

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
l = [0]
if L[0] <= X:
  l.append(L[0])
  for x in range(N - 1):
    a = l[-1] + L[x + 1]
    if a <= X:
      l.append(a)
    elif a > X:
      break

print(len(l))

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(input().split())
D = 1
l = [0]
while max(l) < X:
  if int(l[-1]) + int(L[D - 1]) <= X:
    l.append(int(l[-1]) + int(L[D - 1]))
    D += 1
  else:
    break
print(len(l))

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
l = [0]
if L[0] <= X:
  l.append(L[0])
  for x in range(N - 1):
    a = l[-1] + L[x + 1]
    if a <= X:
      l.append(a)
    elif a > X:
      break

print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):


N, M = [int(x) for x in input().split()]
a = list(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[N]
print(ans)

Fixed submission:


N, M = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[N]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(x) for x in input().split()]
a = list(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[-1]
print(ans)

Fixed submission:


N, M = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[N]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s.replace("BC", "X")
#"AX" -> "XA"
cnt = 0
while "AX" in s:
    cnt += s.count("AX")
    s = s.replace("AX", "XA")
print(cnt)

Fixed submission:
#ABCがBCAになる
#ADがDAになる
s = input()
s = s.replace("BC", "D")

c_A = 0
ans = 0
for v in s:
  if v == "A":
    c_A += 1
  elif v == "D":
    ans += c_A
  else:
    c_A = 0
print(ans)