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

Fixed submission:
# -*- coding:utf-8 -*-

import math

N = int(input())

type_dict = {}
for _ in range(N):
    s = input()
    counts = (
        s.count('a'), s.count('b'), s.count('c'), s.count('d'),
        s.count('e'), s.count('f'), s.count('g'), s.count('h'),
        s.count('i'), s.count('j'), s.count('k'), s.count('l'),
        s.count('m'), s.count('n'), s.count('o'), s.count('p'),
        s.count('q'), s.count('r'), s.count('s'), s.count('t'),
        s.count('u'), s.count('v'), s.count('w'), s.count('x'),
        s.count('y'), s.count('z')
    )
    if counts in type_dict:
        type_dict[counts] = type_dict[counts] + 1
    else:
        type_dict[counts] = 1


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(sum([combinations_count(x, 2) for x in type_dict.values() if x > 1]))

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

import math

N = int(input())

type_dict = {}
for _ in range(N):
    s = input()
    counts = (
        s.count('a'), s.count('b'), s.count('c'), s.count('d'),
        s.count('e'), s.count('f'), s.count('g'), s.count('h'),
        s.count('i'), s.count('j'), s.count('k'), s.count('l'),
        s.count('m'), s.count('n'), s.count('o'), s.count('p'),
        s.count('q'), s.count('r'), s.count('s'), s.count('t'),
        s.count('u'), s.count('v'), s.count('w'), s.count('x'),
        s.count('y'), s.count('z')
    )
    if counts in type_dict:
        type_dict[counts] = type_dict[counts] + 1
    else:
        type_dict[counts] = 1


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(sum([combinations_count(x, 2) for x in type_dict.items() if x > 1]))
Problem p03854 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import re
# 整数の入力
S = input()
S=re.sub('dreamer(?!ase)','',S)
S=re.sub('eraser(?!ase)','',S)
S=S.replace('dream','')
S=S.replace('erase','')
 
if len(S) == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
S.replace('dream','')
S.replace('dreamer','')
S.replace('erase','')
S.replace('eraser','')

if len(S) = 0:
  print('YES')
else:
  print('NO')
Problem p02934 (python)

Fixed submission:
N = int(input())
input_str = input()
array_strs = input_str.split(" ")
sum_recip = 0.0

for i in range(N):
    sum_recip += 1 / float(array_strs[i])

print(1 / sum_recip)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];

  double sum_recip = 0.0;

  for(int i=0; i<N; i++)
    sum_recip += 1 / A[i];

  cout << 1 / sum_recip << endl;
}
Problem p02923 (python)

Fixed submission:
n = int(input())

h = list(map(int, input().split()))

ans = [0]

cnt = 0
l = h[0]
for i in range(1, n):
    r = h[i]
    if l >= r:
        cnt += 1
    else:
        cnt = 0
    l = h[i]
    ans.append(cnt)

print(max(ans))

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

h = list(map(int, input().split()))

ans = []

cnt = 0
l = h[0]
for i in range(1, n):
    r = h[i]
    if l >= r:
        cnt += 1
    else:
        cnt = 0
    l = h[i]
    ans.append(cnt)

print(max(ans))
Problem p02952 (python)

Fixed submission:
n = input()

l = len(n)

ans = 0
j = 1
for i in range(1, l, 2):
    ans += 9 * j
    j *= 100

if l % 2 == 0:
    print(ans)
else:
    ans += (int(n[0]) - 1) * j
    if l != 1:
        ans += int(n[1:]) + 1
    else:
        ans += 1
    print(ans)

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

l = len(n)

ans = 0
j = 1
for i in range(1, l, 2):
    ans += 9 * j
    j *= 100

if l % 2 == 0:
    print(ans)
else:
    ans += (int(n[0]) - 1) * j
    ans += int(n[1:]) + 1
    print(ans)
Problem p02995 (python)

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


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

b_cnt1 = b // c

b_cnt2 = b // d

b_cnt3 = b // lcm(c, d)

a_cnt1 = a // c

a_cnt2 = a // d

a_cnt3 = a // lcm(c, d)

print(b - (b_cnt1 + b_cnt2 - b_cnt3) - (a - (a_cnt1 + a_cnt2 - a_cnt3)))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

b_cnt1 = b // c

b_cnt2 = b // d

b_cnt3 = b // lcm(c, d)

a_cnt1 = a // c

a_cnt2 = a // d

a_cnt3 = a // lcm(c, d)

