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

Fixed submission:
N = int(input())
L = []
for i in range(N):
  A = int(input())
  LA = []
  for j in range(A):
    LA.append(list(map(int,input().split())))
  L.append(LA)
from itertools import product
LL = list(product(range(2), repeat=N))
cnt = 0
for i in LL:
  flg = True
  for j in range(len(L)):
    #jの情報は、(hito=x, singi = y=1,0)
    #iの情報は、(singi = (1/0,...,1/0))
    for x,y in L[j]:
      #jさんの情報      
      #i[j] :sinngi　正解
      #y:sinngi　を変換
      if i[j]==1:
        if i[x-1]!=y:
          flg = False
          break
  if flg:
    cnt = max(cnt,sum(i))
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = []
for i in range(N):
  A = int(input())
  for j in range(A):
    x ,  y= map(int,input().split())
    L.append([i+1,x,y])

from itertools import permutations, combinations,combinations_with_replacement,product
LL = list(product(range(2), repeat=N))
cnt = 0
for i in LL:
  for j in L:
    #jの情報は、(hatsugen=i,hito=x,flg=1,0)
    #iの情報は、(flg(i),...,)
    if i[j[0]-1]==1:
      k = j[2]
    else:
      k = 1- j[2]
    flg = 1
    if i[j[1]-1]!=k:
      flg = 0
      break
  cnt = max(cnt,sum(i)*flg)
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = []
for i in range(N):
  A = int(input())
  for j in range(A):
    x ,  y= map(int,input().split())
    L.append([i+1,x,y])

from itertools import permutations, combinations,combinations_with_replacement,product
LL = list(product(range(2), repeat=N))

cnt = 0
for i in LL:
  ii = list(i)
  Ans =[]
  for j in L:
    if j[2]==1 and ii[j[0]-1]==1:
      k = 1
    elif j[2]==1 and ii[j[0]-1]==0:
      k = 0
    elif j[2]==0 and ii[j[0]-1]==1:
      k = 0
    elif j[2]==0 and ii[j[0]-1]==0:
      k = 1
    Ans.append([j[1],k])
  Ans.sort()
  for l in range(len(Ans)):
    if i[Ans[l][0]-1] != Ans[l][1]:
      flg = 0
      break
    else:
      flg = 1
#  print(i,flg,Ans)
  cnt = max(cnt,sum(i)*flg)
print(cnt)
Problem p02855 (python)

Fixed submission:
H,W,K = map(int, input().split())

def cv(S,cn,pr):
  SS=S
  ans = []
  for i in range(cn):
    ans += [pr+i+1]*(SS.find("#")+1)
    if SS.find("#")<len(SS):
      SS = SS[SS.find("#")+1:]
    else:
      SS = ""
  ans += [pr+cn]*len(SS)
  return ans
    
cnt_pre = 0 #最初のall #no
cnt = 0 # "#"の個数
for i in range(H):
  Lin = input()
  tmp = Lin.count("#")
  if tmp == 0 and cnt == 0:
    cnt_pre +=1
  elif tmp == 0:
    print(*pS)
  else:
    pS = cv(Lin,tmp,cnt)
    for i in range(0,cnt_pre+1):
      print(*pS)
    cnt_pre = 0
  cnt += tmp

Buggy submission (verdict: Runtime Error):
H,W,K = map(int, input().split())
cnt = 0
rep = 1
flg = 0
for i in range(H):
    Lin = input()
    Lin = (Lin.replace("#","1")).replace(".","0")
    if Lin == "0"*W and (i < (H-1)) and flg == 0:
        rep += 1
        pv = str(cnt+1)
    elif Lin == "0"*W :
        print(Str)
    else:
        for j in range(W):
            cnt += int(Lin[j])
            if j == 0:
                Str = pv
            elif Lin[j-1] == "0":
                Str += pv
            elif Lin[j-1] == "1":
                pv = str(int(pv)+1)
                Str += pv
            if j != (W-1):
                Str += " "
        for k in range(rep):
            print(Str)
        rep = 1
        flg = 1
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()
tmp = S[0]
ret = tmp
for i in S:
  if tmp == i:
    tmp = i
  else:
    ret += i
    tmp = i
