Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
memo = [-1] * (N + 1)

for i in range(M):
	a[i] = int(input())

def step(n):
	if memo[n] >= 0:
		return memo[n]
	elif n < 2:
		memo[n] = 1
		return 1
	else:
		memo[n] = (step(n - 1) + step(n - 2)) % mod
		return memo[n]
			
for i in a:
	memo[i] = 0
	
print(step(N))

Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
dp = [0] * (N + 2)
dp[0] = 1
dp[1] = 1

for i in range(M):
	a[i] = int(input())
	
now = 0
next = 0

for i in a:
	next = i
	for j in range(now + 1, next + 1):
		if j == i:
			dp[i] = 0
		else:
			dp[j] = (dp[j - 1] + dp[j - 2]) % mod
	
	now = next

next = N
for j in range(now + 1, next + 1):
		dp[j] = (dp[j - 1] + dp[j - 2]) % mod
print(dp[N])

Buggy python submission (verdict: Runtime Error):
import sys
#sys.setrecursionlimit(2000)

input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
memo = [-1] * (N + 1)

for i in range(M):
	a[i] = int(input())

def step(n):
	if memo[n] >= 0:
		return memo[n]
	elif n < 2:
		memo[n] = 1
		return 1
	else:
		memo[n] = (step(n - 1) + step(n - 2)) % mod
		return memo[n]
			
for i in a:
	memo[i] = 0
	
print(step(N))

Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
dp = [0] * (N + 2)
dp[0] = 1
dp[1] = 1

for i in range(M):
	a[i] = int(input())
	
now = 0
next = 0

for i in a:
	next = i
	for j in range(now + 1, next + 1):
		if j == i:
			dp[i] = 0
		else:
			dp[j] = (dp[j - 1] + dp[j - 2]) % mod
	
	now = next

next = N
for j in range(now + 1, next + 1):
		dp[j] = (dp[j - 1] + dp[j - 2]) % mod
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
import sys, copy

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義

def listgcd(A):
	newA = []
	if len(A) % 2 == 1:
		A.append(0)
	
	for i in range(0, len(A), 2):
		newA.append(gcd(A[i], A[i + 1]))
	
	if len(newA) == 1:
		return newA[0]
	else:
		return listgcd(newA)
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

ans = 0

for i in range(N):
	B = copy.copy(A)
	B[i] = 0
	tmp = listgcd(B)
	if ans < tmp:
		ans = tmp
		
print(ans)


Fixed submission:
import sys

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0] * N
R = [0] * N
ans = 0
L[0] = 0
R[0] = 0

for i in range(1, N):
	L[i] = gcd(L[i - 1], A[i - 1])
	R[i] = gcd(R[i - 1], A[N - i])

for i in range(N):
	tmp = gcd(L[i], R[N - 1 - i])
	if tmp > ans:
		ans = tmp
		
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, copy

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義

def listgcd(A):
	newA = []
	if len(A) % 2 == 1:
		A.append(0)
	
	for i in range(0, len(A), 2):
		newA.append(gcd(A[i], A[i + 1]))
	
	if len(newA) == 1:
		return newA[0]
	else:
		return listgcd(newA)
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

ans = 0

for i in range(N):
	B = copy.copy(A)
	B[i] = 0
	tmp = listgcd(B)
	if ans < tmp:
		ans = tmp
		
print(ans)


Fixed submission:
import sys

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0] * N
R = [0] * N
ans = 0
L[0] = 0
R[0] = 0

for i in range(1, N):
	L[i] = gcd(L[i - 1], A[i - 1])
	R[i] = gcd(R[i - 1], A[N - i])

for i in range(N):
	tmp = gcd(L[i], R[N - 1 - i])
	if tmp > ans:
		ans = tmp
		
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

S = list(input())
S = [int(i) for i in S]

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ S[i]:
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))
		


Fixed submission:
S = list(input())

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ (S[i] == '1'):
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

S = list(input())
S = [int(i) for i in S]

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ S[i]:
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))
		

Fixed submission:
S = list(input())

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ (S[i] == '1'):
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

