Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

N = int(input())
S = input()


ans = S.count('R') * S.count('G') * S.count('B')
for i,j in permutations(range(N), 2):
  if (i+j)%2 or i>=j: continue
  a = S[i]
  b = S[j]
  k = (i+j)//2
  if sorted([a,S[k],b]) == ['B','G','R']:
    ans -= 1
      
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  a = S[i]
  for j in range(i+1,N):
    b = S[j]
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if sorted([a,S[k],b]) == ['B','G','R']:
      ans -= 1
      
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

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

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  a = S[i]
  for j in range(i+1,N):
    b = S[j]
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if [a,S[k],b].sort() == ['B','G','R']
      ans -= 1
      
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  a = S[i]
  for j in range(i+1,N):
    b = S[j]
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([a,S[k],b])) == 3:
      ans -= 1
      
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
s1 = S[:(N-1)//2]
s2 = S[(N+3)//2-1:]

if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
N = len(S)
s1 = S[:(N-1)//2]
s2 = S[(N+3)//2-1:]

if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = str(N)
n = 0
for i in s:
  n += int(i)
  
if N%n==0:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
N = len(S)
s1 = S[:(N-1)//2]
s2 = S[(N+3)//2-1:]

if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

def standard_string(N, st):
  if st = "":
    standard_string(N, "a")
  if len(st) == N:
    print(st)
    return 
  for i in range(97, ord(st[-1])+ 1):
    st += char(i)
    standard_string(N, st)
    st = st[:-1]
standard_string(N, "")

Fixed submission:
N = int(input())

def standard_string(N, st):
    if len(st) == N:
        print(st)
    elif st == "":
        standard_string(N, "a")
    else:
        for i in range(97, ord(max(st))+ 2):
            st += chr(i)
            standard_string(N, st)
            st = st[:-1]
standard_string(N, "")
Buggy python submission (verdict: Runtime Error):
cuts = []
for i in range(2000):
  cuts+= [[int(i*0.08), int(i*0.10)]]
  
A, B = map(int,input().split())

for i in range(1,2000):
  if [A, B] == cuts[i]:
    print(i)
    break
else:
  print(0)

Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R - 100 * (10−N)) 

Fixed submission:
N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R + 100 * (10 - N))
Buggy python submission (verdict: Runtime Error):
N= int(input())
X = list(map(int, input().split()))
mean = X.sum()/N
ans = 0 
for i in range(N):
  ans += (X[i] - mean)**2
  
print(ans)




Fixed submission:
N= int(input())
X = list(map(int, input().split()))
mean = round(sum(X)/N)
ans = 0 
for i in range(N):
  ans += (X[i] - mean)**2
  
print(ans)

Buggy python submission (verdict: Runtime Error):
N= int(input())
X = list(map(int, input().split()))
mean = X.sum()/N
ans = 0 
for i in range(N):
  ans += (X[i] - mean)**2
  
print(ans)




Fixed submission:
N= int(input())
X = list(map(int, input().split()))
mean = round(sum(X)/N)
ans = 0 
for i in range(N):
  ans += (X[i] - mean)**2
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def solve_dp(s):
    n = len(s)
    s = [int(c) for c in s]
    inf = 10**9

    dp = [[inf] * 2 for _ in range(n)]

    d0 = s[0]
    dp[0][0] = d0
    dp[0][1] = d0+1

    for i in range(1, n):
        d = s[i]
        for k in range(10):
            if d + k >= 10:
                dp[i][0] = min(dp[i][0], dp[i-1][1] + 2*k + d - 10)
            else:
                dp[i][0] = min(dp[i][0], dp[i-1][0] + 2*k + d)
        d += 1
        for k in range(10):
            if d + k >= 10:
                dp[i][1] = min(dp[i][1], dp[i-1][1] + 2*k + d - 10)
            else:
                dp[i][1] = min(dp[i][1], dp[i-1][0] + 2*k + d)

    return dp[n-1][0]

if __name__ == '__main__':
    s = input()
    s = "0"+ s
    print(solve_dp(s))

Fixed submission:
Z = [0,1,2,3,4,5,6,7,8,9,10]
C = [0,1,2,3,4,5,6,7,8,9]
X = [0,1,2,3,4,5,6,7,8,9]

def solve_dp(s):
    n = len(s)
    s = [int(c) for c in s]
    inf = 10**9

    dp = [[inf] * 2 for _ in range(n)]

    d0 = s[0]
    dp[0][0] = Z[d0]
    dp[0][1] = Z[d0+1]

    for i in range(1, n):
        for j in range(2):
            d = s[i] + j
            for k in range(10):
                if d + C[k] >= 10:
                    dp[i][j] = min(dp[i][j], dp[i-1][1] + X[k] + Z[d + C[k] - 10])
                else:
                    dp[i][j] = min(dp[i][j], dp[i-1][0] + X[k] + Z[d + C[k]])

    return dp[n-1][0]

if __name__ == '__main__':
    s = input()
    s = "0"+ s
    print(solve_dp(s))

Buggy python submission (verdict: Time Limit Exceeded):
Z = [0,1,2,3,4,5,6,7,8,9,10]
C = [0,1,2,3,4,5,6,7,8,9]
X = [0,1,2,3,4,5,6,7,8,9]

def solve_dp(s):
    n = len(s)
    s = [int(c) for c in s]
    inf = 10**9

    dp = [[inf] * 2 for _ in range(n)]

    d0 = s[0]
    dp[0][0] = Z[d0]
    dp[0][1] = Z[d0+1]

    for i in range(1, n):
        for j in range(2):
            d = s[i] + j
            for k in range(10):
                if d + C[k] >= 10:
                    dp[i][j] = min(dp[i][j], dp[i-1][1] + X[k] + Z[d + C[k] - 10])
                else:
                    dp[i][j] = min(dp[i][j], dp[i-1][0] + X[k] + Z[d + C[k]])

    return dp[n-1][0]

if __name__ == '__main__':
    s = input()
    s = "0"+ s
    print(solve_dp(s))

Fixed submission:
Z = [0,1,2,3,4,5,6,7,8,9,10]
C = [0,1,2,3,4,5,6,7,8,9]
X = [0,1,2,3,4,5,6,7,8,9]

def solve_dp(s):
    n = len(s)
    s = [int(c) for c in s]
    inf = 10**9

    dp = [[inf] * 2 for _ in range(n)]

    d0 = s[0]
    dp[0][0] = Z[d0]
    dp[0][1] = Z[d0+1]

    for i in range(1, n):
        for j in range(2):
            d = s[i] + j
            for k in range(10):
                if d + C[k] >= 10:
                    dp[i][j] = min(dp[i][j], dp[i-1][1] + X[k] + Z[d + C[k] - 10])
                else:
                    dp[i][j] = min(dp[i][j], dp[i-1][0] + X[k] + Z[d + C[k]])

    return dp[n-1][0]

if __name__ == '__main__':
    s = input()
    s = "0"+ s
    print(solve_dp(s))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
L = len(str(N))

suu = []
for i in range(L):
    suu.append(int(str(N)[i]))

DP_1 =[[0 for k in range(L+1)] for i in range(L+1)]
DP_2 =[[0 for k in range(L+1)] for i in range(L+1)]
DP_2[0][0] = 1
for i in range(L):
    for k in range(L+1):
        DP_1[i+1][k] = DP_1[i][k] + DP_1[i][k-1] * 9 
        if suu[i]:
            DP_1[i+1][k] += DP_2[i][k] + DP_2[i][k-1] * max(suu[i] - 1, 0)
            DP_2[i+1][k] = DP_2[i][k-1]
        else:
            DP_2[i+1][k] = DP_2[i][k]
print(DP_1[L][K]+ DP_2[L][K])

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

dic = {S: A, T: B}
U = input()
dic[U] = dic[U]-1
print(dic[S], dic[T])
Buggy python submission (verdict: Runtime Error):
N, K, S =  map(int, input().split())

if S = 10**9:
    print(' '.join(map(str, ([S]*K + [1]*(N-K)))))
else:
    print(' '.join(map(str, ([S]*K + [S+1]*(N-K)))))

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

if S == 10**9:
    print(' '.join(map(str, ([S]*K + [1]*(N-K)))))
else:
    print(' '.join(map(str, ([S]*K + [S+1]*(N-K)))))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = 0
Q = [0] * N
wrong = [0] * N
for i in (M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
ans1 = 0
ans2 = 0
Q = [0] * N
wrong = [0] * N
for i in range(M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans1 += 1
    ans2 += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans1,ans2)
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input().split())
if K*500 => X:
  print("Yes")
else:
  print("No")

Fixed submission:
K, X = map(int, input().split())
if K*500 >= X:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
def check_prime(m):
  prime_flag = 1
  counter = 1
  while counter **2 <= m:
    if not m%counter:
      prime_flag = 0
      break
  return prima_flag


n = int(input())

for i in range(n, 10**6):
  if check_prime(i):
    print(i)
    break

Fixed submission:
def check_prime(m):
  prime_flag = 1
  counter = 2
  while counter **2 <= m:
    if not m%counter:
      prime_flag = 0
      break
    counter += 1
  return prime_flag


n = int(input())

for i in range(n, 10**6):
  if check_prime(i):
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
a,b= map(int,input().split())
ans=[1,2,3]
ans.remove(a)
ans.remove(b)
print(ans[0])

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

ans=[1,2,3]
ans.remove(a)
ans.remove(b)
print(ans[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
st = input()
ans_st = ""

for i in range(N):
  ch_ord = ord(st[i])
  if ch_ord + N > 122:
    ans_st += chr(ch_ord + N - 26)
  else:
    ans_st += chr(ch_ord + N)
print(ans_st)

Fixed submission:
N = int(input())
st = input()
ans_st = ""

for i in range(len(st)):
  ch_ord = ord(st[i])
  if ch_ord + N > 90:
    ans_st += chr(ch_ord + N - 26)
  else:
    ans_st += chr(ch_ord + N)
print(ans_st)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map, input().split())
li = []
for i, a in enumerate(A):
  li += [[a,i]]

li.sort()
for i in range(N):
  print(li[1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
li = []
for i, a in enumerate(A):
  li += [[a,i]]
  
li.sort()

for i in range(N):
  print(li[i][1]+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))
        
S.sort(reverse = 1)
father = S[0]
if S[2**(N-1)+1] >= father - 1:
  print("No")
else:
  print("Yes")

Fixed submission:
import collections, sys

N = int(input())
S = list(map(int, input().split()))
if N ==1 :
  if S[0] == S[1]:
    print("No")
  else:
    print("Yes")
  sys.exit()
  
K = collections.Counter(S)
score_sorted = sorted(K.items(), key=lambda x:x[0], reverse = True)

if score_sorted[0][1] > 1:
  print("No")
  sys.exit()
  

DP = [[0 for i in range(len(K))] for j in range(N+1)]
DP[0][0] = 1
for i in range(N):#日数
  nokoshi = 0
  for k in range(len(K)):
    if k == 0:
      DP[i+1][k] = DP[i][k]
    else:
      hairu = score_sorted[k][1] - DP[i][k]
      ireru = min(hairu, DP[i][k-1] + nokoshi)
      
      DP[i+1][k] = DP[i][k] + ireru
      nokoshi = DP[i][k-1] + nokoshi - ireru
  if nokoshi > 0:
    print("No")
    break
else:
  for i in range(len(score_sorted)):
    if DP[N][i] != score_sorted[i][1]:
      print("No")
      break
  else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
xy = []
for i in range(N):
  x, y = map(int, input().split())
  xy += [(x, y, math.atan2(y,x))]
xy.sort(key=lambda val:val[2])
x_accum = [0]
y_accum = [0]
for i in range(N):
  x_accum += [x_accum[-1] + xy[i][0]]
  y_accum += [y_accum[-1] + xy[i][1]]
  
ans = 0
for i in range(N):
  for j in range(N):
    ans = max(ans,  math.hypot(x_accum[j]-x_accum[i] ,y_accum[j]-y_accum[i]))
print(ans)

Fixed submission:
S = input()
T = input()
ans = 0
for i in range(3):
  if S[i] == T[i]:
    ans+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]

def can_match(i, A, next_set):
  if not A[i]:
    return
  if A[A[i][-1]][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))
      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set, next_set = next_set, set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
    
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)

Fixed submission:

N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]


def can_match(i, A, next_set):
  if not A[i]:
    return
  j = A[i][-1]
  if A[j][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))

      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set = next_set.copy()
  next_set = set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
X = []
Y = []
for i in range(N):
  x, y = map(int, input().split())
  X += [x]
  Y += [y]
  
ans = 0
for i in range(1<<N):
  curr_x = 0
  curr_y = 0
  for j in range(N):
    if (1<<j)&i:
      curr_x += X[j]
      curr_y += Y[j]
  ans = max(ans, curr_x**2+curr_y**2)
  
print(math.sqrt(ans))

Fixed submission:
import math
N = int(input())
xy = []
for i in range(N):
  x, y = map(int, input().split())
  xy += [(x, y, math.atan2(y,x))]
xy.sort(key=lambda val:val[2])
x_accum = [0]
y_accum = [0]
for i in range(N):
  x_accum += [x_accum[-1] + xy[i][0]]
  y_accum += [y_accum[-1] + xy[i][1]]
  
ans = 0
for i in range(N+1):
  for j in range(i,N+1):
    ans = max(ans,  math.hypot(x_accum[j]-x_accum[i] ,y_accum[j]-y_accum[i]))
    ans = max(ans,  math.hypot(x_accum[-1] -x_accum[j]+x_accum[i] ,y_accum[-1]-y_accum[j]+y_accum[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
X = []
Y = []
for i in range(N):
  x, y = map(int, input().split())
  X += [x]
  Y += [y]
  
ans = 0
for i in range(1<<N):
  curr_x = 0
  curr_y = 0
  for j in range(N):
    if (1<<j)&i:
      curr_x += X[j]
      curr_y += Y[j]
  ans = max(ans, curr_x**2+curr_y**2)
  
print(math.sqrt(ans))

Fixed submission:
import math
N = int(input())
xy = []
for i in range(N):
  x, y = map(int, input().split())
  xy += [(x, y, math.atan2(y,x))]
xy.sort(key=lambda val:val[2])
x_accum = [0]
y_accum = [0]
for i in range(N):
  x_accum += [x_accum[-1] + xy[i][0]]
  y_accum += [y_accum[-1] + xy[i][1]]
  
ans = 0
for i in range(N+1):
  for j in range(i,N+1):
    ans = max(ans,  math.hypot(x_accum[j]-x_accum[i] ,y_accum[j]-y_accum[i]))
    ans = max(ans,  math.hypot(x_accum[-1] -x_accum[j]+x_accum[i] ,y_accum[-1]-y_accum[j]+y_accum[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
s = input()
t = input()
table = [[len(s) for i in range(len(s))] for j in range(26)]

for i in range(len(s)):
  table[ord(s[i])-97][i] = 0
for i in range(26):
  for j in range(len(s)):
    table[i][len(s)-j-2] = min(table[i][len(s)-j-1] +1, table[i][len(s)-j-2])
  for j in range(len(s)):
    table[i][len(s)-j-2] = min(table[i][len(s)-j-1] +1, table[i][len(s)-j-2])

for letter in t:
  if s.find(letter) == -1:
    print(-1)
    sys.exit()
    
place = 0
ans = 0
for i in range(len(t)):
  letter = t[i]
  move = table[ord(t[i])-97][place]
  ans += move + 1
  place = (place + move+1)%len(s)
print(ans)

Fixed submission:
a = int(input())
if a >= 3200:
  print(input())
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
a, b=map(int, input().split())
li = [a+b,a-b,a＊b]

print(max(li))

Fixed submission:
a, b=map(int, input().split())
li = [a+b, a-b, a*b]

print(max(li))
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input)
L = list(map(int, input().split()))
d = 0
ans = 1
for i in range(N):
  d += L[i]
  if d <= X:
    ans += 1

print(ans)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
d = 0
ans = 1
for i in range(N):
  d += L[i]
  if d <= X:
    ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input())
L = list(map(int, input().split()))
d = 0
ans = 1
for i in range(N):
  d += L[i]
  if d <= X:
    ans += 1

print(ans)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
d = 0
ans = 1
for i in range(N):
  d += L[i]
  if d <= X:
    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
A = list(map(int, input().split())).sort()
print(sum[:2])

Fixed submission:
A = list(map(int, input().split()))
A.sort()
print(sum(A[:2]))
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans = - 10**7
for i in range(min(N,K)+1):
  for j in range(min(N,K)+1-i
    if j == 0:
      st = A[:i]
    else:
      st = A[:i]+ A[-j:]
    st.sort(reverse = 1)):
    for suteru in range(K - i - j):
      ans = max(ans, sum(st[:i+j-suteru]))
    
print(ans)

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

ans = - 10**7
for i in range(min(N,K)+1):
  for j in range(min(N,K)+1-i):
    if j == 0:
      st = A[:i]
    else:
      st = A[:i]+ A[-j:]
    st.sort(reverse = 1)
    for suteru in range(K - i - j+1):
      ans = max(ans, sum(st[:i+j-suteru]))
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
if K == 0 or M ==0:
  li = []
  for i in range(2**N):
    li += [i]*2
  print(' '.join(map(str, li)))
else:
  print(-1)


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

if K >= 2**M:
    print(-1)
elif M == 0:
    if K == 0:
        print(0,0)
    else:
        print(-1)
elif M == 1:
    if K >= 1:
        print(-1)
    else:
        print(0,0,1,1)
else:
    li = [i for i in range(2**M) if i != K]
    ans = li + [K] + list(reversed(li)) + [K]
    print(*ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
if K == 0:
  li = []
  for i in range(2**(M)):
    li += [i]*2
  print(' '.join(map(str, li)))
else:
  print(-1)


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

if K >= 2**M:
    print(-1)
elif M == 0:
    if K == 0:
        print(0,0)
    else:
        print(-1)
elif M == 1:
    if K >= 1:
        print(-1)
    else:
        print(0,0,1,1)
else:
    li = [i for i in range(2**M) if i != K]
    ans = li + [K] + list(reversed(li)) + [K]
    print(*ans)
Buggy python submission (verdict: Runtime Error):
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :
    flag = 1
  
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 1:
    migi -= 1
  if T[i] == 'D' and ue != 1:
    ue += 1
  if T[i] == 'U' and shita != H:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")
  

Fixed submission:
from collections import deque
H, W = map(int, input().split())
A = [input() for i in range(H)]

dx = [1,-1,0,0]

dy = [0,0,1,-1]
B = [[-1 for i in range(W)] for j in range(H)]
qu = deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      B[i][j] = 0
      qu.append((i,j))
      
      
while qu:
  base = qu.popleft()
  for i in range(4):
    if base[0]+dx[i] < 0 or base[0]+dx[i] >=H or base[1]+dy[i] < 0 or base[1]+dy[i] >=W:
      continue
    if B[base[0]+dx[i]][base[1]+dy[i]] == -1:#未訪問
      qu.append((base[0]+dx[i],base[1]+dy[i]))
      B[base[0]+dx[i]][base[1]+dy[i]] = B[base[0]][base[1]] + 1
      
ans = 0
for i in range(H):
  ans = max(ans,max(B[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H, W = map(int, input().split())
A = [input() for i in range(H)]

dx = [1,-1,0,0]

dy = [0,0,1,-1]
B = [[-1 for i in range(W)] for j in range(H)]
qu = deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      B[i][j] = 0
      qu.append((i,j))
      
      
while qu:
  base = qu.popleft()
  for i in range(4):
    if base[0]+dx[i] < 0 or base[0]+dx[i] >=H or base[1]+dy[i] < 0 or base[1]+dy[i] >=W:
      continue
    if B[base[0]+dx[i]][base[1]+dy[i]] == -1:#未訪問
      qu.append((base[0]+dx[i],base[1]+dy[i]))
      B[base[0]+dx[i]][base[1]+dy[i]] = B[base[0]][base[1]] + 1
      
ans = 0
for i in range(H):
  ans = max(ans,max(B[i]))
print(ans)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
A = [input() for i in range(H)]

dx = [1,-1,0,0]

dy = [0,0,1,-1]
B = [[-1 for i in range(W)] for j in range(H)]
qu = deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      B[i][j] = 0
      qu.append((i,j))
      
      
while qu:
  base = qu.popleft()
  for i in range(4):
    if base[0]+dx[i] < 0 or base[0]+dx[i] >=H or base[1]+dy[i] < 0 or base[1]+dy[i] >=W:
      continue
    if B[base[0]+dx[i]][base[1]+dy[i]] == -1:#未訪問
      qu.append((base[0]+dx[i],base[1]+dy[i]))
      B[base[0]+dx[i]][base[1]+dy[i]] = B[base[0]][base[1]] + 1
      
ans = 0
for i in range(H):
  ans = max(ans,max(B[i]))
print(ans)