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

Fixed submission:
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])
l.sort()

for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = "1000000 1000000"
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(n-1):
    for j in range(i+1, n):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(len(l)):
    for j in range(i+1, len(l)+1):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(len(l)):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(len(l)):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] - x, l[i][1] - y] in l:
        ans += 1

print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
l2 = []

for i in range(n):
    x, y = list(map(int, input().split()))
    l.append([x,y])

for i in range(len(l)):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))


cnt = l2.count(max(l2, key=l2.count))

print(n - cnt)
Problem p03067 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))

if C < A and C > B:
    print ("Yes")

elif C > A and C < B:
    print ("Yes")

else:
    print ("No")

Buggy submission (verdict: Runtime Error):
N = int (input ())
S = str (input ())
 
def dot_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '.':
            cnt += 1
    return cnt
 
def hash_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '#':
            cnt += 1
    return cnt
 
dots = dot_num ()
hashes = hash_num ()
 
if S [0] == '.':
    dots -= 1
 
if S [N-1] == '#':
    hashes -= 1
    
print (min (dots, hashes))

Buggy submission (verdict: Runtime Error):
A = int (input ())
B = int (input ())
C = int (input ())

if C < A and C > B:
    print ("Yes")

elif C > A and C < B:
    print ("Yes")

else:
    print ("No")
Problem p03069 (python)

Fixed submission:
N = int (input ())
S = str (input ())
S = '.' + S
N += 1
cnt = 0
inf = int(1e9)

A = list(range(N))
for i in range(N):
    A[i] =[inf,inf]
A[0][0] = A[0][1] = 0
for i in range (1,N):
    for j in range (2):
        if j == 1:
            if S[i] == '.':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
                A[i][j] = min(A[i][j], A[i-1][1] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0] )
                A[i][j] = min(A[i][j], A[i-1][1] )
        else:
            if S[i] == '#':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0])                

ans = min(A[N-1][0],A[N-1][1])

print (ans)

Buggy submission (verdict: Runtime Error):
N = int (input ())
S = str (input ())

def dot_num ():
    cnt = 0
    for i in range (1, N+1):
        if S [i] == '.':
            cnt += 1
    return cnt

def hash_num ():
    cnt = 0
    for i in range (1, N+1):
        if S [i] == '#':
            cnt += 1
    return cnt

dots = dot_num ()
hashes = hash_num ()

if S [0] == '.':
    dots -= 1

if S [N] == '#':
    hashes -= 1
    
print (min (dots, hashes))

Buggy submission (verdict: Runtime Error):
N = int (input ())
S = str (input ())

def dot_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '.':
            cnt += 1
    return cnt

def hash_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '#':
            cnt += 1
    return cnt

dots = dot_num ()
hashes = hash_num ()

if S [0] == '.' and S [1] == '#':
    dots -= 1

if S [N-1] == '#' and S [N-2] == '.':
    hashes -= 1
    
print (min (dots, hashes))
Problem p02882 (python)

Fixed submission:
import numpy as np

a,b,x = map(int, input().split())

v = a*a*b

if v == x:
    print(0)
    exit(0)

t = None
if x >= v/2:
    pad = a*a*b - x
    h = (2*pad)/(a*a)
    t = np.arctan(h/a)
else:
    w = (2*x)/(a*b)
    t = np.arctan(b/w)
print(t*180/np.pi)

Buggy submission (verdict: Runtime Error):
import numpy as np

a,b,x = map(int, input().split())

v = a*a*b

if v == x:
    print(0)
    exit(0)

h = (2*x)/(a*a)

t = np.arctan(h/a)

print(t*180/np.pi)
Problem p03623 (python)

Fixed submission:
x,a,b=map(int, input().split())
if abs(x-b) > abs(x-a):
  print('A')
else:
  print('B')

Buggy submission (verdict: Runtime Error):
x,a,b=map(int, input()split())
if abs(x-b) > abs(x-a):
  print('A')
else:
  print('B')
Problem p03732 (python)

Fixed submission:
# ARC60 D input
nw = list(map(int, input().split()))
N = nw[0]
w_limit = nw[1]

w = []
v = []
for i in range(N):
    wv = list(map(int, input().split()))
    w.append(wv[0])
    v.append(wv[1])

# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))

Buggy submission (verdict: Runtime Error):
# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))
Problem p03816 (python)

Fixed submission:
N = int(input())

A = len(set(list(map(int, input().split()))))

