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

Fixed submission:
#Python

l = map(int, raw_input().split())

A=l[0]
B=l[1]
#print A
#print B

if A%3==0 or B%3==0 or (A+B)%3==0:
	print 'Possible'
else:
	print 'Impossible'

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque

N=input()

nl=[ [] for i in range(N+1)]
D=[ 0 for i in range(N+1)]	# No.1からの距離
V=[ 0 for i in range(N+1)]	# 訪問済みフラグ

for i in range(N-1):
	a,b=map(int, sys.stdin.readline().split())
	nl[a].append(b)
	nl[b].append(a)


def bfs(v):	#1からの頂点Nまでの距離を算出
	q = deque([]) 
	V[v]=1
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if V[i]==0:
				D[i]=D[v]+1
				V[i]=1
				q.append(i)

bfs(1)


L=deque([]) 	#1-Nまでの最短経路を復元 
def bfs2(v):
	q = deque([]) 
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if D[i]==D[v]-1 and i!=1:
				q.append(i)
				L.appendleft(i)

bfs2(N)


color=[ None for i in range(N+1)]
color[1]="b"
color[N]="w"

l=len(L)
for i in range( (l+1)/2 ):
	color[ L[i] ]="b"

for i in range( (l+1)/2, l ):
	color[ L[i] ]="w"



def bfs3(v):
	q = deque([]) 
	q.append(v)
	while q:
		v=q.popleft()
		for i in nl[v]:
			if color[i] is None:
				color[i]=color[v]
				q.append(i)
for i in L:
	bfs3(i)
		


b_cnt=color.count("b")
w_cnt=color.count("w")


if N%2==1:
	if b_cnt>w_cnt:
		print "Fennec"
	else:
		print "Snuke"
else:
	if b_cnt==w_cnt:	
		print "Snuke"
	elif b_cnt>w_cnt:
		print "Fennec"
	else:
		print "Snuke"
Problem p03697 (python)

Fixed submission:
#Python

A = map(int, raw_input().split())
if A[0]+A[1]>=10:
	print 'error'
else:
	print A[0]+A[1]

Buggy submission (verdict: Runtime Error):
#Python

A = map(int, raw_input().split())
if A[0]+A[1]>=10:
	print ‘error’
else:
	print A[0]+A[1]
Problem p03719 (python)

Fixed submission:
A,B,C=map(int,raw_input().split())
print "Yes" if A<=C and C<=B else "No"

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque

N,M=map(int, sys.stdin.readline().split())
al=[ [] for _ in range(N+1) ]   #隣接リスト
rev_al=[ [] for _ in range(N+1) ]   #戻りを調べる用の隣接リスト
edge=[] #辺の集合
for _ in range(M):
    a,b,c=map(int, sys.stdin.readline().split())
    al[a].append(b)
    rev_al[b].append(a) #逆向きにも辺を張る
    edge.append((a,b,c))


go=[0 for _ in range(N+1)]
back=[0 for _ in range(N+1)]

#頂点１からNに行くまでに使用する頂点を調べる
q=deque()
q.append(1) #スタート地点
go[1]=1

while q:
    fro=q.popleft()
    for to in al[fro]:
        if go[to]==0:
            go[to]=1
            q.append(to)


#頂点Nから1に戻る際に使用する頂点を調べる
q=deque()
q.append(N) #スタート地点
back[N]=1

while q:
    fro=q.popleft()
    for to in rev_al[fro]:
        if back[to]==0:
            back[to]=1
            q.append(to)


new_edge=[]     #有効な辺のみ抽出

for a,b,c in edge:
    if go[a]==1 and back[b]==1:
        new_edge.append((a,b,c))


#ベルマンフォード
dp=[ float("-inf") for _ in range(N+1) ]
dp[1]=0

for i in range(N):
    for fro,to,cost in new_edge:
        alt=dp[fro]+cost
        if dp[to]<alt:
            if i==N-1:
                print float("inf")
                quit()
            dp[to]=alt

print dp[N]
Problem p03729 (python)

Fixed submission:
A,B,C=raw_input().split()
print "YES" if A[-1]==B[0] and B[-1]==C[0] else "NO"

Buggy submission (verdict: Runtime Error):
import heapq
N,W=map(int,raw_input().split())
wv=[]

w_sum=0
for i in range(N):
	w,v=map(int,raw_input().split())
	w_sum+=w
	wv.append((w,v))


