Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1))+b'\n',dtype='S1') == b'.').reshape((H,W+1))

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = -np.arange(L) # 左の壁のindexの-1倍
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.arange(L) # 逆順ソートした上で左の壁のindex
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)


Fixed submission:
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x

# y軸
def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]

# y軸
answer += G()
# 逆順
map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H,W = map(int,input().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=object)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '.')*1

f = np.frompyfunc(lambda x,y: x+1 if y else 0,2,1)

L = f.accumulate(grid,axis=1)
R = f.accumulate(grid[:,::-1],axis=1)[:,::-1]
U = f.accumulate(grid,axis=0)
D = f.accumulate(grid[::-1,:],axis=0)[::-1,:]

answer = (L+R+U+D).max()-3
print(answer)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x

# y軸
def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]

# y軸
answer += G()
# 逆順
map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import lru_cache

MOD = 10**9 + 7

L = int(readline(),2)

@lru_cache(None)
def F(N):
    if N == 0:
        return 1
    if N == 1:
        return 3
    q,r = divmod(N,2)
    if r == 1:
        # (ev,ev): q, (ev,od): q, (od,ev): q
        return (3*F(q))%MOD
    else:
        # (ev,ev): q, (ev,od): q-1, (od,ev): q-1
        return (F(q) + 2*F(q-1))%MOD

answer = F(L)
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
MOD = 10**9 + 7

#上限指定がなければ0,0 or 0,1 or 1,0
pow_3 = [1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)

def F(i):
  # i桁目以降をL[i:]以下で作る方法
  if i == L_size:
    return 1
  result = 0
  c = int(L[i])
  if c == 0:
    # 0,0ととるしかない
    result += F(i+1)
  else:
    # 0,1 あるいは 1,0 ととった場合
    result += 2*F(i+1)
    # 0,0ととった場合は、下の桁は自由
    result += pow_3[L_size - i - 1]
  result %= MOD
  return result



L = input()
L_size = len(L)

answer = F(0)
print(answer)

Buggy python submission (verdict: Runtime Error):
MOD = 10**9 + 7

#上限指定がなければ0,0 or 0,1 or 1,0
pow_3 = [1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)

def F(i):
  # i桁目以降をL[i:]以下で作る方法
  if i == L_size:
    return 1
  result = 0
  c = int(L[i])
  if c == 0:
    # 0,0ととるしかない
    result += F(i+1)
  else:
    # 0,1 あるいは 1,0 ととった場合
    result += 2*F(i+1)
    # 0,0ととった場合は、下の桁は自由
    result += pow_3[L_size - i - 1]
  result %= MOD
  return result



L = input()
L_size = len(L)

answer = F(0)
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
MOD = 10**9 + 7

#上限指定がなければ0,0 or 0,1 or 1,0
pow_3 = [1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)

def F(i):
  # i桁目以降をL[i:]以下で作る方法
  if i == L_size:
    return 1
  result = 0
  c = int(L[i])
  if c == 0:
    # 0,0ととるしかない
    result += F(i+1)
  else:
    # 0,1 あるいは 1,0 ととった場合
    result += 2*F(i+1)
    # 0,0ととった場合は、下の桁は自由
    result += pow_3[L_size - i - 1]
  result %= MOD
  return result



L = input()
L_size = len(L)

answer = F(0)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B,C,D = map(int,input().split())
S = input()

def test(x,y):
  # xからyへ行ける
  x -= 1
  y -= 1
  while x < y:
    if S[x+1] == '.':
      x += 1
      continue
    if S[x+2] == '.':
      x += 2
      continue
  return (x == y)

bl = test(A,C) and test(B,D)
if C > D:
  # 追い越す必要がある
  # 道の存在は保証されているので、局所的に詰まないようにBを配置できればよい
  can_swap = False
  for b in range(B-1,D):
    if S[b] == '#':
      continue
    if S[b-1] == '.' and S[b+1] == '.':
      can_swap = True
      break
  bl = bl and can_swap
answer = 'Yes' if bl else 'No'
print(answer)

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

def test(x,y):
  # xからyへ行ける
  substr = S[x:y-1]
  return substr.find('##') == -1