S = list(input())
S = [int(i) for i in S]

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ S[i]:
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))
		

Fixed submission:
S = list(input())

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ (S[i] == '1'):
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline()

'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)


Fixed submission:
#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)


Fixed submission:
#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []
tmp = []

for i in A:
	for j in B:
		tmp.append(i + j)
		
tmp.sort(reverse=True)

for i in range(K):
	for j in C:
		ans.append(tmp[i] + j)
		
ans.sort(reverse=True)

for i in range(K):
	print(ans[i])


Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []
tmp = []

for i in A:
	for j in B:
		tmp.append(i + j)
		
tmp.sort(reverse=True)

for i in range(min(K, len(tmp))):
	for j in C:
		ans.append(tmp[i] + j)
		
ans.sort(reverse=True)

for i in range(K):
	print(ans[i])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
#'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
x, u = [''] * N, [''] * N
ans = 0.0

for i in range(N):
	x[i], u[i] = input().split()
	x[i] = float(x[i])
	if u[i] == 'JPY':
		ans += x[i]
	else:
		ans += x[i] * 380000.0
	
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
x, u = [''] * N, [''] * N
ans = 0.0

for i in range(N):
	x[i], u[i] = input().split()
	x[i] = float(x[i])
	if u[i] == 'JPY':
		ans += x[i]
	else:
		ans += x[i] * 380000.0
	
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
A = list(map(int, input().split()))

recipe = [2, 5, 5, 4, 5, 6, 3, 7, 6]
available =[]
dp = [-1] * (N + 1)

for i in range(M):
	available.append((A[i], recipe[A[i] - 1]))
	
available.sort(reverse = True)
dp[0] = 0

for i in range(1, N + 1):
	for j in range(M):
		k = i - available[j][1]
		if k >= 0 and dp[k] >= 0:
			if dp[k] + 1 > dp[i]:
				dp[i] = dp[k] + 1

cost = 0
ans = ''

for i in range(dp[N]):
	for j in range(M):
		if dp[N - cost - available[j][1]] == dp[N - cost] - 1:
			cost += available[j][1]
			ans += str(available[j][0])
			break
	
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
A = list(map(int, input().split()))

recipe = [2, 5, 5, 4, 5, 6, 3, 7, 6]
available =[]
dp = [-1] * (N + 1)

for i in range(M):
	available.append((A[i], recipe[A[i] - 1]))
	
available.sort(reverse = True)
dp[0] = 0

for i in range(1, N + 1):
	for j in range(M):
		k = i - available[j][1]
		if k >= 0 and dp[k] >= 0:
			if dp[k] + 1 > dp[i]:
				dp[i] = dp[k] + 1

cost = 0
ans = ''

for i in range(dp[N]):
	for j in range(M):
		if N - cost - available[j][1] >= 0 and dp[N - cost - available[j][1]] == dp[N - cost] - 1:
			cost += available[j][1]
			ans += str(available[j][0])
			break
	
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
A = list(map(int, input().split()))

recipe = [2, 5, 5, 4, 5, 6, 3, 7, 6]
strategy = []

for i in A:
	strategy.append((recipe[i - 1], -i))
	
strategy.sort()
l = []

def dfs(cost):
	if cost > N:
		return False
	elif cost == N:
		return True
		
	for j in range(M):
		res = dfs(cost + strategy[j][0])
		if res:
			l.append(-strategy[j][1])
			return True

	return False
	
dfs(0)
l.sort(reverse=True)
c = map(str, l)
print(''.join(c))

Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
A = list(map(int, input().split()))

recipe = [2, 5, 5, 4, 5, 6, 3, 7, 6]
available =[]
dp = [-1] * (N + 1)

for i in range(M):
	available.append((A[i], recipe[A[i] - 1]))
	
available.sort(reverse = True)
dp[0] = 0

for i in range(1, N + 1):
	for j in range(M):
		k = i - available[j][1]
		if k >= 0 and dp[k] >= 0:
			if dp[k] + 1 > dp[i]:
				dp[i] = dp[k] + 1