a=[ float("-inf") for i in range(w_sum*2) ]

i=0
i=1
q=[]
for ind_i, i in enumerate(wv):
	w=i[0]
	v=i[1]
	#Initialize
	if ind_i==0:
		a[0]=0
		a[w]=v
		continue
	#Put queue
	for ind_j, j in enumerate(a):
		if j!=float("-inf"):
			heapq.heappush(q,(ind_j,j))
	
	while len(q)!=0:
		ind_j, j=heapq.heappop(q)
		a[ind_j+w]=max(a[ind_j+w], a[ind_j]+v)
		
print max(a[:W+1])
Problem p03732 (python)

Fixed submission:
from collections import defaultdict
N,W=map(int,raw_input().split())

a=defaultdict(lambda:[])
for i in range(N):
	w,v=map(int,raw_input().split())
	a[w]=a[w]+[v]

for i,j in a.items():
	a[i]=sorted(j,reverse=True)



lst=[]
for i,j in a.items():
	lst.append( (i,len(j)) )

max_val=0
if len(lst)==1:
	w1=lst[0][0]
	c1=lst[0][1]
	for i in range(c1+1):
		if i*w1<=W:
			max_val=max(max_val, sum(a[w1][:i]))

elif len(lst)==2:
	w1=lst[0][0]; w2=lst[1][0]
	c1=lst[0][1]; c2=lst[1][1]
	for i in range(c1+1):
		for j in range(c2+1):
				if i*w1+j*w2<=W:
					max_val=max(max_val, sum(a[w1][:i])+sum(a[w2][:j]))

elif len(lst)==3:
	w1=lst[0][0]; w2=lst[1][0]; w3=lst[2][0]
	c1=lst[0][1]; c2=lst[1][1]; c3=lst[2][1]
	for i in range(c1+1):
		for j in range(c2+1):
			for k in range(c3+1):
				if i*w1+j*w2+k*w3<=W:
					max_val=max(max_val, sum(a[w1][:i])+sum(a[w2][:j])+sum(a[w3][:k]))

elif len(lst)==4:
	w1=lst[0][0]; w2=lst[1][0]; w3=lst[2][0]; w4=lst[3][0]
	c1=lst[0][1]; c2=lst[1][1]; c3=lst[2][1]; c4=lst[3][1]
	for i in range(c1+1):
		for j in range(c2+1):
			for k in range(c3+1):
				for m in range(c4+1):
					if i*w1+j*w2+k*w3+m*w4<=W:
						max_val=max(max_val, sum(a[w1][:i])+sum(a[w2][:j])+sum(a[w3][:k])+sum(a[w4][:m]))

print max_val

Buggy submission (verdict: Runtime Error):
import heapq
N,W=map(int,raw_input().split())
wv=[]

w_sum=0
for i in range(N):
	w,v=map(int,raw_input().split())
	w_sum+=w
	wv.append((w,v))


a=[ float("-inf") for i in range(w_sum+1) ]


q=[]
for ind_i, i in enumerate(wv):
	w=i[0]
	v=i[1]
	#Initialize
	if ind_i==0:
		a[0]=0
		a[w]=v
		continue

	#Put queue
	for ind_j, j in enumerate(a):
		if j!=float("-inf"):
			heapq.heappush(q,(ind_j,j))
	
	while len(q)!=0:
		ind_j, j=heapq.heappop(q)
		a[ind_j+w]=max(a[ind_j+w], a[ind_j]+v)


print max(a[:W+1])

Buggy submission (verdict: Runtime Error):
import heapq
N,W=map(int,raw_input().split())
wv=[]

w_sum=0
for i in range(N):
	w,v=map(int,raw_input().split())
	w_sum+=w
	wv.append((w,v))


a=[ float("-inf") for i in range(w_sum*2) ]

i=0
i=1
q=[]
for ind_i, i in enumerate(wv):
	w=i[0]
	v=i[1]
	#Initialize
	if ind_i==0:
		a[0]=0
		a[w]=v
		continue
	#Put queue
	for ind_j, j in enumerate(a):
		if j!=float("-inf"):
			heapq.heappush(q,(ind_j,j))
	
	while len(q)!=0:
		ind_j, j=heapq.heappop(q)
		a[ind_j+w]=max(a[ind_j+w], a[ind_j]+v)
		
print max(a[:W+1])