print(b - (b_cnt1 + b_cnt2 - b_cnt3) - (a - (a_cnt1 + a_cnt2 - a_cnt3)))
Problem p03026 (python)

Fixed submission:
n = int(input())

edge = [[] for i in range(n)]

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

cost = list(map(int, input().split()))

c = sorted(cost, reverse=True)

w = [0] * n

w[0] = c.pop(0)

chk = [i for i in edge[0]]

while chk != []:
    node = chk.pop(0)
    if w[node] == 0:
        w[node] = c.pop(0)
        chk.extend(edge[node])

print(sum(cost) - max(cost))

print(' '.join(map(str, w)))

Buggy submission (verdict: Runtime Error):
n = int(input())
edge = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cost = list(map(int, input().split()))
c = sorted(cost, reverse=True)
w = [0] * n
w[0] = c.pop(0)
chk = [*edge[0]]

while chk != []:
    node = chk.pop(0)
    if w[node] == 0:
        w[node] = c.pop(0)
        chk.extend(edge[node])

print(sum(cost) - max(cost))
print(' '.join(map(str, w)))
Problem p02923 (python)

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

top = 0
count = 0

for i in range(N):
    challenge = True
    
    if count > 0:
        count -= 1
    else:
        while challenge == True and i < N-1:
            if high[i] >= high[i+1]:
                count += 1
                if i < N-1:
                    i += 1
            else:
                challenge = False
        
        if top < count:
            top = count

print(top)

Buggy submission (verdict: Runtime Error):
N = int(input())
high = [int(x) for x in input().split()]

top = 0

for i in range(N):
    challenge = True
    
    if count > 0:
        count -= 1
    else:
        while challenge == True and i < N-1:
            if high[i] >= high[i+1]:
                count += 1
                if i < N-1:
                    i += 1
            else:
                challenge = False
        
        if top < count:
            top = count

print(top)
Problem p02953 (python)

Fixed submission:
import sys
N=int(input())
H=list(map(int,input().split()))

le=int(len(H))

a=0
for i in range(0,N):
    if a-1>H[i]:
        print("No")
        sys.exit()
    if H[i]>a:
        a=H[i]
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=list(map(int,input().split()))

L=H
#print(H)
le=int(len(H))
#maxh=max(H)
#print(maxh)
maxi=np.argmax(H)
txt="Yes"
# for i in range(maxi+1,le-1):
#     if H[i]<=H[maxi]-1:
#         txt="No"
#         break
# print(txt)

for j in range(0,le-2):
    if maxi==le-1:
        pass
    else:
        for i in range(maxi+1,le-1):
            if H[i]<=H[maxi]-1:
                txt="No"
                flag=1
                break
        if flag==1:
            break
    L[maxi]=0
    maxi=np.argmax(L)
print(txt)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0]+ str(len(s)-2) + s[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0]+ len(s)-2 + s[len(s-1)])
Problem p04044 (python)

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

list = sorted([input() for i in range(n)])
print("".join(list))

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
s = sortedf([input() for i in range(N)])
print("".join(s))
Problem p03071 (python)

Fixed submission:
l = list(map(int, input().split(' ')))
l.sort()
tmp = l[1]
if (l[1]-1<l[0]):
    print(l[1]+l[0])
elif(l[1]==l[0]):
    print(l[0]+l[1])
else :
    print(l[1]*2-1)

Buggy submission (verdict: Runtime Error):
l = list(map(int, input().split(' ')))
l.sort()
tmp = l[1]
if (l[1]-1>l[0]):
    print(l[1]+l[0])
else if(l[1]=l[0]):
    print(l[0]+l[1]) 
else :
    print(l[1]*2-1)
Problem p03212 (python)

Fixed submission:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret
print(dfs('0'))

Buggy submission (verdict: Runtime Error):
def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret
print(dfs('0'))
Problem p03448 (python)

Fixed submission:
#l = list(map(int, input().split(' ')))

#num = int(input())
#S = str(input())
# k = (X - Ai - Bj) / C
# C = 0
#
A=int(input())
B=int(input())
C=int(input())
X=int(input())
sum = 0

for i in range(0,A+1):
    for j in range(0,B+1):
        # Cが固定のパターン
        if C == 0:
            if i*500 + j*100 == X:
                sum+=1
                break
        # Cが不定のパターン
        else:
            k = ( X - i*500 - j*100 ) / 50
            #print (k)
            if k < 0:
                break
            if k<=C:
                sum+=1
        # for k in range(0,C+1):
        #     if(500*i+100*j+50*k==X):

print(sum)

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

