Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

"""
目標とする最長の長さをxとして、それをk回で達成
できるか
aをソートしたので、途中でkを超えることが判明したら打ち切る
"""

def isOK(x):
    cnt = 0
    for _a in a:
        if _a<=x:
            return True
        cnt+=_a//x
        if cnt>k:
            return False
    return True

ng = 0
ok = 10**9+1

while abs(ng-ok)>0.1:
    mid = (ng+ok)/2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
ok = ceil(ok)
if isOK(ok-1):
    print(ok-1)
else:
    print(ok)

Fixed submission:
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

"""
目標とする最長の長さをxとして、それをk回で達成
できるか
aをソートしたので、途中でkを超えることが判明したら打ち切る
"""

def isOK(x):
    cnt = 0
    for _a in a:
        if _a<=x:
            return True
        try:
            cnt+=_a//x
        except:
            return False
        if cnt>k:
            return False
    return True

ng = 0
ok = 10**9+1

while abs(ng-ok)>0.1:
    mid = (ng+ok)/2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
    if ok < 1:
        break
ok = ceil(ok)
if isOK(ok-1):
    print(ok-1)
else:
    print(ok)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]

c = Counter(s)

for k in ['AC', 'WA', 'TLE', 'RE']:
    if k in c:
        print('{k} x {}'.format(k, c[k]))
    else:
        print('{} x {}'.format(k, c[k]))

Fixed submission:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]

c = Counter(s)