Buggy submission (verdict: Runtime Error):
import heapq
N,W=map(int,raw_input().split())
wv=[]

w_sum=0
for i in range(N):
	w,v=map(int,raw_input().split())
	w_sum+=w
	wv.append((w,v))


a=[ float("-inf") for i in range(w_sum+1) ]

i=0
i=1
q=[]
for ind_i, i in enumerate(wv):
	w=i[0]
	v=i[1]
	#Initialize
	if ind_i==0:
		a[0]=0
		a[w]=v
		continue
	#Put queue
	for ind_j, j in enumerate(a):
		if j!=float("-inf"):
			heapq.heappush(q,(ind_j,j))
	
	while len(q)!=0:
		ind_j, j=heapq.heappop(q)
		a[ind_j+w]=max(a[ind_j+w], a[ind_j]+v)
		

print max(a[:W+1])
Problem p03838 (python)

Fixed submission:
x,y=map(int, raw_input().split())
if 0<=x and 0<=y:
    if x<=y:
        print abs(x-y)
    else:
        print min(1+abs(x*-1-y),2+abs(x-y))
elif x<0 and y<0:
    if x<=y:
        print abs(x-y)
    else:
        print min(2+abs(x-y), 1+abs(x-y*-1))
elif x<0 and y==0:
    print abs(x-y)
elif x<0 and 0<y:
    if x*-1<=y:
        print 1+abs(y-x*-1)
    else:
        print 1+abs(x*-1-y)
elif y<0 and x==0:
    print 1+abs(x-y)
elif y<0 and 0<x:
        print 1+abs(x*-1-y)

Buggy submission (verdict: Runtime Error):
x,y=map(int, raw_input().split())
if 0<=x and 0<=y:
    if x<=y:
        print abs(x-y)
    else:
        print min(2+abs(x-y),1+abs(x+y))
elif x<0 and y<0:
    if x<=y:
        print min(abs(x-y),1+abs(x-y*-1)
    else:
        print min(2+abs(x-y), 1+abs(x-y*-1))
elif x<0 and 0<=y:
    if x*-1<=y:
        print min(1+abs(y-x*-1),1+abs(x-y*-1))
    else:
       print min(abs(x-y),1+abs(x-y*-1))
elif y<0 and 0<=x:
    if y*-1<x:
        print min(abs(x-y),1+abs(x*-1-y))
    else:
        print min(abs(x-y),1+abs(x-y*-1))

Buggy submission (verdict: Runtime Error):
x,y=map(int, raw_input().split())
if 0<=x and 0<=y:
    if x<=y:
        print abs(x-y)
    else:
        print min(2+abs(x-y),1+abs(x+y))
elif x<0 and y<0:
    if x<=y:
        print abs(x-y)
    else:
        print min(2+abs(x-y), 1+abs(x-y*-1))
elif x<0 and 0<=y:
    if x*-1<=y:
        print min(1+abs(y-x*-1),1+abs(x-y*-1)
    else:
       print abs(x-y)
elif y<0 and 0<=x:
    if y*-1<x:
        print min(abs(x-y),1+abs(x*-1-y))
    else:
        print min(abs(x-y),1+abs(x-y*-1))
Problem p04000 (python)

Fixed submission:
import itertools
from collections import defaultdict
from collections import Counter
H,W,N=map(int, raw_input().split())

d=[-1,0,1]
D=list(itertools.product(d,d))

A=defaultdict(lambda: 0)
for i in range(N):
	a,b=map(int, raw_input().split())
	for dx,dy in D:
		cx=a+dx
		cy=b+dy
		if cx>=2 and cx<=H-1 and cy>=2 and cy<=W-1:
			A[(cx,cy)]+=1

C=Counter(A.values())


for i in range(10):
	if i==0:
		print (H-2)*(W-2)-sum(C.values())
	else:
		print C[i]

Buggy submission (verdict: Runtime Error):
import itertools
from collections import defaultdict
H,W,N=map(int, raw_input().split())

A=[ [None for i in range(W+1) ] for j in range(H+1)]
for i in range(N):
	a,b=map(int, raw_input().split())
	A[a][b]=1

d=[-1,0,1]
D=list(itertools.product(d,d))

l=defaultdict(lambda: 0)

for x in range(2,H):
	for y in range(2,W):
		cnt=0
		for i,j in D:
			#print x+i,y+j,A[x+i][y+j]
			if A[x+i][y+j]==1:
				cnt+=1
		l[cnt]+=1


for i in range(10):
	print l[i]

Buggy submission (verdict: Runtime Error):
import itertools
from collections import defaultdict
H,W,N=map(int, raw_input().split())

A=[ [None for i in range(W+1) ] for j in range(H+1)]
for i in range(N):
	a,b=map(int, raw_input().split())
	A[a][b]=1

d=[-1,0,1]
D=list(itertools.product(d,d))

l=defaultdict(lambda: 0)

for x in range(2,H):
	for y in range(2,W):
		cnt=0
		for i,j in D:
			#print x+i,y+j,A[x+i][y+j]
			if A[x+i][y+j]==1:
				cnt+=1
		l[cnt]+=1

print l

for i in range(10):
	print l[i]
Problem p04013 (python)

Fixed submission:
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x
y=map(lambda i:i-A, x)
#print y

max_x=max(max(x),A)
#print max_x

dp=[[0]*(2*N*max_x+1) for i in range(N+1)]

for j in range(N+1):
	for t in range(2*N*max_x):
		if j==0 and t==N*max_x:
			dp[j][t]=1
		elif j>=1 and (t-y[j]<0 or t-y[j]>2*N*max_x):
			dp[j][t]=dp[j-1][t]
		elif j>=1 and t-y[j]>=0 and 2*N*max_x>=t-y[j]: 
			dp[j][t]=dp[j-1][t]+dp[j-1][t-y[j]]
		else:
			dp[j][t]=0

print dp[N][N*max_x]-1

Buggy submission (verdict: Runtime Error):
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x

max_n=max(x)

dp=[[[0]*(N*max_n+1) for k in range(N + 1)] for j in range(N+1)]
#print dp


for j in range(N+1):
	for k in range(N+1):
		for s in range(N*max_n+1):
			if j==k==s==0:
				dp[j][k][s]=1
			elif j>=1 and s<x[j]:
				dp[j][k][s]=dp[j-1][k][s]
			elif j>=1 and k>=1 and s>=x[j]:
				dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]]
			else:
				dp[j][k][s]=0
