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

Fixed submission:
S = list(input())
ans = []
for i in range(len(S)):
    if S[i]=="A":
        ans.append(i)
        break
T = S[::-1]
for i in range(len(T)):
    if T[i]=="Z":
        ans.append(i)
        break
print((len(S)-ans[0])-ans[1])

Buggy submission (verdict: Runtime Error):
S = list(input())
ans = []
for i in range(1, len(S)-1):
    if S[i]=="A":
        ans.append(i)
        break
T = S[::-1]
for i in range(len(T)):
    if T[i]=="Z":
        ans.append(i)
        break
print((len(S)-ans[0])-ans[1])
Problem p03951 (python)

Fixed submission:
N = int(input())
s = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
    cnt = 1
elif N==1:
    ans = N*2
    cnt = 1
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            cnt = 1
            ans = N*2 - (N-i)
print(ans) if cnt==1 else print(N*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
elif N==1:
    ans = N*2
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            ans = N*2 - (N-i)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            ans = N*2 - (N-i)
print(ans)
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
ans = []
for i in range(N):
    A = input()
    ans.append(A)
ans = sorted(ans)
print("".join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = int(input())
ans = {}
for i in range(N):
    A = input()
    ans[A]=1
ans = sorted(ans)
print("".join(ans))
Problem p02675 (python)

Fixed submission:
n=int(input())
a=[2,4,5,7,9]
x=n%10
if x in a:
  print("hon")
elif x==3:
  print("bon")
else:
  print("pon")

Buggy submission (verdict: Runtime Error):
t=int(input())
a=[2,4,5,7,9]
x=n%10
if x in a:
  print("hon")
elif x==3:
  print("bon")
else:
  print("pon")
Problem p03293 (python)

Fixed submission:
input_a = input()
input_b = input()
if input_a == input_b:
    print('Yes')
    exit()

alt_a = input_a
res = False

while True:
    alt_a = alt_a[1:] + alt_a[0]

    if alt_a == input_a:
        break

    if alt_a == input_b:
        res = True
        break

print('Yes' if res else 'No')

Buggy submission (verdict: Runtime Error):
input_a = input()
input_b = input()

a = dict.fromkeys(set(input_a), 0)
for x in input_a:
    a[x] += 1
a = sorted(a.items())

b = dict.fromkeys(set(input_b), 0)
for x in input_b:
    b[x] += 1
b = sorted(b.items())

print('Yes' if all([a[i][0] == b[i][0] and a[i][1] == b[i][1] for i in range(len(a))]) else 'No')
Problem p03294 (python)

Fixed submission:
import fractions

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

n = int(input())
inputs = list(map(int, input().split(' ')))
for i in range(len(inputs)):
    if i == 0:
        x = lcm(inputs[0], inputs[1])
        continue
    if i == 1:
        continue
    x = lcm(x, inputs[i])
x -= 1
s = 0
for i in inputs:
    s += x % i
print(s)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(lst):
    if len(lst) == 2:
        return (lst[0] * lst[1]) // fractions.gcd(lst[0], lst[1])
    l = lcm(lst[1:])
    return (lst[0] * l) // fractions.gcd(lst[0], l)

n = int(input())
inputs = list(map(int, input().split(' ')))
x = lcm(inputs) - 1
s = 0
for i in inputs:
    s += x % i
print(s)

Buggy submission (verdict: Runtime Error):
import math

def lcm(lst):
    if len(lst) == 2:
        return (lst[0] * lst[1]) // math.gcd(lst[0], lst[1])
    l = lcm(lst[1:])
    return (lst[0] * l) // math.gcd(lst[0], l)

n = int(input())
inputs = list(map(int, input().split(' ')))
x = lcm(inputs) - 1
s = 0
for i in inputs:
    s += x % i
print(s)
Problem p02683 (python)

Fixed submission:
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
cost = 0
learn = [0 for _ in range(n)]
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(m)]

	# bit膳探索
	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	# 理解度達成しているか判定
	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False

	# 達成している and 最小コスト更新している
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
cost = 0
learn = [0 for _ in range(n)]
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(n)]

	# bit膳探索
	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	# 理解度達成しているか判定
	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False

	# 達成している and 最小コスト更新している
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
cost = 0
learn = [0 for _ in range(n)]
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(n)]

	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
