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

Fixed submission:
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

dp = [{-1: -1} for i in range(N)]
mark = {}
Q = int(input())
col = [0]*(Q+1)
col[-1] = 0
C = []
for i in range(Q):
    v, d, c = map(int, input().split())
    col[i] = c
    C.append((v-1, d))

def dfs(v, d, idx):
    if d <= max(dp[v]):
        return
    dp[v][d] = idx
    if d:
        for w in G[v]:
            dfs(w, d-1, idx)

for i in range(Q-1, -1, -1):
    v, d = C[i]
    dfs(v, d, i)
print(*(col[max(e.values())] for e in dp), sep='\n')

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

dp = [[-1]*10 for i in range(N)]
mark = {}
Q = int(input())
col = [0]*(Q+1)
col[-1] = 0
C = []
for i in range(Q):
    v, d, c = map(int, input().split())
    col[i] = c
    C.append((v-1, d))

def dfs(v, d, idx):
    if idx < dp[v][d]:
        return
    dp[v][d] = idx
    if d:
        for w in G[v]:
            dfs(w, d-1, idx)

for i in range(Q-1, -1, -1):
    v, d = C[i]
    dfs(v, d, i)
print(*(col[max(e for e in dp[i])] for i in range(N)), sep='\n')
Problem p03774 (python)

Fixed submission:
n, m = map(int, raw_input().split())
P = [map(int, raw_input().split()) for i in xrange(n)]
C = [map(int, raw_input().split()) for i in xrange(m)]
for a, b in P:
    idx = -1; mi = ()
    for i, (c, d) in enumerate(C):
        di = abs(a-c) + abs(b-d)
        if di < mi:
            mi = di
            idx = i
    print idx+1

Buggy submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())
P = [map(int, raw_input().split()) for i in xrange(n)]
C = [map(int, raw_input().split()) for i in xrange(n)]
for a, b in P:
    idx = -1; mi = ()
    for i, (c, d) in enumerate(C):
        di = abs(a-c) + abs(b-d)
        if di < mi:
            mi = di
            idx = i
    print idx+1
Problem p03822 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n = input()
A = {}
for i in xrange(2, n+1):
    v = int(raw_input())
    A.setdefault(v, []).append(i)
f = lambda v: (v in A)/1 and 1+max(e+i for i,e in enumerate(sorted(map(f,A[v]))[::-1]))
print f(1)

Buggy submission (verdict: Runtime Error):
n = input()
A = {}
for i in xrange(2, n+1):
    v = int(raw_input())
    A.setdefault(v, []).append(i)
f = lambda v: (v in A)/1 and 1+max(e+i for i,e in enumerate(sorted(map(f,A[v]))[::-1]))
print f(1)
Problem p02897 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5)
else:
  print((N-(N-1))/2N)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)//2N)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N %2 ==0:
  prnit(0.5)
else:
  print(2/(N+1))

Buggy submission (verdict: Runtime Error):
N = int(input(''))
if (N % 2) == 0:
  print(round(2/N),10)
else:
  print(round((N+1)/2N),10)

Buggy submission (verdict: Runtime Error):
N = int(input(''))
if (N % 2) == 0:
  print(N/2N)
else:
  print((N+1)/2N)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/2N)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print(float((N+1)/2N))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/2N)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N-1)/2N)
Problem p02951 (python)

Fixed submission:
A,B,C =  map(int,input().split())
print(max(0,B+C-A))

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) % 2 == 1:
    sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
print(max(0,B+C-A))
Problem p03208 (python)

Fixed submission:
N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag = 0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
	flag=0
    for i in range(N):
    	if h[i]>0:
        	h[i] -= 1
      	    flag = 1
        if h[i+1] == 0:
        	count += 1
        else:
        	pass
    if flag == 0:
    	break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)
Problem p03329 (python)

Fixed submission:
import math

N=int(input())
number_of_withdrawal=[100000]

# def floor(float_number):
#     integer = 0
#     while integer < float_number:
#         integer+=1
#     if integer == float_number:
#         return integer
#     else:
#         integer-=1
#         return integer