#num = int(input())
#S = str(input())
# k = (X - Ai - Bj) / C
# C = 0
#
A=int(input())
B=int(input())
C=int(input())
X=int(input())
sum = 0

for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if(500*i+100*j+50*k==X):
                sum+=

print(sum)
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input)
print(int(N*(N-1)/2))
Problem p03238 (python)

Fixed submission:
n=int(input())
if n ==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if n ==1:
    print("Hello World")
elif n ==2:
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if n ==1:
    print("Hello World")
else:
    print(a+b)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int,input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for i in range(max(b - k + 1, a + k), b + 1):
    print(i)

Buggy submission (verdict: Runtime Error):
A,B,K =(map(int,input().split()))
TL = list(range(A,B+1))
L = [i for i in TL if ((i>=A) and i<=A+K-1)] 
LU =  [i for i in TL if  ((i>=B-K+1) and i<=B)] 
#L.append( [i for i in TL if ((i<=B) and (i>=B-K))])
LL = set(L + LU)
for i in LL:
    print(i)

Buggy submission (verdict: Runtime Error):
A,B,K =(map(int,input().split()))
TL = list(range(A,B+1))
L = [i for i in TL if ((i>=A) and i<=A+K-1)] 
LU =  [i for i in TL if  ((i>=B-K+1) and i<=B)] 
#L.append( [i for i in TL if ((i<=B) and (i>=B-K))])
LL = set(L + LU)
for i in LL:
    print(i)
Problem p03469 (python)

Fixed submission:
s=str(input())
s=s.replace("2017","2018")
print(s)

Buggy submission (verdict: Runtime Error):
s=str(input())
s[3]="8"
print(s)

Buggy submission (verdict: Runtime Error):
s=str(input())
s[3]="8
print(s)
Problem p03547 (python)

Fixed submission:
a,b=map(str,input().split())
if a>b:
  print(">")
elif a==b:
  print("=")
else:
  print("<")

Buggy submission (verdict: Runtime Error):
a,b=map(str().input())
if a>b:
  print(">")
elif a==b:
  print("=")
else:
  print("<")
Problem p03698 (python)

Fixed submission:
s=input()
S=set(s)
if len(s)==len(S): 
    print("yes")
else: 
    print("no")

Buggy submission (verdict: Runtime Error):
s=input(s)
S=list(s)
b = len(S)
a =len(set(S))
if a==b: print("yes")
else: print("no")
Problem p03778 (python)

Fixed submission:
W,a,b = map(int,input().split())
if a>b:
    a,b=b,a
if b>a+W:
    print(b-(a+W))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
W,a,b = map(int,input().split())
if b> a+W:
    print(b-a-W)
elif a>b+w:
    print(a-b-W)
else:
    print(0)
Problem p04030 (python)

Fixed submission:
#Bとその前１文字を消せば良い
s =list(input())
lis = []
for i in range(len(s)):
    if s[i] == "B":
        if len(lis) >0:
            lis.pop()
    else: lis.append(s[i])
print("".join(lis))

Buggy submission (verdict: Runtime Error):
#Bとその前１文字を消せば良い
s =list(input())
lis = []
for i in range(len(s)):
    if s[i] == "B":
        if len(lis)>1:
            lis[i-1]=""
            lis.append("")
    else: lis.append(s[i])
print("".join(lis))

Buggy submission (verdict: Runtime Error):
#Bとその前１文字を消せば良い
s =list(input())
lis = []
for i in range(len(s)):
    if s[i] == "B": 
        lis[i-1]=""
        lis.append("")
    else: lis.append(s[i])
print("".join(lis))
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split(' '))
cnt = 0
avi = 1
while 1:
    if avi >= b:
        break

    cnt += 1
    avi += a - 1

print(cnt)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split(' '))
cnt += 0
avi = 1
while 1:
    cnt += 1
    avi += a - 1
    if avi >= b:
        break
print(cnt)
Problem p03031 (python)

Fixed submission:
n, m = map(int, input().split())
ks = [[0] for i in range(m)]
jud = []
for i in range(m):
    tmp = list([int(i)-1 for i in input().split()])
    ks[i] = tmp[1:]
jud = list(map(int, input().split()))

ans = 0
c = True
for i in range(2 ** n):
    c = True
    ib = format(i, 'b')
    for iks, j in enumerate(ks):
        ch = 0
        for m in j:
            if len(ib) >= m+1:
                ch += int(ib[-m-1])
        if ch % 2 != jud[iks]:
            c = False
            break
    if c:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ks = [[0] for i in range(m)]
