Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03331 (python)

Fixed submission:
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range((N//2)+1)[1:]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Buggy submission (verdict: Runtime Error):
import math
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range(N)[1:math.ceil(N/2)]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Buggy submission (verdict: Runtime Error):
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range(N)[1:round(N/2)]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))
Problem p03455 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a = int(input()) > 0
b = int(input()) > 0


if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a = int(input())
b = int(input())


if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem p03729 (python)

Fixed submission:
line = input()
Line = line.split()
A = Line[0]
B = Line[1]
C = Line[2]

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B, C= input(), input(), input()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Problem p03737 (python)

Fixed submission:
s1, s2, s3 = input().split()
print(str.upper(s1[0] + s2[0] + s3[0]))

Buggy submission (verdict: Runtime Error):
print(str.upper(input()[0]) + str.upper(input()[0]) + str.upper(input()[0]))
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(k*x + (n - k)*y)
else:
    print(n*x)

Buggy submission (verdict: Runtime Error):
n, k, x, y = [int(input()) for i in range(3)]
print(x*k + y*(n-k))
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
S = list()
result = ''
while n > 0:
    S.append(input())
    n -= 1

for i in sorted(S):
    result += i 

print(result)

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = list()
result = ''
while l > 0:
    S.append(input())
    l -= 1

for i in sorted(S):
    result += i 

print(result)
Problem p02639 (python)

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

for i in range(5):
    if x[i] == 0:
        print(i+1)

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

for i in range(5):
    if x[i] == 0:
        print(i+1)
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())


print(''.join(list(map(lambda x : x if x == S[K-1] else '*', S))))

Buggy submission (verdict: Runtime Error):
def third_select(S):
    right = N - 1
    change = 0
    sharp_appeared = False
    for i, s in enumerate(S[::-1]):
        if s == '#':
            sharp_appeared = True
        elif sharp_appeared:
            right = N - i
            break
        else:
            change += 1

    for s in S[:right]:
        if s == '#':
            change += 1

    for i,s in enumerate(S):
        if s == '#':
            left = i
            break

    return min(change, S[left:].count('.'))

N = int(input())
S = input()

ALL_period = S.count('#')
ALL_sharp = N - ALL_period



print(min(ALL_period, ALL_sharp, third_select(S)))
Problem p03069 (python)

Fixed submission:
from itertools import accumulate

N = int(input())
S = input()
L = list()
for s in S:
    if s == '.':
        L.append(0)
    else:
        L.append(1)

sharp_cumsum = [0] + list(accumulate(L))
period_cumsum = ([0] + list(accumulate([x^1 for x in L[::-1]])))[::-1]

ans = 10 ** 9

for i in range(N):
    left = i
    right = i+1
    tmp_ans = sharp_cumsum[left] + period_cumsum[right]
    ans = tmp_ans if tmp_ans < ans else ans
print(ans)

Buggy submission (verdict: Runtime Error):
def third_select(S):
    right = N - 1
    change = 0
    sharp_appeared = False
    for i, s in enumerate(S[::-1]):
        if s == '#':
            sharp_appeared = True
        elif sharp_appeared:
            right = N - i
            break
        else:
            change += 1

    for s in S[:right]:
        if s == '#':
            change += 1

    for i,s in enumerate(S):
        if s == '#':
            left = i
            break

    return min(change, S[left:].count('.'))

N = int(input())
S = input()

ALL_period = S.count('#')
ALL_sharp = N - ALL_period



print(min(ALL_period, ALL_sharp, third_select(S)))
Problem p03085 (python)

Fixed submission:
basis = input()
if basis == 'A':
    print('T')
elif basis == 'T':
    print('A')
elif basis == 'C':
    print('G')
elif basis == 'G':
    print('C')

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])
Problem p03087 (python)

Fixed submission:
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input.split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input.split())
    print(t[r-1] - t[l-1])
Problem p03206 (python)

Fixed submission:
christmas_day = 25
d = int(input())
print("Christmas", " Eve" * (christmas_day - d))