bl = test(A,C) and test(B,D)
if C > D:
  # 追い越す必要がある
  # 道の存在は保証されているので、局所的に詰まないようにBを配置できればよい
  can_swap = False
  for b in range(B-1,D):
    if S[b] == '#':
      continue
    if S[b-1] == '.' and S[b+1] == '.':
      can_swap = True
      break
  bl = bl and can_swap
answer = 'Yes' if bl else 'No'
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・部分木の中で操作を行った場合の、残りdepth和の最小値と最大値を持ってdp
・補助的にコマの個数も持つ
・最大値：ただのdepthの和
・最小値：一番負担の大きな木から他の部分木を引いていった場合だが…
・最小値＋最大値から全部の最大値の和を引く形で更新
"""

N = int(readline())
S = readline().rstrip()
m = map(int,read().split())
AB = zip(m,m)

INF = 10**18

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

def solve_rooted(root):
    parent = [0] * (N+1)
    ts = []
    stack = [root]
    while stack:
        x = stack.pop()
        ts.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)
    max_dep = [0]*(N+1)
    min_dep = [0]*(N+1)
    cnt = [0] * (N+1)
    for i,x in enumerate(S,1):
        cnt[i]=x-ord('0')
    for v in ts[::-1]:
        p = parent[v]
        max_dep_sum = 0
        x = 0
        for c in graph[v]:
            if c==p:
                continue
            cnt[v] += cnt[c]
            d1 = max_dep[c]; d2 = min_dep[c]
            d1 += cnt[c]; d2 += cnt[c]
            max_dep_sum += d1
            if x<d1+d2:
                x=d1+d2
        max_dep[v] = max_dep_sum
        x -= max_dep_sum
        if x<0:
            x=max_dep_sum&1
        min_dep[v] = x
    if min_dep[root]:
        return INF
    return max_dep[root]//2

answer = min(solve_rooted(v) for v in range(1,N+1))
if answer == INF:
    answer = -1
print(answer)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・部分木の中で操作を行った場合の、残りdepth和の最小値と最大値を持ってdp
・補助的にコマの個数も持つ
・最大値：ただのdepthの和
・最小値：一番負担の大きな木から他の部分木を引いていった場合だが…
・最小値＋最大値から全部の最大値の和を引く形で更新
"""

N = int(readline())
S = readline().rstrip()
m = map(int,read().split())
AB = zip(m,m)

INF = 10**18

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

def solve_rooted(root):
    parent = [0] * (N+1)
    ts = []
    stack = [root]
    while stack:
        x = stack.pop()
        ts.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)
    max_dep = [0]*(N+1)
    min_dep = [0]*(N+1)
    cnt = [0] * (N+1)
    for i,x in enumerate(S,1):
        cnt[i]=x-ord('0')
    for v in ts[::-1]:
        p = parent[v]
        max_dep_sum = 0
        x = 0
        for c in graph[v]:
            if c==p:
                continue
            cnt[v] += cnt[c]
            d1 = max_dep[c]; d2 = min_dep[c]
            d1 += cnt[c]; d2 += cnt[c]
            max_dep_sum += d1
            if x<d1+d2:
                x=d1+d2
        max_dep[v] = max_dep_sum
        x -= max_dep_sum
        if x<0:
            x=max_dep_sum&1
        min_dep[v] = x
    if min_dep[root]:
        return INF
    return max_dep[root]//2

answer = min(solve_rooted(v) for v in range(1,N+1))
if answer == INF:
    answer = -1
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.array(read().split(),np.int64)

def F(d):
    # 公差を固定
    L = S[::d].cumsum()
    R = S[::-d].cumsum()
    if (N-1)%d == 0:
        n = (N-1)//d
        x = np.arange(1,n+2)
        bl = (x+x <= n+1)
        L = L[bl]; R = R[bl]
    return (L+R).max()

def G(n):
    # 項数n+1を固定
    D = (N-1)//n
    L = np.zeros(D+1,np.int64)
    R = np.zeros(D+1,np.int64)
    for i in range(1,n+1):
        L += S[:i*(D+1):i]
        R += S[::-1][:i*(D+1):i]
    ok = np.ones(D+1,np.bool)
    overlap = (np.arange(D+1) * (n+n) >= N-1)
    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)
    x = L+R
    x[overlap] = 0
    return x.max()