anytassei = False

# bit = [0 for _ in range(n)]
mincost = 0
for i in range(n):
	mincost += ca[i][0]

for cnt in range(2**n):
	cost = 0
	learn = [0 for _ in range(n)]

	for i in range(n):
		# bit[i] = (cnt//2**i)%2
		if (cnt//2**i)%2 == 1:
			cost += ca[i][0]
			for j in range(m):
				learn[j] += ca[i][1+j]
	# print(bit)

	tassei = True
	for j in range(m):
		if learn[j] < x: tassei = False
	if tassei and cost <= mincost:
		mincost = cost
		anytassei = True

if anytassei: print(mincost)
else: print(-1)
Problem p02780 (python)

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

dicesum = 0
maxsum = 0
for i in range(n):
	dicesum += p[i]
	if i >= k:
		if n != k: dicesum -= p[i-k]
	maxsum = max(maxsum, dicesum)

ans = (maxsum + k) / 2
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
(
Problem p02921 (python)

Fixed submission:
s = list(input())
t = list(input())
ans = 0
for i in range(3):
	if s[i] == t[i]: ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
	a.append(list(map(int, input().split())))
# print(a)
b = [[0, 0] for _ in range(n)]
# print(b)
cnt = 0
cntmax = n*(n-1)
while cnt < cntmax:
	flag = True
	for i in range(n):
		pass1 = b[i][0]       
		if pass1 >= n-1: continue
		pass2 = b[a[i][pass1] - 1 ][0]      
		if pass2 >= n-1: continue
		
		if a[a[i][pass1] - 1][pass2] - 1 == i:
			b[a[i][b[i][0]] - 1][1] = b[i][1] = max(b[i][1], b[a[i][b[i][0]] - 1][1]) + 1
			b[a[i][b[i][0]] - 1][0] += 1
			b[i][0] += 1
			cnt += 2
			flag = False
			# print("done");print(a);print(b)
	if flag:
		print(-1)
		exit()
	# print(a)
	# print(b)
ans = 0
for i in range(n):
	ans = max(ans, b[i][1])
print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a%b)

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

if c > d:
	tmp = c
	c = d
	d = tmp
lcm = (c * d) // gcd(c, d)

Cstart = a - (a % c) + c if a % c != 0 else a
Cend = b - (b % c)
Dstart = a - (a % d) + d if a % d != 0 else a
Dend = b - (b % d)
LCMstart = a - (a % lcm) + lcm if a % lcm != 0 else a
LCMend = b - (b % lcm)

# print(Cstart, Cend)
# print(Dstart, Dend)
# print(LCMstart, LCMend)
# print()

Ccnt, Dcnt, LCMcnt = 0, 0, 0
if Cstart <= Cend:
	Ccnt = (Cend - Cstart) // c + 1
if Dstart <= Dend:
	Dcnt = (Dend - Dstart) // d + 1
if LCMstart <= LCMend:
	LCMcnt = (LCMend - LCMstart) // lcm + 1

# print(Ccnt, Dcnt, LCMcnt)
# print((Cend - Cstart)//4, Ccnt)

print((b-a+1) - Ccnt - Dcnt + LCMcnt)

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())

lcm = (c * d) // math.gcd(c, d)

Cstart = a - (a % c) + c if a % c != 0 else a
Cend = b - (b % c)
Dstart = a - (a % d) + d if a % d != 0 else a
Dend = b - (b % d)
LCMstart = a - (a % lcm) + lcm if a % lcm != 0 else a
LCMend = b - (b % lcm)

# print(Cstart, Cend)
# print(Dstart, Dend)
# print(LCMstart, LCMend)
# print()