#print dp


ans=0
for k in range(1,N+1):
	ans+=dp[N][k][k*A]

print ans
Problem p04014 (python)

Fixed submission:
import math
n=input()
s=input()

def f(b,n):
	if n<b:
		return n
	elif n>=b:
		return f(b, math.floor(n/b))+n%b

if s==n:
	print n+1
	quit()


# 2 <= b <= sqrt(n)
n_sqrt=int(math.sqrt(n))
for i in range(2, n_sqrt+1):
	if f(i,n)==s:
		print i
		quit()



# sqrt(n) < b <= n
# yakusuu
l=[]
for i in range(1, n_sqrt+1):
	if (n-s)%i==0:
		l.append(i)
		l.append((n-s)/i)
l.sort()

for i in l:
	b=i+1
	if b**2<=n:
		continue
	p=n/b
	q=n%b
	if p+q==s:
		print b
		quit()

print -1

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

def f(b,n):
	if n<b:
		return n
	elif n>=b:
		return f(b, math.floor(n/b))+n%b

if s==n:
	print n+1
	quit()


# 2 <= b <= sqrt(n)
n_sqrt=int(math.sqrt(n))
for i in range(2, n_sqrt+1):
	if f(i,n)==s:
		print i
		quit()



# sqrt(n) < b <= n
# yakusuu
l=[]
for i in range(1, n_sqrt+1):
	if (n-s)%i==0:
		l.append(i)
		l.append((n-s)/i)


for i in l:
	b=i+1
	p=n/b
	q=n%b
	if p+q==s:
		print b
		quit()

print -1

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

def f(b,n):
	if n<b:
		return n
	elif n>=b:
		return f(b, math.floor(n/b))+n%b

if s==1:
	print n
	quit()
if n==1:
	print -1
	quit()



for i in range(2,s+1):
	if f(i,n)==s:
		print i
		quit()
else:
	print -1
Problem p04046 (python)

Fixed submission:
import itertools
import math
H,W,A,B=map(int,raw_input().split())

mod=10**9+7


FACT={}
FACT_INVERSE={}

n=1
for i in range(H+W-1):
	if i==0: n=1
	else: n=(n*i)%mod
	FACT[i]=n