L = (N-1)**.5 + 10
L = min(N-1,L)

x = max(F(n) for n in range(1,L+1))
y = max(F(n) for n in range(1,L+1))
answer = max(x,y)
print(answer)

Fixed submission:
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
  # d = A-B
  cum_left = np.cumsum(S[::d])
  cum_right = np.cumsum(S[::-1][::d])
  score = cum_left + cum_right # 等差数列の長さ-1 -> 得点
  # あとは、その経路がルール内で実現できるかどうか
  for L,s in enumerate(score):
    if answer >= s:
      continue
    # 右左に進んでいることの確認
    A = N-1-L*d
    B = A-d
    if A <= 0:
      continue
    if A<=B:
      continue
    if B<=0:
      continue
    # 同じ場所を取っていないかの確認
    # kd = N-1-ldとなるとまずい
    # 約数のとき、Ld >= N-Ldだとまずい
    if (N-1)%d == 0 and 2*L*d >= N-1:
      continue
    answer = s

print(answer)

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

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
    # d = A-B
    cum_left = np.cumsum(S[::d])
    cum_right = np.cumsum(S[::-1][::d])
    score = cum_left + cum_right # 等差数列の長さ-1 -> 得点
    # あとは、その経路がルール内で実現できるかどうか
    for L,s in enumerate(score):
        if answer >= s:
            continue
        # 右左に進んでいることの確認
        A = N-1-L*d
        B = A-d
        if A<=B:
            continue
		if B<=0:
          	continue
        # 同じ場所を取っていないかの確認
        # kd = N-1-ldとなるとまずい
        # 約数のとき、Ld >= N-Ldだとまずい
        if (N-1)%d == 0 and 2*L*d >= N-1:
            continue
        answer = s


print(answer)


Fixed submission:
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
  # d = A-B
  cum_left = np.cumsum(S[::d])
  cum_right = np.cumsum(S[::-1][::d])
  score = cum_left + cum_right # 等差数列の長さ-1 -> 得点
  # あとは、その経路がルール内で実現できるかどうか
  for L,s in enumerate(score):
    if answer >= s:
      continue
    # 右左に進んでいることの確認
    A = N-1-L*d
    B = A-d
    if A <= 0:
      continue
    if A<=B:
      continue
    if B<=0:
      continue
    # 同じ場所を取っていないかの確認
    # kd = N-1-ldとなるとまずい
    # 約数のとき、Ld >= N-Ldだとまずい
    if (N-1)%d == 0 and 2*L*d >= N-1:
      continue
    answer = s

print(answer)
Buggy python submission (verdict: Runtime Error):
# 連結成分 + 1
# UF tree

N,M = map(int,input().split())
n_component = N

root = list(range(N+1))
depth = [0] * (N+1)

def find_root(x):
  y = root[x]
  if x == y:
    return x
  z = find_root[y]
  root[x] = z
  return z

def merge(x,y):
  global n_component
  xx = find_root(x)
  yy = find_root(y)
  if xx == yy:
    return
  n_component -= 1
  if depth[xx] >= depth[yy]:
    root[yy] = xx
    depth[xx] += 1
  else:
    root[xx] = yy
    depth[yy] += 1
  
for _ in range(M):
  x,y,z = [int(x) for x in input().split()]
  merge(x,y)


answer = n_component
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
# 連結成分
# UF tree

N,M = map(int,input().split())
n_component = N

root = list(range(N+1))
depth = [0] * (N+1)

def find_root(x):
  y = root[x]
  if x == y:
    return x
  z = find_root(y)
  root[x] = z
  return z

def merge(x,y):
  global n_component
  xx = find_root(x)
  yy = find_root(y)
  if xx == yy:
    return
  n_component -= 1
  if depth[xx] >= depth[yy]:
    root[yy] = xx
    depth[xx] += 1
  else:
    root[xx] = yy
    depth[yy] += 1
  