for money_6 in range(0, N+1):
    money_9 = N-money_6

    i=0
    count_6_pow_number=0
    while pow(6,i)<=money_6:
        count_6_pow_number += (math.floor(money_6/pow(6,i)))%6
        i+=1
    j=0
    count_9_pow_number=0
    while pow(9,j)<=money_9:
        count_9_pow_number += (math.floor(money_9/pow(9,j)))%9
        j+=1

    # print(money_6, money_9, sum(count_6_pow_number), sum(count_9_pow_number))
    number_of_withdrawal.append(count_6_pow_number+count_9_pow_number)

print(min(number_of_withdrawal))

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

def floor(float_number):
    integer = 0
    while integer < float_number:
        integer+=1
    if integer == float_number:
        return integer
    else:
        integer-=1
        return integer

for money_6 in range(0, N+1):
    money_9 = N-money_6

    latest = count_6_pow_number+count_9_pow_number

    i=0
    count_6_pow_number=0
    while pow(6,i)<=money_6:
        count_6_pow_number += (floor(money_6/pow(6,i)))%6
        i+=1
    j=0
    count_9_pow_number=0
    while pow(9,j)<=money_9:
        count_9_pow_number += (floor(money_9/pow(9,j)))%9
        j+=1

    # print(money_6, money_9, sum(count_6_pow_number), sum(count_9_pow_number))
    number_of_withdrawal= count_6_pow_number+count_9_pow_number
    if number_of_withdrawal < latest:
        res = number_of_withdrawal


print(res)
Problem p03345 (python)

Fixed submission:
A,B,C,K=list(map(int,input().split()))
print(((-1)**(K%2))*(A-B))

Buggy submission (verdict: Runtime Error):
A,B,C,K=list(map(int.input().split()))
print(((-1)**K)*(A-B))
Problem p02970 (python)

Fixed submission:
x,y = map(int,input().split())
i=0
while x>0:
  i+=1
  x = x-(2*y+1)
print(i)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
print(y//2*n+1)
Problem p03011 (python)

Fixed submission:
a = list(map(int,input().split()))
a.sort()
print(a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a  = list(map(int.input().split()))
a.sort();
print(a[0]+a[1])
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
As = list(map(int, input().split()))
adic = {}
for a in As:
    adic[a] = adic.get(a, 0) + 1

Ds = []
for a in adic:
    Ds.append([a, adic[a]])
for i in range(M):
    B, C = map(int, input().split())
    Ds.append([C,B])

Ds.sort(reverse=True)

count, sum = 0,0
for D in Ds:
    c = D[1] if D[1] + count <= N else N - count
    sum += c * D[0]
    count += c
    if count == N:
        break

print(sum)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
As = list(map(int, input().split()))
Ds = []
for i in range(M):
    B, C = map(int, input().split())
    D = [C] * B
    Ds.extend(D)

Ds.sort(reverse=True)

for i in range(N):
    As.sort()
    if As[0] < Ds[i]:
        As[0] = Ds[i]
    else:
        break

print(sum(As))
Problem p02897 (python)

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(float(1 / 2))
else:
  print(float((a - (a - 1) / 2) / a))

Buggy submission (verdict: Runtime Error):
N = int(input())
K = list(map(int, input().split()))
n = [0] * N

for i in range(N):
  n[K[i]-1] = i + 1

for i in n:
  print(i, end=" ")
Problem p03041 (python)

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

temp = s[k-1].lower()
if k-1 != len(s):
    ans = s[0:k-1] + temp + s[k:]
else:
    ans = k[0:k-1] + temp
print(ans)

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

temp = s[k].lower()
ans = s[0:k]+temp+s[k+1:]
print(ans)
Problem p02897 (python)

Fixed submission:
def main():
    n = int(input())
    print((n+n%2)/2/n)

    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
 
    if (N < 0 or N > 100):
            return 0
        array_len = len([N for i in range(1, N+1) if(i%2==1)])
        result = array_len / N
        return result
    
if __name__ == "__main__":
    main()
Problem p03073 (python)

Fixed submission:
def main(n):
	r = 0
	f = n[0]
	if(f =="0"):
		# zero mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

print(main(input()))
#assert(1 == main("000"))
#assert(3 == main("10010010"))
#assert(0 == main("0"))

Buggy submission (verdict: Runtime Error):
n=input()
r=n[0::2].count("0")+n[1::2].count("1")
print(min(r,len(n-r))

Buggy submission (verdict: Runtime Error):
def main(n):
	odd = "1"
	even= "0"
	if(n[0] =="0"):
		# zero mode
		odd = "0"
		even= "1"
	a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n),2))
	b = sum((((i % 2 == 0) and n[i] == even)) for i in range(0, len(n),2))
	return sum(a,b)

