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

Fixed submission:
I,O,T,J,L,S,Z = map(int,input().split())
print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0)*(L>0)*(J>0),(I//2+J//2+L//2)*2+O))

Buggy submission (verdict: Runtime Error):
I,O,T,J,L,S,Z = map(int,input().split())
print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0*❨L>0❩*❨J>0❩,(I//2+J//2+L//2)*2+O))

Buggy submission (verdict: Runtime Error):
I,O,T,J,L,S,Z = map(int,input().split())
if I==1 and J==1 and L==1:                                                     
    print(3) 
elif ((I-1)//2+(J-1)//2+(L-1)//2)*2+O==0 and (I//2+J//2+L//2)*2+O)==0):
    print(0)
else:
    print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))

Buggy submission (verdict: Runtime Error):
I,O,T,J,L,S,Z = map(int,input().split())
if I==1 and J==1 and L==1:                                                     
    print(3) 
elif ((I-1)//2+(J-1)//2+(L-1)//2)*2+O==0 and (I//2+J//2+L//2)*2+O)==0:
    print(0)
else:
    print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))

Buggy submission (verdict: Runtime Error):
I,O,T,J,L,S,Z = map(int,input().split())
if (I<2 and O=0 and J<2 and L<2) and (I != 1 or J != 1 or L!= 1):
    print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))
else:
    print(0)
Problem p03919 (python)

Fixed submission:
H,W = map(int,input().split())
S = [[i for i in input().split()] for _ in range(H)]

for h in range(H):                  
    for w in range(W):                      
        if S[h][w] == "snuke":              
            break
    else:
        continue 
    break
    
print(chr(ord("A")+w) + str(h+1))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = [[i for i in input().split()] for_ in range(H)]

for h in range(H):
  for w in range(W):
    if S[h][w] == "snuke":
      break
print(chr(ord(A)-1+w) + str(h))
Problem p03947 (python)

Fixed submission:
S = input()
print(sum([a!=b for a,b in zip(S[:-1],S[1:])]))

Buggy submission (verdict: Runtime Error):
S = input()
print(sum([a!=b for a,b in zip(S[:-1],S[1:])])
Problem p03959 (python)

Fixed submission:
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
T_min = [1]*N
T_min[0] = T[0]
for i in range(1,N):
  if T[i-1]<T[i]:
    T_min[i] = T[i]
A_min = [1]*N
A_min[N-1] = A[N-1]
for i in range(N-2,-1,-1):
  if A[i+1]<A[i]:
    A_min[i] = A[i]
M = [0]*N
M_min = [0]*N
for i in range(N):
  M[i] = min(T[i],A[i])
  M_min[i] = max(T_min[i],A_min[i])
ans = 1
mod = 10**9+7
for i in range(N):
  if M[i]<M_min[i]:
    ans = 0
  else:
    ans*=M[i]+1-M_min[i]
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
T_min = [0]*N
T_min[0] = T[0]
for i in range(1,N):
  if T[i-1]<T[i]:
    T_min[i] = T[i]
A_min = [0]*N
A_min[N-1] = A[N-1]
for i in range(N-2,-1,-1):
  if A[i+1]<A[i]:
    A_min[i] = A[i]
M = [0]*N
M_min = [0]*N
for i in range(N):
  M = min(T[i],A[i])
  M_min = max(T_min[i],A_min[i])
ans = 1
mod = 10**9+7
for i in range(N):
  if M[i]<M_min[i]:
    ans = 0
  else:
    ans*=M[i]+1-M_min[i]
    ans%=mod
print(ans)
Problem p03967 (python)

Fixed submission:
S = input()
ans = 0
for i in range(len(S)):
  if i%2 == 0 and S[i] == "p":
    ans -= 1
  elif i%2 == 1 and S[i] == "g":
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
for i in range(S):
  if i%2 == 0 and S[i] == "g":
    ans += 1
  elif i%2 == 1 and S[i] == "p":
    ans -= 1
print(ans)
Problem p03971 (python)

Fixed submission:
N,A,B = map(int,input().split())
S = input()

win = 0  
abr = 0 
for c in S:
    if c == "a":
        if win<A+B:
            print("Yes") 
            win += 1
        else:
            print("No")
    elif c == "b":
        if win < A+B and abr < B: 
            print("Yes")
            win += 1
            abr += 1
        else:
            print("No")
    else:   
        print("No")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
S = input()

win = 0  
abr = 0 
for c in S:
    if c == a:
        if win<A+B:
            print("Yes") 
            win += 1
        else:
            print("No")
    elif c == b:
        if win < A+B and abr <= B:
            print("Yes")
            win += 1
            abr += 1
        else:
            print("No")
    else:   
        print("No")
Problem p03993 (python)

Fixed submission:
N = int(input())
A = [int(i)-1 for i in input().split()]

ans = 0
for i in range(N):
  if A[A[i]]==i: 
    ans += 1
print(ans//2)

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

ans = 0
for i in range(N):
  if A[i] == i+1:
    ans += 1
print(ans)
Problem p04000 (python)

Fixed submission:
H,W,N = map(int,input().split())
dic={}
for _ in range(N):
  a,b = [int(x)-1 for x in input().split()]
  for h in range(a,a+3):
    for w in range(b,b+3):
      if 0<=h-2 and h<H and 0<=w-2 and w<W:
        dic[10**10*h+w] = dic.get(10**10*h+w,0)+1
ans = [0]*10
for x in dic.values():
  ans[x] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])