for _ in range(M):
  x,y,z = [int(x) for x in input().split()]
  merge(x,y)

answer = n_component
print(answer)
Buggy python submission (verdict: Runtime Error):
# 0～7で5を作るには
# 0123467 5 7643210 5
# M = 1がxor sum = 0とならず例外

M,K = map(int,input().split())

def solve(M,K):
  if M == 0:
    if K == 0:
      return '0 0'
   	else:
      return '-1'
  if M == 1:
    if K == 0:
      return '0 1 1 0'
    else:
      return '-1'
  U = 1<<M
  if K >= U:
    return -1
  other = [x for x in range(U) if x != K]
  result = other + [K] + other[::-1] + [K]
  return ' '.join(result)

answer = solve(M,K)
print(answer)

Fixed submission:
# 0～7で5を作るには
# 0123467 5 7643210 5
# M = 1がxor sum = 0とならず例外

M,K = map(int,input().split())

def solve(M,K):
  if M == 0:
    if K == 0:
      return '0 0'
    else:
      return '-1'
  if M == 1:
    if K == 0:
      return '0 1 1 0'
    else:
      return '-1'
  U = 1<<M
  if K >= U:
    return -1
  other = [str(x) for x in range(U) if x != K]
  result = other + [str(K)] + other[::-1] + [str(K)]
  return ' '.join(result)

answer = solve(M,K)
print(answer)
Buggy python submission (verdict: Runtime Error):
a,b,c = input()

print(a,b,c)

Fixed submission:
input = input()
a,b,c = [int(x) for x in input.split()]
if (c-a)*(c-b) < 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
input = input()
a,b = [int(x) for x in input]

if a > b:
  print(a+a-1)
elif a == b:
  print(a+a)
else:
  print(b+b-1)

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

if a == b:
  print(a+b)
elif a > b:
  print(a+a-1)
else:
  print(b+b-1)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int, input().split())
S = [int(x) for x in input()]

memo = np.zeros(10**5+1, dtype = np.int64)
W = min(2*K, 10**5)

current = 1 # 最初は1が0個ある
p = 0

for x in S:
  if x == current:
    memo[x,p] += 1
  else:
    current = 1 - current
    p += 1

ans = memo[:W+1].sum()
x = ans
for r in range(2,10**5+1,2):
  if r+W > 10**5:
    break
  x = x-memo[r-2]-memo[r-1]+memo[r+W]+memo[r+W-1]
  if x > ans:
    ans = x

print(ans)

Fixed submission:
import numpy as np

N,K = map(int, input().split())
S = [int(x) for x in input()]

memo = np.zeros(10**5+1, dtype = np.int64)
W = min(2*K, 10**5)

current = 1 # 最初は1が0個ある
p = 0

for x in S:
  if x == current:
    memo[p] += 1
  else:
    current = 1 - current
    p += 1
    memo[p] += 1

ans = memo[:W+1].sum()
x = ans
for r in range(2,10**5+1,2):
  if r+W > 10**5:
    break
  x = x-memo[r-2]-memo[r-1]+memo[r+W]+memo[r+W-1]
  if x > ans:
    ans = x

print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())
h,w = map(int, input().split())
answer = (H-h)*(W-w)
print(ans)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())
ans = (H-h)*(W-w)
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
from collections import defaultdict

N,M = map(int,input().split())
A = [int(x) for x in input().split()]
L = [None,2,5,5,4,5,6,3,7,6]

l_to_n = [[] for _ in range(10)]
for a in A[1:]:
  l_to_n[L[a]].append(a)
  
l_to_n = [(i,max(x)) for i,x in enumerate(l_to_n) if x]

se = {0} # 1000以下で作れる長さ

for l,_ in l_to_n:
  se = {x+y for x,y in itertools.product(se,range(0,1000,l)) if x+y < 1000}

answer = ''
m_L,x = l_to_n[0]
while N > 100:
  N -= m_L
  answer += str(x)
  
for l,x in l_to_n:
  while N-l in se:
    N -= l
    answer += str(x)
  if N == 0:
    break

answer = ''.join(sorted(answer,reverse=True))

print(answer)

