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

Fixed submission:
import itertools
count =0
ans=0
n,m = map(int,input().split())
num=[0,1]
pattern = list(itertools.product(num, repeat=n))
lists =[]
switches = [1]*n
onoff = [0]*m
for i in range(m):
    lists.append(list(map(int,input().split())))
key_value = list(map(int,input().split()))
for l in pattern:
    switches = list(l)
    onoff = [0]*m
    for j in range(m):
        count=0
        for k in lists[j][1:]:
            if switches[k-1] == 1:
                count += 1
        if count %2 == key_value[j]:
            onoff[j] = 1
        else:
            break
    if not 0 in onoff:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
count =0
ans=0
n,m = map(int,input().split())
pattern = list(itertools.permutations(range(2), n))
pattern.append([0]*m)
pattern.append([1]*m)

lists =[]
switches = [1]*n
onoff = [0]*m
for i in range(m):
    lists.append(list(map(int,input().split())))
key_value = list(map(int,input().split()))
for l in pattern:
    switches = list(l)
    for j in range(m):
        for k in range(int(lists[j][0])):
            if switches[k] == 1:
                count += 1
        if count %2 == key_value[j]:
            onoff[j] = 1
        else:
            break
    if not 0 in onoff:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
count =0
ans=0
n,m = map(int,input().split())
pattern = list(itertools.permutations(range(2), n))
pattern.append([0]*m)
pattern.append([1]*m)

lists =[]
switches = [1]*n
onoff = [0]*m
for i in range(m):
    lists.append(list(map(int,input().split())))
key_value = list(map(int,input().split()))
for l in pattern:
    switches = list(l)
    print(switches)
    for j in range(m):
        for k in range(int(lists[j][0])):
            if switches[k] == 1:
                count += 1
        if count %2 == key_value[j]:
            onoff[j] = 1
        else:
            break
    if not 0 in onoff:
        ans += 1

print(ans)
Problem p03606 (python)

Fixed submission:
N = int(input())
i =0
ans =0

while i < N:
    a = input().split()
    ans += int(a[1]) - int(a[0]) +1
    i = i + 1
print(ans)

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

while i < N:
    a = int(input())
    b = int(input())

    ans += b - a +1
    i += 1
print(ans)
Problem p03633 (python)

Fixed submission:
import numpy as np
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
print(np.lcm.reduce(lis))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm(lis))

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm(lis))

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))

print(lcm(lis))
Problem p03145 (python)

Fixed submission:
l = list(map(int, input().split()))
len=sorted(l)
print(int(len[1]*len[0]/2))

Buggy submission (verdict: Runtime Error):
l = list(map(int, input().split()))
len=sort(l)
print(len[1]*len[2])

Buggy submission (verdict: Runtime Error):
len=input().split
sorted(len, reverse=True)
print(len[0]*len[1]/2)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input().split())
           
print(A * B)
Problem p02706 (python)

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

temp = sum(list(map(int,input().split())))

if N - temp > -1:
  print(N - temp)
else:
  print("-1")

Buggy submission (verdict: Runtime Error):
N,M = input().split()
N = int(N)
M = int(M)

temp = sum(input().split())

if N - temp > -1:
  print(N - temp)
else:
  print("-1")
Problem p02791 (python)

Fixed submission:
N = int(input())

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

result = 0
min_tmp = N + 1
for x in range(N):
    if p_n[x] < min_tmp:
        result += 1
    min_tmp = min(min_tmp,p_n[x])

print(result)

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

p_n = list(input().split())

result = 0
min_tmp = N + 1
for x in range(N):
    if p_n[x] < min_tmp:
        result += 1
    min_tmp = min(min_tmp,p_n[x])

print(result)
Problem p02804 (python)

Fixed submission:
# from scipy.misc import comb

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))

mod = 10**9+7 #出力の制限
# N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

upper = 0
lower = 0
for i in range(N - K + 1):
    # c = comb(K + i - 1, i, exact=True)
    c = cmb(K + i - 1, i, mod)
    upper = (upper + (As[K + i - 1] * c)) % (10 ** 9 + 7)
    lower = (lower + (As[N - K - i] * c)) % (10 ** 9 + 7)
print(((upper - lower) % (10 ** 9 + 7) + 10 ** 9 + 7) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))

upper = 0
lower = 0
for i in range(N - K + 1):
    c = comb(K + i - 1, i, exact=True)
    upper = (upper + (As[K + i - 1] * c)) % (10 ** 9 + 7)
    lower = (lower + (As[N - K - i] * c)) % (10 ** 9 + 7)