if A % 2 == 0:
    print(A - 1)
else:
    print(A)

Buggy submission (verdict: Runtime Error):
from itertools import groupby

N = input()
A = map(int, input().split())

B = [len(list(group)) for key, group in groupby(sorted(A))]
C = []
for i, val in enumerate(B):
	if val % 2 == 0: C.append(2)
	else: C.append(1)

D = [len(list(group)) for key, group in groupby(sorted(C))]

if D[1] % 2 == 0:
	answer = D[0] +D[1]
else:
	answer = D[0] +D[1] - 1

print(answer)
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print(T + S)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
return T + S
Problem p02947 (python)

Fixed submission:
# coding: utf-8

n = int(input())
words = {}
ans = 0

for i in range(n):
  t = ''.join(sorted(input()))
  if t in words:
    ans += words[t]
    words[t] += 1
  else:
    words[t] = 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

n = int(input())
words = {}
ans = 0

for i in range(n):
  t = ''.join(sorted(input()))
  if t in words:
    ans += words[t]
    words[t] += 1
  else:
    words[t] += 1
    
print(ans)
Problem p02952 (python)

Fixed submission:
# coding: utf-8

n = int(input())
d = len(str(n))
ans = 0

if d == 1:
  print(n)
else:
  for i in range(1, d+1):
    if i % 2 == 0:
      continue

    if i == d:
      ans += n - (10**(i-1)) + 1
      break;

    if i == 1:
      ans += 9
    else:
      ans += (10**i) - (10**(i-1))

  print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

n = int(input())
d = len(str(n))
ans = 0

for i in range(1, d+1):
  if i % 2 == 0:
    continue
  
  if i == d:
    print(i)
    print((n % div) + 1)
    div = 10 if (i == 1) else 10**(i-1)
    ans += (n % div) + 1
    break;

  m = 0 if (i == 1) else (10**(i-1))
  mm = 1 if (i == 1) else 0
  ans += (10**(i)) - mm - m

print(ans)
Problem p03160 (python)

Fixed submission:

N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0

for i in range(1, N):
  tmp1 = dp[i-1] + abs(H[i] - H[i-1])
  tmp2 = dp[i-2] + abs(H[i] - H[i-2]) if i > 1 else 2**64
  dp[i] = min(tmp1, tmp2)
  
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

N = int(input())
H = map(int, input().split())

dp = [] * N
dp[0] = 0

for i in range(1, N):
  tmp1 = dp[i-1] + abs(H[i] - H[i-1])
  tmp2 = dp[i-2] + abs(H[i] - H[i-2]) if i > 1 else 2**64
  dp[i] = min(tmp1, tmp2)
  
print(dp[N-1])
Problem p02909 (python)

Fixed submission:
w = ["Sunny","Cloudy","Rainy"]
s = input()
print(w[(w.index(s)+1)%3])