for x in ans:
  print(x)

Buggy submission (verdict: Runtime Error):
H,W,N = map(int,input().split())
dic={}
for _ in range(N):
  a,b = [int(x)-1 for x in input().split()]
  for h in range(a-2,a+3):
    for w in range(b-2,b+3):
      if 0<=h<H and 0<=w<W:
        dic[10**10*h+w] = dic.get(10**10*h+w,0)+1
ans = [0]*10
for x in dic.values():
  ans[x] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])
for x in ans:
  print(x)
Problem p04033 (python)

Fixed submission:
a,b = map(int,input().split())               

if a<=0 and 0<=b:
    print("Zero")
elif 0<a:
    print("Positive")
elif (b-a+1)%2:
    print("Negative")
else:
    print("Positive")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())                    

if a<=0 and 0<=b:
    print("Zero")
elif 0<a:
    print("Positive")
elif (b-a+1)%2:
    print("Negative")
else:
    print("Positive")
Problem p02600 (python)

Fixed submission:
n = int(input())

print(10-n//200)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
    if a >= b:
        b = b*2
    else:
        c = c*2


if a < b and b < c:
    print("Yes")
else:
    print("No")
Problem p02630 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
q = int(input())
l = [0]*(10**5+10)
num = sum(A)
for i in A:
    l[i] = l[i] + 1


for i in range(q):
    b, c = map(int, input().split())
    num += (c-b)*l[b]
    l[c] += l[b]
    l[b] = 0
    print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
q = int(input())
l = [0]*10**5
num = sum(A)
for i in A:
    l[i] = l[i] + 1


for i in range(q):
    b, c = map(int, input().split())
    num += (c-b)*l[b]
    l[c] += l[b]
    l[b] = 0
    print(num)
Problem p02632 (python)

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

n = len(s)
mod = 10**9+7


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 = framod(n, mod)
    b = framod(k, mod)
    c = framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


com = [1]*(k+1)
for i in range(k):
    com[i+1] = com[i]*(n+i)*pow(i+1, mod-2, mod) % mod

a25 = [1]*(k+1)
for i in range(k):
    a25[i+1] = a25[i]*25 % mod
a26 = [1]*(k+1)
for i in range(k):
    a26[i+1] = a26[i]*26 % mod
num = 0
for i in range(0, k+1):
    num = (num+com[i]*a25[i] % mod * a26[k-i]) % mod
print(num)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = input()

n = len(s)
mod = 10**9+7


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 = framod(n, mod)
    b = framod(k, mod)
    c = framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


com = [1]*k
for i in range(k+1):
    comb[i+1] = comb

a25 = [1]*(k+1)
for i in range(k):
    a25[i+1] = a25[i]*25 % mod
a26 = [1]*(k+1)
for i in range(k):
    a26[i+1] = a26[i]*26 % mod
num = 0
for i in range(0, k+1):
    num = (num+comb(i+n-1, n-1, mod)*a25[i] % mod * a26[k-i]) % mod
print(num)
Problem p02641 (python)

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

if n == 0:
    print(x)
    exit()
P = list(map(int, input().split()))

for s in range(-101, 110):
    if s not in P:
        ans = s
        break

for s in range(-101, 110):
    if s not in P:
        if abs(ans-x) > abs(s-x):
            ans = s
        elif abs(ans-x) == abs(s-x):
            ans = min(ans, s)

print(ans)

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

if n == 0:
    print(x)
    exit()
P = list(map(int, input().split()))

for s in range(1, 101):
    if s not in P:
        ans = s
        break

for s in range(1, 101):
    if s not in P:
        if abs(ans-x) > abs(s-x):
            ans = s
        elif abs(ans-x) == abs(s-x):
            ans = min(ans, s)

print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
nux = max(A)
B = set(A)
A.sort()
ans = 0
table = [True]*(nux+1)
for ii, s in enumerate(A):
    if table[s] == False:
        continue
    if ii == n-1:
        ans += 1
    elif A[ii+1] != s:
        ans += 1
    i = 1
    while i*s <= nux:
        table[i*s] = False
        i += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = sorted(map(int, input().split()))
nux = A[-1]+1
ans = 0
table = [True]*nux
for i, s in enumerate(A):
    if table[s] == False:
        continue
    if i == n-1:
        ans += 1
    elif A[i+1] != s:
        ans += 1
    b = 1
    while b*s <= nux:
        table[b*s] = False
        b += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = sorted(map(int, input().split()))
nux = A[-1]+1
ans = 0
table = [True]*nux
for i, s in enumerate(A):
    if table[s] == False:
        continue
    if i == n-1:
        ans += 1
    if A[i+1] != s:
        ans += 1
    b = 1
    while b*s <= nux:
        table[b*s] = False
        b += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
nux = max(A)
B = set(A)
A.sort()
ans = 0
table = [True]*(nux+1)
for ii, s in enumerate(A):
    if table[s] == False:
        continue
    if A[ii+1] != s:
        ans += 1
    i = 1
    while i*s <= nux:
        table[i*s] = False
        i += 1

print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
print(a*b)
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = sum(p[0:k])
l = [a]
for i in range(n-k):
    a = a-p[i]+p[i+k]
    l.append(a)
print((max(l)+k)/2)

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

p = [sum(p[0+i:k+i]) for i in range(n-k+1)]
l = []
a = sum(p[0:k])
for i in range(n-k+1):
    a = a+p[i]-p[i+k-1]
    l.append(a)
print((max(l)+k)/2)
Problem p03165 (python)

Fixed submission:
a = input()
b = input()
na = len(a)
nb = len(b)

dp = [[0]*(nb+1) for _ in range(na+1)]

for i in range(na):
    for j in range(nb):
        if a[i] == b[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
ans = []
num = dp[na][nb]
x = na
y = nb
while num:
    if dp[x][y] == dp[x-1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y-1]:
        y -= 1
    else:
        ans.append(a[x-1])
        x -= 1
        y -= 1
        num -= 1

print("".join(ans[::-1]))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
aa = [s for s in a]
bb = [s for s in b]
na = len(a)
nb = len(b)

dp = [[0]*(nb) for _ in range(na)]
k = 0
for i in range(na):
    if a[i] == b[0]:
        k = 1
    dp[i][0] = k
k = 0
for i in range(nb):
    if b[i] == a[0]:
        k = 1
    dp[0][i] = k

for i in range(1, na):
    for j in range(1, nb):
        if a[i] == b[j]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
x = na-1
y = nb-1
while x != 0 or y != 0:
    if x-1 == 0 and dp[x][y] == dp[x-1][y]+1:
        ans.append(a[x])
        x = x-1
    elif y-1 == 0 and dp[x][y] == dp[x][y-1]+1:
        ans.append(b[y])
        y = y-1
    elif x-1 > 0 and dp[x][y] == dp[x-1][y]:
        x = x-1
    elif y-1 > 0 and dp[x][y] == dp[x][y-1]:
        y = y-1
    else:
        ans.append(a[x])
        x = x-1
        y = y-1

print("".join(ans[::-1]))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
aa = [s for s in a]
bb = [s for s in b]
na = len(a)
nb = len(b)

dp = [[0]*(na+1) for _ in range(nb+1)]
k = 0
for i in range(na):
    if a[i] == b[0]:
        k = 1
    dp[i][0] = k
k = 0
for i in range(nb):
    if b[i] == a[0]:
        k = 1
    dp[0][i] = k

for i in range(1, na):
    for j in range(1, nb):
        if a[i] == b[j]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
x = na-1
y = nb-1
while x != 0 and y != 0:
    if x-1 >= 0 and dp[x][y] == dp[x-1][y]:
        x = x-1
    elif y-1 >= 0 and dp[x][y] == dp[x][y-1]:
        y = y-1
    else:
        ans.append(a[x])
        x = x-1
        y = y-1
if a[0] == b[0]:
    ans.append(a[0])

print("".join(ans[::-1]))
Problem p02601 (python)

Fixed submission:
import sys
 
A , B , C = map(int,input().split())
K = int(input())
 
for i in range(K):
    if B <= A :
        B *= 2
    else:
        C *= 2
    if B > A :
        if C > B:
            print("Yes")
            sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
A , B , C = map(int,input().split())
K = int(input())

for i in range(K):

    if B >= A :
        B *= 2
    else:
        C *= 2
    if B > A 
        if C > B:
            print("Yes")
            break
print("No")
Problem p02613 (python)

Fixed submission:
N=int(input())

AC=0
WA=0
TLE=0
RE=0


for i in range(N):
	word = input()
	if word =="AC":
		AC+=1
	if word =="WA":
		WA+=1
	if word =="TLE":
		TLE+=1
	if word =="RE":
		RE+=1
print("AC x " +str(AC))
print("WA x " +str(WA))
print("TLE x " +str(TLE))
print("RE x " +str(RE))

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

for i in range(N):
	word = input()
    if word =="AC":
      AC+=1
    if word =="WA":
      WA+=1
    if word =="TLE":
      TLE+=1
    if word =="RE":
      RE+=1

print("AC x " +AC)
print("WA x " +WA)
print("TLE x " +TLE)
print("RE x " +RE)
Problem p02639 (python)

Fixed submission:
x = list(map(int,input().split()))
i = 0
for i in range(len(x)):
    if x[i] == 0:
        print (i+1)
        break

Buggy submission (verdict: Runtime Error):
X,Y = list(map(int,input().split()))
if Y <= (4 * X) and (Y / 2 == 0):
    print("Yes")
else:
    print("No")
Problem p02641 (python)

Fixed submission:
import sys



def check_number(p,numbers):
  for plis in p:
    if plis == numbers:
      return 1
  return 0


X,N = map(int,input().split())
p = list(map(int,input().split()))

if N == 0:
  print( X )
  sys.exit()


after_ans = X
i = 100


for i in range(X,X+100,1):#前半
  if check_number(p,i) == 0:
    after_ans = i
    after_abs = abs(X-i)
    break

for i in range(X,X-100,-1):#後半
  if check_number(p,i) == 0:
    before_ans = i
    before_abs = abs(X-i)
    break

if abs(after_abs) == abs(before_abs):
  answer = before_ans
elif abs(after_abs) > abs(before_abs):
  answer = before_ans
else:
  answer = after_ans

print( answer )

Buggy submission (verdict: Runtime Error):
import sys



def check_number(p,numbers):
  for plis in p:
    if plis == numbers:
      return 1
  return 0


X,N = map(int,input().split())
p = list(map(int,input().split()))

if N == 0:
  print( X )
  sys.exit()


after_ans = X
i = 100


for i in range(X+1,101,1):#前半
  if check_number(p,i) == 0:
    after_ans = i
    after_abs = abs(X-i)
    break

for i in range(X-1,-1,-1):#後半
  if check_number(p,i) == 0:
    before_ans = i
    before_abs = abs(X-i)
    break

if abs(after_abs) == abs(before_abs):
  answer = before_ans
elif abs(after_abs) > abs(before_abs):
  answer = before_ans
else:
  answer = after_ans

print( answer )

Buggy submission (verdict: Runtime Error):
import sys



def check_number(p,numbers):
  for plis in p:
    if plis == numbers:
      return 1
  return 0


X,N = map(int,input().split())
p = list(map(int,input().split()))

if N == 0:
  print( X )
  sys.exit()


after_ans = X
i = 100


for i in range(X+1,100,1):#前半
  if check_number(p,i) == 0:
    after_ans = i
    after_abs = abs(X-i)
    break

for i in range(X-1,0,-1):#後半
  if check_number(p,i) == 0:
    before_ans = i
    before_abs = abs(X-i)
    break

if abs(after_abs) == abs(before_abs):
  answer = before_ans
elif abs(after_abs) > abs(before_abs):
  answer = before_ans
else:
  answer = after_ans

print( answer )
Problem p02658 (python)

Fixed submission:
import sys  # sys.exit()を使いたいので

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

A.sort()
ans=1
for i in A:
    ans *= i
    if ans > (10 ** 18):
        print('-1')
        sys.exit()
print(ans)

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

A.sort()
ans=1
for i in A:
    ans *= i
    if(ans > (10 ** 18)):
        print(-1)
        sys.exit()
print(ans)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a = input()
if int(a[0]) * int(a[1]) % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if int(a) * int(b) % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem p02554 (python)

Fixed submission:
N = int(input())
ans = 10**N - 9**N*2 + 8**N
print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math


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


N = int(input())
ans = combinations_count(N, 2) * 10 ** (N-2) * 2 % (10**9 + 7)
print(ans)
Problem p02612 (python)

Fixed submission:
N=int(input())%1000

if N==0:
  print(0)
else:
  print(1000-N)

Buggy submission (verdict: Runtime Error):
print(int(input()[1:]))
Problem p02614 (python)

Fixed submission:
import itertools
import numpy as np
import copy

N,W,K = map(int,input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i,g):
  if (i<N):
    g[i,:] = ['r']*W
  else:
    g[:,i-N] = ['r']*N
  return g

g = g_all

for l in range(N+W+1):
  combi = itertools.combinations([i for i in range(N+W)],l)
  for com in combi:
    g = g_all.copy()
    for i in com:
      if (i<N):
        g[i,:] = ['r']*W
      else:
        g[:,i-N] = ['r']*N
    if np.count_nonzero(g == '#') ==K:
      count+=1
print(count)

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

N, W, K = map(int, input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i, g):
  if (i < N):
    g[i, :] = ['r'] * W
    else:
      g[:, i - N] = ['r'] * N
      return g

    g = g_all

    for L in range(2 ** (N + W)):
      g = g_all.copy()
      for i in range(N + W):
        if (i < N):
          if ((L >> i) & 1):
            g[i, :] = ['r'] * W
            else:
              if ((L >> i) & 1):
                g[:, i - N] = ['r'] * N
                if np.count_nonzero(g == '#') == K:
                  count += 1
                  print(count)

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

N,W,K = map(int,input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i,g):
  if (i<N):
    g[i,:] = ['r']*W
  else:
    g[:,i-N] = ['r']*N
  return g

g = g_all

for L in range(2**(N+W)): #2^n通り
  g = g_all.copy()
  for i in range(N+W):　#bit列分
    if (i<N):
      if ((L>>i)&1):
        g[i,:] = ['r']*W
    else:
      if ((L>>i)&1):
        g[:,i-N] = ['r']*N
  if np.count_nonzero(g == '#') ==K:
    count+=1
print(count)
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))