print(((upper - lower) % (10 ** 9 + 7) + 10 ** 9 + 7) % (10 ** 9 + 7))
Problem p03544 (python)

Fixed submission:
N = int(input())
if N == 1:
    print(1)
else:
    l = 2
    r = 1
    for i in range(N - 1):
        L = l + r
        l = r
        r = L
    print(L)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = 2
r = 1
for i in range(N - 1):
    L = l + r
    l = r
    r = L
print(L)
Problem p03565 (python)

Fixed submission:
S = input().strip()
T = input().strip()
rS = []
if len(S) >= len(T):
    for i in range(len(S)):
        rS.append(S[i])
    for i in range(len(rS) - len(T), -1, -1):
        eq = True
        for j in range(len(T)):
            if not(rS[i + j] == T[j] or rS[i + j] == "?"):
                eq = not(eq)
                break
        if eq:
            for j in range(len(T)):
                rS[i + j] = T[j]
            break
    if eq:
        for i in range(len(rS)):
            if rS[i] == "?":
                rS[i] = "a"
        for i in range(len(rS)):
            print(rS[i], end='')
        print("")
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input().strip()
T = input().strip()
rS = []
for i in range(len(S)):
    rS.append(S[i])
for i in range(len(rS) - len(T)):
    eq = True
    for j in range(len(T)):
        if not(rS[- i - j - 1] == T[- j - 1] or rS[- i - j - 1] == "?"):
            eq = not(eq)
            break
    if eq:
        for j in range(len(T)):
            rS[- i - j - 1] = T[- j - 1]
        break
if eq:
    for i in range(len(rS)):
        if rS[i] == "?":
            rS[i] = "a"
    for i in range(len(rS)):
        print(rS[i], end='')
    print("")
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input().strip()
T = input().strip()
rS = []
for i in range(len(S)):
    rS.append(S[i])
for i in range(len(rS) - len(T), -1, -1):
    eq = True
    for j in range(len(T)):
        if not(rS[i + j] == T[j] or rS[i + j] == "?"):
            eq = not(eq)
            break
    if eq:
        for j in range(len(T)):
            rS[i + j] = T[j]
        break
if eq:
    for i in range(len(rS)):
        if rS[i] == "?":
            rS[i] = "a"
    for i in range(len(rS)):
        print(rS[i], end='')
    print("")
else:
    print("UNRESTORABLE")
Problem p02664 (python)

Fixed submission:
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
x=input()
l=list(x)
c=0
for i in range(len(l)):
	if l[i]=='?':
		if i-1<0:
			if i+1<len(l):
				if l[i+1]=='D':
					l[i]='P'
				elif l[i+1]=='?':
					l[i]='P'
				else:
					l[i]='D'
			else:
				l[i]='D'
		elif l[i-1]=='P':
			l[i]='D'
		elif i+1<len(l):
			if l[i+1]=='D':
				l[i]='P'
			elif l[i+1]=='?':
				l[i]='P'
			else:
				l[i]='D'
		else:
			l[i]='D'
print(''.join(l))

Buggy submission (verdict: Runtime Error):
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
x=input()
l=list(x)
c=0
for i in range(len(l)):
	if l[i]=='?':
		if i-1<0:
			if l[i+1]=='D':
				l[i]='P'
			elif l[i+1]=='?':
				l[i]='P'
			else:
				l[i]='D'
		elif l[i-1]=='P':
			l[i]='D'
		elif i+1<len(l):
			if l[i+1]=='D':
				l[i]='P'
			elif l[i+1]=='?':
				l[i]='P'
			else:
				l[i]='D'
		else:
			l[i]='D'
print(''.join(l))
Problem p02681 (python)

Fixed submission:
#int(input())
#int(x) for x in input().split()
#map(int,input().split())
x=input()
y=input()
if x==y[:-1]:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
from sys import stdin, stdout
cnt=0
def check(a,b):
    global cnt
    for i in range(len(a)):
        cnt-=a[i][0]
        if cnt<0:
            return False
        cnt+=a[i][1]

    for i in range(len(b)):
        cnt-=b[i][0]
        if cnt<0:
            return False
        cnt+=b[i][1]
    if cnt==0:
        return True
    return False