print(main(input()))

Buggy submission (verdict: Runtime Error):
def main(n):
	n = input()
	r = 0
	f = n[0]
	if(f =="0"):
		# zero mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

print(main(input()))
#assert(1 == main("000"))
#assert(3 == main("10010010"))
#assert(0 == main("0"))

Buggy submission (verdict: Runtime Error):
data = input()
a,b = data.split()
if(a==b):
  print(a+b)
elif(a>b):
  print(2*a-1)
else:
  print(2*b-1)
Problem p02897 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
    print(1 / 2)
else:
    print((((n - 1) / 2) + 1) / n)

Buggy submission (verdict: Runtime Error):
n = int(input())
students = [int(x) for x in input().split(' ')]
order = [x for x in range(n)]
for i in range(n):
    order[students[i] - 1] = i+1
print(' '.join([str(x) for x in order]))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from math import factorial

def is_prime(x):
    return factorial(x - 1)  % x == x - 1

a, b = [int(x) for x in input().split(' ')]
i = 0
k = gcd(a, b)
for x in range(1, k): 
    if k % x == 0 and is_prime(x):
        i += 1
        
print(i)

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

if n % 2 == 0:
    print(1 / 2)
else:
    print((((n - 1) / 2) + 1) / n)
Problem p02897 (python)

Fixed submission:
A = int(input())
mod = A%2


if mod==0:
  print("0.5")
else:
  print((A+1)/(A*2))

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
A= list(map(int, input().split()))
A=np.array(A)
S=np.array(range(N))
 
con=np.vstack([A,S])
 
con=con[:, con[0,:].argsort()]
ans=con[1,]+1
ans=str(ans)
print(ans)
Problem p02915 (python)

Fixed submission:
n = int(input())
print (n*n*n)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
 
ans = b[a[0]-1]
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i] > a[i-1]:
        ans += c[a[i-1]-1]
print (ans)
Problem p02916 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
 
ans = b[a[0]-1]
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i]-a[i-1]==1:
        ans += c[a[i-1]-1]
print (ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
c = [*map(int, input().split())]

ans = b[a[0]-1]
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i] > a[i-1]:
        ans += c[a[i]-2]
print (ans)
Problem p02915 (python)

Fixed submission:
print(int(input()) ** 3)