for i in range(5):
  if (x[i]==0):
    print(i+1)

Buggy submission (verdict: Runtime Error):
X,Y = map(int, input().split())
for f4 in range(0,X+1,1):
  if Y==(f4*4)+((X-f4)*2):
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
X,Y = map(int, input().split())
for f4 in range(0,X+1,1):
  if Y==(f4*4)+((X-f4)*2):
    print('Yes')
Problem p02709 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
table = []
 
for i, a in enumerate(A):
    table.append([a,i])
table.sort()
 
# DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ
DP = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
    # i 人目 table[i-1] の幼児を移動させる
    baby, pos = table.pop()
    
    DP[i][0] = DP[i-1][0] + baby * abs(pos-i+1)
    DP[0][i] = DP[0][i-1] + baby * abs(pos-(N-i))
    for x in range(1,i):
        y = i - x
 
        #左端に置く場合と右端に置く場合でmax
        DP[x][y] = max(DP[x-1][y] + baby * abs(pos-x+1),\
                     DP[x][y-1] + baby * abs(pos-(N-y)))
 
ans = 0
for i in range(N+1):
    ans = max(ans, DP[i][N-i])
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
A_list = map(int, input().split())
 
# [活発度, もとの番号] のリストを降順に並べる
A_list = [[A, index] for index, A in enumerate(A_list)]
A_list.sort(reverse=True)
 
# print(A_list)
 
dp = np.zeros((N+2, N+2), int)
# print(dp)
for left in range(0, N):
    for right in range(0, N - left):
        # print(f'left, righte: { left, right }')
        # print(A_list[left + right - 1][0])
        activity = A_list[left + right][0]
        distance_from_left = A_list[left + right][1] - left
        # print(f'distance_from_left: { distance_from_left }')
        distance_from_right = (N - 1 - right) - A_list[left + right][1]
        # print(f'distance_from_right: { distance_from_right }')
        dp[left + 1][right]\
            = max(dp[left + 1][right],
                  dp[left][right] + activity * distance_from_left)
        dp[left][right + 1]\
            = max(dp[left][right + 1],
                  dp[left][right] + activity * distance_from_right)
        # print('dp---')
        # print(dp)
        # print('---dp')
# print(dp)
print(np.max(dp))
Problem p02731 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
s = 0

for i in range(n):
    b[a[i]-1] += 1

for i in range(n):
    s += (b[i]*(b[i]-1))//2

for i in range(n):
    print(s-b[a[i]-1]+1)

Buggy submission (verdict: Runtime Error):
n = input()
print(n*n*n/27)