Buggy submission (verdict: Runtime Error):
w = ["Sunny","Cloudy","Rainy"]
s = input()
print(w[(w.index(s)+1)%3]
Problem p02910 (python)

Fixed submission:
import sys

s = input()
i = 0
while i < 100 and i < len(s):
    if s[i] != "R" and s[i] != "U" and s[i] != "D":
        print("No")
        sys.exit()
    i += 2
i = 1
while i < 100 and i < len(s):
    if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
        print("No")
        sys.exit()
    i += 2

print("Yes")

Buggy submission (verdict: Runtime Error):

s = input()
i = 0
while i < 100 and i < len(s):
    if s[i] != "R" and s[i] != "U" and s[i] != "D":
        print(i)
        print(s[i])
        print("1No")
        sys.exit()
    i += 2
i = 1
while i < 100 and i < len(s):
    if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
        print(s[i])
        print("2No")
        sys.exit()
    i += 2

print("Yes")
Problem p03448 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x==500*i+100*j+50*k:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
x=input()
ans=0
for i in range(a):
  for j in range(b):
    for k in range(c):
      if x==500*i+100*j+50*k:
        ans+=1
print(ans)
Problem p03494 (python)

Fixed submission:
input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
input()
List=list(map(int,input().split()))
ans=0
while all(l%2==0 for l in List):
  List[l/2 for l in List]
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
List=list(map(int,input().split()))
ans=0
while all(l%2==0 for l in List):
  List[l/2 for l in List]
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
List=list(map(int,input().split()))
ans=0
while all(l%2==0 for l in List):
  List[l/2 for l in List]
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
ans=0
while all(i%2==0 for i in l):
  l[i/2 for i in l]
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
l=list(map(int,input().split()))
ans=0
while l%2==0 for i in l:
  l[i/2 for i in l]
  ans += 1
print(ans)
Problem p03827 (python)

Fixed submission:
input()
s=input()
c,m=0,0
for i in range(len(s)):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
        m=max(c,m)
print(m)

Buggy submission (verdict: Runtime Error):
n=input()
s=input()
c,m=0,0
for i in range(n-1):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
print(m)

Buggy submission (verdict: Runtime Error):
n=input()
s=input()
c,m=0,0
for i in range(n):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
print(m)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
y = 0

for i in range(len(s)):
  if s[i] == "I":
    y += 1
    x = max(x,y)
  if s[i] == "D":
    y = y - 1
	x = max(x,y)
print(x)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
y = 0

for i in range(n):
  if s[i] == "I":
    y += 1
    x = max(x,y)
  if s[i] == "D":
    y = y - 1
	x = max(x,y)
print(x)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
y = 0

for i in range(n - 1):
  if s[i] == "I":
    y += 1
    x = max(x,y)
  if s[i] == "D":
    y = y - 1

print(x)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
y = 0

for i in range(n):
  if s[i] == "I":
    y += 1
    x = max(x,y)
  if s[i] == "D":
    y = y - 1

print(x)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
y = 0

for i in range(n):
  if i == "I":
    y += 1
    x = max(x,y)
  if i == "D":
    y = y - 1

print(x)
Problem p04030 (python)

Fixed submission:
s=input()
ans=[]
for i in range(len(s)):
  if s[i]=="0" or s[i]=="1":
    ans.append(s[i])
  else:
    try:ans.pop()
    except:pass
print("".join(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans=[]
for i in range(len(s)):
  if s[i]==0 or s[i]==1:
    ans.append(i)
  else:
    try;ans.pop()
    except:pass
print("".join(ans))
Problem p04044 (python)

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

s = sorted([input() for i in range(n)])

print(*s,sep="")

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

s = sorted([input() for i in range(n)])

print(*s,sep)
Problem p03210 (python)

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

if a == 7 or a == 5 or a == 3:
    print('YES')
else:
    print('NO')

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

if a == 7 || a == 5 || a == 3:
    print('YES')
else:
    print('NO')
Problem p04043 (python)

Fixed submission:
A, B, C = map(int, input().split())
if B < A:
    A, B = B, A

if C < A:
    A ,C = C, A

if C < B:
    B, C = C, B

if A != 5 or B != 5 or C != 7:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if B < A:
    A, B = B, A

if C < A:
    A ,C = C, A

if C < B:
    B, C = C, B

if A != 5 or B != 5 or C != 7:
    print("NO")
else:
    print("YES")
Problem p02806 (python)

Fixed submission:
import sys
lines = sys.stdin.readlines()
n = lines.pop(0)
e = lines.pop(-1).strip()
r = 0
s = False
for l in lines:
    l = l.strip()
    n, t = l.split(' ')
    if s:
        r += int(t)
    elif n == e:
        s = True
print(r)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
factorials = [1] + list(accumulate(range(1,n + 1), mul))

combinations = dict()
def combination(i, j):
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    t = factorials[lt] * combination(n, gt) * factorials[gt]
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))
Problem p03633 (python)

Fixed submission:
import fractions
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b // fractions.gcd(a, b)

n = int(input())

ans = 1
for i in range(n):
    ti = int(input())
    ans = int(lcm(ti, ans))
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / fractions.gcd(a, b)

n = int(input())

ans = 1
for i in range(n):
    ti = int(input())
    ans = int(lcm(ti, ans))
while True:
    try:
        input()
    except EOFError:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / fractions.gcd(a, b)

n = int(input())

ans = 1
for i in range(n):
    ti = int(input())
    ans = int(lcm(ti, ans))
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    if b > a:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)

n = int(input())

ans = 1
for i in range(n):
    ti = int(input())
    ans = int(lcm(ti, ans))
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)

n = int(input())

ans = 1
for i in range(n):
    ti = int(input())
    ans = int(lcm(ti, ans))
print(ans)
Problem p03854 (python)

Fixed submission:
s = input().rstrip()
d = ['dream', 'dreamer']
e = ['erase', 'eraser']
ch = d + e