cost = 0
ans = ''

for i in range(dp[N]):
	for j in range(M):
		if N - cost - available[j][1] >= 0 and dp[N - cost - available[j][1]] == dp[N - cost] - 1:
			cost += available[j][1]
			ans += str(available[j][0])
			break
	
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
x, y = [0] * M, [0] * M
from_x = [[] for _ in range(N)]
memo = [-1] * N
ans = 0

def length(i):
	if memo[i] >= 0:
		return memo[i]
	else:
		if len(from_x[i]) == 0:
			memo[i] = 0
			return memo[i]
		else:
			ret = 0
			
			for j in from_x[i]:
				tmp = length(j) + 1
				if tmp > ret:
					ret = tmp
					
			memo[i] = ret
			return ret

for i in range(M):
	x[i], y[i] = map(int, input().split())
	from_x[y[i] - 1].append(x[i] - 1)

for i in range(N):
	tmp = length(i)
	if tmp > ans:
		ans = tmp

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 5)
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
x, y = [0] * M, [0] * M
from_x = [[] for _ in range(N)]
memo = [-1] * N
ans = 0

def length(i):
	if memo[i] >= 0:
		return memo[i]
	else:
		if len(from_x[i]) == 0:
			memo[i] = 0
			return memo[i]
		else:
			ret = 0
			
			for j in from_x[i]:
				tmp = length(j) + 1
				if tmp > ret:
					ret = tmp
					
			memo[i] = ret
			return ret

for i in range(M):
	x[i], y[i] = map(int, input().split())
	from_x[y[i] - 1].append(x[i] - 1)

for i in range(N):
	tmp = length(i)
	if tmp > ans:
		ans = tmp

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
x, y = [0] * M, [0] * M
from_x = [[] for _ in range(N)]
memo = [-1] * N
ans = 0

def length(i):
	if memo[i] >= 0:
		return memo[i]
	else:
		if len(from_x[i]) == 0:
			memo[i] = 0
			return memo[i]
		else:
			ret = 0
			
			for j in from_x[i]:
				tmp = length(j) + 1
				if tmp > ret:
					ret = tmp
					
			memo[i] = ret
			return ret

for i in range(M):
	x[i], y[i] = map(int, input().split())
	from_x[y[i] - 1].append(x[i] - 1)

for i in range(N):
	tmp = length(i)
	if tmp > ans:
		ans = tmp

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 5)
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
x, y = [0] * M, [0] * M
from_x = [[] for _ in range(N)]
memo = [-1] * N
ans = 0

def length(i):
	if memo[i] >= 0:
		return memo[i]
	else:
		if len(from_x[i]) == 0:
			memo[i] = 0
			return memo[i]
		else:
			ret = 0
			
			for j in from_x[i]:
				tmp = length(j) + 1
				if tmp > ret:
					ret = tmp
					
			memo[i] = ret
			return ret

for i in range(M):
	x[i], y[i] = map(int, input().split())
	from_x[y[i] - 1].append(x[i] - 1)

for i in range(N):
	tmp = length(i)
	if tmp > ans:
		ans = tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = list(map(int, input().split()))

dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(3 * N + 1)]
#dp[n][i3][i2]...n:上に乗ってる寿司の数、i3:寿司が3貫の皿の枚数、i2:2貫の枚数。
n, i3, i2 = 0, 0, 0

for i in range(N):
	if a[i] == 3:
		i3 += 1
		n += 3
	elif a[i] == 2:
		i2 += 1
		n += 2
	elif a[i] == 1:
		n += 1
		
c1, c2, c3 = 0, 0, 0
		
