problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03837
u813102292
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['N, M = map(int, input().split())\nINF = 10**9\n\nedges = []\n\nfor i in range(M):\n edges.append(list(map(int, input().split())))\n\ndist = [[INF for j in range(N)] for i in range(N)]\n\nfor i in range(N):\n dist[i][i] = 0\n\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n dist[a][b] = c[i]\n dist[b][a] = c[i]\n \nfor k in range(N):\n for i in range(N):\n for j in range(N):\n dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])\n\nres = M\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n shortest = False\n for j in range(N):\n if dist[j][a] + c == dist[j][b]:\n shortest = True\n break\n if shortest:\n res -= 1\n\nprint(res)\n', 'N, M = map(int, input().split())\nINF = 10**9\n\nedges = []\n\nfor i in range(M):\n edges.append(list(map(int, input().split())))\n\ndist = [[INF for j in range(N)] for i in range(N)]\n\nfor i in range(N):\n dist[i][i] = 0\n\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n dist[a][b] = c[i]\n dist[b][a] = c[i]\n \nfor k in range(N):\n for i in range(N):\n for j in range(N):\n dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])\n\nres = M\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n shortest = False\n for j in range(N):\n if dist[j][a] + c == dist[j][b]:\n shortest = True\n break\n res -= 1\n\nprint(res)\n', 'N, M = map(int, input().split())\nINF = 10**9\n\nedges = []\n\nfor i in range(M):\n edges.append(list(map(int, input().split())))\n\ndist = [[INF for j in range(N)] for i in range(N)]\n\nfor i in range(N):\n dist[i][i] = 0\n\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n dist[a][b] = c\n dist[b][a] = c\n \nfor k in range(N):\n for i in range(N):\n for j in range(N):\n dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])\n\nres = M\nfor i in range(M):\n a, b, c = edges[i]\n a, b = a - 1, b - 1\n shortest = False\n for j in range(N):\n if dist[j][a] + c == dist[j][b]:\n shortest = True\n break\n if shortest:\n res -= 1\n\nprint(res)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s381793332', 's390080903', 's856479591']
[3316.0, 3316.0, 3572.0]
[21.0, 21.0, 627.0]
[721, 700, 715]
p03837
u844789719
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['V, E = [int(_) for _ in input().split()]\nG = {}\nfor i in range(V):\n G[i] = {}\n G[i][i] = 0\n\nfor _ in range(E):\n s, t, c = [int(_) for _ in input().split()]\n s -= 1 \n t -= 1 \n G[s][t] = c\n G[t][s] = c\n\nINF = 10**10\n\nedges_used = set()\nfor i in range(V):\n D = [INF] * V\n D[i] = 0 \n used = [False] * V\n used[i] = True\n prev = {}\n while True:\n for j in G[i].keys():\n if D[i] + G[i][j] < D[j]:\n D[j] = D[i] + G[i][j]\n prev[j] = i\n v = -1\n for j in range(V):\n if not used[j] and (v == -1 or D[j] < D[v]):\n v = j\n if v == -1:\n break\n else:\n used[v] = True\n i = v\n for key, value in prev.items():\n if key > value:\n key, value = value, key\n edges_used.add((key + 1, value + 1))\n\nprint(edges_used)\nprint(E - len(edges_used))', 'import numpy as np\nfrom scipy.sparse import csr_matrix\nfrom scipy.sparse.csgraph import floyd_warshall\nN, M, *ABC = [int(_) for _ in open(0).read().split()]\nABC = np.array(ABC)\nF = floyd_warshall(\n csr_matrix((ABC[2::3], (ABC[::3], ABC[1::3])), (N + 1, N + 1)), 0)\nprint(np.sum(F[ABC[::3], ABC[1::3]] != ABC[2::3]))\n']
['Wrong Answer', 'Accepted']
['s405124781', 's856915635']
[3188.0, 37680.0]
[227.0, 176.0]
[1000, 319]
p03837
u859897687
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['N,M=map(int,input().split())\nd=[[9999 for _ in range(N)]for _ in range(N)]\n\nfor _ in range(M):\n a,b,c=map(int,input().split())\n d[0][1]=c\n d[1][0]=c\n\nans=0\nfor k in range(N):\n for i in range(N):\n if i == k:\n continue\n for j in range(N):\n if j == k or j == i:\n continue\n print(d[i][j],d[i][k]+d[k][j])\n if d[i][j]>d[i][k]+d[k][j]:\n d[i][j]=d[i][k]+d[k][j]\n d[j][i]=d[i][k]+d[k][j]\n ans+=1\n\nprint(ans)\n', 'N,M=map(int,input().split())\nd=[[9999 for _ in range(N)]for _ in range(N)]\n\nfor _ in range(M):\n a,b,c=map(int,input().split())\n d[0][1]=c\n d[1][0]=c\n\nans=0\nfor k in range(N):\n for i in range(N):\n if i == k:\n continue\n for j in range(N):\n if j == k or j == i:\n continue\n if d[i][j]>d[i][k]+d[k][j]:\n d[i][j]=d[i][k]+d[k][j]\n d[j][i]=d[i][k]+d[k][j]\n ans+=1\n\nprint(ans)\n', 'N,M=map(int,input().split())\ndist=[[9999 for _ in range(N)]for _ in range(N)]\ncost=[[9999 for _ in range(N)]for _ in range(N)]\nfor _ in range(M):\n a,b,c=map(int,input().split())\n cost[a-1][b-1]=c\n cost[b-1][a-1]=c\n dist[a-1][b-1]=c\n dist[b-1][a-1]=c\n\nfor k in range(N):\n for i in range(N):\n if i == k:\n continue\n for j in range(N):\n if j == k or j == i:\n continue\n if i <= j:\n continue\n if dist[i][j]>dist[i][k]+dist[k][j]:\n dist[i][j]=dist[i][k]+dist[k][j]\n dist[j][i]=dist[i][k]+dist[k][j]\n\nans =0\nfor i in range(N):\n for j in range(N):\n if i <= j:\n continue\n if cost[i][j] ==9999:\n continue\n if cost[i][j] != dist[i][j]:\n ans +=1\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s264248014', 's590227656', 's186773431']
[13832.0, 3188.0, 3444.0]
[1764.0, 465.0, 411.0]
[530, 487, 838]
p03837
u879870653
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['from scipy.sparse.csgraph import dijkstra\n\nn,m = map(int,input().split())\nedges = [[int(x) for x in input().split()] for i in range(m)]\ngraph = [[None]*n for i in range(n)]\nfor a, b, c in edges :\n graph[a-1][b-1] = c\n\n#graph = csgraph_from_dense(graph)\ndist = dijkstra(graph, directed=True).astype(int)\n\nused = [0]*m\nfor s in range(n-1) :\n for t in range(s+1, n) :\n for i in range(len(edges)) :\n a, b, c = edges[i]\n a -= 1\n b -= 1\n if dist[s][a] + c + dist[b][t] == dist[s][t] :\n used[i] = 1\nans = m - sum(used)\nprint(ans)\n', 'from scipy.sparse.csgraph import dijkstra\n\nn,m = map(int,input().split())\nedges = [[int(x) for x in input().split()] for i in range(m)]\ngraph = [[0]*n for i in range(n)]\nfor a, b, c in edges :\n graph[a-1][b-1] = c\n\n#graph = csgraph_from_dense(graph)\ndist = dijkstra(graph, directed=True).astype(int)\n\nused = [0]*m\nfor s in range(n-1) :\n for t in range(s+1, n) :\n for i in range(len(edges)) :\n a, b, c = edges[i]\n a -= 1\n b -= 1\n if dist[s][a] + c + dist[b][t] == dist[s][t] :\n used[i] = 1\nans = m - sum(used)\nprint(ans)\n', 'import sys\ninput = sys.stdin.readline\nfrom scipy.sparse.csgraph import csgraph_from_dense, dijkstra\n\nn,m = map(int,input().split())\nA = [0]*m\nB = [0]*m\nC = [0]*m\nfor i in range(m) :\n a, b, c = map(int,input().split())\n A[i] = a-1\n B[i] = b-1\n C[i] = c\n\ngraph = [[0]*n for i in range(n)]\n\nfor i in range(m) :\n graph[A[i]][B[i]] = C[i]\n graph[B[i]][A[i]] = C[i]\n\ngraph = csgraph_from_dense(graph)\ndist = dijkstra(graph)\n\nans = 0\nfor i in range(m) :\n if dist[A[i]][B[i]] != C[i] :\n ans += 1\n\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s121206863', 's240529939', 's129177983']
[17188.0, 16080.0, 14080.0]
[243.0, 2109.0, 179.0]
[595, 592, 528]
p03837
u923279197
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["ans = 0\nn,m = map(int,input().split())\ndis = [[float('inf') for i in range(n)] for j in range(n)] \nabt = []\nfor i in range(m):\n abt.append(list(map(int,input().split()))) \nfor a,b,t in abt:\n dis[a-1][b-1] = t \n dis[b-1][a-1] = t \nfor i in range(n):\n for j in range(n):\n for k in range(n):\n dis[i][j] = min(dis[k][j], dis[k][i] + dis[i][j])\nfor a,b,t in abt:\n if t > dis[a-1][b-1]:\n ans +=1\nprint(ans)", "ans = 0\nn,m = map(int,input().split())\ndis = [[float('inf') for i in range(n)] for j in range(n)] \nabt = []\nfor i in range(m):\n abt.append(list(map(int,input().split()))) \nfor a,b,t in abt:\n dis[a-1][b-1] = t \n dis[b-1][a-1] = t \nfor i in range(n):\n for j in range(n):\n for k in range(n):\n dis[k][j] = min(dis[k][j], dis[k][i] + dis[i][j])\nfor a,b,t in abt:\n if t > dis[a-1][b-1]:\n ans +=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s421333863', 's673927815']
[3572.0, 3700.0]
[651.0, 623.0]
[526, 526]
p03837
u924374652
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import heapq\n\ndef dijkstra(graph, node, start):\n INF = float("inf")\n dist = [INF] * node\n dist[start] = 0\n que = [(0, start)]\n while que:\n cost, one_node = heapq.heappop(heap)\n for next_c, next_n in graph[one_node]:\n dist_candi = dist[one_node] + next_c\n if dist_candi < dist[next_n]:\n dist[next_node] = dist_candi\n heapq.heappush(heap, (dist[next_n], next_n))\n return dist\n\nclass SetGraph:\n def __init__(self, node_num):\n self.graph = [[] for _ in range(node_num)]\n\n def add_one_edge(self, start, end, cost):\n self.graph[start].append((cost, end))\n self.graph[end].append((cost, start))\n\n def get_graph(self):\n return self.graph \n \n\nn, m = map(int, input().split(" "))\ngraph = SetGraph(n)\nadd_process = SetGraph.add_one_edge\nfor i in range(m):\n a, b, c = map(int, input().split(" "))\n add_process(a - 1, b - 1, c)\ngraph = Graph.get_graph()\n\ncost = []\nfor i in range(n):\n temp_cost = dijkstra(graph, n, i)\n cost.append(temp_cost)\n\nresult = 0\nfor i in range(n):\n for c, node in graph[i]:\n if cost[i][node] != c:\n result += 1\n\nprint(result // 2)', 'import heapq\n\ndef dijkstra(graph, node, target):\n INF = float("inf")\n dist = [INF] * node\n dist[target] = 0\n que = [(0, target)]\n while que:\n co, one_node = heapq.heappop(que)\n for next_c, next_n in graph[one_node]:\n dist_candi = dist[one_node] + next_c\n if dist_candi < dist[next_n]:\n dist[next_n] = dist_candi\n heapq.heappush(que, (dist[next_n], next_n))\n return dist\n\n\nclass SetGraph:\n def __init__(self, node_num):\n self.n = node_num\n self.graph = [[] for _ in range(self.n)]\n\n def add_one_edge(self, start, end, cost):\n self.graph[start].append((cost, end))\n self.graph[end].append((cost, start))\n\n def get_graph(self):\n return self.graph \n \n\nn, m = map(int, input().split(" "))\ngraph_set = SetGraph(n)\nfor i in range(m):\n a, b, c = map(int, input().split(" "))\n graph_set.add_one_edge(a - 1, b - 1, c)\ngraph = graph_set.get_graph()\n\ncost = []\nfor i in range(n):\n temp_cost = dijkstra(graph, n, i)\n cost.append(temp_cost)\n\nresult = 0\nfor i in range(n):\n for c, node in graph[i]:\n if cost[i][node] != c:\n result += 1\n\nprint(result // 2)']
['Runtime Error', 'Accepted']
['s393703925', 's500734083']
[3188.0, 3572.0]
[19.0, 100.0]
[1108, 1108]
p03837
u952022797
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['# -*- coding: utf-8 -*-\nimport sys\nimport copy\n\ndef main():\n\tN, M = map(int, input().split(" "))\n\t\n\tgraph = []\n\tmaps = [[9999999 for _ in range(N)] for _ in range(N)]\n\tfor i in range(N):\n\t\tmaps[i][i] = 0\n\t\n\tfor _ in range(M):\n\t\ta, b, c = map(int, input().split(" "))\n\t\ta, b = a-1, b-1\n\t\tmaps[a][b] = c\n\t\tmaps[b][a] = c\n\t\n\tans = 0\n\torg = copy.deepcopy(maps)\n\tfor k in range(N):\n\t\tfor i in range(N):\n\t\t\tfor j in range(N):\n\t\t\t\tif maps[i][j] == 9999999:\n\t\t\t\t\tcontinue\n\t\t\t\tif i <= j:\n\t\t\t\t\tcontinue\n\t\t\t\tmaps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\n\tfor i in range(N):\n\t\tfor j in range(N):\n\t\t\tif i <= j:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] != maps[i][j]:\n\t\t\t\tans += 1\n\t\t\n\tprint(ans // 2)\n\t\nif __name__ == "__main__":\n\tmain()\n\t', '# -*- coding: utf-8 -*-\nimport sys\nimport copy\n\ndef main():\n\tN, M = map(int, input().split(" "))\n\t\n\tgraph = []\n\tmaps = [[9999999 for _ in range(N)] for _ in range(N)]\n\tfor i in range(N):\n\t\tmaps[i][i] = 0\n\t\n\tfor _ in range(M):\n\t\ta, b, c = map(int, input().split(" "))\n\t\ta, b = a-1, b-1\n\t\tmaps[a][b] = c\n\t\tmaps[b][a] = c\n\t\n\tans = 0\n\torg = copy.deepcopy(maps)\n\tfor k in range(N):\n\t\tfor i in range(N):\n\t\t\tfor j in range(N):\n\t\t\t\tmaps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\tmaps[j][i] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\n\tfor i in range(N):\n\t\tfor j in range(N):\n\t\t\tif i <= j:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] == 9999999:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] != maps[i][j]:\n\t\t\t\tans += 1\n\t\t\n\tprint(ans)\n\t\nif __name__ == "__main__":\n\tmain()\n\t']
['Wrong Answer', 'Accepted']
['s311413138', 's135752909']
[3700.0, 3828.0]
[139.0, 820.0]
[725, 746]
p03837
u977389981
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["import heapq\nimport copy\n\nV, M = map(int, input().split())\nd = [0] * V\nprev = [0] * V\n\ncost = [[INF] * V for i in range(V)]\nfor i in range(M):\n a, b, c = map(int, input().split())\n cost[a - 1][b - 1] = c\n cost[b - 1][a - 1] = c\n \ndef dijkstra_back(s, t):\n for i in range(V):\n prev[i] = s\n d[i] = float('inf')\n d[s] = 0\n h = []\n heapq.heappush(h, [0, s])\n \n while h != []:\n p = heapq.heappop(h)\n v = p[1]\n if d[v] < p[0]:\n continue\n \n for i in range(V):\n if d[i] > d[v] + cost[v][i]: \n d[i] = d[v] + cost[v][i]\n heapq.heappush(h, [d[i], i])\n prev[i] = v\n \n path = [t]\n while prev[t] != s:\n path.append(prev[t])\n prev[t] = prev[prev[t]]\n path.append(s)\n path = path[::-1]\n return path\n\ncost2 = copy.deepcopy(cost)\nfor i in range(V - 1):\n for j in range(i + 1, V):\n g = dijkstra_back(i, j)\n # print(i, j, g)\n for k in range(len(g) - 1):\n cost2[g[k]][g[k + 1]] = INF\n cost2[g[k + 1]][g[k]] = INF\n \ncnt = 0\nfor i in range(V):\n for j in range(V):\n if cost2[i][j] != INF:\n cnt += 1\n \nprint(cnt // 2)", "import heapq\nimport copy\n\nV, M = map(int, input().split())\nd = [0] * V\nprev = [0] * V\n\ncost = [[INF] * V for i in range(V)]\nfor i in range(M):\n a, b, c = map(int, input().split())\n cost[a - 1][b - 1] = c\n cost[b - 1][a - 1] = c\n \ndef dijkstra_back(s, t):\n for i in range(V):\n prev[i] = s\n d[i] = float('inf')\n d[s] = 0\n h = []\n heapq.heappush(h, [0, s])\n \n while h != []:\n p = heapq.heappop(h)\n v = p[1]\n if d[v] < p[0]:\n continue\n \n for i in range(V):\n if d[i] > d[v] + cost[v][i]: \n d[i] = d[v] + cost[v][i]\n heapq.heappush(h, [d[i], i])\n prev[i] = v\n \n path = [t]\n while prev[t] != s:\n path.append(prev[t])\n prev[t] = prev[prev[t]]\n path.append(s)\n path = path[::-1]\n return path\n\ncost2 = copy.deepcopy(cost)\nfor i in range(V - 1):\n for j in range(i + 1, V):\n g = dijkstra_back(i, j)\n # print(i, j, g)\n for k in range(len(g) - 1):\n cost2[g[k]][g[k + 1]] = INF\n cost2[g[k + 1]][g[k]] = INF\n \ncnt = 0\nfor i in range(V):\n for j in range(V):\n if cost2[i][j] != INF:\n cnt += 1\n \nprint(cnt // 2)", "import copy\nfrom scipy.sparse.csgraph import floyd_warshall as wf\n\nN, M = map(int, input().split())\nINF = float('inf')\n\nd = [[INF] * (N) for i in range(N)]\ne_list = []\nfor i in range(N):\n d[i][i] = 0\nfor _ in range(M):\n a, b, c = map(int, input().split())\n d[a - 1][b - 1] = c\n d[b - 1][a - 1] = c\n e_list.append([a - 1, b - 1, c])\n \nwf = wf(d)\n\ncnt = M\nfor a, b, c in e_list:\n for i in range(N):\n if wf[i][a] + c == wf[i][b]:\n cnt -= 1\n break\n \nprint(cnt)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s057875876', 's181173681', 's607278549']
[3572.0, 3572.0, 26580.0]
[23.0, 23.0, 417.0]
[1274, 1274, 509]
p03839
u064408584
2,000
262,144
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
['import numpy as np\nn,k=map(int, input().split())\na=np.array(list(map(int, input().split())))\nb=np.maximum(a,0)\nsm=sum(a[:k])\nat=sum(b[k:])\nans=max(sm,0)+at\nfor i in range(k,n):\n sm+=a[i]-a[i-k]\n at+=b[i-k]-b[i]\n ans=max(max(0,sm)+at,ans)\n print(sm,at)\nprint(ans)', 'import numpy as np\nn,k=map(int, input().split())\na=np.array(list(map(int, input().split())))\nb=np.maximum(a,0)\nsm=sum(a[:k])\nat=sum(b[k:])\nans=max(sm,0)+at\nfor i in range(k,n):\n sm+=a[i]-a[i-k]\n at+=b[i-k]-b[i]\n ans=max(max(0,sm)+at,ans)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s672532535', 's198828885']
[23164.0, 23172.0]
[1479.0, 636.0]
[274, 257]
p03839
u476604182
2,000
262,144
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
["from itertools import accumulate as acc\nN, K, *A = map(int, open('0').read().split())\nB = [0]+list(acc(A))\nM = list(acc(a if a>0 else 0 for a in A))\nans = -10**30\ns = sum(A)\nfor i in range(N-K+1):\n mi = B[i+K]-B[i]\n c = M[N-1] - M[i+K-1]\n if i>0:\n c += M[i-1]\n ans = max(ans,mi+c,c)\nprint(ans)", 'N,K,*A = map(int, open(0).read().split())\nm = sum(A[:K])\nn = sum(c if c>0 else 0 for c in A[K:])\nans = max(m+n,n)\nfor i in range(N-K):\n m -= A[i]\n m += A[i+K]\n if A[i]>0:\n n += A[i]\n if A[i+K]>0:\n n -= A[i+K]\n ans = max(ans,n+m,n)\nprint(ans)']
['Runtime Error', 'Accepted']
['s001668204', 's900086493']
[3064.0, 14092.0]
[17.0, 165.0]
[300, 252]
p03839
u547167033
2,000
262,144
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
['n,k=map(int,input().split())\na=list(map(int,input().split()))\nsum_a=[0]*n\nb=[max(0,a[i]) for i in range(n)]\nsum_b=[0]*n\nsum_a[0]=a[0]\nsum_b[0]=a[0]\nfor i in range(1,n):\n sum_a[i]=sum_a[i-1]+a[i]\n sum_b[i]=sum_b[i-1]+b[i]\nans=sum_a[k-1]+sum_b[n-1]-sum_b[k-1]\nans=max(ans,0)\nfor i in range(k,n):\n ans=max(ans,sum_a[i]-sum_a[i-k]+sum_b[n-1]-sum_b[i]+sum_b[i-k])\n ans=max(ans,sum_b[n-1]-sum_b[i]+sum_b[i-k])\nprint(ans)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nsum_a=[0]*(n+1)\nb=[max(0,a[i]) for i in range(n)]\nsum_b=[0]*(n+1)\nsum_a[1]=a[0]\nsum_b[1]=b[0]\nfor i in range(1,n):\n sum_a[i+1]=sum_a[i]+a[i]\n sum_b[i+1]=sum_b[i]+b[i]\nans=-10**18\nfor i in range(n-k+1):\n l,r=i,i+k\n cnt=sum_b[l]-sum_b[0]\n cnt+=max(0,sum_a[r]-sum_a[l])\n cnt+=sum_b[n]-sum_b[r]\n ans=max(ans,cnt)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s191827438', 's504500262']
[17852.0, 17608.0]
[250.0, 235.0]
[418, 388]
p03839
u814986259
2,000
262,144
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
['N,K=map(int,input().split())\na=list(map(int,input().split()))\nans=0\ntmp=0\nfor i in range(N):\n if i < K:\n tmp+=a[i]\n else:\n if a[i]>0:\n ans+=a[i]\nans+=max(0,tmp)\n\nans2=0\ntmp=0\nfor i in range(N-1,-1,-1):\n if ans < N-K:\n if a[i]>0:\n ans2+=a[i]\n else:\n tmp+=a[i]\nans2+=max(0,tmp)\nprint(max(ams2,ans))', 'N,K=map(int,input().split())\na=list(map(int,input().split()))\nans=0\ntmp=0\nsa=[0]*(N+1)\nA=[0]*(N+1)\nfor i in range(N):\n sa[i+1]=sa[i]+a[i]\n if a[i]>0:\n A[i+1]=A[i]+a[i]\n else:\n A[i+1]=A[i]\nfor i in range(N-K+1):\n tmp=sa[i+K]-sa[i]\n tmp2=A[i]+(A[-1]-A[i+K])\n #print(max(0,tmp),tmp2)\n if max(0,tmp)+tmp2>ans:\n ans=max(0,tmp)+tmp2\nprint(ans)']
['Runtime Error', 'Accepted']
['s804837862', 's096691821']
[20032.0, 23664.0]
[86.0, 150.0]
[322, 353]
p03840
u088063513
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['## coding: UTF-8\n\n#from decimal import *\n#from itertools import permutations, combinations,combinations_with_replacement,product\n\n#N = int(input())\n\ns = input().split()\np = [int(w) for w in s]\n\nprint(p)\n\nI = p[0]\nO = p[1]\n\nJ = p[3]\nL = p[4] \n\n\n\nanswer = 0\n\nanswer += O \n\nif(I % 2 == J % 2 and I % 2 == L % 2):\n #[odd,odd,odd] or [even,even,even]\n answer += I+J+L\nelif( (I + J + L) % 2 == 1):\n #[even,even,odd]\n answer += I+J+L-1\nelse:\n if(min(I,J,L) % 2 == 0):\n answer += I+J+L - 2\n else:\n answer += I+J+L - 1\n\nprint(answer)\n', '## coding: UTF-8\n\n#from decimal import *\n#from itertools import permutations, combinations,combinations_with_replacement,product\n\n#N = int(input())\n\ns = input().split()\np = [int(w) for w in s]\n\n#print(p)\n\nI = p[0]\nO = p[1]\n\nJ = p[3]\nL = p[4] \n\n\n\nanswer = 0\n\nanswer += O \n\n\nif(I % 2 == J % 2 and I % 2 == L % 2):\n #[odd,odd,odd] or [even,even,even]\n #[0,0,0],[0,0,even],[0,even,even]\n answer += I+J+L\nelif( (I + J + L) % 2 == 1):\n #[even,even,odd]\n #[0,0,odd],[0,even,odd]\n answer += I+J+L-1\nelif( (I == 0 and J % 2 == 1 and L % 2 == 1) or (J == 0 and I % 2 == 1 and L % 2 == 1) or (L == 0 and J % 2 == 1 and I % 2 == 1) ):\n answer += I+J+L-2\nelse:\n #[even,odd,odd]\n #if(min(I,J,L) % 2 == 0):\n #answer += I+J+L - 2\n #else:\n #answer += I+J+L - 1\n answer += I+J+L-1\n\nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s230716652', 's861809009']
[3064.0, 3064.0]
[17.0, 18.0]
[742, 1014]
p03840
u107077660
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nif max(B) == 1 and B[0] == 0:\n\tprint(0)\nelse:\n\tans = 0\n\tans += B[0]\n\tif min(B[1:]) == 0:\n\t\tfor b in B[1:]:\n\t\t\tif b%2 == 0:\n\t\t\t\tans += 2\n\telif not sum([i%2 for i in B[1:]])%3:\n\t\tans += sum(B[1:])\n\telse:\n\t\tans += sum(B[1:])-1\n\tprint(ans)\n', 'A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nans = 0\nans += B[0]\nif min(B[1:]) == 0:\n\tfor b in B[1:]:\n\t\tif b%2 == 0:\n\t\t\tans += 2\nelif not sum([i%2 for i in B[1:]])%3:\n\tans += sum(B[1:])\nelse:\n\tans += sum(B[1:])-1\nprint(ans)\n', 'A = [int(i) for i in input().split()]\n\nans = 0\nans += B[0]\nif min(B[1:]) == 0:\n\tfor b in B[1:]:\n\t\tif b%2 == 0:\n\t\t\tans += 2\nelif not sum([i%2 for i in B[1:]])%3:\n\tans += sum(B[1:])\nelse:\n\tans += sum(B[1:])-1\nprint(ans)\n', 'A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nif max(B) == 1 and B[0] == 0:\n\tprint(0)\nelse:\n\tprint(B)\n\tans = 0\n\tans += B[0]\n\tif not sum([i%2 for i in B[1:]])%3:\n\t\tans += sum(B[1:])\n\telse:\n\t\tans += sum(B[1:])-1\n\tprint(ans)\n', 'A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nif max(B) == 1 and B[0] == 0:\n\tprint(0)\nelse:\n\tprint(B)\n\tans = 0\n\tans += B[0]\n\tif min(B[1:]) == 0:\n\t\tfor b in B[1:]:\n\t\t\tif b%2 == 0:\n\t\t\t\tans += 2\n\telif not sum([i%2 for i in B[1:]])%3:\n\t\tans += sum(B[1:])\n\telse:\n\t\tans += sum(B[1:])-1\n\tprint(ans)\n', 'A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nans = 0\nans += B[0]\nif min(B[1:]) == 0:\n\tfor b in B[1:]:\n\t\tans += b//2*2\nelif not sum([i%2 for i in B[1:]])%3:\n\tans += sum(B[1:])\nelse:\n\tans += sum(B[1:])-1\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s242373345', 's280129894', 's549668466', 's771602495', 's835153563', 's726013736']
[3188.0, 3188.0, 3064.0, 3064.0, 3192.0, 3192.0]
[163.0, 24.0, 23.0, 23.0, 23.0, 22.0]
[300, 243, 218, 240, 310, 232]
p03840
u118642796
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['I,O,T,J,L,S,Z = map(int,input().split())\nprint(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))\n', 'I,O,T,J,L,S,Z = map(int,input().split())\nprint(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))\n']
['Runtime Error', 'Accepted']
['s691443228', 's546495069']
[3188.0, 2940.0]
[18.0, 17.0]
[134, 127]
p03840
u227082700
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['I,O,R,J,L,S,Z=map(int,input().split())\nans=O\nm=min(I,J,L):\nI-=m\nJ-=m\nL-=m\nans+=m*3\nans+=I//2*2\nans+=J//2*2\nans+=L//2*2\nprint(ans)', 'I,O,R,J,L,S,Z=map(int,input().split())\na=(I//2+J//2+L//2)*2\nb=0\nif I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)\nprint(max(a,b))', 'I,O,R,J,L,S,Z=map(int,input().split())\na=(I//2+J//2+L//2)*2\nb=0\nif I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)\nprint(max(a,b)+O)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s617511759', 's880344144', 's966423542']
[2940.0, 3064.0, 3060.0]
[17.0, 17.0, 17.0]
[129, 128, 130]
p03840
u366886346
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['i,o,t,j,l,s,z=map(int,input().split())\nans=0\nans+=o\nif j==1 and l==1 and i==1:\n ans+=3\nelif j<2 or l<2 or i<2:\n ans+=0\nelif j%2==1 and l%2==1 and i%2==1:\n ans+=j+i+l\nelif j%2==1 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==0:\n ans+=j+i+l\nprint(ans)\n', 'i,o,t,j,l,s,z=map(int,input().split())\nans=0\nans+=o\nif j==1 and l==1 and i==1:\n ans+=3\nelif j<2 and l<2 and i<2:\n ans+=0\nelif j%2==1 and l%2==1 and i%2==1:\n ans+=j+i+l\nelif j%2==1 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==0:\n ans+=j+i+l\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s707001227', 's399126650']
[3064.0, 3064.0]
[18.0, 17.0]
[548, 550]
p03840
u391731808
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['A = {k:a for k,a in zip(list("IOTJLSZ"),map(int,input().split()))}\nm = min(A["I"],A["J"],A["L"])\nans = 0\nfor i in (0,1,m-1,m):\n ans = max(ans, 3*i + A["O"] + (A["I"]-i)//2 + (A["J"]-i)//2 + (A["L"]-i)//2)\nprint(ans)', 'A = {k:a for k,a in zip(list("IOTJLSZ"),map(int,input().split()))}\nm = min(A["I"],A["J"],A["L"])\nans = 0\nfor i in range(min(2,m+1)):\n ans = max(ans, 3*i + A["O"] + (A["I"]-i)//2*2 + (A["J"]-i)//2*2 + (A["L"]-i)//2*2)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s672757208', 's417925711']
[3064.0, 3064.0]
[17.0, 17.0]
[218, 230]
p03840
u536113865
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['i,o,_,j,l,_,_ = list(map(int,input().split()))\n\nans = (i//2)*4 + o*2 + (j//2)*4 + (l//2)*4\nif i&1 and j&1 and l&1: ans += 6\nprint(ans)\n', 'i,o,_,j,l,_,_ = list(map(int,input().split()))\n\nif i>0 and j>0 and l>0:\n ans = max((i//2)*2 + o + (j//2)*2 + (l//2)*2, ((i-1)//2)*2 + o + ((j-1)//2)*2 + ((l-1)//2)*2 +3)\nelse:\n ans = (i // 2) * 2 + o + (j // 2) * 2 + (l // 2) * 2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s725994102', 's148333159']
[2940.0, 3064.0]
[17.0, 17.0]
[135, 246]
p03840
u543954314
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['i,o,t,j,l,s,z = map(int, input().split())\nk = o*2\np = (i//2 + j//2 + l//2)*4\nq = 0\nif i*j*l:\n q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*4 + 6\nprint(k + max(p, q)) \n', 'i,o,t,j,l,s,z = map(int, input().split())\nk = o*2\np = (i//2 + j//2 + l//2)*4\nq = ((i-1)//2 + (j-1)//2 + (l-1)//2)*4 + 6\nprint(k + max(p, q)) ', 'i,o,t,j,l,s,z = map(int, input().split())\nk = o*2\np = (i//2 + j//2 + l//2)*4\nq = 0\nif i*j*k:\n q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*4 + 6\nprint(k + max(p, q)) ', 'i,o,t,j,l,s,z = map(int, input().split())\nk = o\np = (i//2 + j//2 + l//2)*2\nq = 0\nif i*j*l:\n q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*2 + 3\nprint(k + max(p, q)) \n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s123202514', 's519918771', 's533160049', 's212148059']
[2940.0, 3064.0, 3060.0, 2940.0]
[20.0, 17.0, 17.0, 17.0]
[160, 141, 159, 158]
p03840
u619819312
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['a=list(map(int,input().split()))\nk,h=b,b\nk+=a[0]-a[0]%2\nk+=a[3]-a[3]%2\nk+=a[4]-a[4]%2\nif min(a[0],a[3],a[4])>0:\n h+=3\n a[0],a[3],a[4]=a[0]-1,a[3]-1,a[4]-1\n h+=a[0]-a[0]%2\n h+=a[3]-a[3]%2\n h+=a[4]-a[4]%2\nprint(max(k,h))', 'a=list(map(int,input().split()))\nk,h=a[1],a[1]\nk+=a[0]-a[0]%2\nk+=a[3]-a[3]%2\nk+=a[4]-a[4]%2\nif min(a[0],a[3],a[4])>0:\n h+=3\n a[0],a[3],a[4]=a[0]-1,a[3]-1,a[4]-1\n h+=a[0]-a[0]%2\n h+=a[3]-a[3]%2\n h+=a[4]-a[4]%2\nprint(max(k,h))']
['Runtime Error', 'Accepted']
['s091146586', 's958604517']
[3316.0, 3064.0]
[23.0, 17.0]
[233, 239]
p03840
u623687794
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['i,o,t,j,l,s,z=map(int,input().split())\nansl=[o,o]\nansl[0]+=3+(max(0,(i-1)//2))*2+(max(0,(j-1)//2))*2+(max(0,(l-1)//2))*2\nansl[1]+=(i//2)*2+(j//2)*2+(l//2)*2\nprint(max(ansl))\n', 'i,o,t,j,l,s,z=map(int,input().split())\nansl=[o,o]\nansl[0]+=3+(max(0,(i-1)//2))*2+(max(0,(j-1)//2))*2+(max(0,(l-1)//2))*2\nansl[1]+=(i//2)*2+(j//2)*2+(l//2)*2\nif i>=1 and j>=1 and l>=1:\n print(max(ansl))\nelse:\n print(ansl[1])']
['Wrong Answer', 'Accepted']
['s876215501', 's659132897']
[3060.0, 3064.0]
[18.0, 17.0]
[174, 229]
p03840
u691018832
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['import math\n\na = list(map(int, input().split()))\nans = 0\ni = 2 * math.floor(0.5 * a[0])\n\nif a[5] or a[2] or a[6]:\n pass\nelse:\n if a[3] == a[4]:\n ans = ans + a[3]\n \n ans = ans + i + a[1]\n\nprint(ans)', 'import math\n\ndef xv(num):\n return 2 * math.floor(0.5 * num)\n\na = list(map(int, input().split()))\nans = 0\n\nQue = xv(a[0]) + xv(a[3]) + xv(a[4])\n\nif (a[3] or a[4]) == 0:\n pass\nelse:\n a[0] = a[0] - 1\n a[3] = a[3] - 1\n a[4] = a[4] - 1\n\n Qae = 3 + xv(a[0]) + xv(a[3]) + xv(a[4])\n\nans = ans + a[1] + max(Que,Qae)\nprint(ans)', 'import math\n\na = list(map(int, input().split()))\nans = 0\ni = 2 * math.floor(0.5 * a[0])\n\nif a[5] or a[2] or a[6]:\n pass\nelse:\n if a[3] == a[4]:\n ans = ans + a[3] * 2\n \n ans = ans + i + a[1]\n\nprint(ans)\n', 'a = list(map(int, input().split()))\n\nans = a[1] + 2*(a[0]//2 + a[4]//2 + a[3]//2)\nif a[0]>0 and a[3]>0 and a[4]>0:\n ans = max(ans, a[1] + 2*((a[0]-1)//2 + (a[3]-1)//2 + (a[4]-1)//2) + 3)\n \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s290661071', 's576944784', 's638751570', 's716555539']
[3060.0, 3064.0, 3060.0, 3064.0]
[17.0, 18.0, 17.0, 18.0]
[220, 335, 225, 201]
p03840
u729707098
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['a = [int(i) for i in input().split()]\nf = lambda x: max(0,x-x%2)\nprint(max(a[1]+f(a[0])+f(a[3])+f(a[4]),a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3))', 'a = [int(i) for i in input().split()]\nf = lambda x: x-x%2\nans = a[1]+f(a[0])+f(a[3])+f(a[4])\nif a[0] and a[3] and a[4]: ans = max(ans, a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s368611869', 's974972619']
[3064.0, 3064.0]
[17.0, 17.0]
[142, 183]
p03840
u752513456
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())\n\nt = min([aJ, aL, aI])\ns = min([aJ - 1, aL - 1])\nprint(3 * t + 2 * s + (aI - t) // 2 * 2 + aO)\n', 'aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())\n\nif aI * aJ * aL == 0:\n K = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO\nelse:\n K1 = ((aI - 1) // 2 + (aJ - 1) // 2 + (aL - 1) // 2) * 2 + aO + 3\n K2 = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO\n K = max([K1, K2])\n\nprint(K)']
['Wrong Answer', 'Accepted']
['s822477718', 's374339551']
[3188.0, 3064.0]
[33.0, 23.0]
[150, 280]
p03840
u813174766
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['a=list(map(int,input().split()))\nans=min(a[0],a[3],a[4])\na[0]-=ans\na[3]-=ans\na[4]-=ans\nans*=6\nans+=(a[0]//2*4)+(a[3]//2*4)+(a[4]//2*4)+a[1]*2\nprint(ans)', 'a=list(map(int,input().split()))\nans=min(a[0],a[3],a[4])\na[0]-=ans\na[3]-=ans\na[4]-=ans\nans*=3\nif(ans>0&&(a[0]%2+a[3]%2+a[4]%2==2)):\n ans+=1\nans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]\nprint(ans)\n', 'a=list(map(int,input().split()))\nans=min(a[0],a[3],a[4])\na[0]-=ans\na[3]-=ans\na[4]-=ans\nans*=3\nif(ans>0 and (a[0]%2+a[3]%2+a[4]%2==2)):\n ans+=1\nans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s287101589', 's609811950', 's473018859']
[3188.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[152, 198, 201]
p03840
u934019430
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
["#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\ndef f(s):\n _res = s[1]\n x,y,z = s[0],s[3],s[4]\n if ((x%2) + (y%2) + (z%2) > 1) and (x > 0 and y > 0 and z > 0):\n x = x - 1\n y = y - 1\n z = z - 1\n _res = res + 3\n _res = _res + x//2 + y//2 + z//2;\n return _res\n\n\ns = input().split(' ')\nprint(f(list(map(lambda x:int(x),s))))\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nfrom functools import reduce\n\ndef f(s):\n _res = s[1]\n a = [s[0],s[3],s[4]]\n if reduce(lambda x,y: x + y, list(map(lambda x: x%2,a))) > 1 and a[0] > 0 and a[1] > 0 and a[2] > 0 :\n _res = _res + 3\n a = list(map(lambda x: x - 1,a))\n a = list(map(lambda x: x - x % 2,a))\n _res = _res + a[0] + a[1] + a[2]\n return _res\n\n\ns = input().split(' ')\nprint(f(list(map(lambda x:int(x),s))))\n"]
['Wrong Answer', 'Accepted']
['s911399643', 's456150715']
[3192.0, 3828.0]
[23.0, 29.0]
[365, 458]
p03840
u969190727
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['i,o,t,j,l,s,z=map(int,input().split())\nans=0\nif i==0 or j==0 or l==0:\n ans+=o+(i//2)*2+min(j,l)*2\nelse:\n ans+=o+(i//2)*2+min(j,l)*2\n ans1=o+((i-1)//2)*2+max(0,min(j-1.l-1))*2\nprint(ans)', 'i,o,t,j,l,s,z=map(int,input().split())\nans=0\nif i==0 or j==0 or l==0:\n ans+=o+(i//2)*2+(j//2)*2+(l//2)*2\nelse:\n ans+=o+(i//2)*2+(j//2)*2+(l//2)*2\n ans1=o+((i-1)//2)*2+((j-1)//2)*2+((l-1)//2)*2+3\n ans=max(ans,ans1)\nprint(ans)']
['Runtime Error', 'Accepted']
['s684849875', 's641139179']
[2940.0, 3064.0]
[17.0, 17.0]
[188, 228]
p03840
u976162616
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['if __name__ == "__main__":\n AI,AO,AT,AJ,AL,AS,AZ = map(int, input().split())\n result = 0\n resAI = AI // 2\n\n result += 6 * resAI // 3\n resAI -= resAI // 3\n\n resAJAL = min(AJ, AL)\n result += 6 * resAJAL // 3\n resAJAL -= resAJAL // 3\n\n result += 3 * min(resAI, AO)\n tmp = min(resAI, AO)\n resAI -= tmp\n AO -= tmp\n\n result += 3 * min(resAJAL, AO)\n tmp = min(resAJAL, AO)\n resAJAL -= tmp\n AO -= tmp\n\n\n\n\n\n\n\n print (result)\n', 'if __name__ == "__main__":\n AI,AO,AT,AJ,AL,AS,AZ = map(int, input().split())\n result = 0\n resAI = AI // 2\n\n result += 6 * resAI // 3\n resAI -= resAI // 3\n\n result += 3 * min(resAI, AO)\n tmp = min(resAI, AO)\n resAI -= tmp\n AO -= tmp\n \n\n\n\n resAJAL = min(AJ, AL)\n result += 6 * resAJAL // 3\n resAJAL -= resAJAL // 3\n\n\n\n\n\n print (result)\n', 'def solve(A):\n # I + J + L\n res = 0\n I = A[0]\n J = A[3]\n L = A[4]\n\n O = A[1]\n if (I >= 1 and J >= 1 and L >= 1):\n tmp = 3 + ((I - 1) // 2 + (J - 1) // 2 + (L - 1) // 2) * 2 + O\n res = max(res, tmp)\n tmp = (I // 2 + J // 2 + L // 2) * 2 + O\n res = max(res, tmp)\n print (res)\n\n\nif __name__ == "__main__":\n A = list(map(int, input().split()))\n solve(A)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s446308042', 's767153969', 's172784008']
[3064.0, 3060.0, 3064.0]
[17.0, 17.0, 17.0]
[469, 378, 400]
p03840
u984276646
2,000
262,144
A _tetromino_ is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively. Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Here, the following rules must be followed: * When placing each tetromino, rotation is allowed, but reflection is not. * Each square in the rectangle must be covered by exactly one tetromino. * No part of each tetromino may be outside the rectangle. Snuke wants to form as large a rectangle as possible. Find the maximum possible value of K.
['A = list(map(int, input().split()))\nS = A[1] * 2\nS += (A[0] // 2) * 4\nif A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:\n A[4] -= 1\n A[5] -= 1\n S += 3\nS += (A[4] // 2) * 4 + (A[5] // 2) * 4\nprint(S)', 'A = list(map(int, input().split()))\nS = A[1]\nS += (A[0] // 2) * 2\nT = S\n if A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:\n S += (A[4] // 2) * 2 + (A[5] // 2) * 2\n A[4] -= 1\n A[5] -= 1\n T += 3\n T += (A[4] // 2) * 2 + (A[5] // 2) * 2\nprint(max(S, T))\n', 'A = list(map(int, input().split()))\nS = A[1]\nS += (A[0] // 2) * 2 + (A[3] // 2) * 2 + (A[4] // 2) * 2\nif A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 1:\n S += 3\nelif A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 0 and A[0] != 0:\n S += 1\nelif A[3] % 2 == 0 and A[4] % 2 == 1 and A[0] % 2 == 1 and A[3] != 0:\n S += 1\nelif A[3] % 2 == 1 and A[4] % 2 == 0 and A[0] % 2 == 1 and A[4] != 0:\n S += 1\nprint(S)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s083916228', 's147573672', 's400597564']
[3060.0, 2940.0, 3064.0]
[17.0, 18.0, 17.0]
[194, 258, 411]
p03848
u021548497
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import numpy as np\nn = int(input())\na = np.array([int(x) for x in input().split()])\nnp.sort(a)\nkey = True\nif n%2:\n key = False\nans = True\nfor i in range(n):\n if key:\n if a[i] != (i//2)*2+1:\n ans = False\n break\n else:\n if a[i] != ((i+1)//2)*2:\n ans = False\n break\n\nif ans:\n print(pow(2, n//2))\nelse:\n print(0)', 'n = int(input())\na = [int(x) for x in input().split()]\n\na.sort()\nans = True\nif n%2:\n key=0\n if a[0] != key:\n ans = False\n p = 1\nelse:\n key=1\n if a[0] != key or a[1] != key:\n ans = False\n p = 2\n\nfor i in range(p, n):\n if i%2 == n%2:\n key += 2\n if a[i] != key:\n ans = False\n break\n\nif ans:\n print(pow(2, n//2, 10**9+7))\nelse:\n print(0)\n']
['Wrong Answer', 'Accepted']
['s808183292', 's497464163']
[23504.0, 13880.0]
[186.0, 104.0]
[339, 359]
p03848
u024782094
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import sys\ndef input(): return sys.stdin.readline().strip()\nn=int(input())\na=sorted(list(map(int,input().split())))\nif n%2==0:\n l=[]\n for i in range(n//2):\n l.append(i*2+1)\n l.append(i*2+1)\nelse:\n l=[0]\n for i in range(n//2):\n l.append((i+1)*2)\n l.append((i+1)*2)\n\nprint(l)\n\nif a==l:\n print(2**(n//2))\nelse:\n print(0)', 'import sys\ndef input(): return sys.stdin.readline().strip()\nn=int(input())\na=sorted(list(map(int,input().split())))\nif n%2==0:\n l=[]\n for i in range(n//2):\n l.append(i*2+1)\n l.append(i*2+1)\nelse:\n l=[0]\n for i in range(n//2):\n l.append((i+1)*2)\n l.append((i+1)*2)\n\nif a==l:\n print(pow(2,n//2,1000000007))\nelse:\n print(0)']
['Wrong Answer', 'Accepted']
['s981510763', 's371248465']
[13880.0, 13880.0]
[110.0, 97.0]
[363, 366]
p03848
u063052907
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\n\n\nN = int(input())\nlstA = list(map(int, input().split()))\nmod = 10**9 + 7\ncountA = Counter(lstA)\nans = 0\n\nif N % 2:\n if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):\n ans = pow(2, N//2) // mod\nelse:\n if all(countA[i] == 2 for i in range(1, N, 2)):\n ans = pow(2, N//2) // mod\n\n\nprint(ans)\n', 'from collections import Counter\n\n\nN = int(input())\nlstA = list(map(int, input().split()))\nmod = 10**9 + 7\ncountA = Counter(lstA)\nans = 0\n\nif N % 2:\n if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):\n ans = 2**(N//2) % mod\nelse:\n if all(countA[i] == 2 for i in range(1, N, 2)):\n ans = 2**(N//2) % mod\n\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s983475342', 's093385285']
[14820.0, 14820.0]
[70.0, 66.0]
[358, 350]
p03848
u102960641
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n = int(input())\na = list(map(int, input().split()))\na.sort()\nb = True\nfor i,j in enumerate(a):\n if n % 2:\n if j != ((i+1) // 2) * 2:\n b = False\n break\n else:\n if j != (i // 2) * 2 + 1:\n b = False\n break\nif b == True:\n print(((n // 2) ** 2) % mod)\nelse:\n print(0)', 'n = int(input())\na = list(map(int, input().split()))\na.sort()\nb = True\nmod = 10 ** 9 + 7\nfor i,j in enumerate(a):\n if n % 2:\n if j != ((i+1) // 2) * 2:\n b = False\n break\n else:\n if j != (i // 2) * 2 + 1:\n b = False\n break\nif b == True:\n print(pow(2,n//2,mod))\nelse:\n print(0)\n']
['Runtime Error', 'Accepted']
['s301336839', 's620313262']
[13880.0, 13880.0]
[103.0, 102.0]
[293, 306]
p03848
u131881594
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\ndef powmod(a,n,m): #a^n mod m\n ans=1\n while n!=0:\n if n&1: ans*=a\n a**=2\n n>>=1\n return ans\nn=int(input())\na=list(map(int,input().split()))\na.sort()\ndic=Counter(a)\nif n%2==0:\n temp={}\n for i in range(1,n,2):\n temp[i]=2\n if temp!=dict(dic):\n print(0)\n exit()\nelse:\n temp={}\n temp[0]=1\n for i in range(0,n,2):\n temp[i]=2\n if temp!=dict(dic):\n print(0)\n exit()\nprint(powmod(2,n//2,10**9+7))', 'from collections import Counter\n\ndef powmod(a,n,m): #a^n mod m\n ans=1\n while n!=0:\n if n&1: ans=ans*a%m\n a=a*a%m\n n>>=1\n return ans%m\n\nn=int(input())\na=list(map(int,input().split()))\na.sort()\ndic=Counter(a)\nif n%2==0:\n temp={}\n for i in range(1,n,2):\n temp[i]=2\n if temp!=dict(dic):\n print(0)\n exit()\nelse:\n temp={}\n temp[0]=1\n for i in range(2,n,2):\n temp[i]=2\n if temp!=dict(dic):\n print(0)\n exit()\nprint(powmod(2,n//2,10**9+7))']
['Wrong Answer', 'Accepted']
['s563598598', 's173227464']
[24676.0, 24732.0]
[92.0, 89.0]
[512, 523]
p03848
u169138653
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nd=dict()\nfor i in range(n):\n if a[i] not in d:\n d[a[i]]=1\n else:\n d[a[i]]+=1\nd=sorted(list(d.items()))\nif n%2:\n for i in range(len(d)):\n if i==0:\n if d[i][0]!=0 or d[i][1]!=1:\n print(0)\n exit()\n else:\n if d[i][0]!=i*2 or d[i][1]!=2:\n print(0)\n exit()\n print(pow(2,len(d)-1,mod)\nelse:\n for i in range(len(d)):\n if d[i][0]!=2*i+1 or d[i][1]!=2:\n print(0)\n exit()\n print(2,len(d),mod)', 'n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nd=dict()\nfor i in range(n):\n if a[i] not in d:\n d[a[i]]=1\n else:\n d[a[i]]+=1\nd=sorted(list(d.items()))\nif n%2:\n for i in range(len(d)):\n if i==0:\n if d[i][0]!=0 or d[i][1]!=1:\n print(0)\n exit()\n else:\n if d[i][0]!=i*2 or d[i][1]!=2:\n print(0)\n exit()\n print(pow(2,len(d)-1,mod))\nelse:\n for i in range(len(d)):\n if d[i][0]!=2*i+1 or d[i][1]!=2:\n print(0)\n exit()\n print(pow(2,len(d),mod))']
['Runtime Error', 'Accepted']
['s167648925', 's431158748']
[3064.0, 15096.0]
[17.0, 94.0]
[510, 516]
p03848
u193264896
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
["import sys\nfrom collections import defaultdict\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(readline())\n A = list(map(int, readline().split()))\n A.sort()\n if N % 2 == 0:\n for i in range(0, N, 2):\n if A[i] == A[i + 1] == i + 1:\n continue\n else:\n print(0)\n sys.exit()\n else:\n for i in range(1, N, 2):\n if A[i] == A[i + 1] == i + 1:\n continue\n else:\n print(0)\n sys.exit()\n if A[0] != 0:\n print(0)\n sys.exit()\n print(pow(2, (N + 1) // 2, MOD))\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom collections import defaultdict\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(readline())\n A = list(map(int, readline().split()))\n A.sort()\n if N % 2 == 0:\n for i in range(0, N, 2):\n if A[i] == A[i + 1] == i + 1:\n continue\n else:\n print(0)\n sys.exit()\n else:\n for i in range(1, N, 2):\n if A[i] == A[i + 1] == i + 1:\n continue\n else:\n print(0)\n sys.exit()\n if A[0] != 0:\n print(0)\n sys.exit()\n print(pow(2, N // 2, MOD))\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s316749875', 's194462299']
[19852.0, 19724.0]
[71.0, 72.0]
[781, 775]
p03848
u212328220
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import defaultdict,Counter\nn = int(input())\nal = list(map(int, input().split()))\n\nc_al = Counter(al)\n\nif n % 2 == 0 and 0 not in c_al.values():\n print(int(2**(n/2))%(10**9) + 7)\nelif n % 2 != 0 and c_al[0] == 1:\n print(int(2 ** (n // 2))%(10**9) + 7)\nelse:\n print(0)', 'from collections import Counter\n\nn = int(input())\nal = list(map(int, input().split()))\n\nc_al = Counter(al)\nprint(c_al)\nmod = int(10**9 + 7)\n\nif n % 2 == 0:\n for k,v in c_al.items():\n if v != 2:\n print(0)\n exit()\n print((2 ** (n / 2)) % mod)\nelif n % 2 != 0:\n for k, v in c_al.items():\n if k == 0:\n if v != 1:\n print(0)\n exit()\n elif v != 2:\n print(0)\n exit()\n print((2 ** (n // 2)) % mod)', 'from collections import Counter\n\nn = int(input())\nal = list(map(int, input().split()))\n\nc_al = Counter(al)\n\nif n % 2 == 0:\n for k,v in c_al.items():\n if v != 2:\n print(0)\n exit()\n print(pow(2, n // 2, 10 ** 9 + 7))\n\nelif n % 2 != 0:\n for k, v in c_al.items():\n if k == 0:\n if v != 1:\n print(0)\n exit()\n elif v != 2:\n print(0)\n exit()\n print(pow(2, n // 2, 10 ** 9 + 7))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s139494480', 's884405394', 's048063449']
[14820.0, 24984.0, 20624.0]
[57.0, 96.0, 67.0]
[293, 506, 487]
p03848
u216752093
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n=int(input())\na=list(map(int,input().split()))\na.sort()\n\nif a[0]==0:\n a.remove(0)\n sta=0\nelse:\n sta=1\nfor i in range(1,len(a),2):\n if a[i]!=a[i-1] or a[i]%2!=sta or a[i]!=2*(i+1)-sta:\n print(0)\n exit()\nans=2**(len(a)//2)\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\na.sort()\n\nif a[0]==0:\n a.remove(0)\n sta=0\nelse:\n sta=1\nfor i in range(1,len(a),2):\n if a[i]!=a[i-1] or a[i]%2!=sta or a[i]!=i+1-sta:\n print(0)\n exit()\nans=2**(len(a)//2)\nprint(ans%(10**9+7))']
['Wrong Answer', 'Accepted']
['s014484486', 's998298998']
[13880.0, 14008.0]
[76.0, 96.0]
[258, 264]
p03848
u266014018
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
["def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n n = int(input())\n mod = 10**9 + 7\n a.sort()\n check = [i+1 - (i+n)%2 for i in range(n)]\n if a != check:\n print(0)\n return\n else:\n ans = pow(2, n//2, mod)\n print(ans)\n\n\n\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n n = int(input())\n a = map(int, input().split())\n mod = 10**9 + 7\n a.sort()\n check = [i+1 - (i+n)%2 for i in range(n)]\n if a != check:\n print(0)\n return\n else:\n ans = pow(2, n//2, mod)\n print(ans)\n\n\n\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n n = int(input())\n a = list(map(int, input().split()))\n mod = 10**9 + 7\n a.sort()\n check = [i+1 - (i+n)%2 for i in range(n)]\n if a != check:\n print(0)\n return\n else:\n ans = pow(2, n//2, mod)\n print(ans)\n\n\n\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s513585353', 's732066428', 's401123754']
[9104.0, 17092.0, 20556.0]
[27.0, 35.0, 77.0]
[336, 370, 376]
p03848
u281610856
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\nmod = 10 ** 9 + 7\nans = 0\nn = int(input())\nA = list(map(int, input().split()))\nc = Counter(A).most_common()\nval, cnt = zip(*c)\nval = sorted(list(val))\ncnt = sorted(list(cnt))\nif n % 2 == 0:\n if cnt == [2] * (n // 2) and val == [i for i in range(n) if i % 2 != 0]:\n ans = (n // 2) ** 2\nelse:\n if cnt.count(0) == 1 and cnt == [1] + [2] * (n // 2) and val == [i for i in range(n) if i % 2 == 0]:\n ans = (n // 2) ** 2\nprint(ans % mod)\n', 'from collections import Counter\nmod = 10 ** 9 + 7\nans = 0\nn = int(input())\nA = list(map(int, input().split()))\nc = Counter(A)\nflag = True\nif n % 2 == 0:\n odd = 1\n for val, cnt in sorted(c.items()):\n # print(val, cnt)\n if cnt == 2 and val == odd:\n odd += 2\n else:\n flag = False\n break\nelse:\n even = 0\n for val, cnt in sorted(c.items()):\n # print(val, cnt)\n if val == 0 and cnt == 1:\n even += 2\n continue\n if val == even and cnt == 2:\n even += 2\n continue\n else:\n flag = False\n break\nif flag:\n ans = pow(2, n // 2, mod)\nelse:\n ans = 0\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s014773706', 's665885587']
[17372.0, 16088.0]
[96.0, 77.0]
[483, 710]
p03848
u302957509
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = map(int, input().split())\n\nif N%2 == 0:\n count = [(2 if i%2 == 1 else 0) for i in range(N)]\nelse:\n count = [(2 if i%2 == 0 else 0) for i in range(N)]\n count[0] = 1\n\nfor a in A:\n count[a] -= 1\n if count[a] < 0:\n print(0)\n break\nelse:\n print(2**(N//2)/(10**9+7))', 'N = int(input())\nA = map(int, input().split())\n\nif N%2 == 0:\n count = [(2 if i%2 == 1 else 0) for i in range(N)]\nelse:\n count = [(2 if i%2 == 0 else 0) for i in range(N)]\n count[0] = 1\n\nfor a in A:\n count[a] -= 1\n if count[a] < 0:\n print(0)\n break\nelse:\n print(2**(N//2)%(10**9+7))']
['Wrong Answer', 'Accepted']
['s132144732', 's274561406']
[10808.0, 10740.0]
[79.0, 82.0]
[313, 313]
p03848
u305366205
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n = int(input())\na = sorted(list(map(int, input().split())))\nif n % 2 == 1:\n for i in range(0, n, 2):\n if i == 0 and a[i] != 0:\n print(0)\n exit()\n elif a[i] != a[i + 1] or a[i] != 2 * i:\n print(0)\n exit()\nelse:\n for i in range(0, n, 2):\n if a[i] != a[i + 1] or a[i] != 2 * i + 1:\n print(0)\n exit()\nprint(2 ** (n // 2))', 'n = int(input())\na = sorted(list(map(int, input().split())))\nif n % 2 == 1 and a[0] != 0:\n print(0)\n exit()\nfor i in range(n % 2, n, 2):\n if a[i] != a[i + 1] or a[i] != i + 1:\n print(0)\n exit()\nprint(2 ** (n // 2) % (10 ** 9 + 7))']
['Runtime Error', 'Accepted']
['s035654106', 's002416012']
[13880.0, 13880.0]
[78.0, 91.0]
[411, 253]
p03848
u397531548
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import collections\nN=int(input())\nA=list(map(int,input().split()))\nif N%2==1:\n if 0 not in A:\n print(0)\n else:\n B=A.remove(0)\n Bc=dict(collections.Counter(B))\n for i in Bc.keys():\n if Bc[i]!=2:\n print(0)\n break\n else:\n print(2**(B//2)%(10**9+7))\nelse:\n Bc=dict(collections.Counter(A))\n for i in Bc.keys():\n if Bc[i]!=2:\n print(0)\n break\n else:\n print(2**(B//2)%(10**9+7)) ', 'import collections\nN=int(input())\nA=list(map(int,input().split()))\nif N%2==1:\n if 0 not in A:\n print(0)\n else:\n A.remove(0)\n Bc=dict(collections.Counter(A))\n for i in Bc.keys():\n if Bc[i]!=2:\n print(0)\n break\n else:\n print((2**(len(A)//2))%(10**9+7))\nelse:\n Bc=dict(collections.Counter(A))\n for i in Bc.keys():\n if Bc[i]!=2:\n print(0)\n break\n else:\n print((2**(len(A)//2))%(10**9+7)) ']
['Runtime Error', 'Accepted']
['s806803455', 's442304040']
[16352.0, 16352.0]
[70.0, 63.0]
[521, 533]
p03848
u413165887
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
["import sys\nn = int(input())\na = list(map(int, input().split(' ')))\n\na.sort()\nif n%2 == 0:\n for i in range(n-1):\n if i%2 == 0:\n if a[i] == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n else:\n if a[i]+2 == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n print((2 ** (n//2)) % (10**9+7))\nelse:\n if a[0] == 0:\n for i in range(1, n-1):\n if i%2 == 1:\n if a[i] == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n else:\n if a[i]+2 == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n print(2**((n-1)/2)%(10**9+7))\n else:\n print(0)\n sys.exit()", "def main():\n import sys\n n = int(input())\n a = list(map(int, input().split(' ')))\n if n%2 == 1:\n a.append(0)\n a.sort()\n for i in range(n-1):\n if i%2 == 0:\n if a[i] == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n else:\n if a[i]+2 == a[i+1]:\n continue\n else:\n print(0)\n sys.exit()\n result = 2 ** (n//2)\n print(result % (10**9+7))\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s174926434', 's005804371']
[14008.0, 14008.0]
[104.0, 92.0]
[917, 547]
p03848
u422590714
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
["n = int(input())\nlst = [int(e) for e in input().split(' ')]\n\nlst = sorted(lst)\n\nvalid_list = []\nif n % 2 == 1:\n \n valid_list.append(0)\n for i in range(1, int((n + 1) / 2)):\n valid_list.append(i * 2)\n valid_list.append(i * 2)\n if lst == valid_list:\n print((2 ** (((n - 1) / 2) / 5) % 1000000007) ** 5 % 1000000007)\n else:\n print(0)\nelse:\n for i in range(1, int((n / 2) + 1)):\n valid_list.append((i * 2) - 1)\n valid_list.append((i * 2) - 1)\n if lst == valid_list:\n print(int(2 ** ((n / 2) / 5) % 1000000007) ** 5 % 1000000007)\n else:\n print(0)\n", "\n\nn = int(input())\nlst = [int(e) for e in input().split(' ')]\n\nlst = sorted(lst)\nresult = 1\n\nvalid_list = []\nif n % 2 == 1:\n \n valid_list.append(0)\n for i in range(1, int((n + 1) / 2)):\n valid_list.append(i * 2)\n valid_list.append(i * 2)\n if lst == valid_list:\n for i in range(int((n - 1) / 2)):\n result = (result * 2) % 1000000007\n print(int(result))\n else:\n print(0)\nelse:\n for i in range(1, int((n / 2) + 1)):\n valid_list.append((i * 2) - 1)\n valid_list.append((i * 2) - 1)\n if lst == valid_list:\n for i in range(int(n / 2)):\n result = (result * 2) % 1000000007\n print(int(result))\n else:\n print(0)\n"]
['Runtime Error', 'Accepted']
['s004258361', 's437300088']
[13880.0, 13880.0]
[100.0, 107.0]
[630, 789]
p03848
u455696302
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = [int(i) for i in input().split()]\ncount = [0 for _ in range(N+1)]\n\nif N % 2 == 0:\n if len(set(A)) != int(N/2):\n print(0)\n exit()\nelse:\n if len(set(A)) != int(N/2)+1:\n print(0)\n exit()\n\nfor i in A:\n count[i] += 1\n\nres = 1\nfor i in range(N+1):\n if count[i] == 2:\n res *= 2\n else:\n if i != 0 and N%2 != 0:\n print(0)\n exit()\n\nprint(res % (10**9+7))', 'N = int(input())\nA = [int(i) for i in input().split()]\ncount = [0 for _ in range(N+1)]\n\nif N % 2 == 0:\n if len(set(A)) != int(N/2):\n print(0)\n exit()\nelse:\n if len(set(A)) != int(N/2)+1:\n print(0)\n exit()\n\nfor i in A:\n count[i] += 1\n\nres = 1\nfor i in range(N+1):\n if count[i] == 2:\n res *= 2\n else:\n if i != 0 and N%2 != 0:\n print(0)\n exit()\n\nprint(res)', 'N = int(input())\nA = [int(i) for i in input().split()]\ncount = [0 for _ in range(N+1)]\n\nif N % 2 == 0:\n if len(set(A)) != int(N/2):\n print(0)\n exit()\nelse:\n if len(set(A)) != int(N/2)+1:\n print(0)\n exit()\n\nfor i in A:\n count[i] += 1\n\n#print(count)\n\nres = 1\nfor i in range(N+1):\n if count[i] == 2:\n res *= 2\n else:\n if count[i] != 0:\n if N % 2 == 1 and i != 0: \n print(0)\n exit()\n\nprint(res % (10**9+7))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s531018132', 's675819592', 's190419495']
[13880.0, 13880.0, 14008.0]
[141.0, 146.0, 143.0]
[444, 432, 500]
p03848
u485137520
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nco.sort()\nif 0 in co:\n co.remove(0)\n\nif len(co) %2 == 0:\n print(0)\n quit()\n\nelse:\n print(0)\n quit()\n\n\nfor index in range(len(a_list)[:-1:2]):\n if not a_list[index] == a_list[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nco.sort()\nif 0 in co:\n co.remove(0)\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\n\n\nfor index in range(len(a_list)[:-1:2]):\n if not a_list[index] == a_list[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', 'n = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nco.sort()\nif 0 in co or len(co) % 2 == 1:\n co.remove(0)\nelse:\n print(0)\n quit()\n\n\nfor index in range(len(a_list)[:-1:2]):\n if not a_list[index] == a_list[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\n\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[:-1:2]:\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\n\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[:-1:2]:\n print(co[index])\n print(co[index+1])\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[:-2:2]:\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', 'n = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[::2]:\n print(co[index])\n print(co[index+1])\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\n\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nco.sort()\nif 0 in co or len(co) % 2 == 1:\n co.remove(0)\nelse:\n print(0)\n quit()\n\n\nfor index in range(len(a_list)[::2]):\n if not a_list[index] == a_list[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', 'n = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nco.sort()\nif 0 in co:\n co.remove(0)\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nelse:\n print(0)\n quit()\n\n\nfor index in range(len(a_list)[:-1:2]):\n if not a_list[index] == a_list[index + 1]:\n print(0)\n quit()\n\n\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', '\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[:-1:2]:\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))', 'from math import factorial, floor\nn = int(input())\na_list = list(map(int, input().split()))\n\nco = a_list.copy()\nif 0 in co:\n co.remove(0)\nco.sort()\n\n\nif not len(co) % 2 == 0:\n print(0)\n quit()\n\nfor index in range(len(a_list))[:-1:2]:\n if not co[index] == co[index + 1]:\n print(0)\n quit()\n\n\nprint(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s090200745', 's092607017', 's145393213', 's189130759', 's191471418', 's401600112', 's464258818', 's510353646', 's748976521', 's779929400', 's476941803']
[13880.0, 13880.0, 14008.0, 13880.0, 14008.0, 13812.0, 14008.0, 14008.0, 13880.0, 13880.0, 13812.0]
[81.0, 80.0, 81.0, 88.0, 164.0, 86.0, 167.0, 83.0, 82.0, 88.0, 87.0]
[369, 344, 342, 336, 380, 333, 376, 342, 373, 333, 366]
p03848
u519968172
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n=int(input())\na=list(map(int,input().split()))\n\nb=[0 for _ in range(n)]\nfor i in range(n):\n b[a[i]]+=1\nprint(b)\nc= 1 if n%2==0 else 0\n\nif n%2==1:\n if b[0]!=1:\n print(0)\n else:\n for i in range(2,n,2):\n if b[i]!=2:\n print(0)\n break\n else:\n print(2**(n//2))\nelse:\n for i in range(1,n,2):\n if b[i]!=2:\n print(0)\n break\n else:\n print(2**(n//2)) \n', 'n=int(input())\na=list(map(int,input().split()))\n\nb=[0 for _ in range((n+1)//2)]\nfor i in range(n):\n b[a[i]//2]+=1\nif n%2==0:\n for i in range(n//2):\n if b[i]!=2:\n print(0)\n break\n else:\n print(pow(2,n//2,10**9+7))\nelse:\n if b[0]!=1:\n print(0)\n else:\n for i in range(1,n//2+1):\n if b[i]!=2:\n print(0)\n break\n else:\n print(pow(2,n//2,10**9+7)) \n']
['Wrong Answer', 'Accepted']
['s818590589', 's441736521']
[26124.0, 20492.0]
[2231.0, 72.0]
[405, 401]
p03848
u527993431
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N=int(input())\nA=list(map(int,input().split()))\nif N%2==0:\n\tfor i in range (N):\n\t\tA[i]%2!=1:\n\t\t\tprint(0)\n\t\t\texit()\n\tprint((2**N)%(10**9+7))\nelse:\n\tfor i in range (N):\n\t\tA[i]%2!=0:\n\t\t\tprint(0)\n\t\t\texit()\n\tif min(A)!=0:\n\t\tprint(0)\n\t\texit()\n\telse:\n\t\tprint((2**(N-1))%(10**9+7))', 'N=int(input())\nA=list(map(int,input().split()))\nif N%2==0:\n\tfor i in range (N):\n\t\tif A[i]%2 != 1:\n\t\t\tprint(0)\n\t\t\texit()\n\tprint((2**(N//2))%(10**9+7))\nelse:\n\tfor i in range (N):\n\t\tif A[i]%2!=0:\n\t\t\tprint(0)\n\t\t\texit()\n\tif min(A)!=0 or A.count(0)!=1:\n\t\tprint(0)\n\t\texit()\n\telse:\n\t\tprint((2**((N-1)//2))%(10**9+7))']
['Runtime Error', 'Accepted']
['s692676437', 's999195842']
[2940.0, 13812.0]
[17.0, 52.0]
[273, 308]
p03848
u536113865
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['mod = 10**9+7\n\nn = int(input())\na = sorted(f())\nif n&1:\n if all([a[i] == i+i%2 for i in range(n)]):\n print(1<<((n-1)//2)%mod)\n else:\n print(0)\nelse:\n if all([a[i] == i+(i+1)%2 for i in range(n)]):\n print(1<<(n//2)%mod)\n else:\n print(0)', 'f = lambda: list(map(int,input().split()))\nmod = 10**9+7\n\nn = int(input())\na = sorted(f())\nif n&1:\n if all([a[i] == i+i%2 for i in range(n)]):\n print(2**(n//2)%mod)\n else:\n print(0)\nelse:\n if all([a[i] == i+(i+1)%2 for i in range(n)]):\n print(2**(n//2)%mod)\n else:\n print(0)\n']
['Runtime Error', 'Accepted']
['s247060986', 's392096951']
[3064.0, 14004.0]
[18.0, 95.0]
[275, 315]
p03848
u541568482
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import sys\n\ncin = sys.stdin\ncin = open("in.txt", "r")\n\nMODULO = int(10**9+7)\nN = int(cin.readline())\nA = list(map(int, cin.readline().split()))\npos = [0]*(N)\nif (N%2==1):\n pos[N//2+1]=1\nfor ai in A:\n if (ai+N)%2==0:\n print(0)\n exit()\n pos[ai]+=1\n if pos[ai]>2:\n print(0)\n exit()\ncnt = 1\nfor i in range(N//2):\n cnt = cnt * 2 % MODULO\nprint(cnt)', 'import sys\n\ncin = sys.stdin\n#cin = open("in.txt", "r")\n\nMODULO = int(10**9+7)\nN = int(cin.readline())\nA = list(map(int, cin.readline().split()))\npos = [0]*(N+1)\nif (N%2==1):\n pos[0]=1\nfor ai in A:\n if (ai+N)%2==0 or ai>=N or ai<0:\n print(0)\n exit()\n pos[ai]+=1\n if pos[ai]>2:\n print(0)\n exit()\ncnt = 1\nfor i in range(N//2):\n cnt = cnt * 2 % MODULO\nprint(cnt)']
['Runtime Error', 'Accepted']
['s940034262', 's052863617']
[3064.0, 13876.0]
[22.0, 104.0]
[386, 401]
p03848
u561083515
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = sorted([int(i) for i in input().split()], reverse=True)\n\nfrom itertools import groupby\n\ngr = groupby(A)\n\nans = 1\nif N % 2 == 0:\n for _,group in gr:\n if len(tuple(group)) != 2:\n print(0)\n exit()\n else:\n ans *= 2\nelse:\n for key,group in gr:\n if len(tuple(group)) != 2:\n if key == 0 and len(tuple(group)) == 1:\n continue\n else:\n print(0)\n exit()\n else:\n ans *= 2\n\nprint(ans)', 'N = int(input())\nA = [int(i) for i in input().split()]\n\nMOD = 10**9+7\n\nfrom collections import Counter\n \nfor key,count in sorted(Counter(A).items(), key=lambda x:x[0]):\n if key == 0 and N % 2 == 1:\n continue\n if count == 2 and key % 2 != N % 2:\n continue\n print(0)\n exit()\n \n\nif N % 2 == 1:\n N -= 1\n \nprint(2 ** (N//2) % MOD)']
['Wrong Answer', 'Accepted']
['s107692106', 's833908088']
[13940.0, 15904.0]
[176.0, 84.0]
[537, 379]
p03848
u667024514
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import math\nn = int(input())\nlis = list(map(str,input().split()))\nli = [0 for _ in range(math.ceil(n / 2))]\n\nfor i in range(n):\n li[math.floor(lis[i] / 2)] += 1\nfor i in range(len(li)):\n if n % 2 == 1 and i == 0:\n if li[i] != 1:\n print("0")\n exit()\n else:\n if li[i] != 2:\n print("0")\n exit()\nprint(2 ** (math.floor(n/2)))', 'n = int(input())\nlis = list(map(int,input().split()))\nlis.sort()\nif n % 2 == 1:\n if lis[0] != 0:\n print("0")\n exit()\n else:key = 0\nelse:key = -1\nfor i in range(n//2):\n if lis[i*2+key+1] != lis[i*2+key+2] or lis[i*2+key+2] != 2*(i+1) + key:\n print("0")\n exit()\nans = 1\nfor i in range(n//2):\n ans *= 2\n ans %= 10 ** 9 +7\nprint(ans)']
['Runtime Error', 'Accepted']
['s434999877', 's256530231']
[10740.0, 13812.0]
[34.0, 118.0]
[350, 372]
p03848
u667084803
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]', 'def power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\nif N%2:\n correct = [0]\n for i in range(N//2):\n correct += [(i+1)*2]*2\nelse:\n correct = []\n for i in range(N//2):\n correct += [i*2+1]*2\nprint(A, correct)\nif A == correct:\n print(power_func(2, N//2, MOD))\nelse:\n print(0)', 'def power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\nif N%2:\n correct = [0]\n for i in range(N//2):\n correct += [i*2]*2\nelse:\n correct = []\n for i in range(N//2):\n correct += [i*2+1]*2\nif A == correct:\n print(power_func(2, N//2, MOD))\nelse:\n print(0)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]\n if A==B or A==C:\n print(2**N%(10**9+7))\n else:\n print(-1)\nelse:\n B+=[0]\n C+=[1]\n for i in range(0,int(N/2)):\n B+=[2*i+2,2*i+2]\n C+=[2*i+3,2*i+3]\n if A==B or A==C:\n print(2**(N-1)%(10**9+7))\n else: \n print(-1)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]\n if A==B or A==C:\n# ans=2**(N/2)\n print(int(ans)%(10**9+7))\n else:\n print(0)\nelse:\n B+=[0]\n C+=[1]\n for i in range(0,int(N/2)):\n B+=[2*i+2,2*i+2]\n C+=[2*i+3,2*i+3]\n if A==B or A==C:\n# ans=2**((N-1)/2)\n print(int(ans)%(10**9+7))\n else: \n print(0)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]\n if A==B or A==C:\n ans=2**(N/2)\n# print(int(ans)%(10**9+7))\n else:\n print(0)\nelse:\n B+=[0]\n C+=[1]\n for i in range(0,int(N/2)):\n B+=[2*i+2,2*i+2]\n C+=[2*i+3,2*i+3]\n if A==B or A==C:\n ans=2**((N-1)/2)\n# print(int(ans)%(10**9+7))\n else: \n print(0)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]\n if A==B or A==C:\n print(int(2**(N/2))%(10**9+7))\n else:\n print(0)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nC=[]\nans=2^10\nif N%2==0:\n for i in range(0,int(N/2)):\n B+=[2*i,2*i]\n C+=[2*i+1,2*i+1]\n if A==B or A==C:\n# ans=2**(N/2)\n print(int(ans)%(10**9+7))\n else:\n print(0)\nelse:\n B+=[0]\n C+=[1]\n for i in range(0,int(N/2)):\n B+=[2*i+2,2*i+2]\n C+=[2*i+3,2*i+3]\n if A==B or A==C:\n# ans=2**((N-1)/2)\n print(int(ans)%(10**9+7))\n else: \n print(0)', 'def power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n\nMOD = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\nif N%2:\n correct = [0]\n for i in range(N//2):\n correct += [(i+1)*2]*2\nelse:\n correct = []\n for i in range(N//2):\n correct += [i*2+1]*2\n \nif A == correct:\n print(power_func(2, N//2, MOD))\nelse:\n print(0)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s060679361', 's210543320', 's212533023', 's545347162', 's556352649', 's635130620', 's708172561', 's798939390', 's073204613']
[16484.0, 13880.0, 13880.0, 16612.0, 16612.0, 16228.0, 16612.0, 16228.0, 13880.0]
[112.0, 114.0, 94.0, 110.0, 112.0, 111.0, 111.0, 111.0, 96.0]
[171, 478, 456, 406, 448, 448, 246, 457, 465]
p03848
u677440371
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = [int(i) for i in input().split()]\n\ncheck = True\nA = sorted(A)\nprint(A)\nif N % 2 == 0:\n for i in range(N):\n if i % 2 == 0 and A[i] != i + 1:\n check = False\n if i % 2 == 1 and A[i] != i:\n check = False\n\nif N % 2 != 0:\n for i in range(N):\n if i % 2 == 0 and A[i] != i:\n check = False\n if i % 2 == 1 and A[i] != i + 1:\n check = False\n\nif check:\n print((2 ** (N // 2)) % (10 ** 9 + 7))\nelse:\n print(0)\n', 'N = int(input())\nA = [int(i) for i in input().split()]\n\ncheck = True\nA = sorted(A)\nif N % 2 == 0:\n for i in range(N):\n if i % 2 == 0 and A[i] != i + 1:\n check = False\n if i % 2 == 1 and A[i] != i:\n check = False\n\nif N % 2 != 0:\n for i in range(N):\n if i % 2 == 0 and A[i] != i:\n check = False\n if i % 2 == 1 and A[i] != i + 1:\n check = False\n\nif check:\n print((2 ** (N // 2)) % (10 ** 9 + 7))\nelse:\n print(0)\n']
['Wrong Answer', 'Accepted']
['s547035447', 's894026199']
[13880.0, 13940.0]
[122.0, 109.0]
[502, 493]
p03848
u698479721
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import sys\nN = int(input())\nA = list(map(int, input().split()))\nif N%2 == 1:\n if A.count(0) != 1:\n print(0)\n sys.exit()\n i = 1\n while i <= N//2:\n if A.count(2*i) != 2:\n print(0)\n sys.exit()\n i += 1\n j = 0\n ans = 1\n while j <= N//2:\n ans = ans*2\n j += 1\n print(ans)\nif N%2 == 0:\n i = 1\n while i <= N//2:\n if A.count(2*i-1) != 2:\n print(0)\n sys.exit()\n i += 1\n j = 0\n ans = 1\n while j < N//2:\n ans = ans*2\n j += 1\n print(ans)', 'import sys\ndef coun(n):\n i = 0\n ans = 1\n while i < n:\n ans = (ans*2)%(10**9+7)\n i += 1\n return ans\nN = int(input())\nA = list(map(int, input().split()))\nA.sort()\nif len(A)%2 == 1:\n if A[0]!=0:\n print(0)\n sys.exit()\n i = 1\n while i <= len(A)//2:\n if A[2*i-1]==2*i and A[2*i]==2*i:\n i += 1\n else:\n print(0)\n sys.exit()\n print(coun(N//2))\n\nif len(A)%2 == 0:\n i = 0\n while i < N//2:\n if A[2*i] == 2*i+1 and A[2*i+1] == 2*i+1:\n i += 1\n else:\n print(0)\n sys.exit()\n print(coun(N//2))']
['Wrong Answer', 'Accepted']
['s814174458', 's509879734']
[14008.0, 14008.0]
[2104.0, 108.0]
[486, 541]
p03848
u703890795
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A)\nf = True\nif N%2 == 1:\n for i in range(N):\n if A[i] != ((i+1)//2)*2:\n f = False\n break\nelse:\n for i in range(N):\n if A[i] != (i//2)*2 + 1:\n f = False\n break\nm = N//2\nif f:\n print((2**m)//1000000007)\nelse:\n print(0)', 'N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A)\nf = True\nif N%2 == 1:\n for i in range(N):\n if A[i] != ((i+1)//2)*2:\n f = False\n break\nelse:\n for i in range(N):\n if A[i] != (i//2)*2 + 1:\n f = False\n break\nm = N//2\nif f:\n print((2**m)%1000000007)\nelse:\n print(0)']
['Wrong Answer', 'Accepted']
['s226181891', 's967657246']
[13880.0, 13880.0]
[102.0, 98.0]
[310, 309]
p03848
u714378447
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N=int(input())\nA=list(map(int,input().split()))\nA.sort()\n\nf=True\nif N%2!=0:\n\tidx=1\n\tx=2\n\tif A[0]!=0:f=False\nelse:\n\tidx=0\n\tx=1\nprint(A)\nfor i in range(N//2):\n\tprint(idx)\n\tif A[idx]!=x or A[idx+1]!=x:\n\t\tf=False\n\tidx+=2\n\tx+=2\n\nif f:print(2**(N//2)%(10**9+7))\nelse:print(0)', 'N=int(input())\nA=list(map(int,input().split()))\nA.sort()\n\nf=True\nif N%2!=0:\n\tidx=1\n\tx=2\n\tif A[0]!=0:f=False\nelse:\n\tidx=0\n\tx=1\n\nfor i in range(N//2):\n\tif A[idx]!=x or A[idx+1]!=x:\n\t\tf=False\n\tidx+=2\n\tx+=2\n\nif f:print(2**(N//2)%(10**9+7))\nelse:print(0)']
['Wrong Answer', 'Accepted']
['s483338974', 's132779974']
[13880.0, 13880.0]
[143.0, 100.0]
[269, 249]
p03848
u780475861
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import sys\nfrom collections import Counter\nn, *lst = map(int, sys.stdin.read().split())\nlst = sorted(Counter(lst).items())\nl = len(lst)\nmod = 10 ** 9 + 7\nif n % 2:\n for i in range(l):\n if not i:\n if lst[i][0] or lst[i][1] != 1:\n print(0)\n quit()\n if lst[i][0] != i * 2 or lst[i][1] != 2:\n print(0)\n quit()\nelse:\n for i in range(l):\n if lst[i][0] != i * 2 + 1 or lst[i][1] != 2:\n print(0)\n quit()\nprint((1 << (n >> 1)) % mod)\n', "import sys\nfrom collections import Counter\n\n\ndef main():\n n, *lst = map(int, sys.stdin.read().split())\n lst = sorted(Counter(lst).items())\n l = len(lst)\n mod = 10 ** 9 + 7\n if n % 2:\n for i in range(l):\n if not i:\n if lst[i][0] or lst[i][1] != 1:\n print(0)\n quit()\n elif lst[i][0] != i * 2 or lst[i][1] != 2:\n print(0)\n quit()\n else:\n for i in range(l):\n if lst[i][0] != i * 2 + 1 or lst[i][1] != 2:\n print(0)\n quit()\n print((1 << (n >> 1)) % mod)\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s281401664', 's233860319']
[15840.0, 15840.0]
[75.0, 79.0]
[475, 566]
p03848
u785578220
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['a = int(input())\nx = list(map(int, input().split()))\nx.sort()\nx = x[::-1]\nif a == 1:\n if x[0] == 0:print(1)\n else:print(0)\nelse:\n if a %2 == 0:\n for i in range(1,a,2):\n if not i == x[-1] and i ==x[-2]:\n x.pop()\n x.pop()\n print(0)\n break\n else:print(2**(a//2))\n else:\n for i in range(0,a,2):\n if x.pop() != 0:\n print(0)\n exit()\n if not i == x[-1] and i ==x[-2]:\n x.pop()\n x.pop()\n print(0)\n break\n else:print(2**(a//2))\n', '\na = int(input())\nx = list(map(int, input().split()))\nx.sort()\nt =[2]\nx = x[::-1]\nif a == 1:\n if x[0] == 0:print(1)\n else:print(0)\nelse:\n if a %2 == 0:\n for i in range(1,a,2):\n if not i == x[-1] and i ==x[-2]:\n print(0)\n break\n x.pop()\n x.pop()\n else:print(2**(a//2))\n else:\n if x.pop() != 0:\n print(0)\n exit()\n for i in range(0,a,2):\n if not i == x[-1] and i ==x[-2]:\n print(0)\n break\n x.pop()\n x.pop()\n else:print(2**(a//2))\n', 'a = int(input())\nx = list(map(int, input().split()))\nx.sort()\nt =[2]\nx = x[::-1]\nif a == 1:\n if x[0] == 0:print(1)\n else:print(0)\nelse:\n if a %2 == 0:\n for i in range(1,a,2):\n if not i == x[-1] and not i ==x[-2]:\n print(0)\n break\n x.pop()\n x.pop()\n else:print(2**(a//2))\n else:\n tttt = x.pop()\n if tttt != 0:\n print(0)\n exit()\n for i in range(0,a-2,2):\n if not i == x[-1] and not i ==x[-2]:\n print(0)\n break\n x.pop()\n x.pop()\n else:print(2**(a//2))\n\n', 'a = int(input())\nx = list(map(int, input().split()))\nx.sort()\nt =[2]\nx = x[::-1]\nif a == 1:\n if x[0] == 0:print(1)\n else:print(0)\nelse:\n if a %2 == 0:\n for i in range(1,a,2):\n if i == x[-1] and i ==x[-2]:\n x.pop()\n x.pop()\n else:\n print(0)\n break\n else:print(2**(a//2))\n else:\n tttt = x.pop()\n if tttt != 0:\n print(0)\n exit()\n for i in range(0,a-2,2):\n if i == x[-1] and i ==x[-2]:\n x.pop()\n x.pop()\n else:\n print(0)\n break\n\n else:print(2**(a//2))', 'N = int(input())\nA = [int(a) for a in input().split()]\n\nA.sort()\nB = [abs(a-b) for a,b in zip(range(N-1,-1,-1),range(N))]\nB.sort()\n\nif A==B:\n print(pow(2,N//2,10**9+7))\nelse:\n print(0)\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s009173947', 's180812811', 's511835568', 's949922102', 's141414193']
[14008.0, 14008.0, 14008.0, 14008.0, 13880.0]
[90.0, 92.0, 92.0, 95.0, 95.0]
[520, 514, 540, 555, 191]
p03848
u802772880
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n=int(input())\na=list(map(int,input().split()))\na.sort()\nif n%2==1:\n if a[0]!=0:\n print(0)\n exit()\n for i in range(n//2):\n if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):\n print(0)\n exit()\n print((pow(2,n//2))%(1e9+7))\nelse:\n for i in range(n//2):\n if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:\n print(0)\n exit()\n print(((pow(2,n//2))%(1e9+7)))', 'n=int(input())\na=list(map(int,input().split()))\na.sort()\nif n%2==1:\n if a[0]!=0:\n print(0)\n exit()\n for i in range(n//2):\n if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):\n print(0)\n exit()\n print(pow(2,n//2)%(1e9+7))\nelse:\n for i in range(n//2):\n if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:\n print(0)\n exit()\n print(pow(2,n//2)%(1e9+7))', 'n=int(input())\na=list(map(int,input().split()))\na.sort()\nif n%2==1:\n if a[0]!=0:\n print(0)\n exit()\n for i in range(n//2):\n if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):\n print(0)\n exit()\n print((pow(2,n//2))%(1e9+7))\nelse:\n for i in range(n//2):\n if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:\n print(0)\n exit()\n print((pow(2,n//2))%(1e9+7))', 'n=int(input())\na=list(map(int,input().split()))\na.sort()\nif n%2==1:\n if a[0]!=0:\n print(0)\n exit()\n for i in range(n//2):\n if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):\n print(0)\n exit()\n print(pow(2,n//2)%(10**9+7))\nelse:\n for i in range(n//2):\n if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:\n print(0)\n exit()\n print(pow(2,n//2)%(10**9+7))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s030141432', 's676420063', 's834071642', 's759849759']
[14004.0, 14008.0, 14008.0, 14008.0]
[97.0, 99.0, 96.0, 98.0]
[419, 413, 417, 417]
p03848
u804358525
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['# -*- coding: utf-8 -*-\n\npeople_num = int(input())\nline_list = list(map(int, input().split()))\n\nnum_odd = True\nbool_false = True\n\nline_list.sort()\n\nif(people_num%2 == 0):\n num_odd = False\n\nfor i in range(people_num):\n\n if(num_odd):\n if(line_list[i] == 2*((i+1)//2)):\n continue\n else:\n bool_false = False\n break\n else:\n if(line_list[i] == 2*((i)//2) +1):\n continue\n else:\n bool_false = False\n break\n\nprint(bool_false)\nif(bool_false):\n print((people_num//2) **2)\nelse:\n print(0)', '# -*- coding: utf-8 -*-\n\npeople_num = int(input())\nline_list = list(map(int, input().split()))\n\nnum_odd = True\nbool_false = True\n\nline_list.sort()\n\nif(people_num%2 == 0):\n num_odd = False\n\n\n\nfor i in range(people_num):\n\n if(num_odd):\n if(line_list[i] == 2*((i+1)//2)):\n continue\n else:\n bool_false = False\n break\n else:\n if(line_list[i] == 2*((i)//2) +1):\n continue\n else:\n bool_false = False\n break\n\nif(len(people_num) == 1):\n print(1)\nelif(bool_false):\n print((people_num//2) **2)\nelse:\n print(0)', '# -*- coding: utf-8 -*-\n\npeople_num = int(input())\nline_list = list(map(int, input().split()))\n\nnum_odd = True\nbool_false = True\n\nline_list.sort()\n\nif(people_num%2 == 0):\n num_odd = False\n\nfor i in range(people_num):\n\n if(num_odd):\n if(line_list[i] == 2*((i+1)//2)):\n continue\n else:\n bool_false = False\n break\n else:\n if(line_list[i] == 2*(i//2) +1):\n continue\n else:\n bool_false = False\n break\n\nif(people_num == 1):\n print(1)\nelif(bool_false):\n print((2**(people_num // 2) % (10**9 +7)))\nelse:\n print(0)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s319685089', 's616317816', 's034674920']
[14008.0, 13880.0, 13880.0]
[99.0, 100.0, 99.0]
[585, 610, 617]
p03848
u813102292
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n = int(input())\na = list(int(i) for i in input().split())\nif n%2==0 and sum(a)==n*n//2 or n%2 ==1 and sum(a) == (n+1)*n//2:\n print(2**(n//2)%(10**9+7))', 'n = int(input())\na = list(int(i) for i in input().split())\nif n%2==0 and sum(a)==n*n//2 or n%2 ==1 and sum(a) == (n+1)*n//2:\n print(2**(n//2)%(10**9+7))\nelse:\n print(0)', 'n = int(input())\na = list(int(i) for i in input().split())\nif n%2==0 and sum(a)==n*n//2 or n%2==1 and sum(a) == (n+1)*(n//2):\n print(2**(n//2)%(10**9+7))\nelse:\n print(0)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s789985275', 's812083898', 's698387598']
[14008.0, 13880.0, 14004.0]
[49.0, 49.0, 48.0]
[155, 174, 175]
p03848
u835482198
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\n\nN = int(input())\nA = map(int, input().split())\n# N = 5\n# A = [2, 4, 4, 0, 2]\nmod = 10 ** 9 + 7\n\ncnt = Counter(A)\nif N % 2 == 0:\n if len(filter(lambda c: c == 2, cnt.values())) != 0:\n print(0)\n else:\n print(2 ** (N // 2))\nelse:\n if cnt[0] != 1:\n print(0)\n cnt.pop(0)\n if len(filter(lambda c: c == 2, cnt.values())) != 0:\n print(0)\n else:\n print(2 ** (N // 2))\n', '#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\nfrom collections import Counter\nimport sys\nN = int(input())\nA = list(map(int, input().split()))\n\nMOD = 10**9 + 7\nA = Counter(A)\n\nif N % 2 == 1:\n for num, cnt in A.items():\n # print(num, cnt)\n if (num == 0 and cnt != 1):\n print(0)\n sys.exit()\n elif not (num % 2 == 0 and cnt == 2):\n print(0)\n sys.exit()\n print(2 ** (N // 2))\nelse:\n for num, cnt in A.items():\n # print(num, cnt)\n if not (num % 2 == 1 and cnt == 2):\n print(0)\n sys.exit()\n print(2 ** (N // 2))\n', 'from collections import Counter\n\nN = int(input())\nA = map(int, input().split())\n# N = 5\n# A = [2, 4, 4, 0, 2]\nmod = 10 ** 9 + 7\n\ncnt = Counter(A)\nif N % 2 == 0:\n if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:\n print(0)\n else:\n print((2 ** (N // 2)) % mod)\nelse:\n if cnt[0] != 1:\n print(0)\n else:\n cnt.pop(0)\n if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:\n print(0)\n else:\n print((2 ** (N // 2)) % mod)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s337570381', 's503252353', 's720439755']
[16620.0, 14820.0, 16620.0]
[57.0, 172.0, 62.0]
[445, 618, 503]
p03848
u856232850
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n = int(input())\n\na = list(map(int,input().split()))\na.sort()\nif n % 2 == 0:\n b = 0\n for i in range(0,n,2):\n if a[i] == a[i+1] and a[i] == i+1:\n b = 1\n if b == 1:\n print(0)\n else:\n print(2**(n//2))\nelse:\n b = 0\n if a[0] != 0:\n b = 1\n else:\n for i in range(1,n,2):\n if a[i] == a[i+1] and a[i] == i+1:\n b = 1\n if b == 1:\n print(0)\n else:\n print(2**(n//2))', 'n = int(input())\n\na = list(map(int,input().split()))\na.sort()\nif n % 2 == 0:\n b = 0\n for i in range(0,n,2):\n if a[i] != a[i+1] and a[i] != i+1:\n b = 1\n if b == 1:\n print(0)\n else:\n print((2**(n//2))%1000000007)\nelse:\n b = 0\n if a[0] != 0:\n b = 1\n else:\n for i in range(1,n,2):\n if a[i] != a[i+1] and a[i] != i+1:\n b = 1\n if b == 1:\n print(0)\n else:\n print((2**(n//2))%1000000007)']
['Wrong Answer', 'Accepted']
['s565446633', 's832553218']
[14008.0, 14008.0]
[92.0, 88.0]
[466, 492]
p03848
u859897687
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n=int(input())\n#ne,[7,5,3,1,1,3,5,7]8\n#no,[8,6,4,2,0,2,4,6,8]9\nm=[0]*n\nfor i in map(int,input().split()):\n m[i]+=1\nans=1\nfor i in range(n-1,0,-2):\n d[i]!=2:\n ans=0\nif d[0]!=n%2:\n ans=0\nif ans:\n print(2**(n//2)%1000000007)\nelse:\n print(0)\n ', 'n=int(input())\n#ne,[7,5,3,1,1,3,5,7]8\n#no,[8,6,4,2,0,2,4,6,8]9\nm=[0]*n\nfor i in map(int,input().split()):\n m[i]+=1\nans=1\nfor i in range(n-1,0,-2):\n if d[i]!=2:\n ans=0\nif d[0]!=n%2:\n ans=0\nif ans:\n print(2**(n//2)%1000000007)\nelse:\n print(0)\n ', 'n=int(input())\n#ne,[7,5,3,1,1,3,5,7]8\n#no,[8,6,4,2,0,2,4,6,8]9\nm=[0]*n\nfor i in map(int,input().split()):\n m[i]+=1\nans=1\nfor i in range(n-1,0,-2):\n if m[i]!=2:\n ans=0\nif m[0]!=n%2:\n ans=0\nif ans:\n print(2**(n//2)%1000000007)\nelse:\n print(0)\n ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s039549768', 's872487942', 's891475629']
[2940.0, 10616.0, 10616.0]
[17.0, 52.0, 54.0]
[250, 253, 253]
p03848
u860002137
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['import sys\nfrom collections import Counter\n\nn = int(input())\narr = list(map(int, input().split()))\n\nif arr.count(0) > 1:\n print(0)\n sys.exit()\n\nif len(arr) % 2 == 0 and arr.count(0) > 0:\n print(0)\n sys.exit()\n\ncnt = Counter(arr)\n\nli = list(cnt.values())\n\nif li.count(2) != n // 2:\n print(0)\n sys.exit()\n\nif not all([x <= 2 for x in li]):\n print(0)\n sys.exit(0)\n\nprint(reduce(mul, li))', 'import sys\nfrom collections import Counter\n\nn = int(input())\narr = list(map(int, input().split()))\n\nif len(arr) % 2 == 0:\n if 0 in arr:\n print(0)\n sys.exit()\nelse:\n if arr.count(0) != 1:\n print(0)\n sys.exit()\n else:\n arr.remove(0)\n\ncnt = Counter(arr)\n\nvalues = list(cnt.values())\n\nif values.count(2) != len(values):\n print(0)\n sys.exit()\n\nmod = 10**9 + 7\n\nprint(2**(n // 2) % mod)']
['Runtime Error', 'Accepted']
['s088981727', 's708572163']
[14820.0, 14820.0]
[64.0, 60.0]
[408, 430]
p03848
u867848444
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nmod = 10 ** 9 + 7\n\ncnt = Counter(a)\nif n % 2 == 0:\n for i, j in cnt.items():\n if j != 2 or not(1 <= i <= n - 1) :\n print(0)\n exit()\nelse:\n for i, j in cnt.items():\n if i == 0:\n if j != 0:\n print(0)\n exit()\n else:\n if j != 2 or not(1 <= i <= n - 1):\n print(0)\n exit()\n\nnum = n // 2\nans = pow(2, num, mod)\nprint(ans)', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nmod = 10 ** 9 + 7\n\ncnt = Counter(a)\nif n % 2 == 0:\n for i, j in cnt.items():\n if j != 2 or not(1 <= i <= n - 1) :\n print(0)\n exit()\nelse:\n for i, j in cnt.items():\n if i == 0:\n if j != 1:\n print(0)\n exit()\n else:\n if j != 2 or not(1 <= i <= n - 1):\n print(0)\n exit()\n\nnum = n // 2\nans = pow(2, num, mod)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s688392851', 's253701919']
[14812.0, 14812.0]
[66.0, 65.0]
[529, 529]
p03848
u871841829
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N = int(input())\nA = list(map(int, input().split()))\n\nfrom collections import Counter\ncd = Counter(A)\n# A.sort()\n\nif N & 1:\n \n if cd[0] != 1:\n print(0)\n exit(0)\n ng = False\n\n for ix in range(2, N//2 + 1, 2):\n if cd[ix] != 2:\n ng = True\n break\n\n if len(cd) != N//2 + 1:\n ng = True\n \n if ng:\n print(0)\n else:\n print(2**N//2)\n\nelse:\n # even\n ng = False\n for ix in range(1, N//2+1, 2):\n if cd[ix] != 2:\n ng = True\n break\n \n if len(cd) != N//2:\n ng = True\n \n if ng:\n print(0)\n else:\n print(2**N//2)\n', 'N = int(input())\nA = list(map(int, input().split()))\nM = 10**9+7\n\nfrom collections import Counter\ncd = Counter(A)\n# A.sort()\n\nif N & 1:\n \n if cd[0] != 1:\n print(0)\n exit(0)\n ng = False\n\n for ix in range(2, N//2 + 1, 2):\n if cd[ix] != 2:\n ng = True\n break\n\n if len(cd) != N//2 + 1:\n ng = True\n \n if ng:\n print(0)\n else:\n # print(pow(2,(N//2),M))\n ans = 1\n for ix in range(N//2):\n ans *= 2\n ans %= M\n print(ans)\n\nelse:\n # even\n ng = False\n for ix in range(1, N//2+1, 2):\n if cd[ix] != 2:\n ng = True\n break\n \n if len(cd) != N//2:\n ng = True\n \n if ng:\n print(0)\n else:\n # print(pow(2,(N//2),M))\n ans = 1\n for ix in range(N//2):\n ans *= 2\n ans %= M\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s284971023', 's341527778']
[20492.0, 20412.0]
[78.0, 78.0]
[661, 909]
p03848
u899975427
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['n = int(input())\ndp = [2]*n\ndp[0] = 1\nmod = 10**9+7\nan = [int(i) for i in input().split()]\n\nif n % 2 == 1:\n for i in an:\n if i % 2 == 1 or dp[i] == 0:\n print(0)\n exit()\n else:\n dp[i] -= 1\n print(2**((n-1)//2)//mod)\nelse:\n for i in an:\n if i % 2 == 0 or dp[i] == 0:\n print(0)\n exit()\n else:\n dp[i] -= 1\n print(2**(n//2)//mod)', 'n = int(input())\ndp = [2]*n\ndp[0] = 1\nmod = 10**9+7\nan = [int(i) for i in input().split()]\n\nif n % 2 == 1:\n for i in an:\n if i % 2 == 1 or dp[i] == 0:\n print(0)\n exit()\n else:\n dp[i] -= 1\n print(2**((n-1)//2)%mod)\nelse:\n for i in an:\n if i % 2 == 0 or dp[i] == 0:\n print(0)\n exit()\n else:\n dp[i] -= 1\n print(2**(n//2)%mod)']
['Wrong Answer', 'Accepted']
['s238452193', 's077453079']
[14648.0, 14580.0]
[74.0, 74.0]
[370, 368]
p03848
u919633157
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['# 2019/08/11\n\nfrom collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\n\nif c.most_common(1)[0][1]>2 or c[0]>1:\n print(0)\n exit()\n\nfor k,v in c.items():\n if k!=0 and v!=2:\n print(0)\n exit()\n if n%2==v%2:\n print(0)\n exit()\n \nprint(2**(n//2))', '# 2019/08/11\n\nfrom collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\n\nif c.most_common(1)[0][1]>2 or c[0]>1:\n print(0)\n exit()\n\nfor k,v in c.items():\n if k!=0 and v!=2:\n print(0)\n exit()\n if n%2==k%2:\n print(0)\n exit()\n \nprint(2**(n//2)%(10**9+7))']
['Wrong Answer', 'Accepted']
['s365380098', 's466571483']
[14820.0, 14820.0]
[64.0, 79.0]
[324, 334]
p03848
u948524308
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['N,M=map(int,input().split())\nmod=10**9+7\na=[]\nfor i in range(M):\n a.append(int(input()))\n\n\nDP=[1]*(N+1)\n\nif 1 in a:\n DP[1]=0\n\nfor i in range(2,N+1):\n if i in a:\n DP[i]=0\n if DP[i-1]==0:\n print(0)\n exit()\n else:\n DP[i]=DP[i-1]+DP[i-2]\n DP[i]=DP[i]%mod\n\nprint(DP[N])\n', 'import collections\n\nN=int(input())\nA_data=list(map(int,input().split()))\nmod=10**9+7\n\nA=collections.Counter(A_data)\n\nif N%2==1:\n if not A[0]==1:\n ans=0\n else:\n for i in range(2,N,2):\n if not A[i]==2:\n ans=0\n break\n if ans!=0:\n ans=2**((N-1)//2)%mod\nelif N%2==0:\n for i in range(1,N,2):\n if not A[i]==2:\n ans=0\n break\n if ans!=0:\n ans=2**(N//2)%mod\n\nprint(ans)', 'N=int(input())\nA=list(map(int,input().split()))\n\nmod=10**9+7\n\nA.sort()\nf=True\nif N%2==1:\n if A[0]!=0:\n f=False\n else:\n for i in range(1,N,2):\n if not (A[i]==2*(i+1)//2 and A[i+1]==2*(i+1)//2):\n f=False\n break\nelif N%2==0:\n for i in range(0,N,2):\n if not (A[i]==2*(i//2)+1 and A[i+1]==2*(i//2)+1):\n f=False\n break\n\nif f:\n print(2**(N//2)%mod)\nelse:\n print(0)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s438207495', 's606768624', 's836809101']
[3064.0, 14820.0, 14008.0]
[17.0, 67.0, 97.0]
[327, 480, 458]
p03848
u979552932
2,000
262,144
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
['from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nh = Counter()\nfor x in a:\n h[x] += 1\nf = True\nfor k, v in h..most_common():\n if n % 2 == 1 and k == 0:\n if v != 1:\n f = False\n break\n elif v != 2:\n f = False\n break\nMOD = 1000000007\ndef mpow(n, p, mod):\n r = 1\n while p > 0:\n if p & 1 == 1:\n r = r * n % mod\n n = n * n % mod\n p >>= 1\n return r\nprint(mpow(2, int(n / 2), MOD) if f else 0) ', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nh = Counter()\nfor x in a:\n h[x] += 1\nf = True\nfor k, v in h.most_common():\n if n % 2 == 1 and k == 0:\n if v != 1:\n f = False\n break\n elif v != 2:\n f = False\n break\nMOD = 1000000007\ndef mpow(n, p, mod):\n r = 1\n while p > 0:\n if p & 1 == 1:\n r = r * n % mod\n n = n * n % mod\n p >>= 1\n return r\nprint(mpow(2, n // 2, MOD) if f else 0)']
['Runtime Error', 'Accepted']
['s692610192', 's078135778']
[2940.0, 16096.0]
[17.0, 125.0]
[516, 510]
p03856
u018679195
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s=input()\ns=s.replace(\'eraser\',\'#\')\ns=s.replace(\'erase\',\'#\')\ns=s.replace(\'dreamer\',\'#\')\ns=s.replace(\'dream\')\nf=1\nfor it in s:\n if it !=\'#\':\n f=0\n break\n\nif f==1:\n print("YES")\nelse :\n print("NO")', 's=input()\ns=s.replace(\'eraser\',\'*\')\ns=s.replace(\'erase\',\'*\')\ns=s.replace("dreamer","*")\ns=s.replace("dream","*")\nf=1\nfor i in s:\n if i!=\'*\':\n f=0\n break\nif f:\n print("YES")\nelse:\n print("NO")\n']
['Runtime Error', 'Accepted']
['s573952995', 's971973221']
[9180.0, 9164.0]
[27.0, 30.0]
[218, 215]
p03856
u038408819
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["s = input()\ns = s[::-1]\nhoge = ['maerd', 'remaerd', 'esare', 'resare']\ni = 0\nj = 0\nwhile i < len(s):\n j += 1\n i = j\n ans = ''\n while j < len(s):\n ans += s[j]\n if len(ans) > 7:\n print('NO')\n quit()\n if ans in hoge:\n break\n else:\n j += 1\nprint('YES')", "s = input()\ns = s[::-1]\nhoge = ['maerd', 'remaerd', 'esare', 'resare']\ni = 0\nj = 0\nwhile i < len(s):\n ans = ''\n while j < len(s):\n ans += s[j]\n if len(ans) > 7:\n print('NO')\n quit()\n if ans in hoge:\n break\n else:\n j += 1\n j += 1\n i = j\nprint('YES')\n"]
['Wrong Answer', 'Accepted']
['s619289214', 's488608938']
[3188.0, 3188.0]
[78.0, 79.0]
[332, 333]
p03856
u102242691
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['\ns = input()\nl = ["dream","dreamer","erase","eraser"]\n\nwhile len(s) > 0:\n for i in range(len(l)):\n if l[i] in s:\n s = s.replase(l[i],"")\n else:\n break\n \nif len(s) == 0:\n print("YES")\nelse:\n print("NO")\n', '\ns = input()\nl = ["eraser","erase","dreamer","dream"]\n\nwhile len(s) > 0:\n for i in range(len(l)):\n if l[i] in s:\n s = s.replase(l[i],"")\n else:\n break\n \nif len(s) == 0:\n print("YES")\nelse:\n print("NO")\n', "\nS = input()\nS = S[::-1]\n\nl = ['maerd','remaerd','esare','resare']\ni = 0\nwhile i < len(S):\n for w in l:\n if w == S[i:i+len(w)]:\n i += len(w)\n break\n else:\n print('NO')\n exit()\nprint('YES')"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s766839335', 's850062014', 's857340203']
[3188.0, 3316.0, 3188.0]
[17.0, 2104.0, 36.0]
[258, 258, 237]
p03856
u136231568
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s = input().strip()\nstrings = "eraser erase dreamer dream".split()\nexceptions = "dreameraser dreamerase".split()\nwhile 1:\n for string in strings:\n if s.startswith(string):\n if string == "dreamer":\n for exception in exceptions:\n if startswith(exception):\n s = s[len(exception):]\n else:\ns = s[len(string):]\n break\n else:\n break\nprint("NO" if s else "YES")', 'dream, erase = "dream erase".split()\n\ns = input().strip()\nwhile 1:\n if s.startswith(dream):\n s = s[5:]\n if s.startswith("er") and not s.startswith("era"):\n s = s[2:]\n elif s.startswith(erase):\n s = s[5:]\n if s.startswith(\'r\'):\n s = s[1:]\n else:\n break\nprint("NO" if s else "YES")\n']
['Runtime Error', 'Accepted']
['s072498758', 's955053904']
[3064.0, 3316.0]
[22.0, 98.0]
[403, 311]
p03856
u237362582
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["S = input()\nrS = S[::-1]\nkeys = ['dream', 'dreamer', 'erase', 'eraser']\nreversed_keys = [keys[i][::-1] for i in range(len(keys))]\ni = 0\nprint(reversed_keys)\nwhile i < len(rS):\n if rS[i:i+5] in reversed_keys:\n i += 5\n elif rS[i:i+6] in reversed_keys:\n i += 6\n elif rS[i:i+7] in reversed_keys:\n i += 7\n else:\n break\nif i == len(rS):\n print('YES')\nelse:\n print('NO')\n", "S = input()\nrS = S[::-1]\nkeys = ['dream', 'dreamer', 'erase', 'eraser']\nreversed_keys = [keys[i][::-1] for i in range(len(keys))]\ni = 0\n\nwhile i < len(rS):\n if rS[i:i+5] in reversed_keys:\n i += 5\n elif rS[i:i+6] in reversed_keys:\n i += 6\n elif rS[i:i+7] in reversed_keys:\n i += 7\n else:\n break\nif i == len(rS):\n print('YES')\nelse:\n print('NO')\n"]
['Wrong Answer', 'Accepted']
['s962648127', 's623219470']
[3188.0, 3188.0]
[30.0, 30.0]
[410, 390]
p03856
u271063202
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["s = input()\nn = len(s)\nidx = 0\nwhile idx < n:\n if idx+5 <= n and s[idx:idx+5] == 'dream':\n idx += 5\n elif s[idx:idx+4] == 'eras':\n idx += 4\n else:\n break\n if idx+2 <= n and s[idx:idx+2] == 'er' and (idx+2 == n or s[idx+2:idx+3] != 'a'):\n idx += 2\nif idx == n:\n print('YES')\nelse:\n print('NO')", "s = input()\nn = len(s)\nidx = 0\nwhile idx < n:\n if idx+5 > n:\n break\n if s[idx:idx+5] == 'dream':\n idx += 5\n if idx+2 <= n and s[idx:idx+2] == 'er' and (idx+2 == n or s[idx+2:idx+3] != 'a'):\n idx += 2\n elif s[idx:idx+5] == 'erase':\n idx += 5\n if idx+1 <= n and s[idx:idx+1] == 'r':\n idx += 1\n else:\n break\n\nif idx == n:\n print('YES')\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s072710668', 's494984464']
[3188.0, 3188.0]
[17.0, 37.0]
[338, 433]
p03856
u280512618
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["from collections import deque\n\ndef solve(s):\n que = deque()\n que.append(s)\n while len(que) > 0:\n top = que.pop()\n if top == '':\n return 'YES'\n\n if top[:5] == 'dream':\n if top[5:7] == 'er':\n que.append(s[:7])\n que.append(s[:5])\n elif top[:5] == 'erase':\n if top[5] == 'r':\n que.append(top[:6])\n else:\n que.append(top[:5])\n return 'NO'\n\nprint(solve(input()))\n", "from collections import deque\n\ndef solve(s):\n stack = deque()\n stack.append(s)\n while len(stack) > 0:\n top = stack.pop()\n if top == '':\n return 'YES'\n\n if top[:5] == 'dream':\n if top[5:7] == 'er':\n stack.append(top[7:])\n stack.append(top[:5])\n elif top[:5] == 'erase':\n if len(top) > 5 and top[5] == 'r':\n stack.append(top[6:])\n else:\n stack.append(top[5:])\n return 'NO'\n\nprint(solve(input()))\n", "s = input()\nwhile s != '':\n if s[:5] == 'dream' or s[:5] == 'erase':\n if s[5] == 'r':\n s = s[6:]\n else:\n s = s[5:]\n else:\n print('NO')\n quit(0)\n\nprint('YES')\n", "s = input()\nwhile s != '':\n if s[:5] == 'dream' or s[:5] == 'erase':\n if s[5] = 'r':\n s = s[6:]\n else:\n s = s[5:]\n else:\n print('NO')\n quit(0)\n\nprint('YES')\n", "from collections import deque\n\ndef solve(s):\n que = deque()\n que.append(s)\n while len(que) > 0:\n top = que.pop()\n if top == '':\n return 'YES'\n\n if top[:5] == 'dream':\n if top[5:7] == 'er':\n que.append(s[:7])\n que.append(s[:5])\n elif top[:5] == 'erase':\n if len(top) > 5 and top[5] == 'r':\n que.append(top[:6])\n else:\n que.append(top[:5])\n return 'NO'\n\nprint(solve(input()))\n", "from collections import deque\n\ndef solve(s):\n que = deque()\n que.append(s)\n while len(que) > 0:\n top = que.pop()\n if top == '':\n return 'YES'\n\n if top[:5] == 'dream':\n if top[5:7] == 'er':\n que.append(top[:7])\n que.append(top[:5])\n elif top[:5] == 'erase':\n if len(top) > 5 and top[5] == 'r':\n que.append(top[:6])\n else:\n que.append(top[:5])\n return 'NO'\n\nprint(solve(input()))\n", "from collections import deque\n\ndef solve(s):\n stack = deque()\n stack.append(s)\n while len(stack) > 0:\n top = stack.pop()\n if top == '':\n return 'YES'\n\n if top[:5] == 'dream':\n if top[5:7] == 'er':\n stack.append(top[7:])\n stack.append(top[5:])\n elif top[:5] == 'erase':\n if len(top) > 5 and top[5] == 'r':\n stack.append(top[6:])\n else:\n stack.append(top[5:])\n return 'NO'\n\nprint(solve(input()))\n"]
['Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s061885079', 's092955090', 's345262493', 's423214975', 's439387299', 's611471005', 's892647273']
[3444.0, 3572.0, 3188.0, 2940.0, 3444.0, 3444.0, 110880.0]
[2104.0, 2108.0, 18.0, 18.0, 2108.0, 2104.0, 166.0]
[497, 534, 214, 213, 514, 518, 534]
p03856
u284854859
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['dreameraser', "s=list(input())\nn = len(s)\n\nc=0\nk=0\nwhile c==0:\n if k ==n:\n c = 1\n else:\n \n if k + 7 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm' and s[k+5] == 'e' and s[k+6] == 'r' and s[k+7] == 'a':\n k += 5\n elif k + 6 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm' and s[k+5] == 'e' and s[k+6] == 'r':\n k += 7\n elif k + 4 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm':\n k += 5\n elif k+6 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e' and s[k+5] == 'r' and s[k+6] == 'a':\n k+= 5\n elif k+5 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e' and s[k+5] == 'r':\n k += 6\n elif k+4 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e':\n k += 5\n else:\n c = 1\n\nif k == n:\n print('YES')\nelse:\n print('NO')"]
['Runtime Error', 'Accepted']
['s894227964', 's984251189']
[2940.0, 4212.0]
[18.0, 54.0]
[11, 1112]
p03856
u375616706
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s = input()\n\ni = 0\nwhile s:\n str = s[i:i+5]\n if str == "dream" or str == "erase":\n i += 5\n elif str[i:i+2] == "er":\n i += 2\n else:\n print("NO")\n exit()\n\nans = "YES"\nprint(ans)\n', 'import sys\nsys.setrecursionlimit(10**9)\ns1 = "maerd"\ns2 = "remaerd"\ns3 = "esare"\ns4 = "resare"\n\ni = input()\ns = \'\'\nfor c in reversed(i):\n s += c\n\nl = len(s)\n\ni = 0\n\n\ndef dfs(i):\n if i == l:\n print("YES")\n exit()\n if i+5 <= l and s[i:i+5] == s1:\n dfs(i+5)\n elif i+7 <= l and s[i:i+7] == s2:\n dfs(i+7)\n elif i+5 <= l and s[i:i+5] == s3:\n dfs(i+5)\n elif i+6 <= l and s[i:i+6] == s4:\n dfs(i+6)\n else:\n print("NO")\n exit()\n\n\ndfs(0)\n']
['Wrong Answer', 'Accepted']
['s554602156', 's853131780']
[3188.0, 18140.0]
[18.0, 64.0]
[216, 504]
p03856
u398942100
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["S = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')\nif S == '':\n print('Yes')\nelse:\n print('No')", "S = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')\nif S == '':\n print('YES')\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s378434884', 's392177239']
[3188.0, 3188.0]
[19.0, 19.0]
[145, 145]
p03856
u405660020
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s=input()\ns=s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")\nif s:\n print("NO")\nelse:\n print("YES")', 's=input()\ns=s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")\nif s:\n print("NO")\nelse:\n print("YES")']
['Runtime Error', 'Accepted']
['s429548972', 's995387104']
[3188.0, 3188.0]
[20.0, 19.0]
[143, 141]
p03856
u426108351
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["s = list(input())\ns.reverse()\ns = ''.join(map(str, s))\ncount = 0\nword = ['maerd', 'remaerd', 'resare', 'esare']\n\nwhile count <= len(s)-8:\n counttemp = count\n for i in range(4):\n w = word[i]\n if s[count:count+len(w)] == w:\n count += len(w)\n if counttemp == count:\n break\nif s[count:] in word:\n print('YES')\nelse:\n print('NO')\n \n", "s = list(input())\ns.reverse()\ns = ''.join(map(str, s))\ncount = 0\nword = ['maerd', 'remaerd', 'resare', 'esare']\n\nwhile count <= len(s)-8:\n counttemp = count\n for i in range(4):\n w = word[i]\n if s[count:count+len(w)] == w:\n count += len(w)\n if counttemp == count:\n break\n\nif s[count:] in word or s[count:] =='':\n print('YES')\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s351418852', 's062849386']
[4652.0, 4652.0]
[52.0, 52.0]
[349, 362]
p03856
u558528117
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['import sys\n\ndef solve(s):\n sys.stderr.write(s)\n sys.stderr.write("\\n")\n\n while(len(s) >= 1):\n if s == "":\n return True\n elif s.startswith("maerd"):\n s = s[5:]\n elif s.startswith("remaerd"):\n s = s[7:]\n elif s.startswith("esare"):\n s = s[5:]\n elif s.startswith("resare"):\n s = s[6:]\n else:\n return False\n\n\n\ndef main():\n line = sys.stdin.readline().rstrip()\n line_rev = line[::-1]\n\n if solve(line):\n print("YES")\n else:\n print("NO")\n\n return 0\n\nif __name__ == \'__main__\':\n sys.exit(main())\n', 'import sys\nsys.setrecursionlimit(10000)\n\ndef solve(s):\n if s == "":\n return True\n elif s.endswith("dream"):\n return solve(s[:-5])\n elif s.endswith("dreamer"):\n return solve(s[:-7])\n elif s.endswith("erase"):\n return solve(s[:-5])\n elif s.endswith("eraser"):\n return solve(s[:-6])\n else:\n return False\n return False\n\n\ndef main():\n line = sys.stdin.readline()\n\n if solve(line):\n print("YES")\n else:\n print("NO")\n\n return 0\n\nif __name__ == \'__main__\':\n sys.exit(main())\n', 'import sys\n\ndef solve(s):\n if s == "":\n return True\n elif s.endswith("dream"):\n return solve(s[:-5])\n elif s.endswith("dreamer"):\n return solve(s[:-7])\n elif s.endswith("erase"):\n return solve(s[:-5])\n elif s.endswith("eraser"):\n return solve(s[:-6])\n else:\n return False\n return False\n\n\ndef main():\n line = sys.stdin.readline()\n\n if solve(line):\n print("YES")\n else:\n print("NO")\n\n return 0\n\nif __name__ == \'__main__\':\n sys.exit(main())\n', 'import sys\n\ndef solve(s):\n tmp_s = s\n while(len(tmp_s) > 0):\n if tmp_s.startswith("maerd"):\n tmp_s = tmp_s[5:]\n elif tmp_s.startswith("remaerd"):\n tmp_s = tmp_s[7:]\n elif tmp_s.startswith("esare"):\n tmp_s = tmp_s[5:]\n elif tmp_s.startswith("resare"):\n tmp_s = tmp_s[6:]\n else:\n return False\n\n return True\n\ndef main():\n line = sys.stdin.readline().rstrip()\n line_rev = line[::-1]\n\n if solve(line_rev):\n print("YES")\n else:\n print("NO")\n\n return 0\n\nif __name__ == \'__main__\':\n sys.exit(main())\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s120247655', 's468917985', 's966245761', 's023355238']
[3316.0, 3188.0, 3188.0, 3444.0]
[18.0, 18.0, 17.0, 70.0]
[637, 559, 530, 623]
p03856
u765237551
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s = input()\n\ndef solve(s):\n i = 0\n n = len(s)\n\n while i < n:\n if s[i:i+5] == \'dream\':\n if s[i+5:i+7] != \'er\':\n i += 5\n elif i+7 < n and s[i+7] == \'a\':\n i += 5\n else:\n i += 7\n elif s[i:i+5] == \'erase\':\n if s[i+5] == \'r\':\n i += 6\n else:\n i += 5\n else:\n return False\n return True\n\nif solve(s):\n print("Yes")\nelse:\n print(\'No\')\n', 's = input()\n\ndef solve(s):\n i = 0\n n = len(s)\n\n while i < n:\n if s[i:i+5] == \'dream\':\n if s[i+5:i+7] != \'er\':\n i += 5\n elif i+7 < n and s[i+7] == \'a\':\n i += 5\n else:\n i += 7\n elif s[i:i+5] == \'erase\':\n if i+5 < n and s[i+5] == \'r\':\n i += 6\n else:\n i += 5\n else:\n return False\n return True\n\nif solve(s):\n print("YES")\nelse:\n print(\'NO\')\n']
['Runtime Error', 'Accepted']
['s817371347', 's314151717']
[3188.0, 3188.0]
[28.0, 27.0]
[504, 516]
p03856
u780475861
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["if not input().replace('eraser', '').replace('erase', '').replace('dream', '').replace('dreamer', ''):\n print('Yes')\nelse:\n print('No')", "if not input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', ''):\n print('YES')\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s755934755', 's393470762']
[3188.0, 3188.0]
[19.0, 19.0]
[137, 137]
p03856
u816631826
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['s=input(str())\nlst=["eraser","erase","dreamer","dream"]\nfor t in lst:\n s=s.replace(t,"")\nif s=="":\n print(\'NO\')\nelse:\n print(\'YES\')\n ', 's=input()\ns=s.replace(\'eraser\',\'\')\ns=s.replace(\'erase\',\'\')\ns=s.replace(\'dreamer\',\'\')\ns=s.replace(\'dream\',\'\')\nif s==\'\':\n print("YES")\nelse :\n print("NO")']
['Wrong Answer', 'Accepted']
['s050751933', 's783385442']
[9196.0, 9056.0]
[29.0, 27.0]
[145, 158]
p03856
u875291233
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
['# coding: utf-8\n# Your code here!\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\n#n,*a = map(int,readline().split())\n\n\ns = [*input()]\na = [*"dream"]\nb = [*"dreamer"]\nc = [*"erase"]\nd = [*"eraser"]\n\n\nwhile True:\n if not s:\n print("Yes")\n break\n elif s[-5:] == a:\n for _ in range(5): s.pop()\n elif s[-5:] == c:\n for _ in range(5): s.pop()\n elif s[-6:] == b:\n for _ in range(6): s.pop()\n elif s[-6:] == d:\n for _ in range(6): s.pop()\n else:\n print("No")\n break\n\n\n\n\n\n', '# coding: utf-8\n# Your code here!\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\n#n,*a = map(int,readline().split())\n\n\ns = [*input()]\na = [*"dream"]\nb = [*"dreamer"]\nc = [*"erase"]\nd = [*"eraser"]\n\nwhile True:\n if not s:\n print("YES")\n break\n elif s[-5:] == a:\n for _ in range(5): s.pop()\n elif s[-5:] == c:\n for _ in range(5): s.pop()\n elif s[-7:] == b:\n for _ in range(7): s.pop()\n elif s[-6:] == d:\n for _ in range(6): s.pop()\n else:\n print("NO")\n break\n\n\n\n\n']
['Wrong Answer', 'Accepted']
['s486448055', 's184292901']
[9872.0, 9752.0]
[30.0, 45.0]
[636, 634]
p03856
u926678805
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["s=input()\nd=['dream','dreamer','erase','eraser']\nwhile s:\n for m in d:\n if s.endswith(m):\n s=s.rstrip(m)\n break\n else:\n print('NO')\n exit()\nprint('YES')\n", "s=input()\nd=['dream','dreamer','erase','eraser']\nwhile s:\n for m in d:\n if s.endswith(m):\n s=s.strip(m)\n break\n else:\n print('NO')\n exit()\nprint('YES')\n", "s=input()\nd=['dream','dreamer','erase','eraser']\nwhile s:\n for m in d:\n if s.endswith(m):\n s=s[:-len(m)]\n break\n else:\n print('NO')\n exit()\nprint('YES')\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s004865863', 's060386965', 's015948965']
[3188.0, 3188.0, 3188.0]
[18.0, 18.0, 75.0]
[202, 201, 202]
p03856
u932465688
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["s = input()\ncopys = s\ns += 'r'\ni = 0\nt = ''\nwhile i <= len(s)-5:\n if s[i:i+5] == 'dream':\n if s[i+5] == 'r':\n i += 6\n t += 'dreamer'\n else:\n i += 5\n t += 'dream'\n elif s[i:i+5] == 'erase':\n if s[i+5] == 'r':\n i += 6\n t += 'eraser'\n else:\n i += 5\n t += 'erase'\n else:\n break\n\nif t == copys:\n print('YES')\nelse:\n print('NO')", "s = input()\nt = s[::-1]\ni = 0\nk = len(s)\nwhile i <= k-5:\n if k-i >= 7:\n if t[i] != 'r':\n if t[i:i+5] == 'maerd':\n i += 5\n elif t[i:i+5] == 'esare':\n i += 5\n else:\n i = k+1\n else:\n if t[i:i+6] == 'resare':\n i += 6\n elif t[i:i+7] == 'remaerd':\n i += 7\n else:\n i = k+1\n elif k-i == 6:\n if t[i:i+6] == 'resare':\n i = k\n else:\n i = k+1\n else:\n if t[i:i+5] == 'esare':\n i = k\n elif t[i:i+5] == 'maerd':\n i = k\n else:\n i = k+1\nif i == k:\n print('YES')\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s913003459', 's029437969']
[3188.0, 3188.0]
[18.0, 30.0]
[382, 586]
p03856
u966695411
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["S = input()\nfor i in ['eraser', 'erase', 'dreamer', 'dream']:\n S=S.replace(i, 'R')\nprint(['NO', 'YES'][len(s) == 1 and 'R' in s])", "S = input()\nfor i in ['eraser', 'erase', 'dreamer', 'dream']:\n S=S.replace(i, 'R')\ns = set(S)\nprint(['NO', 'YES'][len(s) == 1 and 'R' in s])"]
['Runtime Error', 'Accepted']
['s475454272', 's494227109']
[3316.0, 3188.0]
[25.0, 25.0]
[132, 143]
p03856
u973972117
2,000
262,144
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
["S = input()\nN = len(S)\ni = 0\nwhile i < N:\n sig = 0\n S5 = S[i:i+5]\n if S5 == 'dream':\n sig = 1\n if S[i+5:i+7] == 'er' and S[i+7] != 'a':\n i += 2\n i += 5\n elif S5 == 'erase':\n sig = 1\n if S[i+5:i+6] == 'r':\n i += 1\n i += 5\n if sig == 0:\n sig = 2\n Answer = 'No'\n break\nif sig != 2:\n Answer = 'Yes'\nprint(Answer)", "S = input()\nN = len(S)\ni = 0\nwhile i < N:\n sig = 0\n S5 = S[i:i+5]\n if S5 == 'dream':\n sig = 1\n if S[i+5:i+7] == 'er' and S[i+7] != 'a':\n i += 2\n i += 5\n elif S5 == 'erase':\n sig = 1\n if S[i+5:i+6] == 'r':\n i += 1\n i += 5\n if sig == 0:\n sig = 2\n Answer = 'No'\n break\nif sig != 2:\n Answer = 'Yes'\nprint(Answer)", "S = input()\nN = len(S)\ni = 0\nwhile i < N:\n sig = 0\n S5 = S[i:i+5]\n if S5 == 'dream':\n sig = 1\n if S[i+5:i+7] == 'er' and S[i+7:i+8] != 'a':\n i += 2\n i += 5\n elif S5 == 'erase':\n sig = 1\n if S[i+5:i+6] == 'r':\n i += 1\n i += 5\n if sig == 0:\n sig = 2\n Answer = 'NO'\n break\nif sig != 2:\n Answer = 'YES'\nprint(Answer)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s184391707', 's480912085', 's673311285']
[9156.0, 9136.0, 9108.0]
[39.0, 38.0, 40.0]
[411, 411, 415]
p03864
u023231878
2,000
262,144
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
["s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])", "n, x = map(int, input().split(' '))\na = list(map(int, input().split(' ')))\nans = 0\nif a[0] > x:\n ans += a[0] - x\n a[0] = x\nfor i in range(1,len(a)):\n if a[i-1] + a[i] > x:\n ans += a[i-1] + a[i] - x\n a[i] = x - a[i-1]\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s548351944', 's737001158']
[3060.0, 14132.0]
[17.0, 104.0]
[61, 250]
p03864
u039623862
2,000
262,144
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
["xs,ys,xt,yt = map(int, input().split())\nn = int(input())\nc = [(xs,ys, 0),(xt,yt,0)]\nfor i in range(n):\n x,y,r = map(int, input().split())\n c.append((x,y,r))\n\ndef circle_circle(ax,ay,ar,bx,by,br):\n d =((ax-bx)**2 + (ay-by)**2)**0.5\n return max(0, d-(ar+br))\n\ndef dijkstra(V, edges, root):\n import heapq\n\n visited = [False] * V\n nodes = [[] for i in range(V)]\n cost = [[] for i in range(V)]\n\n for e in edges:\n s, t, d = e\n nodes[s].append(t)\n cost[s].append(d)\n\n dist = [float('inf')] * V\n dist[root] = 0\n\n h = [(0, root)]\n while h:\n c, v = heapq.heappop(h)\n if visited[v]:\n continue\n visited[v] = True\n for i in range(n+1):\n t = nodes[v][i]\n nc = c + cost[v][i]\n if dist[t] > nc:\n dist[t] = nc\n heapq.heappush(h, (nc, t))\n return dist\nedges = []\nfor i in range(n+1):\n for j in range(i+1, n+2):\n d = circle_circle(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2])\n edges.append((i,j,d))\n edges.append((j,i,d))\ndij = dijkstra(n+2, edges, 0)\nprint(dij[1])\n", 'n,x = map(int, input().split())\na = list(map(int, input().split()))\nb = a[::-1]\n\ndef solve(a):\n total = 0\n if a[0] > x:\n total += a[0]-x\n a[0] = x\n\n for i in range(1, n):\n if a[i-1] + a[i] > x:\n d = (a[i-1] + a[i]) - x\n total += d\n a[i] = max(0, a[i] - d)\n return total\n\nprint(min(solve(a), solve(b)))\n']
['Runtime Error', 'Accepted']
['s228202447', 's264509195']
[3316.0, 14548.0]
[23.0, 163.0]
[1140, 368]
p03864
u107077660
2,000
262,144
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
['from math import sqrt\ninf = 10**10\nx_s, y_s, x_t, y_t = map(int, input().split())\nN = int(input())\nxyr = []\nfor i in range(N):\n\tx_i, y_i, r_i = map(int, input().split())\n\txyr.append((x_i, y_i, r_i))\np = (x_s, y_s)\ngoal = (x_t, y_t)\nans = 0\nwhile p != goal and xyr:\n\tD = inf\n\tfor i in range(N):\n\t\tx, y, r = xyr[i]\n\t\td = sqrt((x-p[0])**2+(y-p[1])**2) - 2*r\n\t\tif d < D:\n\t\t\tj = i\n\t\t\tD = d\n\td = sqrt((goal[0]-p[0])**2+(goal[1]-p[1])**2)\n\tif d < D:\n\t\tans += d\n\t\tp = goal\n\telse:\n\t\tx, y, r = xyr.pop(j)\n\t\tp = (x, y)\n\t\tN -= 1\n\t\tans += D\n\nif p != goal:\n\td = sqrt((goal[0]-p[0])**2+(goal[1]-p[1])**2)\n\tans += d\n\nprint(max(0, ans))\n\t', 'N, x = map(int, input().split())\na = [int(i) for i in input().split()]\nans = 0\nfor i in range(N-1):\n\tif a[i] + a[i+1] > x:\n\t\td = a[i] + a[i+1] - x\n\t\tif d <= a[i+1]:\n\t\t\ta[i+1] -= d\n\t\t\tans += d\n\t\telse:\n\t\t\ta[i] -= d - a[i+1]\n\t\t\ta[i+1] = 0\n\t\t\tans += d\nprint(ans)']
['Runtime Error', 'Accepted']
['s894489062', 's792358924']
[3188.0, 14152.0]
[23.0, 142.0]
[621, 258]
p03864
u200239931
2,000
262,144
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
['def getinputdata():\n\n \n array_result = []\n \n data = input()\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nx = int(arr_data[0][1])\n\narr=[int(arr_data[1][x]) for x in range(0,n)]\ncnt=0\nfor i in range(n-1):\n \n if arr[i]+arr[i+1]>x:\n \n if arr[i]-x>=0:\n \n cnt+=arr[i-x]\n arr[i]=0\n \n if arr[i]+arr[i+1]-x>=0:\n \n cnt+=arr[i+1]-x\n arr[i+1]=arr[i+1]-x\n \nprint(cnt) \n ', 'def getinputdata():\n\n \n array_result = []\n \n data = input()\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nx = int(arr_data[0][1])\n\narr=[int(arr_data[1][x]) for x in range(0,n)]\n\ncnt=0\n\nfor i in range(n-1):\n \n zan=arr[i]+arr[i+1]-x\n \n if 0<arr[i+1]<=zan:\n\n cnt+=arr[i+1]\n zan-=arr[i+1]\n arr[i+1]=0\n\n elif arr[i+1]>zan>0:\n\n cnt+=zan\n arr[i+1]-=zan\n zan=0\n\n if 0<arr[i]<=zan:\n\n cnt+=arr[i]\n zan-=arr[i]\n arr[i]=0\n\n elif arr[i]>zan>0:\n\n cnt+=zan\n arr[i]-=zan\n zan=0\n\n \nprint(cnt) ']
['Runtime Error', 'Accepted']
['s885741832', 's561271441']
[14588.0, 14812.0]
[164.0, 162.0]
[849, 925]
p03864
u284854859
2,000
262,144
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
['def dijkstra(s):\n \n \n d = [float("inf")] * n\n used = [False] * n\n d[s] = 0\n \n while True:\n v = -1\n \n for i in range(n):\n if (not used[i]) and (v == -1):\n v = i\n elif (not used[i]) and d[i] < d[v]:\n v = i\n if v == -1:\n break\n used[v] = True\n \n for j in range(n):\n d[j] = min(d[j],d[v]+cost[v][j])\n return d\n\nXs,Ys,Xt,Yt = map(int,input().split())\nn = int(input())\np = [[Xs,Ys,0],[Xt,Yt,0]]\nfor i in range(2,n+2):\n p.append(list(map(int,input().split())))\ncost = [[0]*(n+2)for i in range(n+2)]\n\nfor i in range(n+2):\n for j in range(i,n+2):\n cost[i][j] = cost[j][i] = max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)\n\nn += 2\n\nres = dijkstra(0)\nprint(res[1])\n', 'n,x = map(int,input().split())\na = list(map(int,input().split()))\n\nres = 0\nfor i in range(1,n):\n if a[i]+a[i-1]>= x:\n res += (a[i]+a[i-1]-x)\n if a[i-1]>= x:\n a[i]=0\n else:\n a[i] = x-a[i-1]\n \nprint(res)']
['Runtime Error', 'Accepted']
['s335493707', 's948426895']
[3064.0, 14540.0]
[18.0, 114.0]
[1060, 250]