#print FACT

def C(n,r):
	return (FACT[n]*pow(FACT[r],10**9+5 ,mod)*pow(FACT[n-r],10**9+5 ,mod)) %mod


p=0
for i in range(B,W):
	p+=C(H-A-1+i,i)*C(A-1+W-i-1,W-i-1)
	p=p%mod


print p

Buggy submission (verdict: Runtime Error):
import itertools
import math
H,W,A,B=map(int,raw_input().split())

mod=10**9+7


FACT={}
FACT_INVERSE={}

n=1
for i in range(H+W-1):
	if i==0: n=1
	else: n=(n*i)%mod
	FACT[i]=n

#print FACT


def C(n,r):
	return (FACT[n]*pow(FACT[r],10**9+5 ,mod)*pow(FACT[n-r],10**9+5 ,mod)) %mod

N=(H-A-1)+B
M=(H-1)+(W-1)-N

p=0
for i in range(H-A,H):
	#print N,i,M,(H-1)-i,C(N,i), C(M,(H-1)-i)
	p+=C(N,i)*C(M,(H-1)-i)		#Count patterens via prohibited point.
	p=p%mod


if C(N+M,(H-1))-p>=0:
	print C(N+M,(H-1))-p
else:
	print C(N+M,(H-1))-p+10**9+7

Buggy submission (verdict: Runtime Error):
import itertools
import math
H,W,A,B=map(int,raw_input().split())

mod=10**9+7


FACT={}
FACT_INVERSE={}

n=1
for i in range(H+W-1):
	if i==0: n=1
	else: n=(n*i)%mod
	FACT[i]=n

for x,y in FACT.items():
	FACT_INVERSE[x]=pow(FACT[x],10**9+5 ,mod)


def C(n,r):
	return (FACT[n]*FACT_INVERSE[r]*FACT_INVERSE[n-r]) %mod


N=(H-A-1)+B
M=(H-1)+(W-1)-N

p=0
for i in range(H-A,H):
	#print N,i,M,(H-1)-i,C(N,i), C(M,(H-1)-i)
	p+=C(N,i)*C(M,(H-1)-i)		#Count paterens through prohibited point.
	p=p%mod


if C(N+M,(H-1))-p>=0:
	print C(N+M,(H-1))-p
else:
	print C(N+M,(H-1))-p+10**9+7
Problem p02555 (python)

Fixed submission:
import sys
n=int(input())
dp=[0]*(n+1)
dp[0]=1
s=0
for i in range(3,n+1):
    s+=dp[i-3]
    s=s%1000000007
    dp[i]=s
dp[0]=0
print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[0]*(n+1)
dp[0]=1
dp[1]=0
dp[3]=0
s=0
for i in range(3,n+1):
    s+=dp[i-3]
    s=s%1000000007
    dp[i]=s
print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[0]*(n+1)
dp[0]=1
dp[1]=0
dp[3]=0
s=0
for i in range(3,n+1):
    s+=dp[i-3]
    s=s%1000000009
    dp[i]=s
print(dp[n])
Problem p02536 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 20:52:24 +0900
# LastModified: 2020-09-26 21:19:33 +0900
#


import os
import sys
sys.setrecursionlimit(2000000)
# import numpy as np
# import pandas as pd


def BFS(cnt, color, path, u):
    color[u] = cnt
    for v in path[u]:
        if color[v] == -1:
            BFS(cnt, color, path, v)


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        A, B = map(int, input().split())
        path[A].append(B)
        path[B].append(A)
    color = [-1] * (N+1)
    cnt = 0
    for i in range(1, N+1):
        if color[i] == -1:
            BFS(cnt, color, path, i)
            cnt += 1
    print(max(color))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 20:52:24 +0900
# LastModified: 2020-09-26 21:18:10 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def BFS(cnt, color, path, u):
    color[u] = cnt
    for v in path[u]:
        if color[v] == -1:
            BFS(cnt, color, path, v)


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        A, B = map(int, input().split())
        path[A].append(B)
        path[B].append(A)
    color = [-1] * (N+1)
    cnt = 0
    for i in range(1, N+1):
        if color[i] == -1:
            BFS(cnt, color, path, i)
            cnt += 1
    print(max(color))


if __name__ == "__main__":
    main()