#寿司を引くのではなく足していく
for m in range(0, n + 1):
	for j3 in range(0, N + 1):
		for j2 in range(0, N + 1):
			j1 = m - 3 * j3 - 2 * j2
			if j1 < 0:
				continue
				
			#サイコロで3貫の皿が出たときの処理
			if j3 > 0 and j2 < N:
				c3 = dp[m - 1][j3 - 1][j2 + 1]
				p3 = j3 / N
			else:
				p3 = 0
			
			#2貫
			if j2 > 0:
				c2 = dp[m - 1][j3][j2 - 1] 
				p2 = j2 / N
			else:
				p2 = 0
			
			#1貫
			if j1 > 0:
				c1 = dp[m - 1][j3][j2]
				p1 = j1 / N
			else:
				p1 = 0
			
			p = p3 + p2 + p1
			if p > 0 and p <= 1:
				dp[m][j3][j2] = (c3 * p3 + c2 * p2 + c1 * p1) / p + 1 / p
			
print(dp[n][i3][i2])


Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
#dp[i3][i2][i1]...皿を寿司の数が多い順に並べたとき、i1, i2, i3 はそれぞれ寿司の数が1, 2, 3個の皿が終わる点(スライス)。dpはそのときの期待値。
i3, i2, i1 = 0, 0, 0

for i in range(N):
	if a[i] == 3:
		i3 = i + 1
		i2 = i3
		i1 = i3
	elif a[i] == 2:
		i2 = i + 1
		i1 = i2
	elif a[i] == 1:
		i1 = i + 1
		
c1, c2, c3 = 0, 0, 0

for j3 in range(0, i3 + 1):
	for j2 in range(j3, i2 + 1):
		for j1 in range(j2, i1 + 1):
			#サイコロで3貫の皿が出たときの処理
			if j3 > 0:
				c3 = dp[j3 - 1][j2][j1]
				p3 = j3 / N
			else:
				p3 = 0
			
			#2貫
			if j2 > j3:
				c2 = dp[j3][j2 - 1][j1] 
				p2 = (j2 - j3) / N
			else:
				p2 = 0
			
			#1貫
			if j1 > j2:
				c1 = dp[j3][j2][j1 - 1]
				p1 = (j1 - j2) / N
			else:
				p1 = 0
			
			p = p3 + p2 + p1
			if p > 0:
				dp[j3][j2][j1] = (c3 * p3 + c2 * p2 + c1 * p1) / p + 1 / p
			
print(dp[i3][i2][i1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import copy
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = []
mod = 10 ** 9 + 7
dp = [-1] * (2 ** N)
#dp[n]: 考慮する女の組みを二進数で表す。考慮する男は前から女の数番目まで。そのときの組み合わせ数。
dp[0] = 1
stack = [0]
next_stack = []

for _ in range(N):
	a.append(list(map(int, input().split())))
	
for i in range(N):
	while stack:
		n = stack.pop()
		tmp = n
		for j in range(N):
			r = tmp % 2
			if r == 0 and dp[n + (2 ** j)] == -1:
				next_stack.append(n + 2 ** j)
				dp[n + (2 ** j)] = a[i][j] * dp[n]
			elif r == 0 and dp[n + (2 ** j)] != -1:
				dp[n + (2 ** j)] += a[i][j] * dp[n]
				dp[n + (2 ** j)] %= mod
				
			tmp = tmp // 2
				
	stack = copy.copy(next_stack)
	next_stack = []
	
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
mod = 10 ** 9 + 7
dp = [0] * (1 << N)
#dp[n] = c: 考慮する女の組を二進数で表す。iを考慮する女の数とすると、考慮する男は先頭からi番目まで。c: そのときの組み合わせ数。
dp[0] = 1
def bitcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
	
	
for n in range(1 << N):
	i = bitcount(n)
	c = dp[n]
	tmp = n
	tmp ^= (1 << N) - 1
	for j in range(N):
		r = 1 & tmp
		if r == 1 and a[i - 1][j] == 1:
			nc = dp[n + (1 << j)] + c 
			if nc >= mod:
				nc -= mod
			
			dp[n + (1 << j)] = nc
			
		tmp = tmp >> 1
		if tmp == 0:
			break
				
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
dp = [''] * (N + 1)
dp[0] = 'P'

for i in range(1, N + 1):
	dp[i] = 'B' + dp[i - 1] + 'P' + dp[i - 1] + 'B'
	
print(dp[N][0:X].count('P'))

Fixed submission:
N, X = map(int, input().split())
dp_layer = [1] * (N + 1)
dp_numP = [1] * (N + 1)

for i in range(1, N + 1):
	dp_layer[i] = 3 + 2 * dp_layer[i - 1]
	dp_numP[i] = 1 + 2 * dp_numP[i - 1]
	
x = X
countP = 0
i = N

while x > 0:
	if x >= dp_layer[i]:
		x -= dp_layer[i]
		countP += dp_numP[i]
		if x > 0:
			x -= 1
			countP += 1
	else:
		i -= 1
		x -= 1
		
print(countP)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))

