s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s132140557
p00222
u633068244
1399123833
Python
Python
py
Runtime Error
0
0
48
while 1: n = input() if n == 0: break print n
s023287060
p00222
u633068244
1399123881
Python
Python
py
Runtime Error
0
0
49
while 1: n = input() if n == 0: break print(n)
s188736605
p00222
u633068244
1400422175
Python
Python
py
Runtime Error
0
0
233
r =10000001 p = [1]*r p[0]= p[1] = 0 for i in range(int(r**0.5)): if p[i]: p[2*i::i] = [0 for j in range(2*i,r,i)] while 1: n = input() if n == 0: break n -= 1-n%2 while any(not p[n-i] for i in [0,2,6,8]): n -= 2 print n
s747637393
p00223
u319725914
1535894637
Python
Python3
py
Runtime Error
0
0
1884
from line_profiler import LineProfiler from collections import deque def main(): while(True): W, H = map(int, input().split()) # print(W,H) if not W: break tx,ty = map(int, input().split()) kx,ky = map(int, input().split()) ma = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): for j,a in enumerate(input().split()): ma[i][j+1] = bool(1-int(a)) from pprint import pprint que = deque([[tx,ty,kx,ky,0]]) # pa = [[[[False]*(W+2) for ii in range(H+2)] for jj in range(W+2)] for kk in range(H+2)] pas = [] ans = "NA" while(que): # if len(que)>10:break # pprint(que) tx,ty,kx,ky,c = que.popleft() # import copy # toprint = copy.deepcopy(ma) # toprint[ty][tx] = "tt" # toprint[ky][kx] = "kk" # for i in range(H+2): # print("".join(( toprint[i][j] if toprint[i][j] in ["tt","kk"] else " ") if toprint[i][j] else "**" for j in range(W+2))) if c > 100: break if tx == kx and ty == ky: ans = c break for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]: tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0] kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0] # if pa[tx+tdx][ty+tdy][kx+kdx][ky+kdy]: continue if [tx+tdx,ty+tdy,kx+kdx,ky+kdy] in pas: continue que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1]) # pa[tx+tdx][ty+tdy][kx+kdx][ky+kdy] = True pas.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy]) print(ans) # pprint(ma) if __name__ == "__main__": prf = LineProfiler() prf.add_function(main) prf.runcall(main) prf.print_stats() # main()
s707834581
p00223
u319725914
1535895877
Python
Python3
py
Runtime Error
0
0
1252
# from line_profiler import LineProfiler from collections import deque from sys import stdin def main(): while(True): W, H = map(int, sys.stdin().split()) if not W: break tx,ty = map(int, sys.stdin().split()) kx,ky = map(int, sys.stdin().split()) ma = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): for j,a in enumerate(sys.stdin().split()): ma[i][j+1] = bool(1-int(a)) que = deque([[tx,ty,kx,ky,0]]) pas = set() ans = "NA" while(que): tx,ty,kx,ky,c = que.popleft() if c > 100: break if tx == kx and ty == ky: ans = c break for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]: tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0] kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0] if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1]) pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy)) print(ans) if __name__ == "__main__": # prf = LineProfiler() # prf.add_function(main) # prf.runcall(main) # prf.print_stats() main()
s669080304
p00223
u319725914
1535896094
Python
Python3
py
Runtime Error
0
0
1273
from line_profiler import LineProfiler from collections import deque from sys import stdin def main(): while(True): W, H = map(int, stdin.readline().split()) if not W: break tx,ty = map(int, stdin.readline().split()) kx,ky = map(int, stdin.readline().split()) ma = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): for j,a in enumerate(stdin.readline().split()): ma[i][j+1] = bool(1-int(a)) que = deque([[tx,ty,kx,ky,0]]) pas = set() ans = "NA" while(que): tx,ty,kx,ky,c = que.popleft() if tx == kx and ty == ky: ans = c break for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]: tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0] kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0] if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue if c+1 > 100: continue que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1]) pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy)) print(ans) if __name__ == "__main__": prf = LineProfiler() prf.add_function(main) prf.runcall(main) prf.print_stats() # main()
s604727891
p00223
u319725914
1535896715
Python
Python3
py
Runtime Error
0
0
1299
from line_profiler import LineProfiler from collections import deque from sys import stdin def main(): while(True): W, H = map(int, stdin.readline().split()) if not W: break tx,ty = map(int, stdin.readline().split()) kx,ky = map(int, stdin.readline().split()) ma = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): for j,a in enumerate(stdin.readline().split()): ma[i][j+1] = bool(1-int(a)) que = deque([[tx,ty,kx,ky,0]]) pas = set() ans = "NA" while(que): tx,ty,kx,ky,c = que.popleft() if tx == kx and ty == ky: ans = c break for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]: tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0) kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0) ttx,tty,kkx,kky = tx+tdx,ty+tdy,kx+kdx,ky+kdy if (ttx,tty,kkx,kky) in pas: continue if c+1 > 100: continue que.append([ttx,tty,kkx,kky,c+1]) pas.add((ttx,tty,kkx,kky)) print(ans) if __name__ == "__main__": prf = LineProfiler() prf.add_function(main) prf.runcall(main) prf.print_stats() # main()
s052862371
p00223
u766477342
1419778453
Python
Python3
py
Runtime Error
0
0
1663
direc = ((1,0),(-1,0),(0,1),(0,-1)) #d = [[[[0 for i in range(Y+1)] for i in range(X+1)] for i in range(Y+1)] for i in range(X+1)] #d[1][1][2][2]=3 # print(d) while 1: X, Y = list(map(int,input().split())) if X == 0: break ftx, fty = list(map(lambda x: x-1, map(int, input().split()))) fkx, fky = list(map(lambda x: x-1, map(int, input().split()))) m = [list(map(int, input().split())) for i in range(Y)] d = {(ftx, fty, fkx, fky): 0} s = [[0, (ftx, fty, fkx, fky)]] res = 'NA' while len(s) > 0: spm = s.pop(0) cnt = spm[0] + 1 if cnt > 100: break def search_move(): for i in range(4): tx = spm[1][0]+direc[i][0] ty = spm[1][1]+direc[i][1] kx = spm[1][2]-direc[i][0] ky = spm[1][3]-direc[i][1] hm = 0 if tx < 0 or tx >= X or ty < 0 or ty >= Y or m[ty][tx] == 1: tx = ftx ty = fty hm += 1 if kx < 0 or kx >= X or ky < 0 or ky >= Y or m[ky][kx] == 1: kx = fkx ky = fky hm += 1 hm == 2: continue tpl = (tx,ty,kx,ky) if tpl in d and d[tpl] <= cnt: continue if tx == kx and ty == ky: return True else: s.append([cnt,tpl]) d[tpl] = cnt # print(tpl) return False if search_move(): res = str(cnt) break print(res)
s872824467
p00224
u811434779
1438695705
Python
Python
py
Runtime Error
0
0
1602
import Queue INF = 1 << 29 class Edge: def __init__(self, _v, _cost): self.v = _v self.cost = _cost def parse(s, m, n): if(s[0]=="C"): return int(s.translate(None, "C")) - 1 elif(s[0]=="L"): return int(s.translate(None, "L")) - 1 + m elif(s[0]=="H"): return m + n else: return m + n + 1 while True: m, n, k, d = map(int, raw_input().split()) if m==0 and n==0 and k==0 and d==0: break cake = map(int, raw_input().split()) G = [[]*(m + n + 2) for i in range((m + n + 2))] for i in range(d): dist = raw_input().split() u = parse(dist[0], m, n) v = parse(dist[1], m ,n) G[v].append(Edge(u, int(dist[2]))) G[u].append(Edge(v, int(dist[2]))) D = [[0 for col in range(108)] for row in range(1<<6)] for i in range(m + n + 2): for j in range(1 << m): D[i][j] = INF D[m + n][0] = 0 ans = INF que = Queue.PriorityQueue() que.put([0, [m + n, 0]]) while not que.empty(): item = que.get() d_now = -item[0] u = item[1][0] s = item[1][1] if D[u][s] < d_now: continue if u == m + n + 1: ans = min(ans, d_now) for i in range(len(G[u])): v = G[u][i].v if v < m: if s&1 << v != 0: continue s2 = s | 1 << v d2 = d_now + k * G[u][i].cost - cake[v] else : s2 = s d2 = d_now + k * G[u][i].cost if d2 < D[v][s2]: D[v][s2] = d2 que.put([-d2, [v, s2]]) print ans
s484103854
p00224
u811434779
1438696218
Python
Python
py
Runtime Error
0
0
1590
import Queue INF = 1 << 29 class Edge: def __init__(self, _v, _cost): self.v = _v self.cost = _cost def parse(s, m, n): if(s[0]=="C"): return int(s.translate(None, "C")) - 1 elif(s[0]=="L"): return int(s.translate(None, "L")) - 1 + m elif(s[0]=="H"): return m + n else: return m + n + 1 while True: m, n, k, d = map(int, raw_input().split()) if m==0 and n==0 and k==0 and d==0: break cake = map(int, raw_input().split()) G = [[] for i in range((m + n + 2))] for i in range(d): dist = raw_input().split() u = parse(dist[0], m, n) v = parse(dist[1], m ,n) G[v].append(Edge(u, int(dist[2]))) G[u].append(Edge(v, int(dist[2]))) D = [[0 for col in range(108)] for row in range(1<<6)] for i in range(m + n + 2): for j in range(1 << m): D[i][j] = INF D[m + n][0] = 0 ans = INF que = Queue.PriorityQueue() que.put([0, [m + n, 0]]) while not que.empty(): item = que.get() d_now = -item[0] u = item[1][0] s = item[1][1] if D[u][s] < d_now: continue if u == m + n + 1: ans = min(ans, d_now) for i in range(len(G[u])): v = G[u][i].v if v < m: if s&1 << v != 0: continue s2 = s | 1 << v d2 = d_now + k * G[u][i].cost - cake[v] else : s2 = s d2 = d_now + k * G[u][i].cost if d2 < D[v][s2]: D[v][s2] = d2 que.put([-d2, [v, s2]]) print ans
s309301895
p00224
u811434779
1438697216
Python
Python
py
Runtime Error
39870
5384
1588
import Queue INF = 1 << 29 class Edge: def __init__(self, _v, _cost): self.v = _v self.cost = _cost def parse(s, m, n): if(s[0]=="C"): return int(s.translate(None, "C")) - 1 elif(s[0]=="L"): return int(s.translate(None, "L")) - 1 + m elif(s[0]=="H"): return m + n else: return m + n + 1 while True: m, n, k, d = map(int, raw_input().split()) if m==0 and n==0 and k==0 and d==0: break cake = map(int, raw_input().split()) G = [[] for i in range(m + n + 2)] for i in range(d): dist = raw_input().split() u = parse(dist[0], m, n) v = parse(dist[1], m ,n) G[v].append(Edge(u, int(dist[2]))) G[u].append(Edge(v, int(dist[2]))) D = [[0 for col in range(1<<6)] for row in range(108)] for i in range(m + n + 2): for j in range(1 << m): D[i][j] = INF D[m + n][0] = 0 ans = INF que = Queue.PriorityQueue() que.put([0, [m + n, 0]]) while not que.empty(): item = que.get() d_now = -item[0] u = item[1][0] s = item[1][1] if D[u][s] < d_now: continue if u == m + n + 1: ans = min(ans, d_now) for i in range(len(G[u])): v = G[u][i].v if v < m: if s&1 << v != 0: continue s2 = s | 1 << v d2 = d_now + k * G[u][i].cost - cake[v] else : s2 = s d2 = d_now + k * G[u][i].cost if d2 < D[v][s2]: D[v][s2] = d2 que.put([-d2, [v, s2]]) print ans
s247479102
p00224
u352394527
1530035047
Python
Python3
py
Runtime Error
0
0
2122
from itertools import combinations from heapq import heappop, heappush INF = 10 ** 20 def convert(s, m, n): if s == "H": return 0 if s == "D": return 1 if s[0] == "C": return int(s[1]) + 1 if s[0] == "L": return int(s[1]) + m + 1 def get_cost(start, m, n, edges): cost = [INF] * (m + n + 2) cost[start] = 0 que = [] heappush(que, (0, start)) while que: total, point = heappop(que) for dist, to in edges[point]: if cost[to] > total + dist: cost[to] = total + dist if not (2 <= to <= m + 1): heappush(que, (total + dist, to)) return cost def shortest_path(start, goal, rest, cakes_dist, dic): if not rest: return cakes_dist[start][goal] if (start, rest) in dic: return dic[(now, rest)] ret = INF for to in rest: ret = min(ret, shortest_path(to, goal, tuple((i for i in rest if i != to)), cakes_dist, dic) + cakes_dist[start][to]) dic[(start, rest)] = ret return ret while True: m, n, k, d = map(int, input().split()) if m == 0: break clst = list(map(int, input().split())) """ Home ... 0 D ... 1 Cake ... 2, 3, ... m + 1 Land ... m + 2, m + 3, ... m + n + 1 """ edges = [[] for _ in range(m + n + 2)] for _ in range(d): s, t, e = input().split() e = int(e) s = convert(s, m, n) t = convert(t, m, n) edges[s].append((e, t)) edges[t].append((e, s)) cakes_dist = [[INF] * (m + 2) for _ in range(m + 2)] for start in range(m + 2): cost = get_cost(start, m, n, edges) for to in range(m + 2): if to != start: cakes_dist[start][to] = cost[to] dic = {} """ now ... ็พๅœจใ„ใ‚‹็‚น rest ... ๆฎ‹ใ‚Šใฎใ‚ใใ‚‹็‚น dic[(now, rest)] ... ็พๅœจใ„ใ‚‹็‚นใ€ๆฎ‹ใ‚Šใฎ็‚นใ‚’ใพใ‚ใ‚‹ๆ™‚ใฎๆœ€ๅฐ่ท้›ข dic[(now, rest)] = min(cakes_dist[now][to] + dic[(to, rest - to)] for to in rest) """ ans = INF cakes = [i for i in range(2, m + 2)] for num in range(m + 1): for rest in combinations(cakes, num): cal = sum([clst[i - 2] for i in rest]) ans = min(ans, shortest_path(0, 1, rest, cakes_dist, dic) * k - cal) print(ans)
s746751127
p00224
u352394527
1530035110
Python
Python3
py
Runtime Error
0
0
2164
from itertools import combinations from heapq import heappop, heappush import sys sys.setrecursionlimit(1000000) INF = 10 ** 20 def convert(s, m, n): if s == "H": return 0 if s == "D": return 1 if s[0] == "C": return int(s[1]) + 1 if s[0] == "L": return int(s[1]) + m + 1 def get_cost(start, m, n, edges): cost = [INF] * (m + n + 2) cost[start] = 0 que = [] heappush(que, (0, start)) while que: total, point = heappop(que) for dist, to in edges[point]: if cost[to] > total + dist: cost[to] = total + dist if not (2 <= to <= m + 1): heappush(que, (total + dist, to)) return cost def shortest_path(start, goal, rest, cakes_dist, dic): if not rest: return cakes_dist[start][goal] if (start, rest) in dic: return dic[(now, rest)] ret = INF for to in rest: ret = min(ret, shortest_path(to, goal, tuple((i for i in rest if i != to)), cakes_dist, dic) + cakes_dist[start][to]) dic[(start, rest)] = ret return ret while True: m, n, k, d = map(int, input().split()) if m == 0: break clst = list(map(int, input().split())) """ Home ... 0 D ... 1 Cake ... 2, 3, ... m + 1 Land ... m + 2, m + 3, ... m + n + 1 """ edges = [[] for _ in range(m + n + 2)] for _ in range(d): s, t, e = input().split() e = int(e) s = convert(s, m, n) t = convert(t, m, n) edges[s].append((e, t)) edges[t].append((e, s)) cakes_dist = [[INF] * (m + 2) for _ in range(m + 2)] for start in range(m + 2): cost = get_cost(start, m, n, edges) for to in range(m + 2): if to != start: cakes_dist[start][to] = cost[to] dic = {} """ now ... ็พๅœจใ„ใ‚‹็‚น rest ... ๆฎ‹ใ‚Šใฎใ‚ใใ‚‹็‚น dic[(now, rest)] ... ็พๅœจใ„ใ‚‹็‚นใ€ๆฎ‹ใ‚Šใฎ็‚นใ‚’ใพใ‚ใ‚‹ๆ™‚ใฎๆœ€ๅฐ่ท้›ข dic[(now, rest)] = min(cakes_dist[now][to] + dic[(to, rest - to)] for to in rest) """ ans = INF cakes = [i for i in range(2, m + 2)] for num in range(m + 1): for rest in combinations(cakes, num): cal = sum([clst[i - 2] for i in rest]) ans = min(ans, shortest_path(0, 1, rest, cakes_dist, dic) * k - cal) print(ans)
s063425437
p00224
u352394527
1530036198
Python
Python3
py
Runtime Error
0
0
2186
from itertools import combinations from heapq import heappop, heappush import sys sys.setrecursionlimit(1000000) INF = 10 ** 20 def convert(s, m, n): if s == "H": return 0 if s == "D": return 1 if s[0] == "C": return int(s[1]) + 1 if s[0] == "L": return int(s[1]) + m + 1 def get_cost(start, m, n, edges): cost = [INF] * (m + n + 2) cost[start] = 0 que = [] heappush(que, (0, start)) while que: total, node = heappop(que) for dist, to in edges[node]: if cost[to] > total + dist: cost[to] = total + dist if not (2 <= to <= m + 1): heappush(que, (total + dist, to)) return cost def shortest_path(start, goal, rest, cakes_dist, dic): if not rest: return cakes_dist[start][goal] if (start, rest) in dic: return dic[(now, rest)] ret = INF for to in rest: ret = min(ret, shortest_path(to, goal, tuple((i for i in rest if i != to)), cakes_dist, dic) + cakes_dist[start][to]) dic[(start, rest)] = ret return ret while True: m, n, k, d = map(int, input().split()) if m == 0: break clst = list(map(int, input().split())) """ Home ... 0 D ... 1 Cake ... 2, 3, ... m + 1 Land ... m + 2, m + 3, ... m + n + 1 """ edges = [[] for _ in range(m + n + 2)] for _ in range(d): s, t, e = input().split() e = int(e) s = convert(s, m, n) t = convert(t, m, n) edges[s].append((e, t)) edges[t].append((e, s)) cakes_dist = [[INF] * (m + 2) for _ in range(m + 2)] for start in range(m + 2): cost = get_cost(start, m, n, edges) for to in range(m + 2): if to != start: cakes_dist[start][to] = cost[to] print(cakes_dist) dic = {} """ now ... ็พๅœจใ„ใ‚‹็‚น rest ... ๆฎ‹ใ‚Šใฎใ‚ใใ‚‹็‚น dic[(now, rest)] ... ็พๅœจใ„ใ‚‹็‚นใ€ๆฎ‹ใ‚Šใฎ็‚นใ‚’ใพใ‚ใ‚‹ๆ™‚ใฎๆœ€ๅฐ่ท้›ข dic[(now, rest)] = min(cakes_dist[now][to] + dic[(to, rest - to)] for to in rest) """ ans = INF cakes = [i for i in range(2, m + 2)] for num in range(m + 1): for rest in combinations(cakes, num): cal = sum([clst[i - 2] for i in rest]) ans = min(ans, shortest_path(0, 1, rest, cakes_dist, dic) * k - cal) print(ans)
s615590780
p00224
u352394527
1530036224
Python
Python3
py
Runtime Error
0
0
2194
from itertools import combinations from heapq import heappop, heappush import sys sys.setrecursionlimit(1000000) INF = 10 ** 20 def convert(s, m, n): if s == "H": return 0 if s == "D": return 1 if s[0] == "C": return int(s[1]) + 1 if s[0] == "L": return int(s[1]) + m + 1 def get_cost(start, m, n, edges): cost = [INF] * (m + n + 2) cost[start] = 0 que = [] heappush(que, (0, start)) while que: total, node = heappop(que) for dist, to in edges[node]: if cost[to] > total + dist: cost[to] = total + dist if not (2 <= to <= m + 1): heappush(que, (total + dist, to)) return cost def shortest_path(start, goal, rest, cakes_dist, dic): if not rest: return cakes_dist[start][goal] if (start, rest) in dic: return dic[(now, rest)] ret = INF for to in rest: ret = min(ret, shortest_path(to, goal, tuple((i for i in rest if i != to)), cakes_dist, dic) + cakes_dist[start][to]) dic[(start, rest)] = ret return ret print(0) while True: m, n, k, d = map(int, input().split()) if m == 0: break clst = list(map(int, input().split())) """ Home ... 0 D ... 1 Cake ... 2, 3, ... m + 1 Land ... m + 2, m + 3, ... m + n + 1 """ edges = [[] for _ in range(m + n + 2)] for _ in range(d): s, t, e = input().split() e = int(e) s = convert(s, m, n) t = convert(t, m, n) edges[s].append((e, t)) edges[t].append((e, s)) cakes_dist = [[INF] * (m + 2) for _ in range(m + 2)] for start in range(m + 2): cost = get_cost(start, m, n, edges) for to in range(m + 2): if to != start: cakes_dist[start][to] = cost[to] print(cakes_dist) dic = {} """ now ... ็พๅœจใ„ใ‚‹็‚น rest ... ๆฎ‹ใ‚Šใฎใ‚ใใ‚‹็‚น dic[(now, rest)] ... ็พๅœจใ„ใ‚‹็‚นใ€ๆฎ‹ใ‚Šใฎ็‚นใ‚’ใพใ‚ใ‚‹ๆ™‚ใฎๆœ€ๅฐ่ท้›ข dic[(now, rest)] = min(cakes_dist[now][to] + dic[(to, rest - to)] for to in rest) """ ans = INF cakes = [i for i in range(2, m + 2)] for num in range(m + 1): for rest in combinations(cakes, num): cal = sum([clst[i - 2] for i in rest]) ans = min(ans, shortest_path(0, 1, rest, cakes_dist, dic) * k - cal) print(ans)
s471459494
p00225
u779627195
1355233095
Python
Python
py
Runtime Error
0
0
935
import sys R = lambda:map(int,raw_input().split()) def eulerPath(graph): odd = [x for x in graph.keys() if len(graph[x])&1] if len(odd) > 2: return -1 stack = [graph.keys()[0]] path = [] while stack: #print stack v = stack[-1] if graph[v]: u = graph[v].pop(0) stack.append(u) graph[u].remove(v) #print graph, stack else: path.append(stack.pop()) return path graph = {} while 1: n = int(raw_input()) if not n: break graph = {} for i in xrange(n): a = raw_input() if not a[0] in graph.keys(): graph[a[0]] = [a[-1]] else: graph[a[0]].append(a[-1]) if not a[-1] in graph.keys(): graph[a[-1]] = [a[0]] else: graph[a[-1]].append(a[0]) path = eulerPath(graph) if path is -1: print 'NG' else: print 'OK'
s009510059
p00225
u104911888
1369314986
Python
Python
py
Runtime Error
0
0
274
from collections import defaultdict while True: n=input() if n==0:break dic=defaultdict(int) for i in range(n): w=raw_input() dic[w[0]]+=1 dic[w[-1]]+=1 if len(set(dic.values()))==1: print "OK" else: print "NG"
s005456132
p00225
u104911888
1369315096
Python
Python
py
Runtime Error
0
0
324
from collections import defaultdict while True: try: n=input() except SyntaxError: pass if n==0:break dic=defaultdict(int) for i in range(n): w=raw_input() dic[w[0]]+=1 dic[w[-1]]+=1 if len(set(dic.values()))==1: print "OK" else: print "NG"
s867449336
p00225
u794549850
1372093840
Python
Python
py
Runtime Error
0
0
1676
alphabets = {} alphabets_num = {} vartexs = [] fail_check = {} class Vartex(): def __init__(self, string): global alphabets self.ID = string self.link = [] self.arrival = 0 alphabets[string[0]].append(self) alphabets_num[string[0]] += 1 return def register(self, new_vartex): self.link.append(new_vartex) return def check_all(vartexs): for content in vartexs: if not content.arrival: return False return True def dfs(start_vartex): global vartexs start_vartex.arrival = 1 for link_vartex in start_vartex.link: if link_vartex.arrival: if check_all(vartexs): return True else : continue else: if dfs(link_vartex): return True else: continue start_vartex.arrival = 0 return False while True: alphabets = {} alphabets_num = {} vartexs = [] fail_check = {} for al in range(ord("a"), ord("z")+1): alphabets[chr(al)] = [] alphabets_num[chr(al)] = 0 fail_check[chr(al)] = 0 n = int(raw_input()) if not n: break for x in range(n): vartexs.append(Vartex(raw_input())) for x in range(n): vartex = vartexs[x] string = vartex.ID fail_check[string[-1]] += 1 for content in alphabets[string[-1]]: vartex.register(content) if alphabets_num != fail_check: print "NG" else : start = vartexs[0] if dfs(start): print "OK" else: print "NG"
s717453326
p00225
u794549850
1372094044
Python
Python
py
Runtime Error
0
0
1677
alphabets = {} alphabets_num = {} vartexs = [] fail_check = {} class Vartex(): def __init__(self, string): global alphabets self.ID = string self.link = [] self.arrival = 0 alphabets[string[0]].append(self) alphabets_num[string[0]] += 1 return def register(self, new_vartex): self.link.append(new_vartex) return def check_all(vartexs): for content in vartexs: if not content.arrival: return False return True def dfs(start_vartex): global vartexs start_vartex.arrival = 1 for link_vartex in start_vartex.link: if link_vartex.arrival: if check_all(vartexs): return True else : continue else: if dfs(link_vartex): return True else: continue start_vartex.arrival = 0 return False while True: alphabets = {} alphabets_num = {} vartexs = [] fail_check = {} for al in range(ord("a"), ord("z")+1): alphabets[chr(al)] = [] alphabets_num[chr(al)] = 0 fail_check[chr(al)] = 0 n = int(raw_input()) if n == 0: break for x in range(n): vartexs.append(Vartex(raw_input())) for x in range(n): vartex = vartexs[x] string = vartex.ID fail_check[string[-1]] += 1 for content in alphabets[string[-1]]: vartex.register(content) if alphabets_num != fail_check: print "NG" else : start = vartexs[0] if dfs(start): print "OK" else: print "NG"
s691385727
p00225
u104911888
1372169288
Python
Python
py
Runtime Error
0
0
319
while True: n=input() if n==0:break inWd=[0]*26 outWd=[0]*26 for i in range(n): s=raw_input() inWd[ord(s[0])-ord("a")]+=1 outWd[ord(s[-1])-ord("a")]+=1 for i in range(26): if inWd[i]!=outWd[i]: print "NG" break else: print "OK"
s668386026
p00225
u104911888
1375079105
Python
Python
py
Runtime Error
0
0
727
def dfs(u): visited[u]=True for v in range(26): if (not visited[v]) and G[u][v]: dfs(v) def getNComponent(): nc=0 for i in range(26): if head[i]==0 and tail[i]==0: continue if not visited[i]: nc+=1 dfs(i) return nc while True: n=input() if n==0:break head=[0]*26 tail=[0]*26 visited=[False]*26 G=[[0]*26 for i in range(26)] for i in range(n): s=raw_input() head[ord(s[0])-ord("a")]+=1 tail[ord(s[-1])-ord("a")]+=1 G[ord(s[0])-ord("a")][ord(s[-1])-ord("a")]=1 G[ord(s[-1])-ord("a")][ord(s[0])-ord("a")]=1 print "OK" if head==tail and getNComponent()==1 else "NG"
s685326134
p00225
u104911888
1375080904
Python
Python
py
Runtime Error
0
0
667
def dfs(u): visited[u]=True f=False for v in range(26): if G[u][v]: f=True if not visited[v]: dfs(v) return f def getNComponent(): nc=0 for i in range(26): if (not visited[i]) and dfs(i): nc+=1 return nc while True: n=input() if n==0:break head=[0]*26 tail=[0]*26 visited=[False]*26 G=[[False]*26 for i in range(26)] for i in range(n): s=raw_input() a,b=ord(s[0])-ord("a"),ord(s[-1])-ord("a") head[a]+=1 tail[b]+=1 G[a][b]=G[b][a]=True print "OK" if head==tail and getNComponent()==1 else "NG"
s885828355
p00225
u104911888
1385220428
Python
Python
py
Runtime Error
0
0
1127
def dfs(current_node): for next_node in range(26): if L[current_node][next_node]: L[current_node][next_node] = 0 visited[current_node] = True dfs(next_node) def getNComponent(): count = 0 for i in range(26): if inWd[i]==0 and outWd[i]==0: continue if not visited[i]: count += 1 dfs(i) return count def check(): for i in range(26): if inWd[i]!=outWd[i]: return False return True while True: """ try: n = input() except SyntaxError: break """ n = input() if n==0:break inWd = [0]*26 outWd = [0]*26 visited = [False]*26 L = [[0]*26 for i in range(26)] for i in range(n): s = raw_input() first_char_num = ord(s[0])-ord("a") last_char_num = ord(s[-1])-ord("a") inWd[first_char_num] += 1 outWd[last_char_num] += 1 L[first_char_num][last_char_num] = 1 L[last_char_num][first_char_num] = 1 if check() and getNComponent()==1: print "OK" else: print "NG"
s857163919
p00225
u104911888
1385221579
Python
Python
py
Runtime Error
0
0
1012
def check(): for i in range(26): if inWd[i] != outWd[i]: return False return True def dfs(current_node): visited[current_node] = True for next_node in range(26): if not visited[next_node] and L[current_node][next_node]: dfs(next_node) def getNComponent(): nc = 0 for i in range(26): if inWd[i] == 0 and outWd[i] == 0: continue if not visited[i]: nc += 1 dfs(i) return nc while True: try: n = input() except SyntaxError: break n = input() if n==0:break inWd = [0]*26 outWd = [0]*26 visited = [False]*26 L = [[0]*26 for i in range(26)] for i in range(n): s = raw_input() first = ord(s[0])-ord("a") last = ord(s[-1])-ord("a") inWd[first] += 1 outWd[last] += 1 L[first][last] = 1 L[last][first] = 1 if check() and getNComponent()==1: print "OK" else: print "NG"
s856247717
p00225
u104911888
1385221735
Python
Python
py
Runtime Error
0
0
947
def check(): for i in range(26): if inWd[i] != outWd[i]: return False return True def dfs(current_node): visited[current_node] = True for next_node in range(26): if not visited[next_node] and L[current_node][next_node]: dfs(next_node) def getNComponent(): nc = 0 for i in range(26): if inWd[i] == 0 and outWd[i] == 0: continue if not visited[i]: nc += 1 dfs(i) return nc while True: n = input() if n == 0:break inWd = [0]*26 outWd = [0]*26 visited = [False]*26 L = [[0]*26 for i in range(26)] for i in range(n): s = raw_input() first = ord(s[0])-ord("a") last = ord(s[-1])-ord("a") inWd[first] += 1 outWd[last] += 1 L[first][last] = 1 L[last][first] = 1 if check() and getNComponent()==1: print "OK" else: print "NG"
s329244365
p00225
u633068244
1397003831
Python
Python
py
Runtime Error
0
0
312
while 1: n=input() if n==0: break ini,end={},{} for i in range(n): word=raw_input() try:ini[word[0]]+=1 except:ini[word[0]]=1 try:end[word[-1]]+=1 except:end[word[-1]]=1 for k,v in ini.items(): if k not in end or end[k]!=v: print "NG" break else: print "OK"
s344996129
p00225
u633068244
1397003874
Python
Python
py
Runtime Error
0
0
314
while 1: n=input() if n==0: break ini,end={},{} for i in range(n): word=raw_input() try:ini[word[0]]+=1 except:ini[word[0]]=1 try:end[word[-1]]+=1 except:end[word[-1]]=1 for k,v in ini.items(): if k not in end or end[k]!=v: print "NG" break else: print "OK"
s255080505
p00225
u633068244
1397003951
Python
Python
py
Runtime Error
0
0
283
while 1: n=input() if n==0: break ini,end={},{} for i in range(n): word=raw_input() try:ini[word[0]]+=1 except:ini[word[0]]=1 try:end[word[-1]]+=1 except:end[word[-1]]=1 for k,v in ini.items(): if k not in end or end[k]!=v: print "NG" break else: print "OK"
s611647651
p00225
u633068244
1397004519
Python
Python
py
Runtime Error
0
0
340
while 1: n=input() if n==0: break ini,end={},{} for i in range(n): word=raw_input() if word[0]==word[-1]: continue try:ini[word[0]]+=1 except:ini[word[0]]=1 try:end[word[-1]]+=1 except:end[word[-1]]=1 for k,v in ini.items(): if k not in end or end[k]!=v: print "NG" break else: print "OK"
s530566176
p00225
u633068244
1397004557
Python
Python
py
Runtime Error
0
0
380
while 1: try: n=input() if n==0: break ini,end={},{} for i in range(n): word=raw_input() if word[0]==word[-1]: continue try:ini[word[0]]+=1 except:ini[word[0]]=1 try:end[word[-1]]+=1 except:end[word[-1]]=1 for k,v in ini.items(): if k not in end or end[k]!=v: print "NG" break else: print "OK" except: break
s209450030
p00226
u873482706
1437728665
Python
Python
py
Runtime Error
0
0
287
while True: r, a = raw_input().split() if r == a == 0: break h = 0 _r = [] _a = [] for i in range(4): if a[i] == r[i]: h += 1 else: _r.append(r[i]) _a.append(a[i]) else: print h, len(set(_r)&set(_a))
s606870645
p00226
u546285759
1484201427
Python
Python3
py
Runtime Error
0
0
184
while True: r, a= input().split() if r==a==0: break print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))
s799176987
p00226
u071693485
1509107452
Python
Python3
py
Runtime Error
0
0
421
for q in range(12000): a = tuple(map(int, input().split())) b = input() if a[0] == 0 and b[0] == '0': break hit = 0 for i in range(4): if a[i] == int(b[i]): hit = hit + 1 blow = 0 for j in range(4): for i in range(4): if (int(b[j]) == a[i]) and (a[i] != int(b[i])) and (a[j] != int(b[j])): blow = blow + 1 print(hit, blow)
s107172751
p00226
u460331583
1346528889
Python
Python
py
Runtime Error
0
0
341
while True: aw=[] ar = raw_input() if ar[0] ==0 and ar[1] ==0 and ar[2] ==0: break else: hit=0 blo=0 for t in range(5,9): aw.append(ar[t]) for t in range(0,4): if ar[t] == aw[t]: hit+=1 for t in range(0,4): for y in range(0,4): if ar[t] == aw[y]: if t == y: break else: blo +=1 print hit,blo
s217644249
p00226
u350508326
1382632159
Python
Python
py
Runtime Error
0
0
442
if __name__ == '__main__': while True: a,b = map(str,raw_input().split(' ')) if a == 0 and b == 0: break a = list(a) b = list(b) # print a br = 0 hit = 0 for i,data in enumerate(b): if data in a: if a[i] == data: hit += 1 else: br += 1 print hit,br
s254109919
p00227
u766477342
1414673959
Python
Python3
py
Runtime Error
0
0
340
while True: n,m = list(map(int,input().split())) if n == 0 and m == 0: break amari = n % m yasai = list(map(int,input().split())) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 for y in yasai[amari:]: if i % m > 0: s += y i+=1 print(s)
s440319197
p00227
u766477342
1414674172
Python
Python3
py
Runtime Error
0
0
299
while True: n,m = list(map(int,input().split())) if n == 0 and m == 0: break amari = n % m yasai = list(map(int,input().split())) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 for y in yasai[amari:]: pass print(s)
s788391393
p00227
u766477342
1414674288
Python
Python3
py
Runtime Error
0
0
358
while True: n,m = list(map(int,input().split())) if n == 0 and m == 0: break amari = int(n % m) yasai = list(map(int,input().split())) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 for y in yasai[amari:]: pass if i % m > 0: s += y i+=1 print(s)
s494687397
p00227
u766477342
1414674346
Python
Python3
py
Runtime Error
0
0
177
while True: n,m = list(map(int,input().split())) if n == 0 and m == 0: break amari = int(n % m) yasai = list(map(int,input().split())) print(amari)
s460424976
p00227
u766477342
1414674397
Python
Python3
py
Runtime Error
0
0
69
while True: n,m = list(map(int,input().split())) print(amari)
s416311223
p00227
u766477342
1414674531
Python
Python3
py
Runtime Error
0
0
177
while True: #n,m = list(map(int,input().split())) spam = input().split() n = int(spam[0]) m = int(spam[1]) if n == 0 and m == 0: break print(1)
s551817601
p00227
u766477342
1414674597
Python
Python3
py
Runtime Error
0
0
95
while True: #n,m = list(map(int,input().split())) spam = input().split() print(1)
s355205329
p00227
u766477342
1414674673
Python
Python3
py
Runtime Error
0
0
87
while True: #n,m = list(map(int,input().split())) spam = input() print(1)
s954737843
p00227
u766477342
1414675077
Python
Python
py
Runtime Error
0
0
335
while True: n,m = map(int,raw_input().split()) if n == 0 and m == 0: break amari = n % m yasai = map(int,raw_input().split()) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 for y in yasai[amari:]: if i % m > 0: s += y i+=1 print(s)
s619657621
p00227
u766477342
1414675094
Python
Python3
py
Runtime Error
0
0
335
while True: n,m = map(int,raw_input().split()) if n == 0 and m == 0: break amari = n % m yasai = map(int,raw_input().split()) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 for y in yasai[amari:]: if i % m > 0: s += y i+=1 print(s)
s385523379
p00227
u766477342
1414675158
Python
Python3
py
Runtime Error
0
0
54
while True: n,m = map(int,raw_input().split())
s194227838
p00227
u766477342
1414675183
Python
Python
py
Runtime Error
0
0
53
while True: n,m = map(int,raw_input().split(' '))
s005069079
p00227
u766477342
1414675337
Python
Python
py
Runtime Error
0
0
45
while True: a = raw_input() print 'a'
s103292306
p00227
u766477342
1414675394
Python
Python3
py
Runtime Error
0
0
42
while True: a = input() print('a')
s177266676
p00227
u766477342
1414675449
Python
Python
py
Runtime Error
0
0
43
while True: a = input() print('a')
s204162965
p00227
u104911888
1368319849
Python
Python
py
Runtime Error
0
0
177
while True: n,m=map(int,raw_input().split()) if n==m==0:break L=sorted(map(int,raw_input().split()),reverse=True) print sum(L[i] for i in range(n) if (i+1)%m<>0)
s389234039
p00227
u104911888
1368319949
Python
Python
py
Runtime Error
0
0
226
while True: try: n,m=map(int,raw_input().split()) except ValueError: pass if n==m==0:break L=sorted(map(int,raw_input().split()),reverse=True) print sum(L[i] for i in range(n) if (i+1)%m<>0)
s764113418
p00227
u104911888
1368320041
Python
Python
py
Runtime Error
0
0
193
while True: A=map(int,raw_input().split()) n,m=A[0],A[1] if n==m==0:break L=sorted(map(int,raw_input().split()),reverse=True) print sum(L[i] for i in range(n) if (i+1)%m<>0)
s455721485
p00227
u104911888
1368320194
Python
Python
py
Runtime Error
0
0
164
while True: n,m=input(),input() if n==m==0:break L=sorted(map(int,raw_input().split()),reverse=True) print sum(L[i] for i in range(n) if (i+1)%m<>0)
s991901228
p00227
u260980560
1384356845
Python
Python
py
Runtime Error
0
0
205
while 1: n,m = map(int, raw_input().split()) if n==m==0: break s = 0 p = map(int, raw_input().split()) p.sort(reverse=True) s = sum([p[i] for i in range(n) if i%m!=m-1]) print s
s398909532
p00227
u260980560
1384357169
Python
Python
py
Runtime Error
0
0
221
while 1: n,m = map(int, raw_input().split()) if n==m==0: break p = map(int, raw_input().split()) p.sort(reverse=True) s = 0 for i in range(n): if i%m!=m-1: s += p[i] print s
s123756566
p00227
u260980560
1384357259
Python
Python
py
Runtime Error
0
0
234
while 1: n,m = map(int, raw_input().split()) if n==m==0: break p = map(int, raw_input().split()) p.sort(reverse=True) s = 0 for i in range(n): if i%m!=m-1: s += p[i] del p[:] print s
s147867888
p00227
u647766105
1388619306
Python
Python
py
Runtime Error
0
0
169
while True: n, m = map(int, raw_input().split()) if n|m == 0: break p = sorted(map(int, raw_input().split()))[::-1] print sum(p) - sum(p[m-1::m])
s942655342
p00227
u647766105
1388619398
Python
Python
py
Runtime Error
0
0
186
while True: n, m = map(int, raw_input().split()) if n|m == 0: break p = sorted(map(int, raw_input().split()))[::-1] print sum(p) - sum(p[m-1::m]) if n >= m else 0
s653479535
p00227
u647766105
1388619510
Python
Python
py
Runtime Error
0
0
186
while True: n, m = map(int, raw_input().split()) if n == 0: break p = sorted(map(int, raw_input().split()))[::-1] print sum(p) - (sum(p[m-1::m]) if n >= m else 0)
s130028557
p00227
u350508326
1392480128
Python
Python
py
Runtime Error
0
0
330
while True: n = map(int, raw_input().split()) if n[0] == 0 and n[1] == 0: break # print(n) data = sorted(map(int, raw_input().split()), reverse = True) # print(data) sum = 0 for i in xrange(n[0]): if (i + 1) % n[1] != 0: sum += data[i] # print(i) print(sum)
s975531439
p00227
u350508326
1392480247
Python
Python
py
Runtime Error
0
0
275
while True: n = map(int, raw_input().split()) if n[0] == 0 and n[1] == 0: break data = sorted(map(int, raw_input().split()), reverse = True) sum = 0 for i in xrange(n[0]): if (i + 1) % n[1] != 0: sum += data[i] print(sum)
s749110384
p00227
u350508326
1392480402
Python
Python
py
Runtime Error
0
0
329
while True: n = map(int, raw_input().split()) if n[0] == 0 and n[1] == 0: break # print(n) data = sorted(map(int, raw_input().split()), reverse = True) # print(data) sum = 0 for i in range(n[0]): if (i + 1) % n[1] != 0: sum += data[i] # print(i) print(sum)
s758750575
p00227
u350508326
1392480996
Python
Python
py
Runtime Error
0
0
459
def main(): while True: n = map(int, raw_input().split()) if n[0] == 0 and n[1] == 0: break # print(n) data = sorted(map(int, raw_input().split()), reverse = True) # print(data) sum = 0 for i in range(len(data)): if (i + 1 ) % n[1] != 0: sum += data[i] # print(i) print(sum) if __name__ == '__main__': main()
s678720799
p00227
u633068244
1396279625
Python
Python
py
Runtime Error
0
0
321
def signal(a,e): s="" for i in range(7): s+="0" if a[i]==e[i] else "1" return s ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"] while 1: n=int(raw_input()) if n==-1:break e="0000000" for i in range(n): a=ref[int(raw_input())] print signal(a,e) e=a
s303140216
p00227
u633068244
1396284009
Python
Python
py
Runtime Error
0
0
161
while 1: n,m=map(int, raw_input().split()) if n==0:break c=sorted(map(int,raw_input().split()))[::-1] c[m-1::m] = [0 for i in range(m-1,n,m)] print sum(c)
s265989563
p00227
u633068244
1396284109
Python
Python
py
Runtime Error
0
0
196
while 1: n,m=map(int, raw_input().split()) if n==0:break c=sorted(map(int,raw_input().split()))[::-1] if m > n: print sum(c) else: c[m-1::m] = [0 for i in range(m-1,n,m)] print sum(c)
s086260804
p00227
u633068244
1396284160
Python
Python
py
Runtime Error
0
0
202
while 1: n,m=map(int, raw_input().split()) if n==0:break # c=sorted(map(int,raw_input().split()))[::-1] # if m > n: # print sum(c) # else: # c[m-1::m] = [0 for i in range(m-1,n,m)] # print sum(c)
s324898080
p00227
u633068244
1396284175
Python
Python
py
Runtime Error
0
0
205
while True: n,m=map(int, raw_input().split()) if n==0:break # c=sorted(map(int,raw_input().split()))[::-1] # if m > n: # print sum(c) # else: # c[m-1::m] = [0 for i in range(m-1,n,m)] # print sum(c)
s885584542
p00227
u633068244
1396284208
Python
Python
py
Runtime Error
0
0
204
while True: n,m=map(int, raw_input().split()) if n==0:break c=sorted(map(int,raw_input().split()))[::-1] # if m > n: # print sum(c) # else: # c[m-1::m] = [0 for i in range(m-1,n,m)] # print sum(c)
s543493715
p00227
u633068244
1396284314
Python
Python
py
Runtime Error
0
0
228
while 1: n=map(int, raw_input().split()) if n[0]==0:break # c=sorted(map(int,raw_input().split()))[::-1] # if m > n: # print sum(c) # else: # c[m-1::m] = [0 for i in range(m-1,n,m)] # print sum(c)
s333649595
p00227
u633068244
1396719686
Python
Python
py
Runtime Error
0
0
152
while 1: n,m=map(int,raw_input().split()) if n==0:break v=sorted(map(int,raw_input().split()))[::-1] for i in range(m-1,n,m): v[i]=0 print sum(v)
s885249519
p00227
u759949288
1398140430
Python
Python
py
Runtime Error
0
0
210
while True: n, m = (int(x) for x in raw_input().split(" ")) if n == 0 and m == 0: break p = [int(x) for x in raw_input().split(" ")] s = sum(p) p.sort(reverse=True) for x in p[m - 1::m]: s -= x print s
s958954438
p00227
u759949288
1398140461
Python
Python
py
Runtime Error
0
0
204
while True: n, m = (int(x) for x in raw_input().split()) if n == 0 and m == 0: break p = [int(x) for x in raw_input().split()] s = sum(p) p.sort(reverse=True) for x in p[m - 1::m]: s -= x print s
s007878210
p00227
u759949288
1398140597
Python
Python
py
Runtime Error
0
0
220
while True: n, m = (int(x.strip()) for x in raw_input().split()) if n == 0 and m == 0: break p = [int(x.strip()) for x in raw_input().split()] s = sum(p) p.sort(reverse=True) for x in p[m - 1::m]: s -= x print s
s820969147
p00227
u772196646
1400298832
Python
Python
py
Runtime Error
0
0
269
while 1: nm = map(int, raw_input().split()) if nm == [0, 0]: break n = nm[0] m = nm[1] p = map(int, raw_input().split()) p_sorted = sorted(p) sum = 0 for i in range(n): if (i+1) % m != 0: sum += p_sorted[-1-i] print sum
s379066907
p00227
u772196646
1400299998
Python
Python
py
Runtime Error
0
0
283
while 1: nm = map(int, raw_input().split()) if nm == [0, 0]: break n = nm[0] m = nm[1] p = map(int, raw_input().split()) p_sorted = sorted(p) sum = 0 for i in range(n): if (i+1) % m != 0: sum += p_sorted[-1-i] print sum
s352384406
p00228
u104911888
1367759647
Python
Python
py
Runtime Error
0
0
309
L=[ "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1111110"] while True: n=input() if n==-1:break t="0000000" for i in range(n): a=input() print "".join("1" if L[a][i]<>t[i] else "0" for i in range(len(L[a]))) t=L[a]
s684161431
p00228
u104911888
1367759839
Python
Python
py
Runtime Error
0
0
297
L=[ "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1111110"] while True: n=input() if n==-1:break t="0000000" for i in range(n): a=input() print "".join("1" if i<>j else "0" for i,j in zip(L[a],t)) t=L[a]
s995084822
p00228
u104911888
1367760691
Python
Python
py
Runtime Error
0
0
395
L=[ "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1111110"] while True: n=input() if n==-1:break t="0000000" for i in range(n): a=input() # print "".join("1" if i<>j else "0" for i,j in zip(L[a],t)) f="" for j,k in zip(L[a],t): f+="1" if j<>k else "0" print f t=L[a]
s863228657
p00228
u104911888
1367760868
Python
Python
py
Runtime Error
0
0
289
L=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1111110"] while True: n=input() if n==-1:break t="0000000" for i in range(n): a=input() print "".join(["1" if i<>j else "0" for i,j in zip(L[a],t)]) t=L[a]
s850300572
p00228
u104911888
1367761028
Python
Python
py
Runtime Error
0
0
330
D={0: '0111111', 1: '0000110', 2: '1011011', 3: '1001111', 4: '1100110', 5: '1101101', 6: '1111101', 7: '0100111', 8: '1111111\ ', 9: '1111110'} while True: n=input() if n==-1:break t="0000000" for i in range(n): a=input() print "".join(["1" if i<>j else "0" for i,j in zip(D[a],t)]) t=D[a]
s345629500
p00228
u260980560
1384360097
Python
Python
py
Runtime Error
0
0
430
dig = ["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"] dc = [ ["".join(str(int(dig[i][k])^int(dig[j][k])) for k in range(7)) for j in range(10)] for i in range(10)] while 1: n = input() if n==-1: break buf = -1 for i in range(n): num = input() if buf==-1: print dig[num] else: print dc[buf][num] buf = num
s276288875
p00228
u633068244
1396279356
Python
Python
py
Runtime Error
0
0
315
def signal(a,e): s="" for i in range(7): s+="0" if a[i]==e[i] else "1" return s ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"] while 1: n=input() if n==-1:break e="0000000" for i in range(n): a=ref[int(raw_input())] print signal(a,e) e=a
s640766719
p00228
u633068244
1396279409
Python
Python
py
Runtime Error
0
0
315
def signal(a,e): s="" for i in range(7): s+="0" if a[i]==e[i] else "1" return s ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"] while 1: n=input() if n==-1:break e="0000000" for i in range(n): a=ref[int(raw_input())] print signal(a,e) e=a
s844740018
p00228
u633068244
1396279638
Python
Python
py
Runtime Error
0
0
321
def signal(a,e): s="" for i in range(7): s+="0" if a[i]==e[i] else "1" return s ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"] while 1: n=int(raw_input()) if n==-1:break e="0000000" for i in range(n): a=ref[int(raw_input())] print signal(a,e) e=a
s353463796
p00228
u633068244
1396280491
Python
Python
py
Runtime Error
0
0
161
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=input() if n==-1:break e=0 for i in range(n): a=ref[int(raw_input())] print "{:07b}".format(a^e) e=a
s200628801
p00228
u633068244
1396280792
Python
Python
py
Runtime Error
0
0
165
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=input() if n==-1:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s713732193
p00228
u633068244
1396280838
Python
Python
py
Runtime Error
0
0
174
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==-1:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s990154099
p00228
u633068244
1396280917
Python
Python
py
Runtime Error
0
0
174
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==10:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s600838689
p00228
u633068244
1396280937
Python
Python
py
Runtime Error
0
0
172
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n<0:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s982625473
p00228
u633068244
1396281042
Python
Python
py
Runtime Error
0
0
174
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==-1:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s800629757
p00228
u633068244
1396281074
Python
Python
py
Runtime Error
0
0
175
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n+1==0:break e=0 #for i in range(n): # a=ref[int(raw_input())] # print "{:07b}".format(a^e) # e=a
s321486791
p00228
u633068244
1396281157
Python
Python
py
Runtime Error
0
0
169
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==0:break e=0 for i in range(n): a=ref[int(raw_input())] print "{:07b}".format(a^e) e=a
s077928784
p00228
u633068244
1396281172
Python
Python
py
Runtime Error
0
0
169
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n<=0:break e=0 for i in range(n): a=ref[int(raw_input())] print "{:07b}".format(a^e) e=a
s580933026
p00228
u633068244
1396281389
Python
Python
py
Runtime Error
0
0
43
loop do n =gets.to_i break if n==-1 end
s763557903
p00228
u633068244
1396281446
Python
Python
py
Runtime Error
0
0
175
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==-1: break e=0 for i in range(n): a=ref[int(raw_input())] print ("{:07b}".format(a^e)) e=a
s675588476
p00228
u633068244
1396283097
Python
Python
py
Runtime Error
0
0
170
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==-1:break e=0 for i in range(n): a=ref[int(raw_input())] print "{:07b}".format(a^e) e=a
s212889432
p00228
u633068244
1396443490
Python
Python
py
Runtime Error
0
0
170
ref=[63,6,91,79,102,109,125,39,127,111] while 1: n=int(raw_input()) if n==-1:break e=0 for i in range(n): a=ref[int(raw_input())] print "{:07b}".format(a^e) e=a