Ccnt, Dcnt, LCMcnt = 0, 0, 0
if Cstart <= Cend:
	Ccnt = (Cend - Cstart) // c + 1
if Dstart <= Dend:
	Dcnt = (Dend - Dstart) // d + 1
if LCMstart <= LCMend:
	LCMcnt = (LCMend - LCMstart) // lcm + 1

# print(Ccnt, Dcnt, LCMcnt)
# print((Cend - Cstart)//4, Ccnt)

print((b-a+1) - Ccnt - Dcnt + LCMcnt)
Problem p03074 (python)

Fixed submission:
# import sys
# input = sys.stdin.readline

_, k = map(int, input().split())
s = list(map(int, list(input())))
# print(s)
is_count_zero = True
s0 = [0]
s1 = []
s0_ptr = 0
s1_ptr = -1
for c in s:
    if is_count_zero and c == 0:
        s0[s0_ptr] += 1
    elif not is_count_zero and c == 0:
        s0.append(1)
        s0_ptr += 1
        is_count_zero = True
    elif is_count_zero and c == 1:
        s1.append(1)
        s1_ptr += 1
        is_count_zero = False
    else: # not is_count_zero and c == 1
        s1[s1_ptr] += 1

# print(s0,s1)
is_end_one = True if len(s0) == len(s1) else False

if k >= len(s0):
    print(sum(s0)+sum(s1))
# elif k == 0:
#     if s1 == []:
#         print(0)
#     else:
#         print(max(s1))
else:
    ans = 0
    sum_range = 0
    n = len(s0)-k+1
    for i in range(n):
        if i == 0:
            sum_range = sum(s0[:k]) + sum(s1[:k])
            ans = max(ans, sum_range)
        elif i == n-1:
            sum_range = sum(s0[i:]) + sum(s1[i-1:])
            ans = max(ans, sum_range)
        elif i == 1:
            sum_range = sum_range - s0[0] + s0[k] + s1[k]
            ans = max(ans, sum_range)
        elif i != 0:
            sum_range = sum_range - s0[i-1] + s0[i+k-1] - s1[i-2] + s1[i+k-1]
            ans = max(ans, sum_range)
    print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
is_count_zero = True
sl = [0]
sl_ptr = 0
for c in s:
    if is_count_zero and c == '1':
        sl.append(1)
        sl_ptr += 1
        is_count_zero = False
    elif not is_count_zero and c == '0':
        sl.append(1)
        sl_ptr += 1
        is_count_zero = True
    else:
        sl[sl_ptr] += 1

# print(sl)
# print("len(sl):{} len(sl)-1)//2:{}".format(len(sl), (len(sl)-1)//2))

if k > (len(sl)-1)//2:
    print(sum(sl))
elif k == (len(sl)-1)//2:
    if sl[0] == 0:
        print(sum(sl))
    else:
        print(max(sum(sl[1:]), sum(sl[:-1])))