Buggy submission (verdict: Runtime Error):
christmas_day = 25
d = int(input())
print("Christmas", " Eve" * christmas_day - d)
Problem p03293 (python)

Fixed submission:
from collections import deque
import sys

deque_s = deque(list(input()))
deque_t = deque(list(input()))

for _i in range(len(deque_s)):
    deque_s.rotate()
    if deque_s == deque_t:
        print('Yes')
        sys.exit()

print('No')

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

deque_s = deque(list(input()))
kyoto
deque_t = deque(list(input()))
tokyo

for _i in range(len(deque_s)):
    deque_s.rotate()
    if deque_s == deque_t:
        print('Yes')
        sys.exit()

print('No')
Problem p03308 (python)

Fixed submission:
_n = int(input())
lists = list(map(int, input().split()))
lists.sort()

print(lists[-1] - lists[0])

Buggy submission (verdict: Runtime Error):
_n = int(input())
lists = list(map(int(), input().split()))
lists.sort()

print(lists[-1] - lists[0])

Buggy submission (verdict: Runtime Error):
_n = int(input())
list = map(int(), input().split())
list.sort()

print(list[-1] - list[0])
Problem p03964 (python)

Fixed submission:
n = int(input())
ary = list(map(int, input().split()))
for i in range(n - 1):
  tmp_ary = list(map(int, input().split()))
  t_rate = (ary[0] - 1) // tmp_ary[0] + 1
  a_rate = (ary[1] - 1) // tmp_ary[1] + 1
  rate = max([t_rate, a_rate])
  ary = list(map(lambda x: x * rate, tmp_ary))
print(int(ary[0] + ary[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
ary = []
for i in range(n):
  tmp_ary = list(map(int, input().split()))
  if len(ary) == 0:
    ary = tmp_ary[:]
  else:
    t_rate = math.ceil(ary[0] / tmp_ary[0])
    a_rate = math.ceil(ary[1] / tmp_ary[1])
    rate = max([t_rate, a_rate])
    ary = list(map(lambda x: x * rate, tmp_ary))

print(ary[0] + ary[1])
Problem p04011 (python)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n <= k:
  print(x * n)
else:
  print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n =< k:
  print(x * n)
else:
  print(k * x + (n - x) * y)
Problem p04012 (python)

Fixed submission:
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all([i % 2 == 0 for i in ans.values()]):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all[i % 2 == 0 for i in ans.values()]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all[i % 2 == 0 in i for ans.values()]:
  print('Yes')
else:
  print('No')
Problem p04044 (python)

Fixed submission:
N,L=map(int, input().split())
str_lists = []
for i in range(N):
  str_lists.append(input())

print(''.join(sorted(str_lists)))

Buggy submission (verdict: Runtime Error):
N,L=map(int, input().split())
str_lists = []
for i in ange(N):
  str_lists.append(input())
print(''.join(sorted(str_lists)))

Buggy submission (verdict: Runtime Error):
N,L=map(int, input().split())
str_lists = []
for i in xrange(N):
  str_lists.append(input())
print(''.join(sorted(str_lists)))
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())
if (500 * k) >= x:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
total = 500 * int(input())
line = int(input())
if total >= line:
    print('Yes')
else:
    print('No')
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [list(map(int,input().split())) for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[i[0]-1] + b[i[1]-1] - i[2])

print(min_price)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [input() for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[int(i[0])-1] + b[int(i[2])-1] - int(i[4:]))

print(min_price)
Problem p02921 (python)

Fixed submission:
a = input()
b = input()

x =0

for i in range(3):
    if a[i] == b[i]:
        x += 1

print(x)

Buggy submission (verdict: Runtime Error):
n,m = input().split()
n = int(n)
m = int(m)

i = m - n

if i <= 0:
        print(0)
else:
        count = 1
        while i > 0:
                i -= n-1
                count += 1
        print(count)
Problem p03086 (python)

Fixed submission:
s = list(input())
count = 0
a = []
for i in range(len(s)):
    if s[i] =="A" or s[i] =="T" or s[i] =="G" or s[i] =="C":
        count += 1
    else:
        a.append(count)
        count = 0
a.append(count)
print(max(a))

Buggy submission (verdict: Runtime Error):
s = list(input())
count = 0
a = []
for i in range(len(s)):
    if s[i] =="A" or s[i] =="T" or s[i] =="G" or s[i] =="C":
        count += 1
    else:
        a.append(count)
        count = 0
print(max(a))
Problem p03854 (python)

Fixed submission:
def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))