print(len(ret))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
tmp = S[1]
ret = tmp
for i in S:
  if tmp == i:
    tmp = i
  else:
    ret += i
    tmp = i
print(len(ret))
Problem p02899 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(range(1,N+1,1))
C = zip(A,B)
D = sorted(C)
a, b = zip(*D)
print(" ".join(str(x) for x in b))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(range(1,N+1,1))
C = zip(A,B)
C.sort()
a, b = zip(*C)
print(" ".join(str(x) for x in b))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(range(1,N+1,1))
C = zip(A,B)
C.sort()
a, b = zip(*C)
print(' '.join(b))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(range(1,N+1,1))
C = zip(A,B)
C.sort()
a, b = zip(*C)
print(' '.join(b))
Problem p02911 (python)

Fixed submission:
N,K,Q=map(int, input().split())
A=[int(input()) for i in range(Q)]
from collections import Counter
A=Counter(A)
B=list(A.most_common())
#B.sort(key=lambda x:x[0])
C = [0]*N
for i in B:
  C[i[0]-1]=i[1]
for i in range(N):
  if (Q - C[i])< K:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,K,Q=map(int, input().split())
A=[int(input()) for i in range(Q)]
from collections import Counter
A=Counter(A)
B=list(A.most_common())
B.sort(key=lambda x:x[0])
for i in range(N):
  if (Q - B[i][1])< K:
    print("Yes")
  else:
    print("No")
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
nn=int(input())
pprint(sum([i for i in range(1,n)]))
Problem p02934 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
R = 0.0
for i in range(N):
  R += A[i]**(-1)
print(1/R)

Buggy submission (verdict: Runtime Error):
_=input()
print(1/sum[1/r for r in list(map(int,input().split()))])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
R = 0.0
for i in range(N):
  R += i**(-1)
print(1/R)
Problem p02953 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Buggy submission (verdict: Runtime Error):

    n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)
    ans="No"
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=map(int,input().split())
ans="Yes"
for i in range(n:0:-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)
Problem p02983 (python)

Fixed submission:
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
if (R+1-L)<2019:
  C = combinations(LR, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)

Buggy submission (verdict: Runtime Error):
L,R=map(int, input().split())
from itertools import permutations, combinations,combinations_with_replacement,product
for 
if (R+1-L)<2019:
  LR = range(L,R+1)
  LRA = []
  for i in LR:
    LRA.append(i%2019)
  LRAA = set(LRA)
  C = combinations(LRAA, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)

Buggy submission (verdict: Runtime Error):
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
C = combinations(LR, 2)
Ret = 2019
for i in C:
  Ret = min(Ret,(i[0]*i[1])%2019)
print(Ret)
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0]
cnt=0
for i in L:
  D.append(D[-1]+i)
for i in D:
  if i<=X:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
for i in L:
  D.append(D[-1]+i)
  if D[-1]>X:
    print(len(D)-1)
    break
Problem p03001 (python)

Fixed submission:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W == 2*x and H==2*y:
  R = 1
else:
  R = 0
print(D, R)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if (W/x) == 2 and (H/y)==2:
  R = 1
else:
  R = 0
print(D, R)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W//x==2 and H//y==2:
  R = 1
else:
  R = 0
print(D, R)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
  D = 0.5*H*W
  if W//x==2 and H//y==2:
    R = 1:
  else:
    R = 0
print(D, R)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
if W-x < x:x = W-x
if H-y < y:y = H-y
D1 = x*H
D2 = y*W
if x !=0 and y!=0:
  D = max(D1,D2)
  if x==y:
    R = 1
  else
    R = 0
else:
  D = 0.5*H*W
  R = 0
print(D, R)
Problem p03005 (python)

Fixed submission:
x,y=map(int,input().split())
if y == 1:
  print(0)
else:
  print(x-y)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if y = 1:
  print(0)
else:
  print(x-y)
Problem p03031 (python)

Fixed submission:
N,M=map(int,input().split())
S = []
for i in range(M):
  S.append(list(map(int,input().split())))
P = list(map(int,input().split()))

def check(num, i, P):
  SS = S[i]
  PP = P[i]
  on = 0
  for j in range(1,1+SS[0]):
    on += num>>(SS[j]-1) & 1
    on = on%2
  if on == PP:
    return True
  else:
    return False