a=[]
b=[]
for i in range(int(input())):
    s=stdin.readline().strip()
    #print(s)
    ans=''
    for j in range(len(s)):
        if s[j]=='(':
            ans+='('
        else:
            if len(ans)==0:
                ans+=')'
                continue
            if ans[-1]=='(':
                ans=ans[:-1]
            else:
                ans+=')'
    L=0
    for j in range(len(ans)):
        if ans[j]==')':
            L+=1
        else:
            break
    R=len(ans)-L
    if L<R:
        a.append((L,R))
    else:
        b.append((L,R))

    a.sort()
    b.sort(key=lambda x:x[1],reverse=True)
    #print(a,b)
if check(a,b):
    print('Yes')
else:
    print('No')
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    P=list(map(int,input().split()))
    N=[i for i in range(0,102)]

    for p in P:
        N.pop(N.index(p))

    L=[]
    for a in N:
        l=abs(a-x)
        L.append(l)
    
    m=L.index(min(L))
    print(N[m])

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    P=list(map(int,input().split()))
    N=[i for i in range(1,101)]

    for p in P:
        N.pop(N.index(p))

    L=[]
    for a in N:
        l=abs(a-x)
        L.append(l)
    
    m=L.index(min(L))
    print(N[m])

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    P=list(map(int,input().split()))
    N=[i for i in range(1,101)]

    for p in P:
        N.pop(N.index(p))

    L=[]
    for i in range(n):
        l=abs(N[i]-x)
        L.append(l)
    m=L.index(min(L))
    print(N[m])
Problem p02642 (python)

Fixed submission:
from collections import defaultdict
n=int(input())
A=sorted((map(int,input().split())))
maxA=max(A)
L=[0]*(maxA+1)
AD=defaultdict(int)
for a in A:
	L[a]=1
	AD[a]+=1
for a in A:
	if AD[a]>=2:
		L[a]=0
	for i in range(2*a,maxA+1,a):
		L[i]=0
print(sum(L))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=sorted(map(int,input().split()))
L=[A[0]]
if n==0:
    print(0)
else:
    c=0
    if A[0]!=A[1]:
        c=1
    for i in range(n-1):
        flag=0
        for l in L:
            if A[i+1]%l==0:
                flag=1
                break
            if l>=int(A[i+1]**0.5+1):
                break
        if flag==0:
            L.append(A[i+1])
            c+=1
    print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=sorted(map(int,input().split()))
L=[A[0]]
if n==0:
    print(0)
else:
    c=0
    if A[0]!=A[1]:
        c=1
    for i in range(n-1):
        flag=0
        for l in L:
            if A[i+1]%l==0:
                flag=1
                break

        if flag==0:
            L.append(A[i+1])
            c+=1
    print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=sorted(map(int,input().split()))
L=[A[0]]

c=0
if A[0]!=A[1]:
    c=1
for i in range(n-1):
    flag=0
    for l in L:
        if A[i+1]%l==0:
            flag=1
            break
    if flag==0:
        L.append(A[i+1])
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=sorted(map(int,input().split()))
L=[A[0]]

c=0
if A[0]!=A[1]:
    c=1
for i in range(n-1):
    flag=0
    for l in L:
        if A[i+1]%l==0:
            flag=1
            break
    L.append(A[i+1])
    if flag==0:
        c+=1
print(c)
Problem p02678 (python)

Fixed submission:
from collections import deque

n,m=map(int,input().split())
L=[[] for i in range(n)]

#print(L)

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

#print(L)
d=[float('inf') for i in range(n)]
m=[0 for i in range(n)]

def bfs():

    que=deque([])
    que.append(0)
    d[0]=0
    
    while que:
        p=que.popleft()
        for np in L[p]:
            if d[np]==float('inf'):
                que.append(np)
                d[np]=d[p]+1
                m[np]=p+1

bfs()
if sum(d)==float('inf'):
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(m[i])

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

n,m=map(int,input().split())
L=[[] for i in range(n)]
for i in range(m):
	L[a-1].append(b-1)
	L[b-1].append(a-1)
D=[float('inf') for i in range(n)]

def bfs():
	que=deque([])
	que.append(0)
	D[p]=0
	while que:
		p=que.popleft()
		for np in L[p]:
			if D[np]==float('inf'):
				que.append(np)
				D[np]=p

bfs()

if sum(D)==float('inf'):
	print('No')
else:
	print('Yes')
	for i in range(1,n):
		print(D[i])
Problem p02747 (python)