st = [s]

def search_(s, st, ch):
    if len(s) == 0:
        return
    if len(s) < len(ch):
        return
    else:
        if s[:len(ch)] == ch:
            st.append(s[len(ch):])

def search(s):
    if len(s) == 0:
        return True
    if s[0] == 'd' or s[0] == 'e':
        for ci in ch:
            if search_(s, ci):
                return True
    return False

while st:
    s = st.pop(0)
    if len(s) == 0:
        print('YES')
        exit()
    if s[0] == 'd' or s[0] == 'e':
        for ci in ch:
            search_(s, st, ci)
print('NO')

Buggy submission (verdict: Runtime Error):
s = input().rstrip()
d = ['dream', 'dreamer']
e = ['erase', 'eraser']
ch = d + e

def search_(s, ch):
    if len(s) == 0:
        return True
    if len(s) < len(ch):
        return False
    else:
        if s[:len(ch)] == ch:
            return search(s[len(ch):])
    return False

def search(s):
    if len(s) == 0:
        return True
    if s[0] == 'd' or s[0] == 'e':
        for ci in ch:
            if search_(s, ci):
                return True
    return False

if search(s):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = input().rstrip()
d = ['dream', 'dreamer']
e = ['erase', 'eraser']
ch = d + e

def search_(s, ch):
    if len(s) == 0:
        return True
    if len(s) < len(ch):
        return False
    else:
        if s[:len(ch)] == ch:
            return search(s[len(ch):])

def search(s):
    if len(s) == 0:
        return True
    if s[0] == 'd' or s[0] == 'e':
        for ci in ch:
            if search_(s, ci):
                return True
    return False

if search(s):
    print('YES')
else:
    print('NO')
Problem p02806 (python)

Fixed submission:
n=int(input())
l=[input() for i in range(n)]
target_song = input()

total = 0

ff = False

for i in l:
    s, t = i.split(" ")

    if s == target_song:
        ff = True
        continue
        
    if ff == True:
        total +=  int(t)

print(total)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[input() for i in range(n)]
target_song = input()

total = 0

ff = False

for i in l:
    s, t = i.split(" ")

    if s == target_song:
        f = True
        continue
        
    if f == True:
        total +=  int(t)

print(total)
Problem p02995 (python)

Fixed submission:
import fractions

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

cxd = (c * d) // fractions.gcd(c, d)
sa = b - a
ans = (b - b//c - b//d + b//cxd) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//cxd)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
cxd = (c * d) // math.gcd(c, d)
sa = b - a

ans = (b - b//c - b//d + b//cxd) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//cxd)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
cxd = (c * d) // math.gcd(c, d)
sa = b - a

print(sa - ((sa//c + sa//d) - sa//cxd))
Problem p03030 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append([s, int(p), i])

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

for x in a:
    print(x[2]+1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
s = [[x, *(input().split())] for x in range(n)]

s = sorted(s, key = itemgetter(2), reverse=True)
s = sorted(s, key = itemgetter(1))

for i in s:
    print(i[0]+1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
s = [[x, *(input().split())] for x in range(n)]

s = sorted(s, key = itemgetter(2), reverse=True)
s = sorted(s, key = itemgetter(1))

for i in s:
    print(i[0]+1)
Problem p03043 (python)

Fixed submission:
import math
N, K = map(int, input().split())
score = 0

if K <= N:
	ans = (N-K+1)/N
	end = K
else:
	ans = 0
	end = N+1
for i in range(1, end):
	ans += (1/N) * (1/2)**math.ceil(math.log2(K/i))
	
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
# n < k の場合も考える必要がある

p = 0
for i in range(1, n+1):
    tmp = (n**-1)*(0.5)**int(math.log2(k//i) + 1)
    p+=tmp

print(p)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 7))

def dfs(v, c, parent):
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		if color[u] != -1:
			continue
		if w%2 == 0:
			dfs(u, c, v)
		else:
			dfs(u, 1-c, v)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, parent=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
def dfs(v, c, total):
	if color[v] != -1:
		return
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		total+=w
		if total%2 == 0:
			dfs(u, c, total)
		else:
			dfs(u, 1-c, total)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, total=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
def dfs(v, c, total):
	if color[v] != -1:
		return
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		total+=w
		if total%2 == 0:
			dfs(u, 0, total)
		else:
			dfs(u, 1, total)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(0, 0, 0)
for i in color:
	print(i)