cnt = 0
for nu in range(2**N):
  ck = True
  for i in range(M):
    ck = ck and check(nu,i,P)
    if ck == False:
      break
  if ck == True:
    cnt +=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mod = 10**9+7
fram = [1]
for i in range(1,N+1):
  fram.append(fram[-1]*i%mod)

#def framod(n, mod, a=1):
#    for i in range(1,n+1):
#        a = a * i % mod
#    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=fram[n]
    b=fram[k]
    c=fram[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)])
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)
Problem p03067 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b))):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b)):
  print('Yes')
else:
  print('No')
Problem p03068 (python)

Fixed submission:
N=int(input())
S=list(input())
ks=S[int(input())-1]
for i in range(N):
  if S[i]!=ks:
    S[i]='*'
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
ks=S[int(input())+1]
for i in range(N):
  if S[i]!=ks:
    S[i]='*'
print(ks)
Problem p03086 (python)

Fixed submission:
S = input()
S=S.replace("T","A")
S=S.replace("G","A")
S=S.replace("C","A")
for i in range(10,-1,-1):
  if S.find("A"*i) != -1:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
S = input()
Ans =[]
dic = ["A","T","G","C"]
rmp =""
for i in range(len(S)):
  if S[i] in dic:
    rmp += S[i]
  else:
    Ans.append(len(rmp))
    rmp = ""
print(max(Ans))
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*（W-w）)
Problem p03147 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
H = [0]+H+[0]
def trm(li):
  for i in range(len(li)-2,0,-1):
    if li[i-1]<=li[i]<=li[i+1]:
      li.pop(i)
    elif li[i-1]>=li[i]>=li[i+1]:
      li.pop(i)
  return H
H = trm(H)
cnt = 0
for i in range(max(H),0,-1):
  flg = False
  for j in range(len(H)):
    if H[j]==i:
      if not flg:
        cnt +=1
        flg = True
      H[j]=H[j]-1
    else:
      flg = False
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
H = [0]+H+[0]
for i in range(N,0,-1):
  if H[i-1]<=H[i]<=H[i+1]:
    H.pop(i)
  if H[i-1]>=H[i]>=H[i+1]:
    H.pop(i)
cnt = 0
flg = True
while flg:
  m = max(H)
  if m == 0:
    break
  i = H.index(m)
  d = min(H[i]-H[i+1], H[i]-H[i-1])
  cnt += d
  H[i+1]=max(0,H[i+1]-d)
  H[i-1]=max(0,H[i-1]-d)
  H.pop(i)
print(cnt)
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
DP = [0]*(N+1)  #DP[i]に来るための最小コスト
def dH(i,j):
  return abs(H[i-1] - H[j-1])
DP[2] = dH(1,2)
for i in range(3,N+1):
  DP[i] = min( DP[i-2] + dH(i-2, i) , DP[i-1] + dH(i-1, i) )
print(DP[N])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import sys

def cost(n, h):
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[1]-h[0])
    else:
        ret1 = cost(n-2, h)+abs(h[n-1]-h[n-3])
        ret2 = cost(n-1, h)+abs(h[n-1]-h[n-2])
        return min(ret1, ret2)

def main():
    input = sys.stdin.readline
    N = int(input())
    H = list(map(int, input().split()))
    print(cost(N, H))

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