Fixed submission:
s=input()
if s=='hi' or s=='hihi' or s=='hihihi' or s=='hihihihi' or s=='hihihihihi':
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if s=='hi' or s=='hihi' or s='hihihi' or s=='hihihihi' or s=='hihihihihi':
	print('Yes')
else:
	print('No')
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())
A = []
B = []
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
inf=float('inf')
dp = [[inf] * (h + 1) for i in range(n + 1)]
dp[0][0]=0
for i in range(n):
    for j in range(h + 1):
        if j < A[i]:
            dp[i + 1][j] = min(dp[i][j], B[i])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i])
print(dp[n][h])

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

inf=float('inf')
dp = [[inf] * (h + max(A)-1) for i in range(n + 1)]
dp[0][0]=0
for i in range(n):
    for j in range(h + max(A)-1):
        if j < A[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i])
print(min(dp[n][h:]))
Problem p02918 (python)

Fixed submission:
n,k=map(int,input().split())
S=input()
O=[]
E=[]
flag=0
if n==1:
	print(0)
else:
	c=0
	for i in range(n-1):
		if S[i+1]==S[i]:
			c+=1
		else:
			if flag==0:
				O.append(c)
				c=0
				flag=1
			else:
				E.append(c)
				c=0
				flag=0
	if flag==0:
		O.append(c)
	else:
		E.append(c)
	Osum=sum(O)
	Esum=sum(E)		
	EC=len(E)
	if flag==0:
		print(Osum+Esum+min(EC,k)*2)
	else:
		print(Osum+Esum+min(2*EC-1,2*k))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
S=input()
O=[]
E=[]
flag=0
if n==1:
	print(0)
else:
	c=0
	for i in range(n-1):
		if S[i+1]==S[i]:
			c+=1
		else:
			if flag==0:
				O.append(c)
				c=0
				flag=1
			else:
				E.append(c)
				c=0
				flag=0
	if flag==0:
		O.append(c)
	else:
		E.append(c)
	Osum=sum(O)
	Esum=sum(E)		
	EC=len(E)
if flag==0:
	print(Osum+Esum+min(EC,k)*2)
else:
	print(Osum+Esum+min(2*EC-1,2*k))
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for e in s[1:n]:
    a,b=map(int,e.split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for e in s[n:]:
    c,d=map(int,e.split())
    P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    for j in G[i]:
        if V[j]!=1:
            dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
n,q=map(int,input().split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for i in range(n-1):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
	G[b-1].append(a-1)
for i in range(q):
	c,d=map(int,input().split())
	P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    if G[i]!=[]:
        for j in G[i]:
            if V[j]!=1:
                dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))

Buggy submission (verdict: Runtime Error):
import sys
sys.recursionlimit(100000)
n,q=map(int,input().split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for i in range(n-1):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
	G[b-1].append(a-1)
for i in range(q):
	c,d=map(int,input().split())
	P[c-1]+=d

print(G)
def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    if G[i]!=[]:
        for j in G[i]:
            if V[j]!=1:
                dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for i in range(n-1):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
	G[b-1].append(a-1)
for i in range(q):
	c,d=map(int,input().split())
	P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    if G[i]!=[]:
        for j in G[i]:
            if V[j]!=1:
                dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))
Problem p02960 (python)

Fixed submission:
s=input()
n=len(s)
p=10**9+7
 
dp=[[0]*13 for i in range(n)]
m=[0]*(n-1)+[1]
for i in range(n-1):
    m[-i-2]=m[-i-1]*10%13
 
if s[0]!='?':
    a=int(s[0])*m[0]%13
    dp[0][a]=1
else:
    for k in range(10):
        a=k*m[0]%13
        dp[0][a]=1
 
for i in range(1,n):
    if s[i]!='?':
        for j in range(13):
            dp[i][j]=dp[i-1][(j-int(s[i])*m[i])%13]%p
    else:
        for k in range(10):
            for j in range(13):
                dp[i][j]+=dp[i-1][(j-k*m[i])%13]%p
print(dp[n-1][5]%p)

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

dp=[[0]*13 for i in range(n)]

if s[0]!='?':
    a=int(s[i])*10**(n-1)%13
    dp[0][a]=1
else:
    for k in range(10):
        a=k*10**(n-1)%13
        dp[0][a]=1

for i in range(1,n):
    if s[i]!='?':
        a=int(s[i])*10**(n-i-1)%13
        for j in range(13):
            dp[i][j]+=dp[i-1][(j-a)%13]
    else:
        for k in range(10):
            a=k*10**(n-i-1)%13
            for j in range(13):
                dp[i][j]+=dp[i-1][(j-a)%13]
