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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s822774265 | p01554 | u922450532 | 1529210998 | Python | Python3 | py | Runtime Error | 0 | 0 | 627 | while True:
a = input()
# if a == "0 0 0 0 0":
# break
a = a.split(" ")
b = []
sum = 0
for i in a:
b.append(int(i))
sum += int(i)
if sum == 0:
break
c = input()
c = c.split(" ")
d = []
for i in c:
d.append(int(i))
if b[4] == d[0]:
... |
s525095709 | p01558 | u352394527 | 1546325674 | Python | Python3 | py | Runtime Error | 1940 | 404800 | 346 | def main():
n, m = map(int, input().split())
s = input()
left = right = 0
mem = set()
for _ in range(m):
com = input()
if com == "L++":
left += 1
elif com == "L--":
left -= 1
elif com == "R++":
right += 1
elif com == "R--":
right -= 1
mem.add(s[left:right + 1])
... |
s251949316 | p01564 | u116766943 | 1422522709 | Python | Python3 | py | Runtime Error | 0 | 0 | 13788 | /*
まだ途中セーヴ
ci is ignored for output queries.
このインプットは無視しろってこと?kamo
*/
#include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
// -- segment tree with lazy propagation ---
const int IINF = INT_MAX;
const char EMPTY = 'X';
st... |
s721728822 | p01581 | u104911888 | 1375191200 | Python | Python | py | Runtime Error | 20 | 4204 | 100 | N,M=map(int,raw_input().split())
L=[input() for i in range(N)]
for i in range(M):
print L[N-i-1] |
s456169827 | p01581 | u834962510 | 1378950558 | Python | Python | py | Runtime Error | 0 | 0 | 199 | from collections import deque
N, M = map(int, input().split(' '))
q = deque()
for _ in range(N):
c = int(input())
if len(q) == M:
q.popleft()
q.append(c)
for _ in reversed(q):
print(_) |
s531081024 | p01581 | u834962510 | 1378951460 | Python | Python | py | Runtime Error | 0 | 0 | 212 | N, M = map(int, input().split(' '))
q = []
for _ in range(N):
c = int(input())
if c in q:
q.remove(c)
q.append(c)
else:
if len(q) == M:
q.pop(0)
q.append(c)
for _ in reversed(q):
print(_) |
s636999308 | p01581 | u834962510 | 1378951474 | Python | Python | py | Runtime Error | 20000 | 7556 | 216 | N, M = map(int, raw_input().split(' '))
q = []
for _ in range(N):
c = int(input())
if c in q:
q.remove(c)
q.append(c)
else:
if len(q) == M:
q.pop(0)
q.append(c)
for _ in reversed(q):
print(_) |
s454729609 | p01581 | u834962510 | 1378952145 | Python | Python | py | Runtime Error | 0 | 0 | 217 | N, M = map(int, input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = []
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
|
s092562864 | p01581 | u834962510 | 1378952163 | Python | Python | py | Runtime Error | 20000 | 9340 | 221 | N, M = map(int, raw_input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = []
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
|
s353151467 | p01581 | u834962510 | 1378952322 | Python | Python | py | Runtime Error | 0 | 0 | 224 | N, M = map(int, raw_input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = set()
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
|
s406350447 | p01601 | u633068244 | 1398502860 | Python | Python | py | Runtime Error | 20 | 4204 | 155 | n = input()
mind = n
for i in range(max(0,n-20),min(10001,n+20)):
if i == int(str(i)[::-1]) and abs(n - i) < mind:
mind = abs(n - i)
ans = i
print ans |
s595540550 | p01602 | u104911888 | 1373197872 | Python | Python | py | Runtime Error | 0 | 0 | 317 | s=""
for i in range(input()):
p,x=raw_input().split()
s+=p*int(x)
st=[]
for i in range(len(s)):
if s[i]=="(":
st.append(s[i])
else:
if st==[] or st[-1]!="(":
print "NO"
break
st.pop()
else:
if st==[]:
print "YES"
else:
print "NO" |
s396501438 | p01605 | u104911888 | 1367457068 | Python | Python | py | Runtime Error | 0 | 0 | 178 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print S[A-1:B] if len(S)<B else "." |
s212982905 | p01605 | u104911888 | 1367457542 | Python | Python | py | Runtime Error | 0 | 0 | 181 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print "." if len(S)<=B-A else S[A-1:B] |
s357949757 | p01605 | u104911888 | 1367458782 | Python | Python | py | Runtime Error | 0 | 0 | 155 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print S[A:B] |
s846855087 | p01605 | u104911888 | 1367459109 | Python | Python | py | Runtime Error | 0 | 0 | 182 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
# p="" if p=="." else p
S=S.replace(c,p)
print "." if len(S)<=B-A else S[A-1:B] |
s621042363 | p01609 | u506537276 | 1558936129 | Python | Python | py | Runtime Error | 0 | 0 | 483 | import math
deltax = 0.0000001
w, h, n = map(int, input().split())
high = [0 for i in range(int(w / deltax))]
for i in range(n):
a, p, q = map(int, input().split())
for i in range(int(w / deltax)):
j = i * deltax
f = a * (j - p)**2 + q
if(f <= h):
high[i] = max(high[i], f)
# print(*high) ... |
s107249603 | p01612 | u797673668 | 1470116469 | Python | Python3 | py | Runtime Error | 700 | 40216 | 1120 | def memoize(f):
cache = {}
def helper(arg):
if arg not in cache:
cache[arg] = f(arg)
return cache[arg]
return helper
def solve(edges):
@memoize
def tree_height(node):
en = edges[node]
if not en:
return 0, set()
max_depth = -1
... |
s849862987 | p01614 | u134812425 | 1541126661 | Python | Python3 | py | Runtime Error | 0 | 0 | 1276 | import bisect
import collections
import heapq
import itertools
import math
import string
import sys
from itertools import chain, takewhile
def read(
f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
def read_word():
return f("".join(takewhile(lambda c: c not in whites... |
s489163022 | p01615 | u633068244 | 1399654398 | Python | Python | py | Runtime Error | 10 | 4252 | 322 | inf = 1e10
n,m = map(int,raw_input().split())
edge = [map(int,raw_input().split()) for i in range(m)]
d = [[inf]*n for i in range(n)]
for i in range(m):
d[0] = 0
while 1:
update = False
a,b,c = edge[i]
if d[a] != inf and d[b] > d[a] - c:
d[b] = d[a] - c
update = True
if not update: break
print abs(d[n-1... |
s677055051 | p01620 | u617183767 | 1421566643 | Python | Python | py | Runtime Error | 0 | 0 | 923 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
self.chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', ... |
s412340822 | p01620 | u233891002 | 1430541254 | Python | Python | py | Runtime Error | 0 | 0 | 803 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
station = ""... |
s875213413 | p01620 | u233891002 | 1430541473 | Python | Python | py | Runtime Error | 0 | 0 | 922 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
... |
s488141573 | p01620 | u233891002 | 1430541569 | Python | Python | py | Runtime Error | 0 | 0 | 923 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
... |
s824926121 | p01620 | u233891002 | 1430548737 | Python | Python | py | Runtime Error | 0 | 0 | 925 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
... |
s643491132 | p01620 | u766926358 | 1526633367 | Python | Python3 | py | Runtime Error | 0 | 0 | 316 | while 1:
n = int(input())
k_line = list(map(int, input().split()))
s = input()
if (n == 0):
break;
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
k_line *= (-(-len(s)//len(k_line)))
for num, c in enumerate(s):
index = alpha.index(c) - k_line[num]
print(alpha[index], end='')
print('')
|
s593132280 | p01620 | u929568713 | 1526642837 | Python | Python3 | py | Runtime Error | 0 | 0 | 342 | while 1:
n = int(input())
k_line = list(map(int, input().split()))
s = input()
if (n == 0):
break;
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
k_line *= (-(-len(s) // len(k_line)))
s = [alpha[(alpha.index(c) + 52*10 - k_line[num])%52] for num, c in enumerate(s)]
... |
s599505675 | p01620 | u260980560 | 1403673746 | Python | Python | py | Runtime Error | 0 | 0 | 580 | ef suber(c, k):
if ord('a')<=ord(c):
w = ord(c) - ord('a')
if w < k:
return chr(ord('Z') - (k - w - 1)) if k<=26 else chr(ord('z') - (k - w - 27))
return chr(ord('a') + (w - k))
else:
w = ord(c) - ord('A')
if w < k:
return chr(ord('z') - (k - w - 1... |
s841971067 | p01620 | u260980560 | 1403674150 | Python | Python | py | Runtime Error | 0 | 0 | 255 | station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQESTUVWXYZ"
while True:
n = input()
if n==0:
break
k = map(int, raw_input().split())
s = raw_input()
print "".join(station[station.find(s[i])-k[i%n]] for i in xrange(len(s))) |
s707458074 | p01623 | u072053884 | 1523123672 | Python | Python3 | py | Runtime Error | 0 | 0 | 1934 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
... |
s229685119 | p01623 | u072053884 | 1523154932 | Python | Python3 | py | Runtime Error | 0 | 0 | 1934 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
... |
s663262004 | p01623 | u072053884 | 1523155968 | Python | Python3 | py | Runtime Error | 0 | 0 | 1930 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
... |
s398468464 | p01624 | u118766929 | 1530824127 | Python | Python3 | py | Runtime Error | 0 | 0 | 1969 | # undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return False
else:
op = 0
# +...
f... |
s647909936 | p01634 | u633068244 | 1396608486 | Python | Python | py | Runtime Error | 0 | 0 | 106 | p=raw_input()
if len(p)<6 or islower(p) or isupper(p) or isdigit(p):
print "INVARID"
else:
print "VARID" |
s085781689 | p01646 | u352394527 | 1529469105 | Python | Python3 | py | Runtime Error | 0 | 0 | 1233 | def add_edge(node, adj_lst, adj_rev, s1, s2):
ind = 0
max_len = min(len(s1), len(s2))
while ind < max_len and s1[ind] == s2[ind]:
ind += 1
if ind == max_len:
if max_len < len(s1):
return True
return False
c1 = ord(s1[ind]) - ord("a")
c2 = ord(s2[ind]) - ord("a")
adj_lst[c1].add(c2)
adj... |
s369005925 | p01646 | u647766105 | 1392007367 | Python | Python | py | Runtime Error | 39860 | 88204 | 1229 | graph = []
def init():
global graph
graph = [[False] * 26 + [True] for _ in xrange(27)]
graph[26][26] = False
def atoi(c):#index
if c == "#":
return 26
return ord(c) - ord("a")
def make_graph(L):
global graph
tmp = []
while "" in L:
L.remove("")
for s1, s2 in zip(L... |
s439086253 | p01646 | u647766105 | 1392008164 | Python | Python | py | Runtime Error | 39870 | 88192 | 1171 | graph = []
def init():
global graph
graph = [[False] * 26 + [True] for _ in xrange(27)]
graph[26][26] = False
def atoi(c):#index
if c == "#":
return 26
return ord(c) - ord("a")
def make_graph(L):
global graph
tmp = []
while "" in L:
L.remove("")
for s1, s2 in zip(L... |
s284283068 | p01656 | u633068244 | 1393702019 | Python | Python | py | Runtime Error | 0 | 0 | 201 | data = [[1, "kogaku10gokan"]
n, q = map(int, raw_input().split())
for i in range(n):
a, b = map(int, raw_input().split())
data.append([a,b])
for i in data:
if i[0] > q:
print i[1] |
s379166016 | p01656 | u772196646 | 1400302739 | Python | Python | py | Runtime Error | 10 | 4212 | 218 | nq = map(int, raw_input().split())
n = nq[0]
q = nq[1]
yn = [[1, 'kogakubu10gokan']]
for i in range(n):
yn.append(raw_input().split())
y = 1
k = 0
while y <= q:
k += 1
y = int(yn[k][0])
print yn[k-1][1] |
s670346902 | p01672 | u248404432 | 1520404865 | Python | Python3 | py | Runtime Error | 0 | 0 | 860 | import numpy as np
from scipy.signal import correlate
n = int( input() ) # Get grid width
c = []
for i in range(n):
c.append( input().split() ) # Get line info
c = np.array(c, dtype=np.double)
R = np.int32(np.round(correlate(c,c, method='fft'))) # Autocorrelation w/ FFT
center = np.array([1, 1]) * (n-1)
histogram =... |
s281879693 | p01682 | u144532944 | 1530522437 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | import re
S = lambda x: x*x%int(1e9+7)
s = input()
while s != '#':
s = s.replace(' ', '')
s = re.sub(r'>>(\d+)', r'XX\1', s)
s = s.translate(str.maketrans('<>X', '()>'))
print(eval(s))
s = input()
|
s626415562 | p01682 | u260980560 | 1400182196 | Python | Python | py | Runtime Error | 0 | 0 | 994 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
x = pos
while pos<l and s[pos].isdigit():
pos += 1
return int(s[x:pos]) if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
global pos
if pos>=l:
... |
s702370876 | p01682 | u260980560 | 1400182421 | Python | Python | py | Runtime Error | 0 | 0 | 1026 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
x = pos
while pos<l and s[pos].isdigit():
pos += 1
return int(s[x:pos]) if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
global pos
if pos>=l:
... |
s076011468 | p01682 | u260980560 | 1400182897 | Python | Python | py | Runtime Error | 0 | 0 | 1063 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
ret = 0
x = pos
while pos<l and s[pos].isdigit():
ret = 10*ret + int(s[pos])
pos += 1
return ret if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
... |
s813566108 | p01694 | u609255173 | 1416727659 | Python | Python | py | Runtime Error | 0 | 0 | 575 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
def main():
while True:
n = input()
if not n: break
w = 0
a = [0, 0]
ans = 0
for s in raw_input().split():
f = 0 if s[0] == "l" else 1
u = 0 if s[1] == "d" else 1
a[f] = u
if w == 0 and a[0] == 1 and a[1] == 1:
w ... |
s026394802 | p01694 | u966364923 | 1436627431 | Python | Python3 | py | Runtime Error | 0 | 0 | 311 | def main():
while True:
n = int(input())
if n == 0:
exit()
f = [s for input().split()]
pm = 'd'
cnt = 0
for m in f:
if m[1] == pm:
cnt += 1
pm = m[1]
print(cnt)
if __name__ == '__main__':
main() |
s597515499 | p01694 | u052632641 | 1528468832 | Python | Python | py | Runtime Error | 0 | 0 | 489 | import sys,os
k = int(raw_input())
al = raw_input().split()
up = 0
sup = 0
cnt = 0
lu = False
ru = False
for a in al:
if a == "lu":
lu = True
elif a == "ld":
lu = False
elif a == "ru":
ru = True
elif a == "rd":
ru = False
if lu and ru:
up = 2
elif ... |
s994442310 | p01695 | u467175809 | 1530976766 | Python | Python | py | Runtime Error | 0 | 0 | 629 | while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '.' and lst[i][j + 1] != '.':
pos = j
for k in range(i, 0, -1):
... |
s536841100 | p01695 | u467175809 | 1530979233 | Python | Python | py | Runtime Error | 0 | 0 | 629 | while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '.' and lst[i][j + 1] != '.':
pos = j
for k in range(i, 0, -1):
... |
s662264863 | p01695 | u467175809 | 1530979631 | Python | Python | py | Runtime Error | 0 | 0 | 794 | #!/usr/bin/env python
import sys
import math
import itertools as it
from collections import deque
sys.setrecursionlimit(10000000)
while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]... |
s183256857 | p01695 | u591052358 | 1529630483 | Python | Python3 | py | Runtime Error | 0 | 0 | 758 | def count_dot(lis):
c=0
for i in lis:
if not(i=='.'):
return c
c+=1
def solve(N):
a=[]
dot =[]
for i in range(N):
a.append([char for char in input()])
dot.append(count_dot(a[i]))
for i in range(N):
for j in range(len(a[i])):
if a[... |
s649358189 | p01695 | u591052358 | 1529630570 | Python | Python3 | py | Runtime Error | 0 | 0 | 758 | def count_dot(lis):
c=0
for i in lis:
if not(i=='.'):
return c
c+=1
def solve(N):
a=[]
dot =[]
for i in range(N):
a.append([char for char in input()])
dot.append(count_dot(a[i]))
for i in range(N):
for j in range(len(a[i])):
if a[... |
s984387166 | p01696 | u731941832 | 1530590379 | Python | Python3 | py | Runtime Error | 0 | 0 | 752 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[... |
s950168623 | p01696 | u731941832 | 1530590531 | Python | Python3 | py | Runtime Error | 0 | 0 | 749 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[... |
s453400008 | p01696 | u731941832 | 1530590552 | Python | Python3 | py | Runtime Error | 0 | 0 | 748 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[... |
s371003155 | p01696 | u731941832 | 1530590662 | Python | Python3 | py | Runtime Error | 0 | 0 | 764 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[... |
s047912802 | p01696 | u731941832 | 1530591096 | Python | Python3 | py | Runtime Error | 0 | 0 | 765 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[... |
s304635391 | p01696 | u731941832 | 1530612084 | Python | Python3 | py | Runtime Error | 0 | 0 | 806 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index)
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index = s.find... |
s594176656 | p01696 | u731941832 | 1530612234 | Python | Python3 | py | Runtime Error | 0 | 0 | 814 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index, len(s))
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index ... |
s367691272 | p01702 | u827448139 | 1418360848 | Python | Python3 | py | Runtime Error | 19930 | 7516 | 600 | while 1:
n,m,q=map(int,input().split())
if (n|m|q)==0: break
p=[]
res=[[_ for _ in range(n)] for _ in range(m)]
for i in range(q):
s,b=[[int(c) for c in s] for s in input().split()]
if i>0:
for j in range(n):
s[j]^=p[j]
for j in range(n):
for k in range(m):
if s[j]!=... |
s267091660 | p01702 | u633068244 | 1423509183 | Python | Python | py | Runtime Error | 0 | 0 | 622 | ref = "0123456789ACDEFGHIJKLMNOPQRSTUVWXYZ"
while 1:
N,M,Q = map(int,raw_input().split())
if N == 0: break
corr = [set(range(N)) for _ in range(M)]
s = ["0"]*N
for loop in xrange(Q):
S,B = raw_input().split()
for i in range(N):
if S[i] == "1": s[i] = {"0":"1","1":"0"}[s[... |
s173141626 | p01702 | u633068244 | 1423509878 | Python | Python | py | Runtime Error | 0 | 0 | 556 | ref = "0123456789ACDEFGHIJKLMNOPQRSTUVWXYZ"
while 1:
N,M,Q = map(int,raw_input().split())
if N == 0: break
sn = set(range(N))
corr = [set(range(N)) for _ in range(M)]
s = [0]*N
for loop in xrange(Q):
S,B = raw_input().split()
s = [1-s[i] if S[i] == "1" else s[i] for i in range(N)... |
s771507084 | p01702 | u509278866 | 1529231463 | Python | Python3 | py | Runtime Error | 0 | 0 | 1923 | 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
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... |
s467787917 | p01712 | u273756488 | 1559290225 | Python | Python3 | py | Runtime Error | 20 | 5612 | 554 | n, W, H = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]
imos_h = [0] * (H + 2)
imos_w = [0] * (W + 2)
for x, y, w in X:
imos_h[max(0, y - w)] += 1
imos_h[min(W + 1, y + w + 1)] -= 1
imos_w[max(0, x - w)] += 1
imos_w[min(H + 1, x + w + 1)] -= 1
for h in range(H)... |
s937756726 | p01712 | u273756488 | 1559290300 | Python | Python3 | py | Runtime Error | 20 | 5616 | 554 | n, W, H = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]
imos_h = [0] * (H + 2)
imos_w = [0] * (W + 2)
for x, y, w in X:
imos_h[max(0, y - w)] += 1
imos_h[min(W + 1, y + w + 1)] -= 1
imos_w[max(0, x - w)] += 1
imos_w[min(H + 1, x + w + 1)] -= 1
for h in range(H)... |
s335970129 | p01712 | u296492699 | 1422625489 | Python | Python | py | Runtime Error | 0 | 0 | 502 | input_lines = raw_input()
n,w,h = map(int, input_lines.split())
wifi_list=[]
x_list = [False for i in range(w+1)]
y_list = [False for i in range(h+1)]
for i in range(n):
input_lines = raw_input()
xi,yi,wi = map(int, input_lines.split()))
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=y... |
s391045986 | p01712 | u296492699 | 1422626407 | Python | Python | py | Runtime Error | 0 | 0 | 491 | import sys
in_txt=sys.stdin.read().splitlines()
n,w,h = map(int, in_txt[0].split())
wifi_list=[]
x_list = [False for i in range(w+1)]
y_list = [False for i in range(h+1)]
for i in in_txt[1:]:
xi,yi,wi = map(int, i.split())
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=yi-wi if yi-... |
s507979866 | p01712 | u296492699 | 1422635350 | Python | Python | py | Runtime Error | 0 | 0 | 578 | mport sys
in_txt=sys.stdin.read().splitlines()
n,w,h = map(int, in_txt[0].split())
wifi_list=[]
area = [[False for i in range(w+1)] for j in range(h+1)]
for i in in_txt[1:]:
xi,yi,wi = map(int, i.split())
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=yi-wi if yi-wi>=0 else 0
ye=yi... |
s396647562 | p01712 | u753085696 | 1425897669 | Python | Python | py | Runtime Error | 0 | 0 | 374 | # your code goes here
import numpy as np
buf = raw_input()
buf = buf.split(" ")
n = int(buf[0])
w = int(buf[1])
h = int(buf[2])
array = np.zeros((h, w))
for i in xrange(n):
buf = raw_input()
buf = buf.split(" ")
x = int(buf[0])
y = int(buf[1])
w = int(buf[2])
array[(y-w):(y+w),:]=True
array[:,(x-w):(x+w)]=T... |
s390973156 | p01712 | u474983612 | 1463255984 | Python | Python3 | py | Runtime Error | 0 | 0 | 936 | test_file = open('C:\\Users\\nanashi\Downloads\\2600-in21.txt')
input = lambda: test_file.readline().rstrip()
N, W, H = [int(x) for x in input().split()]
map_x = [False] * W
count_x = 0
map_y = [False] * H
count_y = 0
wifi_x = []
wifi_y = []
for _ in range(N):
x, y, w = [int(x) for x in input().split()]
wi... |
s825141223 | p01713 | u352394527 | 1530436469 | Python | Python3 | py | Runtime Error | 0 | 0 | 781 | def search_left(ind):
doors = []
for j in range(ind - 1, -1, -1):
if alst[j] < 0:
doors.append((j, -alst[j]))
if alst[j] == 0:
ret = alst[ind]
for pos, lim in doors:
ret = min(ret, lim - (ind - pos))
ret = max(0, ret)
return ret
return 0
def search_right(ind):
doors... |
s962645052 | p01714 | u567380442 | 1426078153 | Python | Python3 | py | Runtime Error | 19930 | 6988 | 2910 | from itertools import combinations
from itertools import groupby
def solve(xyuv):
if len(xyuv) <= 2 or is_all_same(xyuv) or is_all_same_attime(xyuv):
return len(xyuv)
max_ij = 0
for i, j in combinations(range(len(xyuv)), 2):
if xyuv[i] == xyuv[j]:
continue
xyi,uvi = xyuv[... |
s353683596 | p01714 | u567380442 | 1426144397 | Python | Python3 | py | Runtime Error | 30 | 6920 | 2732 | def take2(i):
while True:
yield next(i),next(i)
def main(f):
_ = int(f.readline())
xyuv = [[x+y*1j for x,y in take2(map(int, line.split()))] for line in f]
print(solve(xyuv))
def is_all_same_attime(xyuv):
xy0, uv0 = xyuv[0]
for i in range(len(xyuv)):
if xyuv[0] == xyuv[i]:
... |
s126505987 | p01714 | u083285064 | 1426956447 | Python | Python3 | py | Runtime Error | 19930 | 6768 | 849 | import itertools
N = int(input())
km = []
for i in range(N):
km.append(input().split(' '))
nmax = 0
try:
for i in range(1000):
ks = []
for j in range(N):
x, y, u, v = list(map(int, list(km[j])))
ks.append((x + u * i, y + v * i))
for k in list(itertools.combinat... |
s878641653 | p01715 | u567380442 | 1426301410 | Python | Python3 | py | Runtime Error | 150 | 12856 | 948 | from operator import itemgetter
#@profile
def calc(w,pdp,pl,pr,dp,l,r):
if l >= r:
return
m = (l + r) // 2
dp[m], i = min([(pdp[i] + w[i+1][m],i) for i in range(pl,min(pr,m))], key=itemgetter(0))
calc(w,pdp,pl,i,dp,l,m-1)
calc(w,pdp,i,pr,dp,m+1,r)
return dp
import sys
f = sys.stdin
s,n... |
s987405682 | p01716 | u567380442 | 1426381406 | Python | Python3 | py | Runtime Error | 19930 | 6876 | 1829 | def dfs(p,s,c,cmin,cmax):
if len(p) == 0:
return solve(s,c,cmin,cmax)
lower, u = p[0]
c += lower
if u <= 9:
cmin[lower] = 0
cmax[lower] = u
return dfs(p[1:],s,c,cmin,cmax)
cmin[lower] = 0
cmax[lower] = 9
ret = dfs(p[1:],s,c,cmin,cmax)
upper = lower.u... |
s456113901 | p01722 | u939118618 | 1429524150 | Python | Python | py | Runtime Error | 20 | 4384 | 425 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = s... |
s416302687 | p01722 | u939118618 | 1429524241 | Python | Python | py | Runtime Error | 20 | 4380 | 425 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = s... |
s562740857 | p01722 | u939118618 | 1429524373 | Python | Python | py | Runtime Error | 10 | 4392 | 427 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = s... |
s400623501 | p01722 | u939118618 | 1429524451 | Python | Python | py | Runtime Error | 10 | 4384 | 426 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = s... |
s572779317 | p01722 | u823513038 | 1448250506 | Python | Python3 | py | Runtime Error | 0 | 0 | 35 | n=int(input())
print(n?n>3?0:3-n:1) |
s397176132 | p01731 | u633068244 | 1433095836 | Python | Python | py | Runtime Error | 20 | 4356 | 297 | def dfs(i, z):
print "." * z + name[i]
for j in child[i]:
dfs(j, z + 1)
n = int(raw_input())
name = []
child = [[] for i in xrange(n)]
for i in xrange(n):
k = int(raw_input())
m = raw_input()
name.append(m)
if k == 0: continue
child[k - 1].append(i)
dfs(0, 0) |
s952328585 | p01731 | u633068244 | 1433095879 | Python | Python | py | Runtime Error | 0 | 0 | 335 | import sys
sys.setrecursionlimi(9999)
def dfs(i, z):
print "." * z + name[i]
for j in child[i]:
dfs(j, z + 1)
n = int(raw_input())
name = []
child = [[] for i in xrange(n)]
for i in xrange(n):
k = int(raw_input())
m = raw_input()
name.append(m)
if k == 0: continue
child[k - 1].appen... |
s291640217 | p01731 | u506554532 | 1514360375 | Python | Python3 | py | Runtime Error | 40 | 5856 | 266 | N = int(input())
src = []
for i in range(N):
k = int(input())
s = input()
src.append((s,[]))
if i == 0: continue
src[k-1][1].append(i)
def dfs(i,depth):
s,ch = src[i]
print('.'*depth + s)
for c in ch:
dfs(c,depth+1)
dfs(0,0) |
s238629497 | p01741 | u633068244 | 1433319737 | Python | Python | py | Runtime Error | 0 | 0 | 169 | import math
d = float(raw_input())
res = math.sqrt(2) * d
for x in xrange(1, 11):
if x * x <= d * d <= x * 2 + 1:
ans = max(ans, d + 1.0)
print "%.10f" % ans |
s927772015 | p01751 | u979136186 | 1478763489 | Python | Python | py | Runtime Error | 0 | 0 | 393 | while True:
a, b, c = map(int, raw_input().split())
if(a | b | c == 0):break
i = 0
canArrive = False
now = 0
while True:
if now <= c and c <= now + b:
canArrive = True
break
now += (a + b)
now %= 60
if now == 0 : break
i +=... |
s045262134 | p01751 | u136916346 | 1530512185 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | from itertools import count
a,b,c=map(int,raw_input().split())
g=set()
for n in count(0):
p=(c+60*n)//(a+b)
print (a+b)*p,c+60*n,(a+b)*p+a
if ((a+b)*p-(c+60*n),(c+60*n)-((a+b)*p+a)) in g:
n=-1
break
if (a+b)*p<=c+60*n<=(a+b)*p+a:
break
else:
d=(a+b)*p-(c+60*n)
... |
s118525931 | p01755 | u352394527 | 1546560053 | Python | Python3 | py | Runtime Error | 30 | 5792 | 3711 | def parse_prog(prog, pointer, level, code):
while True:
pointer, code = parse_sent(prog, pointer, level, code)
if pointer == len(prog):break
if prog[pointer] in ("]", "}"):break
return pointer + 1, code
def parse_sent(prog, pointer, level, code):
head = prog[pointer]
if head == "[":
pointer, co... |
s018493194 | p01772 | u359169485 | 1434762671 | Python | Python | py | Runtime Error | 0 | 0 | 120 | while True:
d = filter(lambda x:x in "AZ", raw_input())
if len(d)<1:
print "-1"
elif d[-1] == "Z":
print d |
s955177492 | p01803 | u898097781 | 1467377837 | Python | Python | py | Runtime Error | 0 | 0 | 496 |
def a2c(name):
c = name[0]
boin=['a','i','u','e','o']
for b in name:
if i, b in enumerate(boin[:-1]):
c += name[i+1]
return c
while True:
n = int(raw_input())
if n == 0:
break
names = []
length = -1
for i in xrange(n):
tmp = a2c(raw_input())
names.append(tmp)
length = max(length, len(tmp))... |
s582083298 | p01803 | u260980560 | 1501602422 | Python | Python3 | py | Runtime Error | 0 | 0 | 559 | while 1:
n = int(input())
S = []
for i in range(n):
s = input()
b = []
for j in range(len(s)):
if j < 1 or s[j-1] in "aiueo":
b.append(s[j])
S.append(b)
ans = 0
S.sort()
for i in range(n-1):
A = S[i]; B = S[i+1]
if A == ... |
s122934191 | p01809 | u606573458 | 1499748826 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s782897080 | p01809 | u606573458 | 1499748847 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s901410179 | p01809 | u606573458 | 1499748906 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s874413830 | p01809 | u606573458 | 1499748918 | Python | Python | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s307616922 | p01809 | u606573458 | 1499748991 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s966096455 | p01809 | u606573458 | 1499749073 | Python | Python3 | py | Runtime Error | 0 | 0 | 181 | import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p //= g
q //= g
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) |
s932566079 | p01809 | u314932236 | 1529464707 | Python | Python3 | py | Runtime Error | 0 | 0 | 73 | import math
p = int(input())
q = int(input())
print(b/(math.gcd(p,q)))
|
s655992491 | p01809 | u314932236 | 1529464757 | Python | Python3 | py | Runtime Error | 0 | 0 | 73 | import math
p = int(input())
q = int(input())
print(q/(math.gcd(p,q)))
|
s902350403 | p01809 | u314932236 | 1529465008 | Python | Python3 | py | Runtime Error | 0 | 0 | 78 | import math
p = int(input())
q = int(input())
print(int(q/(math.gcd(p,q))))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.