Fixed submission:
N, K = map(int,input().split())
H = list(map(int,input().split()))
import numpy as np
dp = np.zeros(N,dtype=np.int)
harr = np.array(H)
for i in range(1,N):
  St = max(0,i-K)
  Hi = harr[i]
  dp[i] = min(dp[max(0,i-K):i] + np.abs(Hi - harr[max(0,i-K):i]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*(N+1)
for _ in range(2,N+1):
  Hi = H[i-1]
  DP[i] = min( [DP[j] + abs(Hi - H[j-1]) for j in range(max(1,i-K),i)])
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*N
for i in range(1,N):
  DP[i] = min( [DP[j] + abs(H[i] - H[j]) for j in range(max(1,i-K),i)])
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*(N+1)
def dH(i,j):
  return abs(H[i-1] - H[j-1])
for i in range(2,N+1):
  DP[i] = DP[i-1] + dH(i-1, i)
  for j in range(2,K+1):
    jc = DP[i-j] + dH(i-j, i)
    if (i-j)>=1 and jc < DP[i]:
      DP[i] = jc
print(DP[N])

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*(N+1)  #DP[i] iに来るための最小コスト
def dH(i,j):
  return abs(H[i-1] - H[j-1])
for i in range(2,N+1):
  DP[i] = DP[i-1] + dH(i-1, i)
  for j in range(2,min(K+1,i+1):
      DP[i] = min( DP[i], DP[i-j] + dH(i-j, i) )
print(DP[N])
Problem p03164 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Buggy submission (verdict: Runtime Error):
max_Vi = 10**3
max_Wi = W
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=[0]+[max_Wi+1]*(N*max_Vi)
dp=np.array(dp)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
max_Vi = 10**3
max_Wi = W
dp=[max_Wi+1]*(N*max_Vi+1)
dp[0]=0
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])
Problem p03165 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

####################################################
# LCS(longest common sequence)
# 部分列で最長の共通のもの
####################################################

# dp[i+1][j+1]:= s の i 文字目までと t の j 文字目まででの LCS の長さ

import numpy as np

def main():
    S = np.array(list(input()), dtype='unicode')
    T = np.array(list(input()), dtype='unicode')
    ls = len(S)
    lt = len(T)

    equal = S[:, None] == T[None,:]
#    print(eq)

    dp = np.zeros((ls + 1, lt + 1), dtype=int)

    for i in range(ls):
        dp[i + 1][1:] = np.maximum(dp[i][1:], dp[i][:-1] + equal[i])
        dp[i + 1] = np.maximum.accumulate(dp[i + 1])

#    for i in range(ls):
#        for j in range(lt):
#            dp[i+1][j+1] = max(dp[i][j+1], dp[i][j]+ eq[i][j])
#            dp[i+1][j+1] = max(dp[i+1][j+1] , dp[i+1][j])

#    print(dp)

    # 復元
    res = ''
    i, j = ls, lt
    while (i > 0 and j > 0):
        # (i-1, j) -> (i, j) と更新されていた場合
        if dp[i][j] == dp[i-1][j]:
            i-=1   # DP の遷移を遡る
        # (i, j-1) -> (i, j) と更新されていた場合
        elif dp[i][j] == dp[i][j-1]:
            j-=1   # DP の遷移を遡る
        # (i-1, j-1) -> (i, j) と更新されていた場合
        else:
            res = S[i-1] + res
            # このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            i-=1
            j-=1   # DP の遷移を遡る
    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

####################################################
# LCS(longest common sequence)
# 部分列で最長の共通のもの
####################################################

# dp[i+1][j+1]:= s の i 文字目までと t の j 文字目まででの LCS の長さ

def main():
    S = input()
    T = input()
    ls = len(S)
    lt = len(T)

    dp = [[0]*(lt+1) for _ in range(ls+1)]
    for i in range(ls):
        for j in range(lt):
            if S[i]==T[j]:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1], dp[i][j]+1)
            elif:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
#    print(dp)
#    print(dp[ls][lt])

    # 復元
    res = ''
    i, j = ls, lt
    while (i > 0 and j > 0):
        # (i-1, j) -> (i, j) と更新されていた場合
        if dp[i][j] == dp[i-1][j]:
            i-=1   # DP の遷移を遡る
        # (i, j-1) -> (i, j) と更新されていた場合
        elif dp[i][j] == dp[i][j-1]:
            j-=1   # DP の遷移を遡る
        # (i-1, j-1) -> (i, j) と更新されていた場合
        else:
            res = S[i-1] + res
            # このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            i-=1
            j-=1   # DP の遷移を遡る
    print(res)

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

Fixed submission:
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:N]*P[n]
    prob = prob * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:n]*P[n]
    prob[:n] = prob[:n] * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(float, input().split()))
prob_memo = [[-1]*(N+1) for _ in range(N+1)]
prob_memo[0] = [1] + [0]*N

def prob(n,k):
  if prob_memo[n][k]==-1:
    prob_memo[n][k] = prob(n-1,k-1)*P[n-1] + prob(n-1,k)*(1-P[n-1])
  return prob_memo[n][k]