print(dp[n-1][5]%(10**9+7))
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*(r**2))

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

i=n-1
while i>=0:
	if A[i]==1:
		break
	i-=1

if i==-1:
	print(0)
elif i==0:
	print(1)
	print(1)
else:
	i=(i+1)//2-1
	while i>=0:
		B=[A[j] for j in range(i,n,i+1)]
		r=sum(B[1:])
		
		A[i]=A[i]^r%2
		
		i-=1
		C=[m for m,k in enumerate(A,1) if k!=0]
		print(len(C))
		print(*C)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
e=(c*d)//gcd(c, d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
e=(c*d)//math.gcd(c, d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
e=c*d//math.gcd(c, d)
print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))
Problem p03014 (python)

Fixed submission:
h,w=map(int,input().split())
M=[list(input()) for i in range(h)]
D=[[0]*w for i in range(h)]
U=[[0]*w for i in range(h)]
R=[[0]*w for i in range(h)]
L=[[0]*w for i in range(h)]

for i in range(h):
    c=0
    for j in range(w):
        if M[i][j]=='.':
            c+=1
            R[i][j]=c
        else:
            c=0
for i in range(h):
    c=0
    for j in range(w):
        if M[i][w-1-j]=='.':
            c+=1
            L[i][w-1-j]=c
        else:
            c=0
for j in range(w):
    c=0
    for i in range(h):
        if M[i][j]=='.':
            c+=1
            D[i][j]=c
        else:
            c=0
for j in range(w):
    c=0
    for i in range(h):
        if M[h-1-i][j]=='.':
            c+=1
            U[h-1-i][j]=c
        else:
            c=0
r=0
for i in range(h):
    for j in range(w):
        r=max(r,R[i][j]+L[i][j]+D[i][j]+U[i][j]-3)
print(r)

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

h,w=map(int,input().split())
M=np.array([list(input()) for i in range(h)])
L=np.array([[0]*w for i in range(h)])

for i in range(w):
	c=0
	for k,g in groupby(M[:,i]):
		l=len(list(g))
		if k=='.':
			L[c:c+l,i]+=l
		c+=l

for i in range(h):
	c=0
	for k,g in groupby(M[i,:]):
		l=len(list(g))
		if k=='.':
			L[i,c:c+l]+=l
		c+=l

print(np.amax(L)-1)

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

h,w=map(int,input().split())
M=np.array([list(input()) for i in range(h)])
C=np.array([[0]*w for i in range(h)])
R=np.array([[0]*w for i in range(h)])
L=np.array([[0]*w for i in range(h)])

for i in range(w):
	c=0
	for k,g in groupby(M[:,i]):
		l=len(list(g))
		if k=='#':
			C[c:c+l,i]=0
		else:
			C[c:c+l,i]=l
		c+=l

for i in range(h):
	c=0
	for k,g in groupby(M[i,:]):
		l=len(list(g))
		if k=='#':
			R[i,c:c+l]=0
		else:
			R[i,c:c+l]=l
		c+=l

r=0
for i in range(h):
	for j in range(w):
		r=max(r,C[i][j]+R[i][j]-1)
print(r)
Problem p03047 (python)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
print(int(input())+1)
Problem p03206 (python)

Fixed submission:
D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
D = int(input)
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
Problem p03240 (python)

Fixed submission:
n=int(input())
 
L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,h=LSort[-1]

for cx in range(0,101):
	for cy in range(0,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h==max(H-abs(x-cx)-abs(y-cy),0) for x,y,h in LSort]):
		    print(cx,cy,H)
		    exit()

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

L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,z=LS[-1]

for cx in range(1,101):
	for cy in range(1,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h=max(H-abs(x-cx)-abs(y-cy),0) for x,y,h in LSort])
		print(cx,cy,H)
		exit()

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

L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,z=LS[-1]

for cx in range(1,101):
	for cy in range(1,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h=max(H-abs(x-cx)-abs(y-cy),0) for x,y,z in LSort])
		print(cx,cy,H)
		exit()
Problem p03266 (python)

Fixed submission:
n,k=map(int,input().split())
a=n//k
if k%2==1 or k==1:
	print(a**3)
else:
	b=n//(k//2)
	print((b-a)**3+a**3)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=n//k
b=n//(k//2)
if k%2==1:
	print(a**3)
else:
	print((b-a)**3+a**3)