jud = []
for i in range(m):
    tmp = list([int(i)-1 for i in input().split()])
    ks[i] = tmp[1:]
jud = list(map(int, input().split()))

ans = 0
c = True
for i in range(2 ** n):
    tmp = list()
    c = True
    for j in range(m):
        t = ks[j]
        ch = 0
        for m in t:
            ib = format(i, 'b')
            if len(ib) >= m+1:
                ch += int(ib[m])
            else:
                break
        if ch % 2 != jud[j]:
            c = False
            break
    if c:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ks = [[0] for i in range(m)]
jud = []
for i in range(m):
    tmp = list([int(i)-1 for i in input().split()])
    ks[i] = tmp[1:]
jud = list(map(int, input().split()))

ans = 0
c = True
for i in range(2 ** n):
    tmp = list()
    c = True
    for j in range(m):
        t = ks[j]
        ch = 0
        for m in t:
            ch += tmp[m]
        if ch % 2 != jud[j]:
            c = False
            break
    if c:
        ans += 1
print(ans)
Problem p03061 (python)

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
r = [0 for i in range(n)]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
for i in range(n - 1)[::-1]:
    r[i] = gcd(r[i+1], v[i+1])
m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
v = [int(i) for i in input().split()]
if n == 2:
    print(max(v))


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
Y = [0 for i in range(n)]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
for i in range(n - 1)[::-1]:
    r[i] = gcd(r[i+1], v[i+1])
m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
v = [int(i) for i in input().split()]
if n == 2:
    print(max(v))

l = [0 for i in range(n)]
r = l[:]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


for i in range(n):
    l[i+1] = gcd(l[i], v[i])
    r[-i] = gcd(r[-i-1], v[-i-1])
m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))
Problem p03140 (python)

Fixed submission:
import sys

n=int(sys.stdin.readline())
a=sys.stdin.readline()
b=sys.stdin.readline()
c=sys.stdin.readline()


cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys

n=int(input())
for _ in range(n):
    a=input()
    b=input()
    c=input()


cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys

n=int(sys.stdin.readline())
for _ in range(n):
    a=sys.stdin.readline()
    b=sys.stdin.readline()
    c=sys.stdin.readline()


cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys

n=int(sys.stdin.readline())
M=[]
for _ in range(n):
    M.append(sys.stdin.readline())

cnt = 0
for i in range(n):
    if M[0][i] == M[1][i] == M[2][i]:
        continue
    elif M[0][i] == M[1][i] or M[1][i] == M[2][i] or M[2][i] == M[0][i]:
        cnt = cnt + 1
    else:
        cnt = cnt + 2
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys

n=int(sys.stdin.readline())
M=[]
for _ in range(n):
    M.append(sys.stdin.readline())

cnt = 0
for i in range(n):
    tmp = 0
    if M[0][i] != M[1][i]:
        tmp = tmp + 1
    if M[0][i] != M[2][i]:
        tmp = tmp + 1
    if M[1][i] == M[2][i] and tmp == 2:
        tmp = tmp - 1
    cnt = cnt + tmp
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys

n=int(sys.stdin.readline())
M=[]
for _ in range(n):
    M.append(sys.stdin.readline())

cnt = 0
for i in range(n):
    tmp = 0
    if M[0][i] != M[1][i]:
        tmp = tmp + 1
    if M[0][i] != M[2][i]:
        tmp = tmp + 1
    if M[1][i] == M[2][i] and tmp == 2:
        tmp = tmp - 1
    cnt = cnt + tmp
print(cnt)
Problem p03192 (python)

Fixed submission:
n=int(input())
cnt=0
while n >= 1:
    if n%10==2:
        cnt+=1
    n=int(n/10)
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
n,p=map(int,input().split())
if p==1:
    print(1)
    exit()
if n==1:
    print(p)
    exit()
i = 2
cnt,ans=0,1
while i<=p:
    if p % i == 0:
        cnt+=1
        p/=i
    else:
        if cnt>=n:
            ans*=i*math.floor(cnt/n)
        cnt=0
        if i==2:
            i+=1
        else:
            i+=2
if cnt>=n:
    ans*=i*math.floor(cnt/n)
print(ans)
Problem p02972 (python)

Fixed submission:

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

M = 0
ans_lst = [0] * N

for i in range(N-1, -1, -1):
    if sum(ans_lst[i::i+1]) % 2 != a_lst[i]:
        ans_lst[i] = 1
    

m = sum(ans_lst)    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1) + " "
print(ans_str)