def prob_ret():
  ret = 0
  for k in range(N//2+1,N+1):
    ret += prob(N,k)
  return ret

print(prob_ret())
Problem p03214 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
t=sum(A)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
t=sum(a)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break
Problem p03231 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from fractions import gcd   #for python3.4
#from math import gcd        #for python3.8

def lcm(a,b):
    G = gcd(a, b) #最大公約数
    L = (a//G)*b #最小公倍数
    return L

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()
    L = lcm(N,M)
    if S[::L//M]==T[::L//N]:
        print(L)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from fractions import gcd   #for python3.4
from math import gcd        #for python3.8

def lcm(a,b):
    G = gcd(a, b) #最大公約数
    L = (a//G)*b #最小公倍数
    return L

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()
    L = lcm(N,M)
    if S[::L//M]==T[::L//N]:
        print(L)
    else:
        print(-1)

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

Fixed submission:
S=input()
C1=S[0]=='A' and S[-1].islower()
C1=C1 and S[1].islower()
C2=0
C3=0
for i in S[2:len(S)-1]:
  if i=='C':
    C2+=1
  elif i.islower():
    C3=C3
  else:
    C3+=1
if C1 and C2==1 and C3==0:
  print('AC')
else:
  print('WA')

Buggy submission (verdict: Runtime Error):
S=input()
C1=S[0]=='A' and S[-1].islower()
C1=C1 and S[1].islower()
C2=0
C3=0
for i in S[2:len(S)-1]:
  if i=='C':
    C2+=1
  elif i.islower():
  else:
    C3+=1
if C1 and C2==1 and C3==0:
  print('AC')
else:
  print('WA')

Buggy submission (verdict: Runtime Error):
S=input()
C1=(S[0]=='A')
C2=0
for i in range(2:len(S)):
  if S[i]=='C' and i in range(2:len(S)-1):
    C2+=1
  else:
    C1=C1 and S[i].islower()
if C1 and C2==1:
  print('AC')
else:
  print('WA')
Problem p03292 (python)

Fixed submission:
a = list(map(int,input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
a = list(map(int,input()))
print(max(a)-min(a))
Problem p03324 (python)

Fixed submission:
D,N = map(int,input().split())
k = 100**D
m = 100**(D+1)
cnt = 0
for i in range(1,200):
  if (i*k)%m != 0:
    cnt +=1
    if cnt ==N:
      print(i*k)
      break

Buggy submission (verdict: Runtime Error):
D,N = map(int,input().split())
k = 100**D
m = 100**(D+1)
cnt = 0
for i in range(1,200):
  if (i*k)%m != 0:
    cnt +=1
    if cnt =N:
      print(i*k)
      break
Problem p03328 (python)

Fixed submission:
a,b=map(int,input().split())
i=b-a
print(i*(i+1)//2-b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
i=b-a
print(i*(i+1)//2-b)
Problem p03337 (python)

Fixed submission:
a,b =map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b =map(int,input().split())
print(max(a+b,a-b,a*b)
Problem p03338 (python)

Fixed submission:
N = int(input())
S = list(input())
print(max([len(set(S[:i]) & set(S[i:])) for i in range(1,N)]))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
print(max([len(set(S[:i]) & set(S[i:])) for
Problem p03352 (python)

Fixed submission:
X = int(input())
if X != 1:
  A =[]
  for b in range(1,int(X**0.5)+1):
    for p in range(2,X):
      if b**p > X:
        A.append(b**(p-1))
        break
  print(max(A))
else:
  print(1)

Buggy submission (verdict: Runtime Error):
X = int(input())
A =[]
for b in range(1,int(X**0.5)+1):
  for p in range(2,X):
    if b**p > X:
      A.append(b**(p-1))
      break
print(max(A))

Buggy submission (verdict: Runtime Error):
a=int(input())
import math
b=int(math.log(a, 2)
c=1
if b!=1:
  for i in range(2,b+1,1):
    c=max(c,int(a**(1/i))**i)
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
import math
b=int(math.sqrt(a))
c=1
for i in range(b):
  c=max(c,int(a**(1/i))**i)
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
import math
b=int(math.sqrt(a))
c=1
for i in range(b):
  c=max(c,(int(a**(1/i)))**i)
print(c)