Buggy submission (verdict: Runtime Error):
def dfs(string):
    can = ["dream", "dreamer", "erase", "eraser"]
    stack = []
    stack.append("dream")
    stack.append("dreamer")
    stack.append("erase")
    stack.append("eraser")
    while stack:
        judge = stack.pop()
        if judge == string:break
        for temp in can:
            ans = judge + temp
            print(ans)
            if ans == string[:len(ans)]:
                stack.append(ans)
    return "YES" if judge == string else "NO"

if __name__ == '__main__':
    s = input()
    print(dfs(s))

Buggy submission (verdict: Runtime Error):
S = input()
T = ""

i = 0
while i <= len(S) - 7:
    if  S[i] == "d":
        if S[i+5] == "d" or S[i+7] == "a":
            T += "dream"
            i += 5
        else:
            T += "dreamer"
            i += 7
    else:
        if S[i+5] == "r":
            T += "eraser"
            i += 7
        else:
            T += "erase"
            i += 5

if S == T+"dream" or S == T+"dreamer" or S == T+"erase" or S == T+"eraser":
    print("YES")
else:
    print("NO")
Problem p02786 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math
N = int(input())
ans = 0
for i in range(int(math.log(N, 2))+1):
    ans += 2 ** i

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
N = int(input())
ans = 0
for i in range(int(math.log2(N))+1):
    ans += 2 ** i

print(ans)
Problem p03006 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())

if N == 1:
    print(1)
    exit()

#
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split(' '))
    X.append(x)
    Y.append(y)

#
import collections
xy_frq_dict = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        x, y = X[i] - X[j], Y[i] - Y[j]
        xy_frq_dict[(x, y)] += 1

xy_frq_pairs = list(xy_frq_dict.items())
xy_frq_pairs.sort(key=lambda x: x[1])
ret = N - xy_frq_pairs[-1][1]
print(ret)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())

#
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split(' '))
    X.append(x)
    Y.append(y)

#
import collections
xy_frq_dict = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        x, y = X[i] - X[j], Y[i] - Y[j]
        xy_frq_dict[(x, y)] += 1

xy_frq_pairs = list(xy_frq_dict.items())
xy_frq_pairs.sort(key=lambda x: x[1])
ret = N - xy_frq_pairs[-1][1]
print(ret)
Problem p03263 (python)

Fixed submission:
# -*- coding: utf-8 -*-
H, W = map(int, input().split(' '))
table = [list(map(int, input().split(' '))) for _ in range(H)]

def get_next():
    for h in range(H):
        if h % 2:
            for w in range(W-1, -1, -1):
                yield h, w
        else:
            for w in range(W):
                yield h, w


ret = []
routes = list(get_next())
prv_h, prv_w = routes[0]
for h, w in routes[1:]:
    if table[prv_h][prv_w] % 2:
        ret.append((prv_h, prv_w, h, w))
        table[h][w] += 1

    prv_h, prv_w = h, w