Fixed submission:
import itertools

N,M = map(int,input().split())
A = [int(x) for x in input().split()]
L = [100,2,5,5,4,5,6,3,7,6]

len_set = set(L[x] for x in A)

INF = 10**18
can_make = [-INF]*(N+1)
can_make[0] = 0 # 何桁で作れるか

for n in range(1,N+1):
  for x in len_set:
    if n-x >= 0 and can_make[n] < can_make[n-x] + 1:
        can_make[n] = can_make[n-x] + 1

answer = []

A.sort(reverse = True)
# なるべく大きいのを使いたい。作れる桁数が減らないようにする。
for a in A:
  x = L[a]
  while N-x >= 0 and can_make[N] == can_make[N-x]+1:
    answer.append(str(a))
    N -= x
      
answer = ''.join(answer)
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
列ベクトルが M 個ある
いくつかを選ぶ（和をとる）→すべての行が0となる選び方：0、その他：2^{N-1}通り
列ベクトル空間の生成する次元：d次元
ans = 2^{N-1} * (2^M - 2^[M-d})
= 2^{N+M-1} * (1-2^{-rank})
"""

import numpy as np
MOD = 998244353
N,M = map(int,input().split())
A = np.array([[int(x) for x in input().split()] for _ in range(N)])

def rank(A):
    # F_2 上の行列のrank
    N,M = A.shape
    if N == 0 or M == 0:
        return 0
    nz = np.nonzero(A[0])[0]
    if len(nz) == 0:
        # first col = zero
        return rank(A[1:])
    i = nz[0]
    # swap
    temp = A[:,i].copy()
    A[:,i] = A[:,0]
    A[:,0] = temp
    # (0,0) 成分が 1 になった。行基本変形。
    A ^= A[0] * A[:,0]
    return 1 + rank(A[1:,1:])

d = rank(A)
answer = pow(2,N+M-1,MOD) * (1 - pow(2,(-d)%(MOD-1), MOD)) % MOD
print(answer)



Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
列ベクトルが M 個ある
いくつかを選ぶ（和をとる）→すべての行が0となる選び方：0、その他：2^{N-1}通り
列ベクトル空間の生成する次元：d次元
ans = 2^{N-1} * (2^M - 2^[M-d})
= 2^{N+M-1} * (1-2^{-rank})
"""

import numpy as np
MOD = 998244353
N,M = map(int,input().split())
A = np.array([[int(x) for x in input().split()] for _ in range(N)])

def rank(A):
    # F_2 上の行列のrank
    N,M = A.shape
    if N == 0 or M == 0:
        return 0
    nz = np.nonzero(A[0])[0]
    if len(nz) == 0:
        # first col = zero
        return rank(A[1:])
    i = nz[0]
    # swap
    temp = A[:,i].copy()
    A[:,i] = A[:,0]
    A[:,0] = temp
    # (0,0) 成分が 1 になった。行基本変形。
    A ^= A[0][None,:] * A[:,0][:,None]
    return 1 + rank(A[1:,1:])

d = rank(A)
answer = pow(2,N+M-1,MOD) * (1 - pow(2,(-d)%(MOD-1), MOD)) % MOD
print(answer)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
print(a/b)

Fixed submission:
a,b = map(int,input().split())
print(a/b)
Buggy python submission (verdict: Runtime Error):
# 最大価値が取れて種類数も増えるなら必ずとる
# 
# 種類数を固定すると：各種類のベストを見て貪欲に種類を決めているはず
# あとは種類数を更新できないものの中から貪欲
#
# 最大価値が等しい2種類：第2種の貪欲が使われだすなら両方取ってるはずなので優先度は同じでよい
#
# 種類数を増やしたときの変化を見る

import sys
input = sys.stdin.readline
from heapq import heappush,heappop

N,K = map(int,input().split())
kind_value = [[] for _ in range(N+1)]
for _ in range(N):
  t,d = map(int,input().split())
  kind_value[t].append(d)
for li in kind_value:
  li.sort()
  
first_type = [(li[-1],i) for i,li in enumerate(kind_value) if li]
first_type.sort(reverse = True)