for k in ['AC', 'WA', 'TLE', 'RE']:
    if k in c:
        print('{} x {}'.format(k, c[k]))
    else:
        print('{} x {}'.format(k, c[k]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 0
while a:
    st = 0
    if len(a)>1 and a[0] == a[1]:
        st = 1
    else:
        st = 0
        ans += 1
    a = [a[i] for i in range(st, len(a)) if a[i] % a[0] > 0]
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
m = max(a)+1

numbers = [0] * m

for i in a:
    numbers[i] += 1

    if numbers[i] == 1:
        for j in range(2*i, m, i):
            numbers[j] += 2

print(numbers.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, deque
n = int(input())
a = list(map(int, input().split()))
a.sort()

na = a[::]
ans = 0
while na:
    st = 0
    if len(na)>1 and na[0] == na[1]:
        st = 1
    else:
        st = 0
        ans += 1
    nna = []
    for i in range(st, len(na)):
        if na[i] % na[0] > 0:
            nna.append(na[i])
    na = nna
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
m = max(a)+1

numbers = [0] * m

for i in a:
    numbers[i] += 1

    if numbers[i] == 1:
        for j in range(2*i, m, i):
            numbers[j] += 2

print(numbers.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, deque
n = int(input())
a = list(map(int, input().split()))
a.sort()

na = a[::]
ans = 0
while na:
    st = 0
    if len(na)>1 and na[0] == na[1]:
        st = 1
    else:
        st = 0
        ans += 1
    nna = []
    for i in range(st, len(na)):
        if na[i] % na[0] > 0:
            nna.append(na[i])
    na = nna
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
m = max(a)+1

numbers = [0] * m

for i in a:
    numbers[i] += 1

    if numbers[i] == 1:
        for j in range(2*i, m, i):
            numbers[j] += 2

print(numbers.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 1
for aa in a:
    ans*=aa
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 1
f = True
if a[0] == 0:
    print(0)
    f = False
else:
    for aa in a[::-1]:
        ans*=aa
        if ans > 10**18:
            print(-1)
            f = False
            break
if f:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

dp = [[0] * (s+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    a = A[i]
    for j in range(s+1):
        if j < s:
            dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j])%mod
        if j+a<s+1:
            dp[i+1][j+a] = (dp[i+1][j+a] + dp[i][j])%mod

ans = 0
for i in range(1, n+1):
    ans = (ans + dp[i][s] * pow(2, n-i, mod)) % mod
print(ans)




Fixed submission:
n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

dp = [[0] * (s+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    a = A[i]
    for j in range(s+1):
        if j < s:
            dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j])%mod
        if j+a<s+1:
            dp[i+1][j+a] = (dp[i+1][j+a] + dp[i][j])%mod

ans = 0
for i in range(1, n+1):
    ans = (ans + dp[i][s] * pow(2, n-i, mod)) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
 t = list(input())


for i in range(len(t)-1, -1, -1):
    if t[i] == '?':
        t[i] = 'D'
print(''.join(list(map(str, t))))

Fixed submission:
t = list(input())
for i in range(len(t)-1, -1, -1):
    if t[i] == '?':
        t[i] = 'D'
print(''.join(list(map(str, t))))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a]
visited = [-1]*n
route = []
now = 0
hop = 0
while visited[now] == -1:
    visited[now]=hop
    route.append(now)
    now = a[now]
    hop+=1
loop_st = 0
for r in route:
    if r==now: break
    loop_st+=1
loop = route[loop_st:]
if k-1 < len(route):
    print(route[k]+1)
else:
    print(loop[(k-loop_st)%len(loop)]+1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a]
visited = [-1]*n
route = []
now = 0
hop = 0
while visited[now] == -1:
    visited[now]=hop
    route.append(now)
    now = a[now]
    hop+=1
loop_st = 0
for r in route:
    if r==now: break
    loop_st+=1
loop = route[loop_st:]
if k < len(route):
    print(route[k]+1)
else:
    print(loop[(k-loop_st)%len(loop)]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ai = [[a_, i] for i, a_ in enumerate(a)]
ai.sort(reverse=True)

# dp[i][j] 左端からi個、右端からj個を入れた場合の最適
dp = [[0]*(n+1) for _ in range(n+1)]

for i in range(n):
    for j in range(n-i):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ai[i+j][0] * (ai[i+j][1] - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ai[i+j][0] * ((n-1-j) - ai[i+j][1]))
ans = 0    
for i in range(n):
    ans = max(ans, dp[i][n-i])
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ai = [[a_, i] for i, a_ in enumerate(a)]
ai.sort(reverse=True)

# dp[i][j] 左端からi個、右端からj個を入れた場合の最適
dp = [[0]*(n+1) for _ in range(n+1)]

for i in range(n):
    for j in range(n-i):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ai[i+j][0] * (ai[i+j][1] - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ai[i+j][0] * ((n-1-j) - ai[i+j][1]))
ans = 0    
for i in range(n):
    ans = max(ans, dp[i][n-i])
print(ans)
Buggy python submission (verdict: Runtime Error):
    DVSR = 1000000007
    def POW(x, y): return pow(x, y, DVSR)
    def INV(x, d=DVSR): return pow(x, d - 2, d)
    def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
    def LI(): return [int(x) for x in input().split()]
    def LF(): return [float(x) for x in input().split()]
    def LS(): return input().split()
    def II(): return int(input())
    
    n = II()
    n = str(n)
    if '7' in n:
        print('Yes')
    else:
        print('No')

Fixed submission:
n = input()
if '7' in n:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque, Counter
n, x, y = map(int, input().split())
edge = [[] for i in range(n)]

for i in range(n-1):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x-1].append(y-1)
edge[y-1].append(x-1)

def bfs(i):
    dq = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while dq:
        now = dq.popleft()
        d = dist[now]
        for e in edge[now]:
            if dist[e]==-1:
                dist[e] = d + 1
                dq.append(e)
    return dist

c = Counter()
for i in range(n):
    c = c + Counter(bfs(i))

for i in range(1, n):
    print(c[i]//2)


Fixed submission:
from collections import deque, Counter
n, x, y = map(int, input().split())
edge = [[] for i in range(n)]

for i in range(n-1):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x-1].append(y-1)
edge[y-1].append(x-1)

def bfs(i):
    dq = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while dq:
        now = dq.popleft()
        d = dist[now]
        for e in edge[now]:
            if dist[e]==-1:
                dist[e] = d + 1
                dq.append(e)
    return dist

c = Counter()
for i in range(n):
    c = c + Counter(bfs(i))

for i in range(1, n):
    print(c[i]//2)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
    if v == 1:
        dp_on[k] = 0
        dp_off[k] = 0
    elif v == 2:
        dp_on[k] = 1
        dp_off[k] = 0
    else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
    comb_sum = sum([v for v in dp_on.values()])
    for i in range(n):
        print(comb_sum - dp_on[a[i]] + dp_off[a[i]])

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
    if v == 1:
        dp_on[k] = 0
        dp_off[k] = 0
    elif v == 2:
        dp_on[k] = 1
        dp_off[k] = 0
    else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
    print(comb_sum - dp_on[a[i]] + dp_off[a[i]])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
if v < 2:
        dp_on[k] = 0
        dp_off[k] = 0
elif v < 3:
        dp_on[k] = 1
        dp_off[k] = 0
else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
print(comb_sum - dp_on[a[i]] + dp_off[a[i]])

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
    if v == 1:
        dp_on[k] = 0
        dp_off[k] = 0
    elif v == 2:
        dp_on[k] = 1
        dp_off[k] = 0
    else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
    print(comb_sum - dp_on[a[i]] + dp_off[a[i]])
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod)-1

modp = mod                     # 素数であることが前提
max_r = 10 ** 7               # 必要分だけ用意する 10**7が限度
factinv = [1, 1] + [0]*max_r  # factinv[n] = ((n!)^(-1) mod modp)
inv = [0, 1] + [0]*max_r      # factinv 計算用

fact = {}

def cmb(n, r, p):
    assert n < p, 'n is less than modp'
    assert r < max_r, 'n in less than max_n'
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    if (n, r) in fact:
        return fact[(n, r)] * factinv[r] % p
    else:
        f = 1
        for i in range(n, n-r, -1):
            f = f * i % p
        fact[(n, r)] = f
        return f * factinv[r] % p

for i in range(2, max_r + 1):
    inv[i] = (-inv[modp % i] * (modp // i)) % modp
    factinv[i] = (factinv[i-1] * inv[i]) % modp

ans-=cmb(n, a, mod)
ans-=cmb(n, b, mod)
print(ans%mod)


Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod)-1

modp = mod

def cmb(n, r, p):
    r = min(r, n-r)
    upper = 1
    for i in range(n, n-r, -1):
        upper = (upper*i)%p
        
    lower = 1
    for i in range(1, r+1):
        lower = (lower*i)%p
    
    # フェルマーの小定理よりp素数ならupper**(p-2)は逆元
    return (upper*pow(lower, p-2, p))%p

ans-=cmb(n, a, mod)
ans-=cmb(n, b, mod)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
aa = map(int, input().split())

p = []
for i in range(N-1):
  for j in range(i+1, N):
    p.append(i*j)

print(p.sorted[K])

Fixed submission:
abc = map(int, input().split())
 
abc_set = set(abc)

if len(abc_set) == 2:
  print('Yes')
else:
  print('No')

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

f = False
for a in aa:
  if a % 2 == 0:
    if (a % 3 != 0) and (a % 5 != 0):
      print('DENIED')
      f = True
      break
if not f:
  print('APPROVED')

Fixed submission:
abc = map(int, input().split())
 
abc_set = set(abc)

if len(abc_set) == 2:
  print('Yes')
else:
  print('No')

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

f = False
for a in aa:
  if a % 2 == 0:
    if a % 3 != 0:
      print('DENIED')
      f = True
      break
    elif a % 5 != 0:
      print('DENIED')
      f = True
      break
if not f:
  print('APPROVED')


Fixed submission:
abc = map(int, input().split())
 
abc_set = set(abc)

if len(abc_set) == 2:
  print('Yes')
else:
  print('No')

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

abc_set = set(abc)

if len(set) == 2:
  print('Yes')
else:
  print('No')

Fixed submission:
abc = map(int, input().split())
 
abc_set = set(abc)

if len(abc_set) == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
ss = []
for i in range(N):
  ss.append(input())

c = Counter(ss)

max_count = max(c.values())

out_k = []
for k, v in c.items():
  if v == max_count:
    out_k.append(k)
sort(out_k)
for k in out_k:
  print(k)

Fixed submission:
from collections import Counter

N = int(input())
ss = []
for i in range(N):
  ss.append(input())

c = Counter(ss)

max_count = max(c.values())

out_k = []
for k, v in c.items():
  if v == max_count:
    out_k.append(k)
out_k.sort()
for k in out_k:
  print(k)
Buggy python submission (verdict: Runtime Error):
    a, b = input().split()
    an, bn = map(int, input().split())
    s = input()

    d = {a: an, b:bn}
    d[s] -= 1

    print("{} {}".format(d[a], d[b]))

Fixed submission:
a, b = input().split()
an, bn = map(int, input().split())
s = input()

d = {a: an, b:bn}
d[s] -= 1

print("{} {}".format(d[a], d[b]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_kitai = [(1 + p)/2 for p in P]

max_kitai = 0
for i in range(N - K + 1):
    res = sum(P_kitai[i:i+K])
    max_kitai = max(max_kitai, res)
print(max_kitai)

Fixed submission:
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_kitai = [(1 + p)/2 for p in P]

max_kitai = 0
res = 0
for i in range(N - K + 1):
    if i == 0: 
        res = sum(P_kitai[i:i+K])
    else:
        res = res - P_kitai[i-1] + P_kitai[i+K-1]
    max_kitai = max(max_kitai, res)
print(max_kitai)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().strip())

if N==M:
  print('Yes')
else:
  print('No')

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

if N==M:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
P = list(map(int, input().split()))

count = 0
last_min = P[i]
for i in range(N):
    last_min = min(last_min, P[i])
    if i == 0:
        count += 1
    elif last_min == P[i]:
        count += 1
print(count)

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

count = 0
last_min = P[0]
for i in range(N):
    last_min = min(last_min, P[i])
    if i == 0:
        count += 1
    elif last_min == P[i]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
P = list(map(int, input().split()))

count = 0
for i in range(N):
    if i == 0:
        count += 1
    elif min(P[:i+1]) == P[i]:
        count += 1
print(count)

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

count = 0
last_min = P[0]
for i in range(N):
    last_min = min(last_min, P[i])
    if i == 0:
        count += 1
    elif last_min == P[i]:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
print(chr(ord(s)+1)))

Fixed submission:
c = input()
a  = ord(c)
print(chr(a+1))
Buggy python submission (verdict: Runtime Error):
a = int(input());b = int(input())
ans = [1, 2, 3].delete(a).delete(b)
print(ans[0])

Fixed submission:
a = int(input()); b=int(input())
ans = [1, 2, 3]
ans.remove(a)
ans.remove(b)
print(ans[0])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f = factorization(n)
l = []
for k, v in f:
    l += [k]*v
ans = n-1
for bit in product([True, False], repeat=len(l)):
    down = 1
    right = 1
    for i in range(len(l)):
        if bit[i]:
            down *= l[i]
        else:
            right *= l[i]
    ans = min(ans, down -1 + right - 1)
print(ans)

Fixed submission:
from itertools import product
n = int(input())

ans = n-1
for a in range(1, int(n**0.5)+1):
    if n%a==0:
        b = n//a
        ans = min(ans, b+a-2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f = factorization(n)
l = []
for k, v in f:
    l += [k]*v
ans = n-1
for bit in product([True, False], repeat=len(l)):
    down = 1
    right = 1
    for i in range(len(l)):
        if bit[i]:
            down *= l[i]
        else:
            right *= l[i]
    ans = min(ans, down -1 + right - 1)
print(ans)






Fixed submission:
from itertools import product
n = int(input())

ans = n-1
for a in range(1, int(n**0.5)+1):
    if n%a==0:
        b = n//a
        ans = min(ans, b+a-2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
f = list(map(int, input().split()))
f.sort(reverse=True)

asum = sum(a)

def test(x):
    t = [min(a[i], x//f[i]) for i in range(n)]
    return asum - sum(t)


ng = -1
ok = 10**13
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if test(mid) <= k:
        ok = mid
    else:
        ng = mid

print(ok)

Fixed submission:
import heapq
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
f = list(map(int, input().split()))
f.sort(reverse=True)

asum = sum(a)

def test(x):
    t = [min(a[i], x//f[i]) for i in range(n)]
    return asum - sum(t)


ng = -1
ok = 10**13
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if test(mid) <= k:
        ok = mid
    else:
        ng = mid

print(ok)
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()

if a => 3200:
    print(s)
else:
    print("red")

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

if a >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if l//2019 - r//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                break
    print(ans)

Fixed submission:
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if r//2019 - l//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if l//2019 - r//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Fixed submission:
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if r//2019 - l//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                break
    print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b, c, d = map(int, input().split())
"""
ans: (B-A) - {Cの倍数の個数＋Dの倍数の個数 - CDの倍数の個数}
"""
def count(t):
    amari = a % t
    return (b - a - amari ) // t
print( b-a - (count(c) + count(d) - count(c*d)))


Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())
"""
ans: B以下の整数から条件を満たす個数　 - A-1以下の整数から条件を満たす個数
X以下の整数から条件： X - X//c -X//d + X//lcm(c,d)
"""
def count(X, t):
    return X//t
cd = c * d // gcd(c, d)
b_under = b - count(b, c) - count(b, d) + count(b, cd)
a_under = a-1 - count(a-1, c) - count(a-1, d) + count(a-1, cd)

print( b_under - a_under )
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

xnow = 0
ans = 0
while xnow <= x:
    ans+=1
    xnow += l[ans-1]
print(ans)


Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

cum = [0] * (n+1)
for i in range(1, n+1):
    cum[i] = cum[i-1] + l[i-1]

f = True
for i in range(n+1):
    if cum[i] > x:
        f = False
        print(i)
        break
if f:
    print(n+1)