ans = [i+1 for i in range(N)]
cnt = len([_ for a, b in zip(p, ans) if a != b])

if cnt == 2 or cnt == 0:
    print('YES')
else:
    print('NO')

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

ans = [i+1 for i in range(N)]
cnt = len([a for a, b in zip(p, ans) if a != b])

if cnt == 2 or cnt == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A = [int(input()) for i in range(N)] 

for i in range(N):
    print(max(A[:i]+A[i+1:]))

Fixed submission:
N=int(input())
A = [int(input()) for i in range(N)] 

ans=sorted(A, reverse=True)[:2]
for n in A:
    if n == ans[0]:
        print(ans[1])
    else:
        print(ans[0])
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
l =list(map(int, input().split()))

d=[0]
for v in l:
    d.append(d[-1]+v)

print(len([_ for v in d if v <= X]))

Fixed submission:
N, X = map(int, input().split())
l =list(map(int, input().split()))

d=[0]
for v in l:
    d.append(d[-1]+v)

print(len([v for v in d if v <= X]))
Buggy python submission (verdict: Runtime Error):
_ = input()
nums = [int(x) for x in input().split()]
max_ = max(nums)
pop(nums.index(max_))
rest = sum(nums)
if rest > max_:
    print('Yes')
else:
    print('No')

Fixed submission:
a,b = map(lambda x: int(x), input().split())
print(a/b)
Buggy python submission (verdict: Runtime Error):
_ = input()

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

max_ = max(nums)

pop(nums.index(max_))

rest = sum(nums)

if rest > max_:
    print('Yes')
else:
    print('No')

Fixed submission:
_ = input()

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

max_ = max(nums)

nums.pop(nums.index(max_))

rest = sum(nums)

if rest > max_:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
%%time
N, Y = map(int,input().split())

ans = (-1, -1, -1)
for x in range(N+1):
    y_max = N - x
    if ans == (-1, -1, -1) and 0 <= Y - 10000*x <= 5000*y_max:
        for y in range(N+1):
            z = N - x - y
            if 10000*x + 5000*y + 1000*z == Y:
                ans = (x, y, z)
                break
print(' '.join(map(str,ans)))

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

ans = (-1, -1, -1)
for x in range(N+1):
    if ans == (-1, -1, -1) and 0 <= Y - 10000*x <= 5000*(N-x):
        for y in range(N+1):
            z = N - x - y
            if 10000*x + 5000*y + 1000*z == Y:
                ans = (x, y, z)
                break

print(' '.join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
K, S = map(int,input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= k:
            cnt +=1
print(cnt)

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            cnt +=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int,input().split())

cnt = 0
for i in range(K+1):
    x = i
    for j in range(K+1):
        y = j
        for k in range(K+1):
            z = k
            if x + y + z == S:
                cnt += 1
print(cnt)

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            cnt +=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

cnt = 0

def main():
    N, X = map(int, input().split())
    L = [int(e) for e in input().split()]

    def rec(i, d):
        global cnt
        if d > X:
            return
        cnt += 1
        return rec(i+1, d + L[i])

    rec(0, 0)
    print(cnt)


main()


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

import sys

input = sys.stdin.readline

cnt = 0

def main():
    N, X = map(int, input().split())
    L = [int(e) for e in input().split()]

    def rec(i, d):
        global cnt
        if d > X:
            return
        cnt += 1
        if i >= N:
            return
        return rec(i+1, d + L[i])

    rec(0, 0)
    print(cnt)


main()