kind = 0
value_type1 = 0
second_type = []
second_type_sum = 0
second_type_cnt = 0

answer = 0
for v,i in first_type:
  kind += 1
  value_type1 += v
  for d in kind_value[i][:-1]:
    heappush(second_type,d)
    second_type_sum += d
    second_type_cnt += 1
  while second_type_cnt > K-kind:
    d = heappop(second_type)
    second_type_cnt -= 1
    second_type_sum -= d
  value = kind*kind + value_type1 + second_type_sum
  if answer < value:
    answer = value

print(answer)


Fixed submission:
# 最大価値が取れて種類数も増えるなら必ずとる
# 
# 種類数を固定すると：各種類のベストを見て貪欲に種類を決めているはず
# あとは種類数を更新できないものの中から貪欲
#
# 最大価値が等しい2種類：第2種の貪欲が使われだすなら両方取ってるはずなので優先度は同じでよい
#
# 種類数を増やしたときの変化を見る

import sys
input = sys.stdin.readline
from heapq import heappush,heappop

N,K = map(int,input().split())
kind_value = [[] for _ in range(N+1)]
for _ in range(N):
  t,d = map(int,input().split())
  kind_value[t].append(d)
for li in kind_value:
  li.sort()
  
first_type = [(li[-1],i) for i,li in enumerate(kind_value) if li]
first_type.sort(reverse = True)

kind = 0
value_type1 = 0
second_type = []
second_type_sum = 0
second_type_cnt = 0

answer = 0
for v,i in first_type:
  kind += 1
  if kind > K:
    break
  value_type1 += v
  for d in kind_value[i][:-1]:
    heappush(second_type,d)
    second_type_sum += d
    second_type_cnt += 1
  while second_type_cnt > K-kind:
    d = heappop(second_type)
    second_type_cnt -= 1
    second_type_sum -= d
  value = kind*kind + value_type1 + second_type_sum
  if answer < value:
    answer = value

print(answer)
Buggy python submission (verdict: Runtime Error):
from numpy import *
N,K,*A=map(int,open(0).split())
d=zeros(K+1,int64)
d[0]=1
for a in A:
    d[a+1:]-=d.copy()[:-(a+1)]
    d=cumsum(d)%(10**9+7)
print(d[K])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
(1+x+...+x^a) をたくさんかける
(1-x^{a+1}) をかけて、(1-x)^{-1}をかける
"""

import numpy as np
MOD = 10 ** 9 + 7
N,K = map(int,input().split())
dp = np.zeros(K+1, dtype=np.int64)
dp[0] = 1

for a in map(int,input().split()):
    # numpyのバージョン違いにより
    prev = dp.copy()
    dp[a+1:] -= prev[:-(a+1)]
    np.cumsum(dp, out=dp)
    dp %= MOD

answer = dp[K]
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
最後の2つを決める：[0,x) [x,N)
小問題2つに分割できる。
全ての連続区間を計算すればよい
"""

from functools import lru_cache
import itertools

N = int(input())
A = [int(x) for x in input().split()]

A_cum = tuple(itertools.accumulate(A))

@lru_cache(None)
def min_cost(L,R):
    # 区間[L,R)
    if R - L == 1:
        return 0
    x = min(min_cost(L,i) + min_cost(i,R) for i in range(L+1,R))
    x += A_cum[R-1] - (A_cum[L-1] if L > 0 else 0)
    return x

answer = min_cost(0,N)
print(answer)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

"""
最後の2つを決める：[0,x) [x,N)
小問題2つに分割できる。
全ての連続区間を計算すればよい
"""

N = int(input())
A = np.array(input().split(), np.int64)

# Acum[L,R] = A[L:R].sum()
Acum = np.zeros((N,N+1), dtype=np.int64)
for L in range(N):
    Acum[L,L+1:] = A[L:].cumsum()

dp = np.zeros((N,N+1), dtype=np.int64)
for size in range(2,N+1):
    for L in range(N-size+1):
        R = L + size
        dp[L,R] = (dp[L,L+1:R] + dp[L+1:R,R]).min() + Acum[L,R]

answer = dp[0,N]
print(answer)