s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s139068227
p00744
u871901071
1405335773
Python
Python3
py
Runtime Error
0
0
2134
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) h g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return b = [] while len(b) < m: b += list(map(int, input().split())) r = [] while len(r) < n: r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
File "/tmp/tmptszwurr1/tmp53bogw8l.py", line 40 h g = [[] for _ in range(V)] ^ SyntaxError: invalid syntax
s526661185
p00744
u871901071
1405335834
Python
Python3
py
Runtime Error
0
0
2074
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) h g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return b = [] b += list(map(int, input().split())) r = [] r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
File "/tmp/tmpc1n9b2v_/tmpk_1mjz1n.py", line 40 h g = [[] for _ in range(V)] ^ SyntaxError: invalid syntax
s252909332
p00744
u871901071
1405335888
Python
Python3
py
Runtime Error
0
0
2073
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return b = [] b += list(map(int, input().split())) r = [] r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
Traceback (most recent call last): File "/tmp/tmpp9my63pi/tmp9jdcbham.py", line 82, in <module> main() File "/tmp/tmpp9my63pi/tmp9jdcbham.py", line 62, in main m, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s895389148
p00744
u871901071
1405335977
Python
Python3
py
Runtime Error
0
0
2134
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) h g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return b = [] while len(b) < m: b += list(map(int, input().split())) r = [] while len(r) < n: r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
File "/tmp/tmpqompi1sh/tmpgyf5lqw1.py", line 40 h g = [[] for _ in range(V)] ^ SyntaxError: invalid syntax
s242592122
p00744
u871901071
1405336009
Python
Python3
py
Runtime Error
39850
98524
2133
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return b = [] while len(b) < m: b += list(map(int, input().split())) r = [] while len(r) < n: r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
Traceback (most recent call last): File "/tmp/tmp7qpbu9ws/tmpihxwa6hh.py", line 84, in <module> main() File "/tmp/tmp7qpbu9ws/tmpihxwa6hh.py", line 62, in main m, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s492098535
p00744
u871901071
1405336176
Python
Python3
py
Runtime Error
39860
98528
2173
from collections import deque inf = 100000000000000000 def bfs(graph, s, t): V = len(graph) q = deque([(s, -1, -1)]) prev = [(-1, -1)] * V visited = [False] * V while len(q) > 0: (v, p, e) = q.popleft() if visited[v]: continue visited[v] = True prev[v] = p, e for i in range(len(graph[v])): e = graph[v][i] if e['cap'] > 0: q.append((e['to'], v, i)) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = bfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return data = [] while len(data) < n + m: data += list(map(int, input().split())) b = data[:m] r = data[m:] while len(r) < n: r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
Traceback (most recent call last): File "/tmp/tmpcmswolz5/tmp23ntc68j.py", line 85, in <module> main() File "/tmp/tmpcmswolz5/tmp23ntc68j.py", line 62, in main m, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s961697481
p00744
u871901071
1405337688
Python
Python3
py
Runtime Error
39850
92328
2260
from collections import deque inf = 100000000000000000 def dfs(graph, s, t): V = len(graph) prev = [(-1, -1)] * V visited = [False] * V visited[0] = True def iter(cur): if cur == t: return True for i in range(len(graph[cur])): e = graph[cur][i] if not visited[e['to']] and e['cap'] > 0 : prev[e['to']] = (cur, i) visited[e['to']] = True if iter(e['to']): return True return False iter(s) if not visited[t]: return None else: return prev def decrease_graph(graph, s, t, prev): ((p, e), c) = prev[t], t m = inf while p != -1: m = min(graph[p][e]['cap'], m) ((p, e), c) = prev[p], p ((p, e), c) = prev[t], t while p != -1: graph[p][e]['cap'] -= m graph[c][graph[p][e]['rev']]['cap'] += m ((p, e), c) = prev[p], p return m def maximum_flow(graph, s, t): V = len(graph) g = [[] for _ in range(V)] for v in range(V): nei = graph[v] for (u, cap) in nei: g[v].append({'to' : u, 'from': v, 'cap': cap, 'rev': len(g[u])}) g[u].append({'to' : v, 'from': u, 'cap': 0, 'rev': len(g[v]) - 1}) sum = 0 while True: prev = dfs(g, s, t) if prev == None: break sum += decrease_graph(g, s, t, prev) return sum def gcd(x, y): while y > 0: x, y = y, x % y return x def main(): while True: m, n = map(int, input().split()) if m == 0 and n == 0: return data = [] while len(data) < n + m: data += list(map(int, input().split())) b = data[:m] r = data[m:] while len(r) < n: r += list(map(int, input().split())) g = [[] for i in range(n + m + 2)] for i in range(m): g[0].append((i + 1, 1)) for i in range(n): g[m + i + 1].append((n + m + 1, 1)) for i in range(m): for j in range(n): if gcd(b[i], r[j]) > 1: g[i + 1].append((m + j + 1, 1)) print(maximum_flow(g, 0, n + m + 1)) main()
Traceback (most recent call last): File "/tmp/tmpdm2br8pj/tmpuxs6rv_i.py", line 88, in <module> main() File "/tmp/tmpdm2br8pj/tmpuxs6rv_i.py", line 65, in main m, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s127894035
p00744
u844945939
1423750275
Python
Python3
py
Runtime Error
19930
14820
1030
from fractions import gcd def add_edge(u, v): G[u].append(v) G[v].append(u) def dfs(v): used[v] = True for u in G[v]: w = match[u] if w < 0 or not used[w] and dfs(w): match[v] = u match[u] = v return True else: return False def bipartite_matching(): result = 0 match[:] = [-1] * (numv) for v in range(numv): if match[v] < 0: used[:] = [False] * numv if dfs(v): result += 1 return result while True: m, n = map(int, input().split()) if (m, n) == (0, 0): break numv = m + n cards = [] while len(cards) < numv: cards.extend(map(int, input().split())) blues = cards[:m] reds = cards[m:] G = [[] for i in range(numv)] used = [False] * numv match = [-1] * numv for i, b in enumerate(blues): for j, r in enumerate(reds, m): if gcd(b, r) > 1: add_edge(i, j) print(bipartite_matching())
Traceback (most recent call last): File "/tmp/tmprad03gpu/tmp88fvsndq.py", line 1, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
s854257341
p00744
u844945939
1423750343
Python
Python3
py
Runtime Error
19930
14824
1030
from fractions import gcd def add_edge(u, v): G[u].append(v) G[v].append(u) def dfs(v): used[v] = True for u in G[v]: w = match[u] if w < 0 or not used[w] and dfs(w): match[v] = u match[u] = v return True else: return False def bipartite_matching(): result = 0 match[:] = [-1] * (numv) for v in range(numv): if match[v] < 0: used[:] = [False] * numv if dfs(v): result += 1 return result while True: m, n = map(int, input().split()) if (m, n) == (0, 0): break numv = m + n cards = [] while len(cards) < numv: cards.extend(map(int, input().split())) blues = cards[:m] reds = cards[m:] G = [[] for i in range(numv)] used = [False] * numv match = [-1] * numv for i, b in enumerate(blues): for j, r in enumerate(reds, m): if gcd(b, r) > 1: add_edge(i, j) print(bipartite_matching())
Traceback (most recent call last): File "/tmp/tmp2wgfser8/tmplj03dg7_.py", line 1, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
s587410174
p00744
u844945939
1423750643
Python
Python3
py
Runtime Error
19920
14828
1031
from fractions import gcd def add_edge(u, v): G[u].append(v) G[v].append(u) def dfs(v): used[v] = True for u in G[v]: w = match[u] if w < 0 or not used[w] and dfs(w): match[v] = u match[u] = v return True else: return False def bipartite_matching(): result = 0 match[:] = [-1] * (numv) for v in range(numv): if match[v] < 0: used[:] = [False] * numv if dfs(v): result += 1 return result while True: m, n = map(int, input().split()) if (m, n) == (0, 0): break numv = m + n cards = [] while len(cards) < numv: cards.extend(map(int, input().split())) blues = cards[:m] reds = cards[m:] G = [[] for i in range(numv)] used = [False] * numv match = [-1] * numv for i, b in enumerate(blues): for j, r in enumerate(reds, m): if gcd(b, r) > 1: add_edge(i, j) print(bipartite_matching())
Traceback (most recent call last): File "/tmp/tmp6n2bmwl6/tmp_89aw93v.py", line 2, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
s952644784
p00744
u811733736
1521379727
Python
Python3
py
Runtime Error
0
0
2107
# -*- coding: utf-8 -*- """ Cards http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1163&lang=jp """ import sys from sys import stdin from collections import namedtuple from fractions import gcd input = stdin.readline edge = namedtuple('edge', ['to', 'cap', 'rev']) def add_edge(G, f, t, c): G[f].append(edge(t, c, len(G[t]))) G[t].append(edge(f, 0, len(G[f]) - 1)) def dfs(G, used, v, t, f): if v == t: return f used[v] = True for i in range(len(G[v])): e = G[v][i] if (not used[e.to]) and (e.cap > 0): d = dfs(G, used, e.to, t, min(f, e.cap)) if d > 0: G[v][i] = edge(e.to, e.cap - d, e.rev) G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev) return d return 0 def max_flow(G, V,s, t): used = [False] * V flow = 0 while True: for i in range(len(used)): used[i] = False f = dfs(G, used, s, t, float('inf')) if f == 0: return flow flow += f def main(args): """ 0: ソース 1〜m: 青 m+1〜m+n: 赤 m+n+1: シンク """ while True: m, n = map(int, input().split()) if m == 0 and n == 0: break blue_cards = [] red_cards = [] while True: blue_cards.extend([int(b) for b in input().split()]) if len(blue_cards) == m: break while True: red_cards.extend([int(r) for r in input().split()]) if len(red_cards) == n: break G = [[] for _ in range(m+n+2)] for b in range(1, m+1): add_edge(G, 0, b, 1) for r in range(m+1, m+n+1): add_edge(G, r, m+n+1, 1) for bi, b in enumerate(blue_cards, start=1): for ri, r in enumerate(red_cards, start=m+1): if gcd(b, r) != 1: add_edge(G, bi, ri, 1) ans = max_flow(G, m+n+2, 0, m+n+1) print(ans) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmpla318aq_/tmpkh1kvfpo.py", line 10, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
s434684999
p00744
u811733736
1521380129
Python
Python3
py
Runtime Error
0
0
2102
# -*- coding: utf-8 -*- """ Cards http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1163&lang=jp """ import sys from sys import stdin from collections import namedtuple from math import gcd input = stdin.readline edge = namedtuple('edge', ['to', 'cap', 'rev']) def add_edge(G, f, t, c): G[f].append(edge(t, c, len(G[t]))) G[t].append(edge(f, 0, len(G[f]) - 1)) def dfs(G, used, v, t, f): if v == t: return f used[v] = True for i in range(len(G[v])): e = G[v][i] if (not used[e.to]) and (e.cap > 0): d = dfs(G, used, e.to, t, min(f, e.cap)) if d > 0: G[v][i] = edge(e.to, e.cap - d, e.rev) G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev) return d return 0 def max_flow(G, V,s, t): used = [False] * V flow = 0 while True: for i in range(len(used)): used[i] = False f = dfs(G, used, s, t, float('inf')) if f == 0: return flow flow += f def main(args): """ 0: ソース 1〜m: 青 m+1〜m+n: 赤 m+n+1: シンク """ while True: m, n = map(int, input().split()) if m == 0 and n == 0: break blue_cards = [] red_cards = [] while True: blue_cards.extend([int(b) for b in input().split()]) if len(blue_cards) == m: break while True: red_cards.extend([int(r) for r in input().split()]) if len(red_cards) == n: break G = [[] for _ in range(m+n+2)] for b in range(1, m+1): add_edge(G, 0, b, 1) for r in range(m+1, m+n+1): add_edge(G, r, m+n+1, 1) for bi, b in enumerate(blue_cards, start=1): for ri, r in enumerate(red_cards, start=m+1): if gcd(b, r) != 1: add_edge(G, bi, ri, 1) ans = max_flow(G, m+n+2, 0, m+n+1) print(ans) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmpeka5sct_/tmpfs3d5buq.py", line 87, in <module> main(sys.argv[1:]) File "/tmp/tmpeka5sct_/tmpfs3d5buq.py", line 55, in main m, n = map(int, input().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s242171415
p00744
u811733736
1521413802
Python
Python3
py
Runtime Error
0
0
2523
# -*- coding: utf-8 -*- """ Cards http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1163&lang=jp """ import sys from sys import stdin from collections import namedtuple, deque from math import gcd input = stdin.readline edge = namedtuple('edge', ['to', 'cap', 'rev']) def add_edge(G, f, t, c): G[f].append(edge(t, c, len(G[t]))) G[t].append(edge(f, 0, len(G[f]) - 1)) def bfs(G, level, s): for i in range(len(level)): level[i] = -1 que = deque() level[s] = 0 que.append(s) while que: v = que.popleft() for e in G[v]: if e.cap > 0 and level[e.to] < 0: level[e.to] = level[v] + 1 que.append(e.to) def dfs(G, iter, level, v, t, f): if v == t: return f for i in range(iter[v], len(G[v])): e = G[v][i] if e.cap > 0 and level[v] < level[e.to]: d = dfs(G, iter, level, e.to, t, min(f, e.cap)) if d > 0: G[v][i] = edge(e.to, e.cap - d, e.rev) G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev) return d return 0 def max_flow(G, V, s, t): level = [0] * V flow = 0 while True: bfs(G, level, s) if level[t] < 0: return flow iter = [0] * V while True: f = dfs(G, iter, level, s, t, float('inf')) if f > 0: flow += f else: break def main(args): """ 0: ソース 1〜m: 青 m+1〜m+n: 赤 m+n+1: シンク """ while True: m, n = map(int, input().split()) if m == 0 and n == 0: break blue_cards = [] red_cards = [] while True: blue_cards.extend([int(b) for b in input().split()]) if len(blue_cards) == m: break while True: red_cards.extend([int(r) for r in input().split()]) if len(red_cards) == n: break G = [[] for _ in range(m+n+2)] for b in range(1, m+1): add_edge(G, 0, b, 1) for r in range(m+1, m+n+1): add_edge(G, r, m+n+1, 1) for bi, b in enumerate(blue_cards, start=1): for ri, r in enumerate(red_cards, start=m+1): if gcd(b, r) != 1: add_edge(G, bi, ri, 1) ans = max_flow(G, m+n+2, 0, m+n+1) print(ans) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmpkcvh2clh/tmpnsu35fh9.py", line 104, in <module> main(sys.argv[1:]) File "/tmp/tmpkcvh2clh/tmpnsu35fh9.py", line 72, in main m, n = map(int, input().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s536641198
p00744
u647766105
1386331311
Python
Python
py
Runtime Error
39850
36860
1331
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): global visited flow = 0 while True: visited = [False]*MAX_V f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break G = [[] for _ in xrange(MAX_V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i,b in enumerate(blue): add_edge(MAX_V-2,i,1) for i,r in enumerate(red): add_edge(i+m,MAX_V-1,1) for i in xrange(m): for j in xrange(n): if gcd(blue[i],red[j]) != 1: add_edge(i,j+m,1) print max_flow(MAX_V-2,MAX_V-1)
File "/tmp/tmpz79rmgpe/tmp3ypjmnez.py", line 56 print max_flow(MAX_V-2,MAX_V-1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s197023854
p00744
u647766105
1386331494
Python
Python
py
Runtime Error
39860
36860
1331
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1003 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): global visited flow = 0 while True: visited = [False]*MAX_V f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break G = [[] for _ in xrange(MAX_V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i,b in enumerate(blue): add_edge(MAX_V-2,i,1) for i,r in enumerate(red): add_edge(i+m,MAX_V-1,1) for i in xrange(m): for j in xrange(n): if gcd(blue[i],red[j]) != 1: add_edge(i,j+m,1) print max_flow(MAX_V-2,MAX_V-1)
File "/tmp/tmp5ojl3xuv/tmpgsuemkjz.py", line 56 print max_flow(MAX_V-2,MAX_V-1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s432972109
p00744
u647766105
1386331935
Python
Python
py
Runtime Error
39850
36860
1331
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): global visited flow = 0 while True: visited = [False]*MAX_V f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break G = [[] for _ in xrange(MAX_V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i,b in enumerate(blue): add_edge(MAX_V-2,i,1) for i,r in enumerate(red): add_edge(i+m,MAX_V-1,1) for i in xrange(m): for j in xrange(n): if gcd(blue[i],red[j]) != 1: add_edge(i,j+m,1) print max_flow(MAX_V-2,MAX_V-1)
File "/tmp/tmpaqhqj0r2/tmpxm5u5hai.py", line 56 print max_flow(MAX_V-2,MAX_V-1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s347629347
p00744
u647766105
1386332419
Python
Python
py
Runtime Error
39860
36864
1331
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): global visited flow = 0 while True: visited = [False]*MAX_V f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break G = [[] for _ in xrange(MAX_V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i,b in enumerate(blue): add_edge(MAX_V-2,i,1) for i,r in enumerate(red): add_edge(i+m,MAX_V-1,1) for i in xrange(m): for j in xrange(n): if gcd(blue[i],red[j]) != 1: add_edge(i,j+m,1) print max_flow(MAX_V-2,MAX_V-1)
File "/tmp/tmpf_w97vdj/tmp0gsqztuo.py", line 56 print max_flow(MAX_V-2,MAX_V-1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s577296836
p00744
u647766105
1386332546
Python
Python
py
Runtime Error
39860
36864
1274
from fractions import gcd INF = 2 << 30 V = 1003 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap <= 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): flow = 0 while True: for i in xrange(V): visited[i] = False f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break V = m+n+2 G = [[] for _ in xrange(V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i,b in enumerate(blue): add_edge(V-2,i,1) for i,r in enumerate(red): add_edge(i+m,V-1,1) for i in xrange(m): for j in xrange(n): if gcd(blue[i],red[j]) != 1: add_edge(i,j+m,1) print max_flow(V-2,V-1)
File "/tmp/tmp6vkhbxnp/tmpnqp5ko9o.py", line 55 print max_flow(V-2,V-1) ^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s392149434
p00744
u647766105
1386643452
Python
Python
py
Runtime Error
39860
36864
1265
from fractions import gcd INF = 2 << 30 V = 1002 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): flow = 0 while True: for i in xrange(V): visited[i] = False f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break V = m+n+2 G = [[] for _ in xrange(V)] data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i in xrange(m): add_edge(V-2,i,1) for i in xrange(m,m+n): add_edge(i,V-1,1) for i,b in enumerate(blue): for j,r in enumerate(red,m): if gcd(b,r) != 1: add_edge(i,j,1) print max_flow(V-2,V-1)
File "/tmp/tmpmskcfn3p/tmpnsu07027.py", line 55 print max_flow(V-2,V-1) ^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s068443553
p00744
u647766105
1386643688
Python
Python
py
Runtime Error
39850
36864
1361
from fractions import gcd INF = 2 << 30 V = 1002 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): flow = 0 while True: for i in xrange(V): visited[i] = False f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if m|n == 0: break V = m+n+2 G = [[] for _ in xrange(V)] visited = [True] * V data = [] dbg = 0 while len(data) < n+m: dbg += 1 data += map(int,raw_input().split()) if dbg >= 1500: break blue = data[:m] red = data[m:] for i in xrange(m): add_edge(V-2,i,1) for i in xrange(m,m+n): add_edge(i,V-1,1) for i,b in enumerate(blue): for j,r in enumerate(red,m): if gcd(b,r) != 1: add_edge(i,j,1) print max_flow(V-2,V-1)
File "/tmp/tmpgjwhk6t8/tmpyhv3qfu2.py", line 60 print max_flow(V-2,V-1) ^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s492984252
p00744
u647766105
1386644849
Python
Python
py
Runtime Error
39850
36864
1339
from fractions import gcd INF = 2 << 30 V = 1002 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): flow = 0 dbg = 0 while True: for i in xrange(V): visited[i] = False f = dfs(s,t,INF) if f == 0: return flow flow += f dbg += 1 if dbg > 600: return -1 while True: m,n = map(int,raw_input().split()) if m|n == 0: break V = m+n+2 G = [[] for _ in xrange(V)] visited = [True] * V data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i in xrange(m): add_edge(V-2,i,1) for i in xrange(m,m+n): add_edge(i,V-1,1) for i,b in enumerate(blue): for j,r in enumerate(red,m): if gcd(b,r) != 1: add_edge(i,j,1) print max_flow(V-2,V-1)
File "/tmp/tmphuzut5rw/tmpnohposvg.py", line 60 print max_flow(V-2,V-1) ^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s385782233
p00744
u647766105
1386646027
Python
Python
py
Runtime Error
39860
36864
1272
from fractions import gcd INF = 2 << 30 V = 1002 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v])): if visited[to] or cap == 0: continue d = dfs(to,t,min(f,cap)) if d > 0: G[v][i][1] -= d G[to][rev][1] += d return d return 0 def max_flow(s,t): flow = 0 while True: for i in xrange(V): visited[i] = False f = dfs(s,t,INF) if f == 0: return flow flow += f while True: m,n = map(int,raw_input().split()) if (m,n) == (0,0): break V = m+n+2 G = [[] for _ in xrange(V)] visited = [True] * V data = [] while len(data) < n+m: data += map(int,raw_input().split()) blue = data[:m] red = data[m:] for i in xrange(m): add_edge(V-2,i,1) for i in xrange(m,m+n): add_edge(i,V-1,1) for i,b in enumerate(blue): for j,r in enumerate(red,m): if gcd(b,r) != 1: add_edge(i,j,1) print max_flow(V-2,V-1)
File "/tmp/tmpcq3yqceu/tmpwtydcp_c.py", line 56 print max_flow(V-2,V-1) ^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s415400778
p00746
u616098312
1466507033
Python
Python
py
Runtime Error
0
0
671
while True: N=int(input()) if N==0:break t=[0] y=[0] lst=list(range(N)) for k in lst[1:]: [x,d]=input().slice() [x,d]=[int(x),int(d)] if d==0: t=t+[t[x]] y=y+[y[x]-1] if d==1: t=t+[t[x]-1] y=y+[y[x]] if d==2: t=t+[t[x]] y=y+[y[x]+1] if d==3: t=t+[t[x]+1] y=y+[y[x]] ht=0 lt=0 hy=0 ly=0 for f in range(N): if ht<t[f]: ht+=1 if lt>t[f]: lt-=1 if hy<y[f]: hy+=1 if ly>y[f]: ly-=1 print(ht-lt+1,hy-ly+1)
Traceback (most recent call last): File "/tmp/tmpcon6bwqm/tmp___cgp1b.py", line 2, in <module> N=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s919813666
p00746
u616098312
1466507044
Python
Python3
py
Runtime Error
0
0
671
while True: N=int(input()) if N==0:break t=[0] y=[0] lst=list(range(N)) for k in lst[1:]: [x,d]=input().slice() [x,d]=[int(x),int(d)] if d==0: t=t+[t[x]] y=y+[y[x]-1] if d==1: t=t+[t[x]-1] y=y+[y[x]] if d==2: t=t+[t[x]] y=y+[y[x]+1] if d==3: t=t+[t[x]+1] y=y+[y[x]] ht=0 lt=0 hy=0 ly=0 for f in range(N): if ht<t[f]: ht+=1 if lt>t[f]: lt-=1 if hy<y[f]: hy+=1 if ly>y[f]: ly-=1 print(ht-lt+1,hy-ly+1)
Traceback (most recent call last): File "/tmp/tmpezyekn46/tmpjjsfi38d.py", line 2, in <module> N=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s240761145
p00747
u316268279
1422197165
Python
Python3
py
Runtime Error
19920
18760
1584
#!/usr/bin/env python # -*- coding: utf-8 -*- from heapq import heappop,heappush def bfs(sx,sy,W,H): queue = [] heappush(queue,(0,sx,sy)) dxdy = [(0,1),(0,-1),(1,0),(-1,0)] visited = [[ 10**8 for i in range(W)] for j in range(H)] while queue != []: count,x,y = heappop(queue) visited[y][x] = min(visited[y][x],count) for nx,ny in dxdy: if 0 <= x + nx < W and 0 <= y + ny < H: if visited[y + ny][x + nx] == 10**8: nextValue = Maze[y + ny][x + nx] if ((nx,ny) == (1,0) and nextValue & 1 > 0) or ((nx,ny) == (0,1) and nextValue & 2 > 0) or ((nx,ny) == (-1,0) and Maze[y][x] & 1 > 0) or ((nx,ny) == (0,-1) and Maze[y][x] & 2 > 0 ): continue else: heappush(queue,(count + 1,x+nx,y+ny)) return visited while True: w,h = map(int,input().split(" ")) if h == 0 and w == 0: break Maze = [[0 for j in range(w)] for i in range(h)] for i in range(h-1): row = list(map(int,input().split())) for j in range(len(row)): if row[j] == 1: Maze[i][j+1] += 1 col = list(map(int,input().split())) for j in range(len(col)): if col[j] == 1: Maze[i+1][j] += 2 else: i += 1 row = list(map(int,input().split())) for j in range(len(row)): if row[j] == 1: Maze[i][j+1] += 1 ret = bfs(0,0,w,h)[h-1][w-1] print(ret + 1 if ret != 10**8 else 0)
Traceback (most recent call last): File "/tmp/tmpp4y0oqpw/tmpkggxr42o.py", line 26, in <module> w,h = map(int,input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s814024892
p00747
u120360464
1423713980
Python
Python
py
Runtime Error
19930
12096
1018
#! /usr/bin/python # -*- coding: utf-8 -*- while 1: ans = 0 (w, h) = map(int, raw_input().split()) used = [[False]*w for i in range(h)] if h == 0:break que = [[0, 0, 1]] vir = [] hor = [] for i in range(h): vir.append(map(int, raw_input().split())) if i == h-1:break hor.append(map(int, raw_input().split())) while que!=[]: y = que[0][0] x = que[0][1] cost = que[0][2] used[y][x] = True que.pop(0) if y==h-1 and x==w-1: ans = cost break if x+1 < w and used[y][x+1] == False and vir[y][x] == 0: que.append([y, x+1, cost+1]) if x-1 >= 0 and used[y][x-1] == False and vir[y][x-1] == 0: que.append([y, x-1, cost+1]) if y+1 < h and used[y+1][x] == False and hor[y][x] == 0: que.append([y+1, x, cost+1]) if y-1 >= 0 and used[y-1][x] == False and hor[y-1][x] == 0: que.append([y-1, x, cost+1]) print ans
File "/tmp/tmpigp5w6ft/tmpowavfukh.py", line 33 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s552003186
p00747
u661290476
1487657331
Python
Python3
py
Runtime Error
0
0
1213
def bfs(maze): d = [[0] * 70 for i in range(70)] d[1][1] = 1 que = [(1, 1)] while 0 < len(que): new_que = [] for x, y in que: if x == 2 * w - 1 and y == 2 * h - 1: return d[y][x] for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)): mx, my = x + dx, y + dy nx, ny = mx + dx, my + dy if nx < 0 and w < nx and ny < 0 and h < ny: continue if maze[my][mx] == 0 and d[ny][nx] == 0: new_que.append((nx, ny)) d[ny][nx] = d[y][x] + 1 que = new_que return 0 while True: w, h = map(int, input().split()) maze = [[0] * (w * 2) for i in range(h * 2)] if w == h == 0: break for x in range(w * 2 + 1): maze[0][x] = maze[h * 2][x] = 1 for y in range(h * 2 + 1): maze[y][0] = maze[y][w * 2] = 1 for y in range(1, h * 2): a = [int(i) for i in input().split()] if y % 2 == 1: for x in range(w - 1): maze[y][2 * x + 2] = a[x] else: for x in range(w): maze[y][2 * x + 1] = a[x] print(bfs(maze))
Traceback (most recent call last): File "/tmp/tmpwwwqjz5x/tmp2ori2ip_.py", line 22, in <module> w, h = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s801936829
p00747
u131811591
1495030555
Python
Python3
py
Runtime Error
40000
18392
1284
# coding: utf-8 import sys from collections import deque if __name__ == '__main__': while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [] l.append([0,0,1]) res = 0 while len(l) != 0: bf = l[0] l.pop(0) if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: l.append([bf[0]-1,bf[1],bf[2]+1]) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: l.append([bf[0],bf[1]+1,bf[2]+1]) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: l.append([bf[0],bf[1]-1,bf[2]+1]) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: l.append([bf[0]+1,bf[1],bf[2]+1]) print(res)
Traceback (most recent call last): File "/tmp/tmpuk2f7wnz/tmp04lma5zv.py", line 8, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s144418554
p00747
u131811591
1495030753
Python
Python3
py
Runtime Error
40000
238116
1310
# coding: utf-8 import sys from collections import deque if __name__ == '__main__': while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] deq = deque() deq.append([0,0,1]) res = 0 while len(deq) != 0: bf = deq[0] deq.popleft() if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: deq.append([bf[0]-1,bf[1],bf[2]+1]) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: deq.append([bf[0],bf[1]+1,bf[2]+1]) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: deq.append([bf[0],bf[1]-1,bf[2]+1]) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: deq.append([bf[0]+1,bf[1],bf[2]+1]) print(res)
Traceback (most recent call last): File "/tmp/tmpomw1y3r6/tmp40wpwmbc.py", line 8, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s370608187
p00747
u131811591
1495031031
Python
Python3
py
Runtime Error
40000
18084
1213
# coding: utf-8 if __name__ == '__main__': while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [[0,0,1]] res = 0 while l: bf = l[0] l.pop(0) if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: l.append([bf[0]-1,bf[1],bf[2]+1]) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: l.append([bf[0],bf[1]+1,bf[2]+1]) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: l.append([bf[0],bf[1]-1,bf[2]+1]) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: l.append([bf[0]+1,bf[1],bf[2]+1]) print(res)
Traceback (most recent call last): File "/tmp/tmpsjk0gusb/tmpyrxeo66f.py", line 5, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s062214134
p00747
u131811591
1495031102
Python
Python3
py
Runtime Error
40000
18160
1065
# coding: utf-8 while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [[0,0,1]] res = 0 while l: bf = l[0] l.pop(0) if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: l.append([bf[0]-1,bf[1],bf[2]+1]) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: l.append([bf[0],bf[1]+1,bf[2]+1]) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: l.append([bf[0],bf[1]-1,bf[2]+1]) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: l.append([bf[0]+1,bf[1],bf[2]+1]) print(res)
Traceback (most recent call last): File "/tmp/tmp4vhwsjdw/tmp3jcluoxt.py", line 3, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s037974260
p00747
u131811591
1495031239
Python
Python3
py
Runtime Error
40000
15908
1052
# coding: utf-8 while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [(0,0,1)] res = 0 while l: bf = l.pop(0) if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: l.append((bf[0]-1,bf[1],bf[2]+1)) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: l.append((bf[0],bf[1]+1,bf[2]+1)) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: l.append((bf[0],bf[1]-1,bf[2]+1)) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: l.append((bf[0]+1,bf[1],bf[2]+1)) print(res)
Traceback (most recent call last): File "/tmp/tmpvjjicl42/tmprti1js0y.py", line 3, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s994419513
p00747
u131811591
1495031563
Python
Python3
py
Runtime Error
40000
15864
1036
while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [(0,0,1)] res = 0 while l: bf = l.pop(0) if bf[0] == n-1 and bf[1] == m-1: res = bf[2] break flag[bf[0]][bf[1]] = 1 if 1 <= bf[0] and bw[bf[0]-1][bf[1]] == 0 and flag[bf[0]-1][bf[1]] == 0: l.append((bf[0]-1,bf[1],bf[2]+1)) if bf[1] < m-1 and sw[bf[0]][bf[1]] == 0 and flag[bf[0]][bf[1]+1] == 0: l.append((bf[0],bf[1]+1,bf[2]+1)) if 1 <= bf[1] and sw[bf[0]][bf[1]-1] == 0 and flag[bf[0]][bf[1]-1] == 0: l.append((bf[0],bf[1]-1,bf[2]+1)) if bf[0] < n-1 and bw[bf[0]][bf[1]] == 0 and flag[bf[0]+1][bf[1]] == 0: l.append((bf[0]+1,bf[1],bf[2]+1)) print(res)
Traceback (most recent call last): File "/tmp/tmpwdge7yde/tmpz2yzwbv1.py", line 2, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s515661986
p00747
u131811591
1495031951
Python
Python3
py
Runtime Error
40000
15860
922
while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [(0,0,1)] res = 0 while l: bf = l.pop(0) x,y,z = bf[0],bf[1],bf[2] if x == n-1 and y == m-1: res = z break flag[x][y] = 1 if 1 <= x and bw[x-1][y] == 0 and flag[x-1][y] == 0: l.append((x-1,y,z+1)) if y < m-1 and sw[x][y] == 0 and flag[x][y+1] == 0: l.append((x,y+1,z+1)) if 1 <= y and sw[x][y-1] == 0 and flag[x][y-1] == 0: l.append((x,y-1,z+1)) if x < n-1 and bw[x][y] == 0 and flag[x+1][y] == 0: l.append((x+1,y,z+1)) print(res)
Traceback (most recent call last): File "/tmp/tmpnvoq9__a/tmpbd_mbkzb.py", line 2, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s345415612
p00747
u131811591
1495031981
Python
Python3
py
Runtime Error
40000
15896
922
while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [(0,0,1)] res = 0 while l: bf = l.pop(0) x,y,z = bf[0],bf[1],bf[2] if x == n-1 and y == m-1: res = z break flag[x][y] = 1 if 1 <= x and bw[x-1][y] == 0 and flag[x-1][y] == 0: l.append((x-1,y,z+1)) if y < m-1 and sw[x][y] == 0 and flag[x][y+1] == 0: l.append((x,y+1,z+1)) if 1 <= y and sw[x][y-1] == 0 and flag[x][y-1] == 0: l.append((x,y-1,z+1)) if x < n-1 and bw[x][y] == 0 and flag[x+1][y] == 0: l.append((x+1,y,z+1)) print(res)
Traceback (most recent call last): File "/tmp/tmpj2u7gmcb/tmpjuugt4s2.py", line 2, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s238299000
p00747
u131811591
1495032049
Python
Python3
py
Runtime Error
40000
15996
923
while True: m,n = map(int,input().split()) sw = [] bw = [] if m == 0 and n == 0: break for i in range(2*n-1): if i % 2 == 0: sw.append(list(map(int,input().split()))) else: bw.append(list(map(int,input().split()))) flag = [[0 for i in range(m)] for j in range(n)] l = [(0,0,1)] res = 0 while l: bf = l.pop(0) x,y,z = bf[0],bf[1],bf[2] if x == n-1 and y == m-1: res = z break flag[x][y] += 1 if 1 <= x and bw[x-1][y] == 0 and flag[x-1][y] == 0: l.append((x-1,y,z+1)) if y < m-1 and sw[x][y] == 0 and flag[x][y+1] == 0: l.append((x,y+1,z+1)) if 1 <= y and sw[x][y-1] == 0 and flag[x][y-1] == 0: l.append((x,y-1,z+1)) if x < n-1 and bw[x][y] == 0 and flag[x+1][y] == 0: l.append((x+1,y,z+1)) print(res)
Traceback (most recent call last): File "/tmp/tmpocm46oci/tmppioe7e1h.py", line 2, in <module> m,n = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s937372317
p00747
u131811591
1495032666
Python
Python3
py
Runtime Error
40000
15928
973
while True: w, h = map(int, input().split()) vart = [] hori = [] if w == 0 and h ==0: break for i in range(2*h-1): if i % 2 == 0: vart.append(list(map(int, input().split()))) else: hori.append(list(map(int, input().split()))) node = [[0 for i in range(h)] for i in range(w)] queue = [(0,0,1)] res = 0 while queue: p = queue.pop(0) x, y, z = p[0], p[1], p[2] if x == w-1 and y == h-1: res = z break node[x][y] = 1 if y-1 >= 0 and hori[y-1][x] == 0 and node[x][y-1] == 0: queue.append((x,y-1,z+1)) if y+1 < h and hori[y][x] == 0 and node[x][y+1] == 0: queue.append((x,y+1,z+1)) if x-1 >= 0 and vart[y][x-1] == 0 and node[x-1][y] == 0: queue.append((x-1,y,z+1)) if x+1 < w and vart[y][x] == 0 and node[x+1][y] == 0: queue.append((x+1,y,z+1)) print(res)
Traceback (most recent call last): File "/tmp/tmp5s_f97lc/tmphsgllfe_.py", line 2, in <module> w, h = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s826500961
p00747
u506554532
1513571138
Python
Python3
py
Runtime Error
0
0
811
from collections import deque while True: W,H = map(int, input().split()) if W == 0: break es = [[] for i in range(W*H)] for y in range(H): walls_h = map(int, input().split()) for x in range(W-1): if walls_h[x]: continue es[y*W + x].append(y*W + x+1) es[y*W + x+1].append(y*W + x) if y == H-1: break walls_v = map(int, input().split()) for x in range(W): if walls_v[x]: continue es[y*W + x].append((y+1)*W + x) es[(y+1)*W + x].append(y*W + x) q = deque([0]) dist = [0] * (W*H) dist[0] = 1 while q: fr = q.popleft() for to in es[fr]: if dist[to] == 0: dist[to] = dist[fr] + 1 q.append(to) print(dist[-1])
Traceback (most recent call last): File "/tmp/tmp6tu1vn6a/tmp5epbjxu_.py", line 3, in <module> W,H = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s539806095
p00747
u506554532
1513578491
Python
Python3
py
Runtime Error
0
0
824
from collections import deque while True: W,H = map(int, input().split()) if W == 0: break es = [[] for i in range(W*H)] for y in range(H): walls_h = map(int, input().split()) for x in range(W-1): if walls_h[x]: continue es[y*W + x].append(y*W + x+1) es[y*W + x+1].append(y*W + x) if y == H-1: break walls_v = map(int, input().split()) for x in range(W): if walls_v[x]: continue es[y*W + x].append((y+1)*W + x) es[(y+1)*W + x].append(y*W + x) q = deque() q.append(0) dist = [0] * (W*H) dist[0] = 1 while q: fr = q.popleft() for to in es[fr]: if dist[to] == 0: dist[to] = dist[fr] + 1 q.append(to) print(dist[-1])
Traceback (most recent call last): File "/tmp/tmpibatpbdi/tmpcvlcp193.py", line 3, in <module> W,H = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s416948531
p00747
u855199458
1529674617
Python
Python3
py
Runtime Error
0
0
1052
# -*- coding: utf-8 -*- from collections import defaultdict, deque W, H = map(int, input().split()) while W: G = defaultdict(list) for h in range(H): for w, b in enumerate(map(int, input().split())): if b == 0: G[(w, h)].append((w+1, h)) G[(w+1, h)].append((w, h)) if h == H-1: break for w, b in enumerate(map(int, input().split())): if b == 0: G[(w, h)].append((w, h+1)) G[(w, h+1)].append((w, h)) dist = defaultdict(lambda: 1000) Q = deque([(0, 0)]) dist[(0, 0)] = 1 found = False while Q: x, y = Q.pop() c = dist[(x, y)] for px, py in G[(x, y)]: if (px, py) == (W-1, H-1): print(c+1) Q = [] found = True break elif dist[(px, py)] >= c+1: dist[(px, py)] = c+1 Q.append((px, py)) if not found: print(0) W, H = map(int, input().split())
Traceback (most recent call last): File "/tmp/tmpsh29764r/tmpoqa87yrv.py", line 3, in <module> W, H = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s818597404
p00748
u731235119
1422873161
Python
Python
py
Runtime Error
19930
99684
550
MAX = 10**6 - 1 inf = float("inf") tetra_sum = [inf for i in range(MAX+1)] tetra_sum_odd = [inf for i in range(MAX+1)] tetra_sum[0] = 0 tetra_sum_odd[0] = 0 for n in range(1,181): tetra_n = n * (n+1) * (n+2) / 6 for i in range(tetra_n,MAX+1): if tetra_sum[i-tetra_n] + 1 < tetra_sum[i]: tetra_sum[i] = tetra_sum[i-tetra_n] + 1 if (tetra_n % 2) == 1 and tetra_sum_odd[i-tetra_n] + 1 < tetra_sum_odd[i]: tetra_sum_odd[i] = tetra_sum_odd[i-tetra_n] + 1 while 1: N = int(raw_input()) if N == 0: break print tetra_sum[N], tetra_sum_odd[N]
File "/tmp/tmpmad9ht60/tmpwqv9pdgv.py", line 18 print tetra_sum[N], tetra_sum_odd[N] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s312318744
p00748
u731235119
1422874416
Python
Python
py
Runtime Error
19930
75708
740
MAX = 10**6 - 1 inf = float("inf") tetra_n = [i*(i+1)*(i+2)/6 for i in range(1,181)] tetra_sum = [inf for i in range(MAX+1)] tetra_sum_odd = [inf for i in range(MAX+1)] tetra_sum[0] = 0 tetra_sum_odd[0] = 0 tmp_max = 0 for tn in tetra_n: tmp_max = max(tmp_max + 4 * tn, 5 * tn) if (tn % 2) == 0: for i in range(tn,min(tmp_max,MAX)+1): if tetra_sum[i-tn] + 1 < tetra_sum[i]: tetra_sum[i] = tetra_sum[i-tn] + 1 else: for i in range(tn,MAX+1): if i <= tmp_max and tetra_sum[i-tn] + 1 < tetra_sum[i]: tetra_sum[i] = tetra_sum[i-tn] + 1 if tetra_sum_odd[i-tn] + 1 < tetra_sum_odd[i]: tetra_sum_odd[i] = tetra_sum_odd[i-tn] + 1 while 1: N = int(raw_input()) if N == 0: break print tetra_sum[N], tetra_sum_odd[N]
File "/tmp/tmp19og09u0/tmp0qsv12hw.py", line 25 print tetra_sum[N], tetra_sum_odd[N] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s520790139
p00748
u731235119
1422874801
Python
Python
py
Runtime Error
19930
99700
655
MAX = 10**6 - 1 inf = float("inf") tetra_n = [i*(i+1)*(i+2)/6 for i in range(1,181)] tetra_sum = [inf for i in range(MAX+1)] tetra_sum_odd = [inf for i in range(MAX+1)] tetra_sum[0] = 0 tetra_sum_odd[0] = 0 for tn in tetra_n: if tn % 2 == 0: for i in range(tn,MAX+1): if tetra_sum[i-tn] + 1 < tetra_sum[i]: tetra_sum[i] = tetra_sum[i-tn] + 1 else : for i in range(tn,MAX+1): if tetra_sum[i-tn] + 1 < tetra_sum[i]: tetra_sum[i] = tetra_sum[i-tn] + 1 if tetra_sum_odd[i-tn] + 1 < tetra_sum_odd[i]: tetra_sum_odd[i] = tetra_sum_odd[i-tn] + 1 while 1: N = int(raw_input()) if N == 0: break print tetra_sum[N], tetra_sum_odd[N]
File "/tmp/tmpiuud3wf5/tmp03aob69b.py", line 23 print tetra_sum[N], tetra_sum_odd[N] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s680940224
p00748
u633068244
1423763325
Python
Python
py
Runtime Error
19930
19860
368
R = 10**6+1 T = [i*(i+1)*(2*i+1)/6 for i in xrange(145)] dp1 = [100]*R dp2 = [100]*R for t in T: dp1[t] = 1 for i in xrange(t,R): if dp1[i-t]: dp1[i] = min(dp1[i],dp1[i-t]+1) if t%2 == 0: continue dp2[t] = 1 for i in xrange(t,R): if dp2[i-t]: dp1[i] = min(dp2[i],dp2[i-t]+1) while 1: n = int(raw_input()) print dp1[n],dp2[n]
File "/tmp/tmp_ii25e37/tmpxxoxjmrf.py", line 15 print dp1[n],dp2[n] ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s052758497
p00748
u633068244
1423763689
Python
Python
py
Runtime Error
19930
67880
424
R = 10**6+1 T = [i*(i+1)*(i+2)/6 for i in xrange(145)] dp1 = [1e10]*R dp2 = [1e10]*R dp1[0] = dp2[0] = 0 for t in T: dp1[t] = 1 for i in xrange(t,R): if dp1[i-t] < 1e10: dp1[i] = min(dp1[i],dp1[i-t]+1) if t%2 == 0: continue dp2[t] = 1 for i in xrange(t,R): if dp2[i-t] < 1e10: dp2[i] = min(dp2[i],dp2[i-t]+1) while 1: n = int(raw_input()) if n == 0: break print dp1[n],dp2[n]
File "/tmp/tmp202tz6rk/tmp0dezi819.py", line 18 print dp1[n],dp2[n] ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s858023311
p00748
u383876854
1429602010
Python
Python
py
Runtime Error
19920
11180
828
MAX=1000000 INF=100000 import math def f(a): return (a*(a+1)*(a+2))/6 def solve(lst): global ans global n count=2 while True: if ans[n]!=INF: return ans[n] keepans=[0]*(n+1) for i in range(n+1): if ans[i]!=INF: for j in range(n+1): if i+j<=n: if ans[j]!=INF and ans[i+j]>ans[i]+ans[j]: keepans[i+j]=ans[i]+ans[j] #print i,j,"=",keepans[i+j] c=0 for l in ans: if keepans[c]!=0: ans[c]=keepans[c] c=c+1 #print "----------" count=count+1 while True: n=int(raw_input()) if n==0: break box=[] oddbox=[] ans=[INF]*(n+1) oddans=[INF]*(n+1) for i in range(200): num=f(i) if num>n: break box.append(num) if i!=0:ans[num]=1 if num%2==1: oddbox.append(num) oddans[num]=1 print solve(box) ans=oddans print solve(oddbox)
File "/tmp/tmph9328wl9/tmpaxqx1__i.py", line 66 print solve(box) ^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s378559344
p00748
u383876854
1429602372
Python
Python
py
Runtime Error
19930
11184
833
MAX=1000000 INF=100000 import math def f(a): return (a*(a+1)*(a+2))/6 def solve(lst): global ans global n count=2 while True: if ans[n]!=INF: return ans[n] keepans=list(ans) for i in range(n+1): if ans[i]!=INF: for j in range(n+1): if i+j<=n: if ans[j]!=INF and keepans[i+j]>ans[i]+ans[j] : keepans[i+j]=ans[i]+ans[j] #print i,j,"=",keepans[i+j] c=0 for l in ans: if keepans[c]!=0: ans[c]=keepans[c] c=c+1 #print "----------" count=count+1 while True: n=int(raw_input()) if n==0: break box=[] oddbox=[] ans=[INF]*(n+1) oddans=[INF]*(n+1) for i in range(200): num=f(i) if num>n: break box.append(num) if i!=0:ans[num]=1 if num%2==1: oddbox.append(num) oddans[num]=1 print solve(box) ans=oddans print solve(oddbox)
File "/tmp/tmpspqwvvji/tmp66o0kxry.py", line 66 print solve(box) ^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s916743592
p00748
u383876854
1429607259
Python
Python
py
Runtime Error
19930
49564
775
MAX=1000000 INF=100000 import math def f(a): return (a*(a+1)*(a+2))/6 def solve(lst): global ans global n while True: keepans=list(ans) for i in range(n+1): if ans[i]!=INF: for j in range(n+1): if ans[n]!=INF: return ans[n] if i+j<=n: if ans[j]!=INF and keepans[i+j]>ans[i]+ans[j] : keepans[i+j]=ans[i]+ans[j] print i,j,"=",keepans[i+j] ans=list(keepans) a1=[INF]*(MAX) a2=[INF]*(MAX) ans=[INF]*(MAX) while True: n=int(raw_input()) if n==0: break box=[] oddbox=[] for i in range(200): num=f(i) if num>n: break box.append(num) if i!=0:a1[num]=1 if num%2==1: oddbox.append(num) a2[num]=1 ans=list(a1) print solve(box) a1=list(ans) ans=list(a2) print solve(oddbox) a2=list(ans)
File "/tmp/tmpcjkm6md3/tmped_hvpy5.py", line 26 print i,j,"=",keepans[i+j] ^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s196137769
p00748
u228002579
1462291107
Python
Python
py
Runtime Error
40000
101732
485
MAX = 1000000 tetra = [] dp = [0] * (MAX+1) dpodd = [0] * (MAX+1) for i in range(1,MAX+1): dp[i] = i dpodd[i] = i i = 0 while True: i += 1 t = i * (i+1) * (i+2) / 6 if t > MAX: break tetra.append(t) for p in tetra: #print(p) for i in range(0,MAX-p): dp[i+p] = min(dp[i+p], dp[i]+1) if p % 2 == 1: dpodd[i+p] = min(dpodd[i+p], dpodd[i]+1) while True: n = int(raw_input()) if n == 0: break print dp[n],dpodd[n]
File "/tmp/tmpzc5k2u6g/tmpibtj04vx.py", line 28 print dp[n],dpodd[n] ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s476245124
p00748
u228002579
1462291609
Python
Python3
py
Runtime Error
40000
86308
488
MAX = 1000000 tetra = [] dp = [0] * (MAX+1) dpodd = [0] * (MAX+1) for i in range(1,MAX+1): dp[i] = i dpodd[i] = i i = 0 while True: i += 1 t = i * (i+1) * (i+2) // 6 if t > MAX: break tetra.append(t) for p in tetra: #print(p) for i in range(0,MAX-p): dp[i+p] = min(dp[i+p], dp[i]+1) if p % 2 == 1: dpodd[i+p] = min(dpodd[i+p], dpodd[i]+1) while True: n = int(raw_input()) if n == 0: break print (dp[n],dpodd[n])
s386263988
p00748
u228002579
1462291938
Python
Python3
py
Runtime Error
40000
86384
488
MAX = 1000010 tetra = [] dp = [0] * (MAX+1) dpodd = [0] * (MAX+1) for i in range(1,MAX+1): dp[i] = i dpodd[i] = i i = 0 while True: i += 1 t = i * (i+1) * (i+2) // 6 if t > MAX: break tetra.append(t) for p in tetra: #print(p) for i in range(0,MAX-p): dp[i+p] = min(dp[i+p], dp[i]+1) if p % 2 == 1: dpodd[i+p] = min(dpodd[i+p], dpodd[i]+1) while True: n = int(raw_input()) if n == 0: break print (dp[n],dpodd[n])
s800922311
p00748
u078042885
1485539638
Python
Python3
py
Runtime Error
40000
97984
308
while 1: n=int(input()) if n==0:break dp=[0]+[10**10]*n odd=[0]+[10**10]*n for i in range(1,n+1): a=i*(i+1)*(i+2)//6 if a>n:break for j in range(a,n+1): dp[j]=min(dp[j],dp[j-a]+1) if a&1:odd[j]=min(odd[j],odd[j-a]+1) print(dp[n],odd[n])
Traceback (most recent call last): File "/tmp/tmp1omeo5ld/tmp2qo9meyp.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s112394936
p00748
u798803522
1485786813
Python
Python3
py
Runtime Error
0
0
2602
with open("input.txt") as f: while True: target = int(f.readline()) if target == 0: break pascal = [] tmp = 1 nexpas = 1 oddpas = [] while target >= nexpas: pascal.append(nexpas) if nexpas % 2 == 1: oddpas.append(nexpas) tmp += 1 nexpas = (tmp * (tmp + 1) * (tmp + 2)) // 6 length = len(pascal) dp = [float("inf") for n in range(target + 1)] ans = - 1 for i in range(length): dp[pascal[i]] = 1 if pascal[i] == target: ans = 1 cnt = 0 while cnt < 10: #print(dp) cnt += 1 tmpdp = dp[:] if ans != -1: break else: for outer in range(target + 1): if dp[outer] != float("inf"): nowcnt = dp[outer] for i in range(length): nextnum = outer + pascal[i] if nextnum > target: break elif nextnum == target: ans = nowcnt + 1 break tmpdp[nextnum] = min(dp[nextnum],nowcnt + 1) #print(dp,tmpdb) dp = tmpdp oddlen = len(oddpas) odddp = [float("inf") for n in range(target + 1)] oddans = -1 for i in range(oddlen): odddp[oddpas[i]] = 1 if oddpas[i] == target: oddans = 1 cnt = 0 #print(oddpas) while cnt < 50: #print(odddp) cnt += 1 tmpdp = odddp[:] if oddans != -1: break else: for outer in range(target + 1): if odddp[outer] != float("inf"): nowcnt = odddp[outer] for i in range(oddlen): nextnum = outer + oddpas[i] #print(nextnum) if nextnum > target: break elif nextnum == target: oddans = nowcnt + 1 break tmpdp[nextnum] = min(odddp[nextnum],nowcnt + 1) odddp = tmpdp print(str(ans) + " " + str(oddans)) #print(odddp,oddpas,oddans,target) #print(dp,pascal,ans,target)
Traceback (most recent call last): File "/tmp/tmpbypbdgka/tmperrwky87.py", line 1, in <module> with open("input.txt") as f: ^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'input.txt'
s961865082
p00748
u798803522
1485786891
Python
Python3
py
Runtime Error
40000
62388
2272
while True: target = int(input()) if target == 0: break pascal = [] tmp = 1 nexpas = 1 oddpas = [] while target >= nexpas: pascal.append(nexpas) if nexpas % 2 == 1: oddpas.append(nexpas) tmp += 1 nexpas = (tmp * (tmp + 1) * (tmp + 2)) // 6 length = len(pascal) dp = [float("inf") for n in range(target + 1)] ans = - 1 for i in range(length): dp[pascal[i]] = 1 if pascal[i] == target: ans = 1 cnt = 0 while cnt < 10: #print(dp) cnt += 1 tmpdp = dp[:] if ans != -1: break else: for outer in range(target + 1): if dp[outer] != float("inf"): nowcnt = dp[outer] for i in range(length): nextnum = outer + pascal[i] if nextnum > target: break elif nextnum == target: ans = nowcnt + 1 break tmpdp[nextnum] = min(dp[nextnum],nowcnt + 1) #print(dp,tmpdb) dp = tmpdp oddlen = len(oddpas) odddp = [float("inf") for n in range(target + 1)] oddans = -1 for i in range(oddlen): odddp[oddpas[i]] = 1 if oddpas[i] == target: oddans = 1 cnt = 0 #print(oddpas) while cnt < 50: #print(odddp) cnt += 1 tmpdp = odddp[:] if oddans != -1: break else: for outer in range(target + 1): if odddp[outer] != float("inf"): nowcnt = odddp[outer] for i in range(oddlen): nextnum = outer + oddpas[i] #print(nextnum) if nextnum > target: break elif nextnum == target: oddans = nowcnt + 1 break tmpdp[nextnum] = min(odddp[nextnum],nowcnt + 1) odddp = tmpdp print(str(ans) + " " + str(oddans)) #print(odddp,oddpas,oddans,target) #print(dp,pascal,ans,target)
Traceback (most recent call last): File "/tmp/tmp327i1a5v/tmphsm8k3fu.py", line 2, in <module> target = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s414930942
p00748
u078042885
1485791953
Python
Python3
py
Runtime Error
40000
93996
350
dp = [0] + [10 ** 10] * 10**6 odd = [0] + [10 ** 10] * 10**6 for i in range(1, 10**6 + 1): a = i * (i + 1) * (i + 2) // 6 if a > 10**6: break for j in range(a, 10**6 + 1): dp[j] = min(dp[j], dp[j - a] + 1) if a & 1: odd[j] = min(odd[j], odd[j - a] + 1) while 1: n=int(input()) if n==0:break print(dp[n],odd[n])
s353971662
p00748
u078042885
1485794041
Python
Python3
py
Runtime Error
40000
86424
300
N=10**6 dp = [i for i in range(N+1)] odd = [i for i in range(N+1)] p=4;n=3 while p<=N: for i in range(N+1-p): dp[i+p]=min(dp[i+p],dp[i]+1) if p&1:odd[i+p]=min(odd[i+p],odd[i]+1) p=n*(n+1)*(n+2)//6 n+=1 while 1: n=int(input()) if n==0:break print(dp[n],odd[n])
s650629072
p00748
u144068724
1495445692
Python
Python3
py
Runtime Error
0
0
1276
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Scanner sc = new Scanner(System.in); int[] list1 = new int[180]; int[] cnt1 = new int[1000001]; int[] cnt2 = new int[1000001]; for(int i = 0; i < 180; i++) { list1[i] = (i+1)*(i+2)*(i+3)/6; } // Here your code ! for(int i = 0; i <= 1000000; i++){ cnt1[i] = i; cnt2[i] = i; } for(int n = 3, p = 4; p <= 1000000; n++){ for(int i = 0; i+p <= 1000000; i++){ cnt1[i+p] = Math.min(cnt1[i+p], cnt1[i] + 1); } if(p % 2 == 1){ for(int i = 0; i+p <= 1000000; i++){ cnt2[i+p] = Math.min(cnt2[i+p], cnt2[i] + 1); } } // p?????????????????§??´??° p = n * (n+1) * (n+2) / 6; } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while(true){ int num = Integer.parseInt(br.readLine()); if(num == 0) break; System.out.println(cnt1[num] + " " + cnt2[num]); } } }
File "/tmp/tmpxxzl1hka/tmp4hoe4lcs.py", line 28 // p?????????????????§??´??° ^ SyntaxError: invalid character '§' (U+00A7)
s615743348
p00748
u598745142
1502084549
Python
Python3
py
Runtime Error
40000
74036
788
INF = 1000000 while True: n = input() n = int(n) if n == 0: break i = 1 tetra = [] while True: t = i*(1+i)*(2+i)/6 if t <= n: tetra.append(int(t)) i += 1 else: break dp = [[INF for _ in range(n+1)] for _ in range(len(tetra)+1)] for i in range(len(tetra)+1): dp[i][0] = 0 for i in range(len(tetra)): for j in range(n): if j + tetra[i] <= n: m = INF for k in range(i+1): if dp[k+1][j] < m: m = dp[k+1][j] dp[i+1][j+tetra[i]] = m+1 output = INF for i in range(len(tetra)+1): if dp[i][n] < output: output = dp[i][n] print(output)
Traceback (most recent call last): File "/tmp/tmp_7n3e0g4/tmpabxkkjv2.py", line 4, in <module> n = input() ^^^^^^^ EOFError: EOF when reading a line
s843135898
p00748
u598745142
1502086913
Python
Python3
py
Runtime Error
40000
14300
672
INF = 1000000 while True: n = input() n = int(n) if n == 0: break i = 1 tetra = [] while True: t = i*(1+i)*(2+i)/6 if t <= n: tetra.append(int(t)) i += 1 else: break dp1 = [INF for _ in range(n+1)] dp2 = [INF for _ in range(n+1)] dp1[0] = 0 dp2[0] = 0 for i in range(n): for j in range(len(tetra)): if i + tetra[j] <= n: dp1[i+tetra[j]] = min(dp1[i+tetra[j]], dp1[i]+1) if tetra[j] % 2 == 1: dp2[i+tetra[j]] = min(dp2[i+tetra[j]], dp2[i]+1) print("%d %d" % (dp1[n], dp2[n]))
Traceback (most recent call last): File "/tmp/tmpl6hrbs_z/tmp33mfh7_p.py", line 4, in <module> n = input() ^^^^^^^ EOFError: EOF when reading a line
s134883473
p00748
u672443148
1514949729
Python
Python3
py
Runtime Error
0
0
554
def pollockConjection(): inf=int(1e6) dp=list(range(0,inf+1)) odp=list(range(0,inf+1)) n=2 s=1 os=1 while s<inf+1: s=n*(n+1)*(n+2)//6 n+=1 if s%2==1: os=s for i in range(0,inf+1-s): dp[i+s]=min(dp[i+s],dp[i]+1) for i in range(0,inf+1-os): odp[i+os]=min(odp[i+os],odp[i]+1) return dp,odp if __name__=="__main__": dp,odp=pollockConjection() while True: N=int(input()) if N==0: break print(dp[N],odp[N])
s537065841
p00748
u672443148
1514950415
Python
Python3
py
Runtime Error
0
0
518
def pollockConjection(): inf=int(1e6) dp=list(range(0,inf+1)) odp=list(range(0,inf+1)) n=2 s=1 os=1 while s<inf+1: s=n*(n+1)*(n+2)//6 n+=1 if s%2==1: os=s for i in range(0,inf+1-s): dp[i+s]=min(dp[i+s],dp[i]+1) odp[i+os]=min(odp[i+os],odp[i]+1) return dp,odp if __name__=="__main__": dp,odp=pollockConjection() while True: N=int(input()) if N==0: break print(dp[N],odp[N])
s310094590
p00748
u672443148
1514951778
Python
Python3
py
Runtime Error
0
0
506
def pollockConjection(): inf=int(1e6) dp=list(range(0,inf+1)) odp=list(range(0,inf+1)) n=2 s=1 os=1 while s<inf+1: s=n*(n+1)*(n+2)//6 n+=1 if s%2==1: os=s for i in range(0,inf+1-s): dp[i+s]=min(dp[i+s],dp[i]+1) odp[i+os]=min(odp[i+os],odp[i]+1) return dp,odp if __name__=="__main__": dp,odp=pollockConjection()   while True: N=int(input()) if N==0: break print(dp[N],odp[N])
File "/tmp/tmpf55isr79/tmpps42dqih.py", line 20   while True: ^ SyntaxError: invalid non-printable character U+3000
s894459336
p00748
u506554532
1515034857
Python
Python3
py
Runtime Error
0
0
764
import bisect import sys MAX = 10**6 sys.setrecursionlimit(MAX) arr1 = [1] arr2 = [1] n = 1 while True: n += 1 tmp = n*(n+1)*(n+2)//6 if tmp > MAX: break arr1.append(tmp) if tmp%2: arr2.append(tmp) def rec(remain, depth, mindepth, onlyodd): if remain == 0: return depth if mindepth - depth <= 1: return mindepth arr = arr2 if onlyodd else arr1 i = bisect.bisect_right(arr,remain) if i == 1: return min(mindepth, depth + remain) for j in range(1,i): mindepth = rec(remain-arr[j], depth+1, mindepth, onlyodd) return mindepth def solve(n, onlyodd=False): return rec(n,0,n,onlyodd) while True: N = int(input()) if N == 0: break print('{0} {1}'.format(solve(N), solve(N,True)))
Traceback (most recent call last): File "/tmp/tmpszaogb1q/tmpo7c8aq9s.py", line 31, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s602084273
p00748
u266872031
1527081213
Python
Python
py
Runtime Error
0
0
695
import itertools P1=[p*(p+1)*(p+2)/6 for p in range(1,181)] P2=[p for p in P1 if p%2] maxnum=1000000 A1=[999999 for x in range(maxnum+1)] A2=[999999 for x in range(maxnum+1)] for X in [[P1,A1],[P2,A2]]: P=X[0] A=X[1] tmp=P bk=0 cnt=2 for p in tmp: if p<maxnum: A[p]=1 bk+=1 while bk<maxnum: tmp2=[] for t in tmp: for p in P: if t+p > maxnum: break if A[t+p]>cnt: A[t+p]=cnt bk+=1 tmp2.append(t+p) tmp=tmp2[:] cnt+=1 while(1): n=int(raw_input()) if n==0: break print A1[n], A2[n]
File "/tmp/tmp82lvnx7y/tmp0ji4zp56.py", line 35 print A1[n], A2[n] ^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s439975673
p00748
u509278866
1528277697
Python
Python3
py
Runtime Error
0
0
1149
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): rr = [] m = 10**6 a = [inf] * m b = [inf] * m a[0] = 0 b[0] = 0 for i in range(1,200): t = i * (i+1) * (i+2) // 6 for j in range(t,m): if a[j] > a[j-t] + 1: a[j] = a[j-t] + 1 if t % 2 == 0: continue for j in range(t,m): if b[j] > b[j-t] + 1: b[j] = b[j-t] + 1 while True: n = I() if n == 0: break rr.append('{} {}'.format(a[n],b[n])) return '\n'.join(map(str, rr)) print(main())
s780214125
p00748
u072053884
1528689738
Python
Python3
py
Runtime Error
0
0
1024
def solve(): import sys file_input = sys.stdin def tetra_num(n): for i in range(1, 181): t = i * (i + 1) * (i + 2) // 6 if t <= n: yield t else: break while True: n = int(file_input.readline()) if n == 0: break n_lim = 1000000 rec = [n_lim] * (n + 1) rec[0] = 0 odd_rec = [n_lim] * (n + 1) odd_rec[0] = 0 for t in tetra_num(n): if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl rec[i] = min(a, b + 1) else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl rec[i] = min(a, b + 1) odd_rec[i] = min(c, d + 1) print(rec[n], odd_rec[n]) solve()
Traceback (most recent call last): File "/tmp/tmpb12vlegx/tmp_xxx3rkj.py", line 38, in <module> solve() File "/tmp/tmpb12vlegx/tmp_xxx3rkj.py", line 14, in solve n = int(file_input.readline()) ^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s479959703
p00748
u072053884
1528702152
Python
Python3
py
Runtime Error
0
0
1000
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if a < b: rec[i] = a else: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if a < b: rec[i] = a else: rec[i] = b d += 1 if c < d: odd_rec[i] = c else: odd_rec[i] = d import sys file_input = sys.stdin n = int(file_input.readline()) while n: print(rec[n], odd_rec[n]) n = int(file_input.readline()) solve()
s406894994
p00748
u072053884
1528703536
Python
Python3
py
Runtime Error
0
0
837
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if b < a: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if b < a: rec[i] = b d += 1 if d < c: odd_rec[i] = d import sys file_input = sys.stdin n = int(file_input.readline()) while n: print(rec[n], odd_rec[n]) n = int(file_input.readline()) solve()
s021655469
p00748
u072053884
1528704558
Python
Python3
py
Runtime Error
0
0
877
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if b < a: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if b < a: rec[i] = b d += 1 if d < c: odd_rec[i] = d import sys #file_input = sys.stdin file_input = open("1167_in", 'r')# n = int(file_input.readline()) while n: print(rec[n], odd_rec[n]) n = int(file_input.readline()) solve()
s920136880
p00748
u072053884
1528704612
Python
Python3
py
Runtime Error
0
0
837
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if b < a: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if b < a: rec[i] = b d += 1 if d < c: odd_rec[i] = d import sys file_input = sys.stdin n = int(file_input.readline()) while n: print(rec[n], odd_rec[n]) n = int(file_input.readline()) solve()
s462965267
p00748
u072053884
1528704789
Python
Python3
py
Runtime Error
0
0
767
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if b < a: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if b < a: rec[i] = b d += 1 if d < c: odd_rec[i] = d n = int(input()) while n: print(rec[n], odd_rec[n]) n = int(input()) solve()
s383724048
p00748
u591052358
1528873330
Python
Python3
py
Runtime Error
0
0
640
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] N1[0] = 0 N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > len(N1) : continue for j in range(p_,len(N1)): # print(j) N1[j] = min(N1[j],N1[j-p_]+1) for p_ in p2: if p_ > len(N2) : continue for j in range(p_,len(N2)): N2[j] = min(N2[j],N2[j-p_]+1) #print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s595096174
p00748
u591052358
1528873946
Python
Python3
py
Runtime Error
0
0
626
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] N1[0] = 0 N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue for j in range(p_,N+1): # print(j) N1[j] = min(N1[j],N1[j-p_]+1) for p_ in p2: if p_ > N +1 : continue for j in range(p_,N +1): N2[j] = min(N2[j],N2[j-p_]+1) #print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s591553304
p00748
u591052358
1528895848
Python
Python3
py
Runtime Error
0
0
698
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,10**6) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue for j in range(p_,N +1): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s092368276
p00748
u591052358
1528895951
Python
Python3
py
Runtime Error
0
0
714
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,10**6) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue n = min(p*5,N) for j in range(p_,n): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s075297440
p00748
u591052358
1528897329
Python
Python3
py
Runtime Error
0
0
715
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,N) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue #n = min(p_*5,N+1) for j in range(p_,N): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 #print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s029445554
p00748
u591052358
1528898106
Python
Python3
py
Runtime Error
0
0
715
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,N) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue #n = min(p_*5,N+1) for j in range(p_,N): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 #print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s981025696
p00748
u591052358
1529584229
Python
Python3
py
Runtime Error
0
0
714
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,N) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue n = min(p_*7,N+1) for j in range(p_,n): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 #print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s832215295
p00748
u591052358
1529587371
Python
Python3
py
Runtime Error
0
0
867
N = 1000000 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: #if p_ > N +1: # continue n = min(p_*5,N) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 """ if p_%2==0: continue for j in range(p_,N): if N2[j] >N2[j-p_]+1: N2[j]=N2[j-p_]+1 """ #print("a") for p_ in p2: # if p_ > N +1 : # continue #n = min(p_*7,N+1) for j in range(p_,N): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 #print('a') """ """ while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s129238903
p00748
u855199458
1529684345
Python
Python3
py
Runtime Error
0
0
675
from collections import defaultdict from bisect import bisect_left, bisect def solve(): i = 1 P = [] x = 1 M = 10**6 while x < M: P.append(x) i += 1 x = (i)*(i+1)*(i+2)//6 P = P[1:] Q = [p for p in P if p%2] DP1 = list(range(M+1)) DP2 = list(range(M+1)) for i in range(M): for p in P[:bisect(P, M-i)]: DP1[i+p] = min(DP1[i+p], DP1[i]+1) for q in Q[:bisect(Q, M-i)]: DP2[i+q] = min(DP2[i+q], DP2[i]+1) N = int(input()) while N: print("{} {}".format(DP1[N], DP2[N])) N = int(input()) if __name__ == "__main__": solve()
s390415633
p00748
u855199458
1529684476
Python
Python3
py
Runtime Error
0
0
675
from collections import defaultdict from bisect import bisect_left, bisect def solve(): i = 1 P = [] x = 1 M = 10**6 while x < M: P.append(x) i += 1 x = (i)*(i+1)*(i+2)//6 P = P[1:] Q = [p for p in P if p%2] DP1 = list(range(M+1)) DP2 = list(range(M+1)) for i in range(M): for p in P[:bisect(P, M-i)]: DP1[i+p] = min(DP1[i+p], DP1[i]+1) for q in Q[:bisect(Q, M-i)]: DP2[i+q] = min(DP2[i+q], DP2[i]+1) N = int(input()) while N: print("{} {}".format(DP1[N], DP2[N])) N = int(input()) if __name__ == "__main__": solve()
s773578364
p00748
u855199458
1529684972
Python
Python3
py
Runtime Error
0
0
715
from collections import defaultdict from bisect import bisect_left, bisect def solve(): ans = [] i = 1 P = [] x = 1 M = 10**6 while x < M: P.append(x) i += 1 x = (i)*(i+1)*(i+2)//6 P = P[1:] Q = [p for p in P if p%2] DP1 = list(range(M+1)) DP2 = list(range(M+1)) for i in range(M): for p in P[:bisect(P, M-i)]: DP1[i+p] = min(DP1[i+p], DP1[i]+1) for q in Q[:bisect(Q, M-i)]: DP2[i+q] = min(DP2[i+q], DP2[i]+1) N = int(input()) while N: ans.append("{} {}".format(DP1[N], DP2[N])) N = int(input()) print("\n".join(ans)) if __name__ == "__main__": solve()
s322365021
p00748
u855199458
1529685212
Python
Python3
py
Runtime Error
0
0
671
# -*- coding: utf-8 -*- from bisect import bisect_left, bisect def solve(): i = 1 P = [] x = 1 M = 10**6 while x < M: P.append(x) i += 1 x = (i)*(i+1)*(i+2)//6 P = P[1:] Q = [p for p in P if p%2] DP1 = list(range(M+1)) DP2 = list(range(M+1)) for i in range(M): for p in P[:bisect(P, M-i)]: DP1[i+p] = min(DP1[i+p], DP1[i]+1) for q in Q[:bisect(Q, M-i)]: DP2[i+q] = min(DP2[i+q], DP2[i]+1) N = int(input()) while N: print("{} {}".format(DP1[N], DP2[N])) N = int(input()) if __name__ == "__main__": solve() exit()
s960899134
p00748
u855199458
1529686526
Python
Python3
py
Runtime Error
0
0
21
while True: pass
s742759000
p00748
u072053884
1530108952
Python
Python3
py
Runtime Error
0
0
770
def solve(): rec = list(range(1000000)) odd_rec = rec.copy() for i in range(2, 181): t = i * (i + 1) * (i + 2) // 6 if t % 2 == 0: for i, tpl in enumerate(zip(rec[t:], rec), start=t): a, b = tpl b += 1 if b < a: rec[i] = b else: z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec) for i, tpl in enumerate(z_rec, start=t): a, b, c, d = tpl b += 1 if b < a: rec[i] = b d += 1 if d < c: odd_rec[i] = d n = int(input()) while n: print(rec[n], odd_rec[n]) n = int(input()) solve()
s341430311
p00748
u352394527
1530531974
Python
Python3
py
Runtime Error
0
0
650
INIT = 100 query = [] ans = [] while True: q = int(input()) if q == 0: break query.append(q) MAX = max(query) table = [INIT] * (MAX + 1) table[0] = 0 all_item = [i * (i + 1) * (i + 2) // 6 for i in range(1, 181)] odd_item = [i for i in all_item if i % 2] eve_item = [i for i in all_item if not i % 2] for v in odd_item: for j in range(v, MAX + 1): if table[j] > table[j - v] + 1: table[j] = table[j - v] + 1 for q in query: ans.append(table[q]) for v in eve_item: for j in range(v, MAX + 1): if table[j] > table[j - v] + 1: table[j] = table[j - v] + 1 for i, q in enumerate(query): print(table[q], ans[i])
Traceback (most recent call last): File "/tmp/tmpepaxb37h/tmpfoxyn7up.py", line 6, in <module> q = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s837412197
p00753
u023525982
1556368405
Python
Python
py
Runtime Error
0
0
591
def get(num): n=0 is_prime=[0]*200050 for i in range(0,num+1): is_prime[i]=True is_prime[0]=is_prime[1]=False for i in range(2,num+1): if(is_prime[i]): n+=1 for j in range(2*i,num+1,i): is_prime[j]=False return n while True: try: a=map(int,raw_input().strip().split()) b=a[0] if(b==0): break p=get(2*b)-get(b) # p=0 # for i in range(b+1,2*b+1): # if(judge(i)): # p+=1 print(p) except EOFError: break
Traceback (most recent call last): File "/tmp/tmpljm11hoi/tmpfg9m0n7j.py", line 16, in <module> a=map(int,raw_input().strip().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s762149602
p00753
u023525982
1556368889
Python
Python
py
Runtime Error
0
0
523
def get(num): n=0 is_prime=[0]*200050 for i in range(0,num+1): is_prime[i]=True is_prime[0]=is_prime[1]=False for i in range(2,num+1): if(is_prime[i]): n+=1 for j in range(2*i,num+1,i): is_prime[j]=False return n while True: a=map(int,raw_input().strip().split()) b=a[0] if(b==0): break p=get(2*b)-get(b) # p=0 # for i in range(b+1,2*b+1): # if(judge(i)): # p+=1 print(p)
Traceback (most recent call last): File "/tmp/tmpe01z3hvy/tmpvbyauevb.py", line 15, in <module> a=map(int,raw_input().strip().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s895304775
p00753
u023525982
1556369501
Python
Python
py
Runtime Error
0
0
118
while True: a, b = map(int, raw_input().strip().split()) if a == 0 and b == 0: break print a + b,
File "/tmp/tmp4o8zz6ps/tmpqd4a0o6n.py", line 5 print a + b, ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s836273104
p00753
u731235119
1421923887
Python
Python
py
Runtime Error
19930
8088
220
import math while 1: n = int(raw_input()) if n == 0: break count = 0 for p in range(n+1,2*n+1): for d in range(2, int(math.sqrt(p)) + 1): if p != d and p % d == 0: break else: count += 1 print count
File "/tmp/tmp5baoawqi/tmpnb7opu_7.py", line 13 print count ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s233441900
p00753
u731235119
1421924248
Python
Python
py
Runtime Error
19930
8088
219
import math while 1: n = int(raw_input()) if n == 0: break count = 0 for p in range(n+1,2*n+1): for d in range(2, int(math.sqrt(p)) + 1): if p != d and p % d == 0: break else: count += 1 print count
File "/tmp/tmpuhno6c1c/tmpubejez41.py", line 13 print count ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s272676397
p00753
u731235119
1421937349
Python
Python
py
Runtime Error
19930
8076
235
import math while 1: n = int(raw_input()) if n == 0: break count = 0 for p in range(n+1,2*n+1): d = 2 ub = math.sqrt(p) + 1 while d <= ub : if p != d and p % d == 0: break d += 1 else: count += 1 print count
File "/tmp/tmpttga254_/tmpm059qymt.py", line 16 print count ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s700357513
p00753
u124909914
1426155194
Python
Python3
py
Runtime Error
19930
10104
504
from math import sqrt while True: n = int(input()) if n == 0: break nums = [ x for x in range(n, 2*n+1) if x % 2 == 1 or x == 2] #print(nums) for i in range(2,int(sqrt(2*n))): nums = [x for x in nums if x % i != 0 or x == i] #print(i, nums) print(len(nums)) # ans = 0 # for i in range(n, 2*n+1): # for j in [x for x in range(2,i) if x * x <= i]: # if i % j == 0: # break # else: # ans += 1 # print(ans)
Traceback (most recent call last): File "/tmp/tmpxgh3yaep/tmplb_cwwkd.py", line 4, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s583607218
p00753
u124909914
1426231232
Python
Python3
py
Runtime Error
19930
10108
257
from math import sqrt while True: n = int(input()) if n == 0: break nums = [ x for x in range(n, 2*n+1) if x % 2 == 1 or x == 2] for i in range(2,int(sqrt(2*n))): nums = [x for x in nums if x % i != 0 or x == i] print(len(nums))
Traceback (most recent call last): File "/tmp/tmpxmtz0zjq/tmpt6sff3w5.py", line 4, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s900588899
p00753
u248416507
1464095498
Python
Python
py
Runtime Error
0
0
423
import math def isPrime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False for i in range(3, int(math.sqrt((x))) + 1, 2): if x % i == 0: return False return True if __name__ == "__main__": while True: n = input() ans = 0 for i in range(n + 1, 2 * n + 1): if isPrime(i): ans += 1 print ans
File "/tmp/tmpvsav5h_g/tmpko_30zc9.py", line 24 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s037048887
p00753
u633333374
1503533674
Python
Python
py
Runtime Error
40000
8000
269
while 1: n = int(input()) if n == 0: break lst = [] for i in range(n+1,n*2+1,1): sum = 0 for j in range(2,i/2+1): if i%j == 0: sum += 1 if sum == 0: lst.append(i) print len(lst)
File "/tmp/tmpx9stcath/tmpvb43mbvo.py", line 13 print len(lst) ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s814492273
p00753
u633333374
1503535179
Python
Python
py
Runtime Error
40000
10356
431
import math while 1: n = int(input()) if n == 0: break lst = [] for i in range(n+1,n*2+1,1): sum = 0 if isinstance(math.sqrt(i),int) == False: x = math.floor(math.sqrt(i)) + 1 else: x = math.sqrt(i) + 1 for j in range(2,math.trunc(x)): if i%j == 0: sum += 1 if sum == 0: lst.append(i) print len(lst)
File "/tmp/tmpst52rxje/tmpdn2iejab.py", line 18 print len(lst) ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s236736605
p00753
u814249052
1370883790
Python
Python
py
Runtime Error
20000
6508
395
def isPrimeNumber(number): return all([number % i != 0 for i in range(2, number)]) def result(number): return sum([isPrimeNumber(i) for i in range(number + 1, number * 2 + 1)]) if __name__ == "__main__": import sys import fileinput for line in fileinput.input(): n = int(line.strip()) if n == 0: break print result(n) sys.exit(0)
File "/tmp/tmppiyhpb__/tmp9cixw8i9.py", line 17 print result(n) ^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s136677171
p00753
u814249052
1370883978
Python
Python
py
Runtime Error
0
0
427
def isPrimeNumber(number): from math import sqrt return all([number % i != 0 for i in range(2, sqrt(number))]) def result(number): return sum([isPrimeNumber(i) for i in range(number + 1, number * 2 + 1)]) if __name__ == "__main__": import sys import fileinput for line in fileinput.input(): n = int(line.strip()) if n == 0: break print result(n) sys.exit(0)
File "/tmp/tmpwtog0v_x/tmpuf8f9nnw.py", line 18 print result(n) ^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s406359578
p00754
u328199937
1556031211
Python
Python
py
Runtime Error
0
0
628
ans_list = [] while True: s = input() if s == ".": break q_list = ["" for i in range(len(s))] now = -1 ans = "yes" for i in list(s): if i == "(" or i == "[": now += 1 q_list[now] = i elif i == ")" or i == "]": if (i == ")" and q_list[now] == "(") or (i == "]" and q_list[now] == "["): now -= 1 elif now < 0 or i != q_list[now]: #print(i, now, q_list) ans = "no" break if ans == "no": break ans_list.append(ans) for i in ans_list: print(i)
Traceback (most recent call last): File "/tmp/tmpmgb0wzr1/tmplgm0j5ee.py", line 3, in <module> s = input() ^^^^^^^ EOFError: EOF when reading a line