print(len(ret))
for prv_h, prv_w, h, w in ret:
    print(prv_h + 1, prv_w + 1, h + 1, w + 1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
H, W = map(int, input().split(' '))
table = [list(map(int, input().split(' '))) for _ in range(H)]

def get_next():
    for h in range(H):
        if h % 2:
            for w in range(W-1, -1, -1):
                yield h, w
        else:
            for w in range(W):
                yield h, w


ret = []
prv_h, prv_w = -1, -1
for h, w in get_next():
    if prv_h >= 0 and prv_w >= 0:
        if table[prv_h][prv_w] % 2:
            ret.append(prv_h, prv_w, h, w)

    prv_h, prv_w = h, w


print(len(ret))
for prv_h, prv_w, h, w in ret:
    print(prv_h + 1, prv_w + 1, h + 1, w + 1)
Problem p03569 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
ans = 0
left, right = 0, len(S)-1
while left < right:
    if S[left] == S[right]:
        left += 1
        right -= 1
    elif S[left] == 'x':
        left += 1
        ans += 1
    elif S[right] == 'x':
        right -= 1
        ans += 1
    else:
        print(-1)
        exit()

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = input()

#
can_solve = True
m = [s for s in S if s != 'x']
len_m = len(m)
for i in range(len_m):
    if m[i] != m[len_m - i - 1]:
        can_solve = False
        break

#
if can_solve:
    nums = [0 for _ in range(len_m+1)]
    i, n = 0, 0
    for s in S:
        if s == 'x':
            n += 1
        else:
            nums[i] = n
            i += 1
            n = 0
    nums[i] = n

    len_nums = len_m+1
    ans = 0
    for i in range(len_nums // 2):
        ans += max(nums[i], nums[len_nums - i - 1])
    if len_nums % 2 == 1:
        ans += nums[len_nums // 2 + 1] % 2
    # print(nums)
    print(ans)


else:
    print(-1)
Problem p03994 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S = list(input())
K = int(input())

for i in range(len(S)):
    if S[i] == 'a':
        continue

    d = ord('z') - ord(S[i]) + 1
    if K >= d:
        S[i] = 'a'
        K -= d
    # print(K, d)

if K > 0:
    j = ord(S[-1]) + K % 26
    S[-1] = chr(j)

print(''.join(S))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = list(input())
K = int(input())

for i in range(len(S)-1):
    if S[i] == 'a':
        continue

    d = ord('z') - ord(S[i]) + 1
    if K >= d:
        S[i] = 'a'
        K -= d
    # print(K, d)

if K > 0:
    j = ord(S[-1]) + K
    S[-1] = chr(j)

print(''.join(S))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = list(input())
K = int(input())

for i in range(len(S)):
    d = ord('z') - ord(S[i]) + 1
    if K >= d:
        S[i] = 'a'
        K -= d
    # print(K, d)

if K > 0:
    j = ord(S[-1]) + K
    S[-1] = chr(j)

print(''.join(S))
Problem p02641 (python)

Fixed submission:
import numpy as np
X, N = map(int, input().split())
P = list(map(int, input().split()))
candidate = list([x - 500 for x in range(1, 1000)])
P = sorted(set(candidate).difference(set(P)))
i = np.argmin([abs(p - X) for p in P])
print(P[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
X, N = map(int, input().split())
P = list(map(int, input().split()))
candidate = list(range(1, 101))
P = sorted(set(candidate).difference(set(P)))
i = np.argmin([abs(p - X) for p in P])
print(P[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
X, N = map(int, input().split())
P = list(map(int, input().split()))
candidate = list(range(1, 101))
P = sorted(set(candidate).difference(set(P)))
i = np.argmin([abs(p - X) for p in P])
print(P[i])
Problem p02786 (python)

Fixed submission:
import math
H = int(input())
n = math.floor(math.log(H, 2))
c = 1
for i in range(n):
    c += (2 ** (i+1))
print(c)

Buggy submission (verdict: Runtime Error):
import math
H = int(input())
n = math.floor(math.log2(H))
c = 1
for i in range(n):
    c += (2 ** (i+1))
print(c)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

def lcm(a, b):
    return (a*b) // gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M // k


if b % 2 == 0:
    r = int(b/2)
else:
    r = int((b + 1) / 2)

for a in A[1:]:
    if k // a % 2 == 0:
        r = 0
        break

print(r)

Buggy submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

def lcm(a, b):
    return (a*b) // math.gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M % 2
if b == 1:
    print(((M / k)+1)/2)
else:
    print((M / k) / 2)

Buggy submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

def lcm(a, b):
    return (a*b) // math.gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M % 2
if b == 1:
    print((M / k)+1/2)
else:
    print((M / k) / 2)
Problem p02837 (python)

Fixed submission:
N = int(input())

status = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        status[i].append((x-1,y))

honest = 0

# bit全探索
for i in range(2 ** N):
    flag = True
    for j in range(N):
        if ((i >> j) & 1) == 1:
            # bitが立っている箇所に対して処理。つまり,人jが正直者だとしたとき、
            # その人の発言と、矛盾していないか判定
            for x, y in status[j]: # 人jの証言            
                if ((i >> x) & 1) != y:
                    flag = False
                    break
    if flag:
        honest = max(honest, bin(i)[2:].count('1'))  # 0bが先頭につくため

print(honest)

Buggy submission (verdict: Runtime Error):
import numpy as np
from copy import deepcopy
N = int(input())

status = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        status[i].append((x-1,y))

honest = 0

# bit全探索
for i in range(2 ** N):
    flag = True
    for j in range(N):
        if ((i >> j) & 1) == 1:
            # bitが立っている箇所に対して処理。つまり,人jが正直者だとしたとき、
            # その人の発言と、矛盾していないか判定
            for x, y in status[j]: # 人jの証言            
                if ((i >> x) & 1) != y:
                    flag = False
                    break
    if flag:
        honest = max(honest, bin(i)[2:].count('1'))  # 0bが先頭につくため

print(honest)
Problem p02888 (python)

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

s = 0
for i in range(N):
    for j in range(i + 1, N):        
        k = bisect.bisect_left(L, L[i] + L[j])
        s += k - j - 1

print(s)

Buggy submission (verdict: Runtime Error):
s = 0
for i in range(N-2):
    for j in range(i + 1, N-1):        
        if L[j + 1] > abs(L[i] - L[j]):
            s += N - (j + 1)
            k = N - 1
            while True:
                if L[k] > abs(L[i] - L[j]):
                    break
                else:
                    s -= 1
                    k -= 1
print(s)
Problem p02995 (python)

Fixed submission:
from fractions import gcd

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

a, b, c, d = list(map(int, input().split()))

_ac = (a-1) // c # a以下のcの倍数の数
_bc = b // c # b以下のcの倍数の数

_ad = (a-1) // d # a以下のdの倍数の数
_bd = b // d # b以下のdの倍数の数

_acd = (a-1) // lcm(c,d) # a以下のcdの倍数の数
_bcd = b // lcm(c,d) # b以下のcdの倍数の数

m = (b-a+1) - ((_bc-_ac) + (_bd-_ad) - (_bcd-_acd))
print(m)

Buggy submission (verdict: Runtime Error):
import math

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

a, b, c, d = list(map(int, input().split()))

_ac = (a-1) // c # a以下のcの倍数の数
_bc = b // c # b以下のcの倍数の数

_ad = (a-1) // d # a以下のdの倍数の数
_bd = b // d # b以下のdの倍数の数

_acd = (a-1) // lcm(c,d) # a以下のcdの倍数の数
_bcd = b // lcm(c,d) # b以下のcdの倍数の数

m = (b-a+1) - ((_bc-_ac) + (_bd-_ad) - (_bcd-_acd))
print(m)

Buggy submission (verdict: Runtime Error):
import math

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

a, b, c, d = list(map(int, input().split()))

_ac = (a-1) // c
_bc = b // c

_ad = (a-1) // d
_bd = b // d

_acd = (a-1) // lcm(c,d)
_bcd = b // lcm(c,d)

m = (b-a+1) - ((_bc-_ac) + (_bd-_ad) - (_bcd-_acd))
print(m)

Buggy submission (verdict: Runtime Error):
import math

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

a, b, c, d = list(map(int, input().split()))

_ac = (a-1) // c # a以下のcの倍数の数
_bc = b // c # b以下のcの倍数の数

_ad = (a-1) // d # a以下のdの倍数の数
_bd = b // d # b以下のdの倍数の数

_acd = (a-1) // lcm(c,d) # a以下のcdの倍数の数
_bcd = b // lcm(c,d) # b以下のcdの倍数の数

m = (b-a+1) - ((_bc-_ac) + (_bd-_ad) - (_bcd-_acd))
print(m)