Buggy submission (verdict: Runtime Error):

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

M = 0
ans_lst = [0] * N

t = 0
for i in range(N-1, -1, -1):
    t = sum(ans[i::i+1])
        
    if t % 2 != a_lst[i]:
        ans_lst[i] = 1
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1) + " "
print(ans_str)

Buggy submission (verdict: Runtime Error):

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

M = 0
ans_lst = [0] * N

t = 0
for i in range(N, -1, -1):
    t = 0
    for j in range(2*i, N, i+1):
        t += ans_lst[j]
        
    if (t + 1) % 2 == a_lst[i]:
        ans_lst[i] = 1
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        if i != 0:
            ans_str += " "
        ans_str += str(i+1)
print(ans_str)
Problem p02995 (python)

Fixed submission:

A, B, C, D = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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


CD = lcm(C, D)

#print(CD)

C_count = B//C - (A-1)//C 
D_count = B//D - (A-1)//D
CD_count = B//CD - (A-1)//CD 



#print(C_count, D_count, CD_count)

print(B - A + 1 - C_count - D_count + CD_count)

Buggy submission (verdict: Runtime Error):

import math

A, B, C, D = map(int, input().split())
CD = int(C * D / math.gcd(C, D))

#print(CD)

C_count = B//C - (A-1)//C 
D_count = B//D - (A-1)//D
CD_count = B//CD - (A-1)//CD 



#print(C_count, D_count, CD_count)

print(B - A + 1 - C_count - D_count + CD_count)
Problem p03014 (python)

Fixed submission:
#   ABC129　D問題
H, W = map(int, input().split())    #   1 <= H, W <= 2000
S_arr = []
for _ in range(H):
    S_arr.append(list(input()))

point_arr = [[0]*W for _ in range(H)]

start = 0
stop = W
for y in range(H):
    start = 0
    stop = W
    for x in range(W):
        if S_arr[y][x] == "#":
            stop = x
            for i in range(start, stop):
                point_arr[y][i] += stop - start
            start = stop + 1
    for i in range(start, W):
        point_arr[y][i] += W - start


for x in range(W):  #   コードのコピペ禁止の原則に違反してるけど、改善方法が思いつかない問題
    start = 0
    stop = H
    for y in range(H):
        if S_arr[y][x] == "#":
            stop = y
            for i in range(start, stop):
                point_arr[i][x] += stop - start
            start = stop + 1
    for i in range(start, H):
        point_arr[i][x] += H - start

ans = 0
for i in range(H):
    for j in range(W):
        if ans < point_arr[i][j]:
            ans = point_arr[i][j]
ans -= 1
print(ans)
#   O(H*W)程度の計算量で十分高速だと思ってたのに、そうでもない問題
#   2019/06/10 現在未解決　PyPy使ったらどうなるのかやってみた。Numpy含まれてるからランタイムエラーになるのだろうか？

Buggy submission (verdict: Runtime Error):
#   ABC129　D問題
import numpy as np

H, W = map(int, input().split())    #   1 <= H, W <= 2000
S_arr = []
for _ in range(H):
    S_arr.append(list(input()))

point_arr = np.zeros((H, W))

start = 0
stop = W
for y in range(H):
    start = 0
    stop = W
    for x in range(W):
        if S_arr[y][x] == "#":
            stop = x
            point_arr[y, start:stop] += stop - start
            start = stop + 1
    point_arr[y, start:W] += W - start
    

for x in range(W):  #   コードのコピペ禁止の原則に違反してるけど、改善方法が思いつかない問題
    start = 0
    stop = H
    for y in range(H):
        if S_arr[y][x] == "#":
            stop = y
            point_arr[start:stop, x] += stop - start
            start = stop + 1
    point_arr[start:H, x] += H - start

print(int(np.max(point_arr))-1) 
#   O(H*W)程度の計算量で十分高速だと思ってたのに、そうでもない問題
#   2019/06/10 現在未解決　PyPy使ったらどうなるのかやってみた。Numpy含まれてるからランタイムエラーになるのだろうか？
Problem p03136 (python)

Fixed submission:
N = int(input())
 
L_lst = list(map(int, input().split()))
 
L_lst.sort()
L_sum = sum(L_lst)
L_max = L_lst[-1]
 
if L_max * 2 >= L_sum:
  print("No")
else:
  print("Yes")

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

L_lst = map(int, input().split())

L_lst.sort()
L_sum = sum(L_lst)
L_max = L_lst[-1]

if L_max * 2 >= L_sum:
  print("No")
else:
  print("Yes")