else:
    ans = 0
    for i in range((len(sl)+1)//2-(k-1)):
        if i == 0:
            ans = max(ans, sum(sl[:k*2-1]))
            # print("sl[:k*2-1]:{} sum:{}".format(sl[:k*2-1], sum(sl[:k*2-1])))
        else:
            ans = max(ans, sum(sl[i*2-1:(i+k)*2]))
            # print("sl[i*2-1:(i+k)*2-1]: {}".format(sl[i*2-1:(i+k)*2]))
    print(ans)
Problem p02681 (python)

Fixed submission:
s = input().strip()
t = input().strip()

if s == t[:len(s)] and len(t) == len(s) + 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input().strip()
t = input().strip()

print "Yes" if s == t[:len(s)] and len(t) == len(s) + 1 else "No"
Problem p02690 (python)

Fixed submission:
x = int(input())

x2 = int(x**0.5)
if x2**5 == x:
  print(x2, 0)
  exit()
elif x2**5-1 == x:
  print(X2, -1)
  exit()

for i in range(1, int(x**0.5)+2):
  if x%i == 0:
    tmp1 = 0
    tmp2 = 0
    a1 = i
    b1 = 0
    a2 = i-1
    b2 = -1
    while abs(tmp1) <= x**2 or abs(tmp2) <= x**2:
      tmp1 = a1**5 - b1**5
      tmp2 = a2**5 - b2**5
      if tmp1 == x:
        print(a1, b1)
        exit()
      elif tmp2 == x:
        print(a2, b2)
        exit()
      a1+=1
      b1+=1
      a2-=1
      b2-=1

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

x2 = int(x**0.5)
if x2**5 == x:
  print(x2, 0)
  exit()
elif x2**5-1 == x:
  print(X2, -1)
  exit()

for i in range(1, x**0.5+2):
  if i==0:
    continue
  if x%i == 0:
    tmp1 = 0
    tmp2 = 0
    a1 = i
    b1 = 0
    a2 = i-1
    b2 = -1
    while tmp1 <= x or tmp2 <= x:
      tmp1 = a1**5 - b1**5
      tmp2 = a2**5 - b2**5
      if tmp1 == x:
        print(a1, b1)
        exit()
      elif tmp2 == x:
        print(a2, b2)
        exit()
      a1+=1
      b1+=1
      a2-=1
      b2-=1
Problem p02705 (python)

Fixed submission:
print(int(input())*2*3.141592)

Buggy submission (verdict: Runtime Error):
print(int(input)*2*3.141592)
Problem p02924 (python)

Fixed submission:
n = int(input())
print(int(n*(n-1)//2))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
lst1 = np.array([list(range(1,n))])

if n==1:
  print(0)
else:
  print(lst1.sum())

Buggy submission (verdict: Runtime Error):
n = int(input())
lst1 = list(range(1,n))
#lst2 = list(range(2,n+1))
#lst2.append(1)
#lst3 = list(range(2,n+1))
#del lst3[lst3.index(n//2+1)]
#lst3.append(n//2+1)
m_sum = sum(lst1)
#m_sum2 = sum(list(map(lambda x,y,:x%y, lst1, lst3)))
if n==1:
  print(0)
else:
  print(m_sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst1 = list(range(1,n+1))
lst2 = list(range(2,n+1))
lst2.append(1)
#lst3 = list(range(2,n+1))
#del lst3[lst3.index(n//2+1)]
#lst3.append(n//2+1)
m_sum = sum(list(map(lambda x,y,:x%y, lst1, lst2)))
#m_sum2 = sum(list(map(lambda x,y,:x%y, lst1, lst3)))
if n==1:
  print(0)
else:
  print(m_sum)
Problem p02947 (python)

Fixed submission:
from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

Buggy submission (verdict: Runtime Error):
#from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(soted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)
Problem p02953 (python)

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flg = True

for i in range(len(lst)-2, 0, -1):
  if lst[i] == 1 + lst[i+1]:
    lst[i] -= 1
  elif lst[i] > 1 + lst[i+1]:
    flg = False
    break

#if lst.index(max(lst)) < lst.index(min(lst)) and max(lst)>min(lst)+1:
if sorted(lst) != lst:
  flg = False
  
if flg:
  print("Yes")
else:
  print("No")

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

for i in range(lst):
  if lst[i] > lst[i+1]:
    lst[i] -= 1
if sorted(lst) == lst:
  print("Yes")
else:
  print("No")
Problem p02981 (python)

Fixed submission:
n, a, b = map(int, input().split())
lst = [n*a, b]
print(min(lst))

Buggy submission (verdict: Runtime Error):
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())
l3 = l
l2 = 2019*(l//2019)
r -= l2
l %= 2019

if r>= 2019:
  print(0)
else:
  print(l*(l+1)%2019)

#for i in range()

#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)
"""
for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)
"""
#*/
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
tmp = 2019*(l//2019)
l -= tmp
r -= tmp
if r >= 2019:
  print(0)
else:
  m = 2020
  for i in range(l, r):
    for j in range(i+1, r+1):
      if m > i*j%2019:
        m = i*j%2019
  print(m)

Buggy submission (verdict: Runtime Error):
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())
l = l3
l2 = 2019*(l//2019)
r -= l2
l %= 2019

if r>= 2019:
  print(0)
else:
  print(l3*(l3+1))

#for i in range()

#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)
"""
for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)
"""
#*/

Buggy submission (verdict: Runtime Error):
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
"""
l, r = map(int, input().split())
l %= 2019
r %= 2019

lst = []

for i in range(l,r):
  for j in range(i+1,r+1):
    lst.append(i*j%2019)
print(min(lst))
#*/
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d = map(int,input().split())
#cnt = 0
#lst = [i for i in range(a,b+1) if i%c!=0 and i%d!=0]
#print(len(lst))

c_d = int(c*d/gcd(c,d))
a -= 1
c2 = (b//c) - (a//c)
d2 = (b//d) - (a//d)
cd = (b//(c_d)) - (a//(c_d))
print(b-a - (c2+d2-cd))
#print(b-a-(b//c+b//d - a//c+a//d  - b//c_d - a//c_d))
"""
a-=1
a2 = a//c + a//d - a//(c*d)
print(b-a-(b//c + b//d - b//(c*d) - a2))
"""
"""
for i in range(a,b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
print(cnt)
"""

Buggy submission (verdict: Runtime Error):
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
  long long a,b,c,d,cnt;
  cnt = 0;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  //printf("%lld%lld%lld%lld",a,b,c,d);
  for(int i=a;i<=b;i++){
    if(i % c != 0 && i % d != 0){
      cnt++;
    }
  }
  printf("%lld\n",cnt);
}
Problem p02999 (python)

Fixed submission:
x, a = map(int,input().split())
if a > x:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
lst = list(map(int, input().split()))
#cnt = 0
ans = []
"""
def arr(m,a):
  if m==n:
    print(a+sum([1 for j in range(n) if not j+m>n and sum(lst[j:j+m])>=k]))
    return
  return arr(m+1,a+sum([1 for j in range(n) if not j+m>n and sum(lst[j:j+m])>=k]))
  
arr(1,0)
"""

for i in range(1,n+1):
  ans += [1 for j in range(n) if not j+i>n and sum(lst[j:j+i])>=k]
print(sum(ans))
"""
  for j in range(n):
    if j+i > n:
      continue
    if sum(lst[j:j+i]) >= k:
      cnt += 1
      #print(j,j+1,sum(lst[j:j+i]),cnt)
"""

#ans += [lst[j] for j in lst if sum(lst) >= k:]
Problem p03007 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

while max(x) > -1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(nma+" "+i)
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []


while len(x) > 2:
  mi = min(x)
  ma = max(x)
  if mi < 0:
    lst.append(str(ma)+" "+str(mi))
    del x[x.index(mi)]
    del x[x.index(ma)]
    x.append(ma - mi)
  lst.append(str(ma)+" "+str(mi))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

print(max(x) - min(x))
for i in range(len(lst)):
  print(lst[i])
print(max(x),min(x))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []


while len(x) > 2:
  mi = min(x)
  ma = max(x)
  if mi < 0:
    lst.append(str(ma)+" "+str(mi))
    del x[x.index(mi)]
    del x[x.index(ma)]
    x.append(ma - mi)
    lst.append(str(ma)+" "+str(mi))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

print(max(x) - min(x))
for i in range(len(lst)):
  print(lst[i])
print(max(x),min(x))
Problem p03544 (python)

Fixed submission:
n=int(input())
a, b = 2, 1
for i in range(n-1):
  a, b = b, a + b
  
print(b)

Buggy submission (verdict: Runtime Error):
a = int(input())

def luc(n):
  if n = 0:
    return 2
  elif n = 1:
    return 1
  else:
    return luc(n-1) + luc(n-2)

print(luc(a))