Buggy submission (verdict: Runtime Error):
print(int(input() ** 3)

Buggy submission (verdict: Runtime Error):
print(3 ** int(input())
Problem p02897 (python)

Fixed submission:
a=int(input())
b=a+1
c=0
d=0
for i in range(b):
	c=i%2
	if c == 1:
		d=d+1
	else:
		pass
e=d/a
print(e)

Buggy submission (verdict: Runtime Error):
a=input().split(' ')
b=int(a[0])
c=int(a[1])
data=input().split(' ')
data_1=0
data_2=0
for i in range(b):
	data_1=int(data[i])
	if data_1 >= c:
		data_2=data_2+1
	else:
		pass
print(data_2)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=a+1
c=0
d=0
for i in range(a):
	c=i%2
    if c==1:
    	d=d+i
	else:
    	pass
e=d/a
print(e)

Buggy submission (verdict: Runtime Error):
a=int(input()
b=a*0,000000001
print(b)
Problem p03835 (python)

Fixed submission:
import sys

data=input().split(' ')
k=int(data[0])
data_1sub=k+1
s=int(data[1])
d=0
e=0
for i in range(data_1sub):
    for j in range(data_1sub):
        d=s-i-j
        if (0 <= d) and (d <= k):
            e=e+1
        else:
            pass
print(e)

Buggy submission (verdict: Runtime Error):
data=int(input().split
b=data[0]
c=data[1]
d=0
e=0
f=0
for i in range(b):	
	for j in range(b):
         for k in range(b):
         	d=i+j+k
         	if d <=15:
         		e=e+1
         	else:
         		pass
print(e)

Buggy submission (verdict: Runtime Error):
import random

data=int(input().split
b=data[0]
c=data[1]
count_data=0
random_data=random.randint(0,b)
random_data2=random.randint(0,b)
random_data3=random.randint(0,b)
resalt=random_data+random_data2+random_data3
if resart<= c:
     count_data=count_data+1
else:
	pass
print(count_data)
Problem p02897 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(0.5)
else:
    print((n//2+1)/n)

Buggy submission (verdict: Runtime Error):
import math

def gcd(a,b):
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
    
a,b=list(map(int,input().strip().split()))
c=gcd(a,b)
e=c
d=0
for i in range(2,math.ceil(math.sqrt(e)+2)):
    if c%i==0:
        d=d+1
        c=c//i
print(d+1)
Problem p02984 (python)

Fixed submission:
def D_RainFlowsintoDams():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    x = total - 2*sum([A[i] for i in range(1, N -1, 2)])
    for i in range(N):
        print(x, end=" ")
        x = 2 * A[i] - x
def D_Determinant():
    # 行列式を使うと時間がかかりすぎる
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    B = np.linalg.solve(X, A.T)
    # 両辺に左からX^{-1}をかける
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()

Buggy submission (verdict: Runtime Error):
def D_RainFlowsintoDams():
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    B = np.linalg.solve(X, A.T)
    # 両辺に左からX^{-1}をかける
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()

Buggy submission (verdict: Runtime Error):
def D_RainFlowsintoDams():
    import numpy as np
    N = int(input())
    A = np.array([list(map(int, input().split()))])
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    X = np.linalg.inv(X)
    # 両辺に左からX^{-1}をかける
    B = np.dot(X, A.T)
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()
Problem p03013 (python)

Fixed submission:
def C_TypicalStairs():
    N, M = map(int, input().split())
    am = [int(input()) for i in range(M)]
    n_list = [i for i in range(N+1)]
    can_move = True
    num_move = 0
    if(M == 0):
        num_move = fib(len(n_list))
    else:
        # 到達不可を除く
        for i in range(M-1):
            if ((am[i] + 1) == am[i+1]):
                can_move = False
        if (can_move):
            num_move = fib(len(n_list[:am[0]]))
            if (M <= 1):
                pass
            else:
                for i in range(M-1):
                    num_move *= fib(len(n_list[am[i]+1:am[i+1]]))
            num_move *= fib(len(n_list[am[M-1]+1:]))
    print(num_move % 1000000007)

def fib(n):
    if (n <= 1):
        a0 = n
    else:
        a0, a1 = 0, 1
        for _ in range(n):
            a0, a1 = a1, a0 + a1
    return a0
if __name__ == "__main__":
    C_TypicalStairs()

Buggy submission (verdict: Runtime Error):
def C_TypicalStairs():
    N, M = map(int, input().split())
    am = [int(input()) for i in range(M)]
    n_list = [i for i in range(N+1)]
    can_move = True
    num_move = 0
    # 到達不可を除く
    for i in range(M-1):
        if ((am[i] + 1) == am[i+1]):
            can_move = False
    if (can_move):
        num_move = fib(len(n_list[:am[0]]))
        if (M <= 1):
            pass
        else:
            for i in range(M-1):
                num_move *= fib(len(n_list[am[i]+1:am[i+1]]))
        num_move *= fib(len(n_list[am[M-1]+1:]))
    print(num_move % 1000000007)

def fib(n):
    if (n <= 1):
        a0 = n
    else:
        a0, a1 = 0, 1
        for _ in range(n):
            a0, a1 = a1, a0 + a1
    return a0
if __name__ == "__main__":
    C_TypicalStairs()
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
s = list(input())
print("".join(s[:K-1]+ list(s[K-1].lower()) + s[K:]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
s = list(input())
print("".join(s[:K]+ list(s[K].lower()) + s[K + 1:]))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
t = [int(i) for i in input().split()]

x = 0

for i in t:
  x += 1 / i

print(1 / x)
Problem p02897 (python)

Fixed submission:
a = int(input())
if a % 2 == 0:
  print((a//2)/a)
else:
  print(((a//2)+1)/a)

Buggy submission (verdict: Runtime Error):
rule = input().split()
men = input().split()

mens = 0
for i in men:
  if int(rule[0]) <= int(i):
    mens += 1

print(mens)
Problem p02933 (python)

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

if a >= 3200:
    print(s)
else:
    print("red")

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

tree = {i:[] for i in range(1, n + 1)}
for _ in range(1, n):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

tmp = [1]
while len(tmp) != 0:
    tmp2 = tmp
    tmp = []
    for oya in tmp2:
        tmp.extend(tree[oya])
        for ko in tree[oya]:
            tree[ko].remove(oya)


cnt = [list(map(int, input().split())) for _ in range(q)]

ans = [0]*n
for p, x in cnt:
    tmp = [p]
    while len(tmp) != 0:
        for i in tmp:
            ans[i-1] += x
        tmp2 = tmp
        tmp = []
        for aaa in tmp2:
            tmp.extend(tree[aaa])


print(" ".join(map(str, ans)))
Problem p02897 (python)

Fixed submission:
a = int(input())
b = 0
ans = 0
if a % 2 != 0:
  b = a / 2 + 0.5
  ans = b / a

else:
  b = a /2
  ans = b / a

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
array = list(map(int,input().split()))
ans = 0
i = 0
while N > i:
  if array[i] >= K:
    ans += 1
    
  i += 1
print(ans)
Problem p03013 (python)

Fixed submission:
import sys
 
n, m = list(map(int, input().split()))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7
 
for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD
print(dp[n])

Buggy submission (verdict: Runtime Error):
import math
N, M = (int(i) for i in input().split())

list_a = list()
for i in range(M):
  list_a.append(int(input()))


curr = 0

list_pat = list()
for i in range(M+1):
  if i==M:
   dist=N
  else:
   dist=list_a[i]-1
  if dist-curr<=1:
   if dist==N:
    break
   else:
    if list_a[i]==1:
     curr=2
    else:
     list_pat.append(0)
#     print('break!')
     break
  else:
   diff_dist = dist-curr
#   print('diff_dist' + str(diff_dist))
   if diff_dist == 0:
    list_pat.append(1)
#    print('a')
   else:
    max_num_2 = diff_dist//2
    if max_num_2 == 0:
     list_pat.append(1)
#     print('b')
    else:
     list_pat_this = list()
     for num_2 in range(max_num_2+1):
      num_1 = diff_dist-num_2*2
#      print('num_1:'+str(num_1))
#      print('num_2:'+str(num_2))
      list_pat_this.append(math.factorial(num_1+num_2)/math.factorial(num_1)/math.factorial(num_2))
#     print(list_pat_this)
     list_pat.append(int(sum(list_pat_this)))
     if dist!=N: 
      curr = list_a[i]+1

#print(list_pat)
pat=1
for pat_this in list_pat:
 pat=pat*pat_this

print(pat%1000000007)
Problem p02912 (python)

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

A.sort(reverse = True)
i = 0
for j in range(M):
	A[i] = A[i]//2
	if i <= N-2 and A[i] < A[i+1] and A[0] < A[i+1]:
		i += 1
	else :
		A.sort(reverse=True)
		i = 0
print(str(sum(A)))

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

for i in range(N):
	A[N] = A[N]// 2
	A.sort()

B = sum(A)

print(B)

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

for i in range(N):
	A[N] // 2
	A.sort()

B = sum(A)

print(B)