Problem p02642 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_3
# CreatedDate:  2020-06-19 15:09:52 +0900
# LastModified: 2020-06-19 15:27:30 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    _ = int(input())
    a_s = list(map(int, input().split()))
    m = max(a_s)+1
    cnt = [0 for _ in range(m)]

    for a in a_s:
        if cnt[a] != 0:
            cnt[a] = 2
            continue
        for n in range(a, m, a):
            cnt[n] += 1

    print(sum(cnt[a] for a in a_s if cnt[a]==1))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_4
# CreatedDate:  2020-07-20 00:18:24 +0900
# LastModified: 2020-07-20 00:26:33 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    A = sorted(map(int, input().split()))
    ans = [1]*n
    for i, a in enumerate(A):
        if ans[i] == 0:
            continue
        for j in range(i+1, n):
            if A[j]%a == 0:
                ans[j] = 0
    if A[0] == A[1]:
        ans[0] = 0
    print(sum(ans))

if __name__ == "__main__":
    main()
Problem p02690 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-08-08 01:53:55 +0900
# LastModified: 2020-08-08 01:56:11 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    x = int(input())
    for a in range(-120, 120):
        for b in range(-120, a):
            if a**5-b**5 == x:
                print("{} {}".format(a, b))
                return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-03 22:36:44 +0900
# LastModified: 2020-05-03 22:56:22 +0900
#


import os
import sys


def main():
    x=int(input())
    tmp=1
    for i in range(2,x):
        if x%i==0:
            tmp=i
            break

    b=-1
    for i in range(x):
        if x==((tmp-1)*i)**5+1:
            a=(tmp-1)*i
            break
    print("{} {}".format(a,b))
    return 

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-03 22:36:44 +0900
# LastModified: 2020-05-03 22:38:33 +0900
#


import os
import sys


def main():
    x=int(input())
    b=-1
    for i in range(x):
        if x==i**5+1:
            a=i
            break
    print("{} {}".format(a,b))


if __name__ == "__main__":
    main()
Problem p02706 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-04-19 21:11:23 +0900
# LastModified: 2020-04-19 21:15:31 +0900
#


import os
import sys

def main():
    n,m=map(int,input().split())
    a = list(map(int,input().split()))
    if n-sum(a)<0:
        print(-1)
        return 

    print(n-sum(a))
    


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-04-19 21:11:23 +0900
# LastModified: 2020-04-19 21:14:03 +0900
#


import os
import sys
import numpy as np
import pandas as pd


def main():
    n,m=map(int,input().split())
    a = list(map(int,input().split()))
    if n-sum(a)<0:
        print(-1)
        return 

    print(n-sum(a))
    


if __name__ == "__main__":
    main()
Problem p02843 (python)

Fixed submission:
def main():
    X = input()
    if(len(X)<3):
        print(0)
        return
    last = int(X[:len(X)-2])
    two = int(X[-2:])
    if two <= last*5:
        print(1)
    else:
        print(0)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    X = input()
    A = [100,101,102,103,104,105]
    last = int(X[:len(X)-2])
    two = int(X[-2:])
    if two <= last*5:
        print(1)
    else:
        print(0)

if __name__=='__main__':
    main()
Problem p03196 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:53:52 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt
from collections import Counter


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box.append(2)
        p //= 2

    for i in range(3, int(sqrt(p))+1, 2):
        while p % i == 0:
            prime_box.append(i)
            p //= i
    if p > 2:
        prime_box.append(p)


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = []
    prime_factors(p, prime_box)
    prime_box = list(map(list, Counter(prime_box).items()))
    prime_box = [[s, t//n] for s, t in prime_box]
    ans = 1
    for s, t in prime_box:
        ans *= s**t
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:22:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box[2] += 1
        p //= 2

    for i in range(3, len(prime_box), 2):
        while p % i == 0:
            prime_box[i] += 1
            p //= i


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = [0] * (p+1)
    prime_factors(p, prime_box)
    prime_box = list(map(lambda x: x//n, prime_box))
    if sum(i*prime_box[i] for i in range(len(prime_box))) == 0:
        print(1)
    else:
        print(sum(i*prime_box[i] for i in range(len(prime_box))))


if __name__ == "__main__":
    main()
Problem p03611 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:33:28 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    cnt_list = Counter(a)

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        cnt = 0
        if center in cnt_list.keys():
            cnt += cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:31:15 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    cnt_list = Counter(a)

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        if center in cnt_list.keys():
            cnt = cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()