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
s983495764
p00275
u546285759
1488857188
Python
Python3
py
Runtime Error
0
0
496
while True: N = int(input()) if N==0:break dataset = input() mens = ["" for _ in range(N)] i = 0 p = "" while dataset: if i == N: i = 0 card, dataset = dataset[0], dataset[1:] if card == "M": mens[i] += card elif card == "S": p += card + mens[i] mens[i] = "" else: mens[i] += card + p p = "" i += 1 print(*[v for v in sorted(len(m) for m in mens)], len(p))
s168434568
p00276
u766477342
1415277508
Python
Python3
py
Runtime Error
0
0
254
for i in range(int(input())): res = 0 c,a,n = list(map(int,input().split())) res = min(n,a,c) c -= res a -= res if c >= 2 and a >= 1: cca += min(c//2,a) c -= cca*2 if c >=3: res += c//3 print(res)
s592149604
p00276
u221679506
1467542854
Python
Python3
py
Runtime Error
0
0
510
for i in range(int(input())): c,a,n = map(int,input().split()) cnt1 = min(c,a,n) c -= cnt1 a -= cnt1 cnt2 = min(c//2,a) c -= cnt2*2 cnt3 = c//3 print(cnt1+cnt2+cnt3) #for i in range(int(input())): # c,a,n = map(int,input().split()) # cnt = 0 # while True: # if c<1 or a<1 or n<1: # break # c -= 1 # a -= 1 # n -= 1 # cnt += 1 # while True: # if c<2 or a<1: # break # c -= 2 # a -= 1 # cnt += 1 # while True: # if c<3: # break # c -= 3 # cnt += 1 # print(cnt)
s621912631
p00277
u494314211
1492292507
Python
Python3
py
Runtime Error
0
0
1490
N, R, L = list(map(int, input().split(" "))) i = 1 while i<N*2: i<<=1 t = [0 for j in range(N)] time = [0 for j in range()] def foo(a,x): newmax = -1 def bar(k,a,x,l,r): mid = a<(l+r)//2 if r-l == 1: t[k] += x newmax = r return(t[k]) elif a<mid: t[k] = max(bar(k*2,a,x,l,mid), t[k]) else: t[k] = max(bar(k*2+1,a,x,mid,r), t[k]) bar(1,a,x,0,i//2) return(t[1],newmax) nowtime = 0 nowmax = 0 nowpoint = 0 for i in range(R): d,t,x = map(int, input().split(" ")) time[nowmax] += d-nowtime nowtime = d newpoint, newmax = foo(d,x) if nowpoint < newpoint: nowmax = newmax nowpoint = newpoint elif nowpoint == newpoint: nowmax = min(nowmax, newmax) time[nowmax] += L-nowtime print(time.index(max(time))) N, R, L = list(map(int, input().split(" "))) i = 1 while i<N*2: i<<=1 t = [0 for j in range(N)] time = [0 for j in range()] def foo(a,x): newmax = -1 def bar(k,a,x,l,r): mid = a<(l+r)//2 if r-l == 1: t[k] += x newmax = r return(t[k]) elif a<mid: t[k] = max(bar(k*2,a,x,l,mid), t[k]) else: t[k] = max(bar(k*2+1,a,x,mid,r), t[k]) bar(1,a,x,0,i//2) return(t[1],newmax) nowtime = 0 nowmax = 0 nowpoint = 0 for i in range(R): d,t,x = map(int, input().split(" ")) time[nowmax] += d-nowtime nowtime = d newpoint, newmax = foo(d,x) if nowpoint < newpoint: nowmax = newmax nowpoint = newpoint elif nowpoint == newpoint: nowmax = min(nowmax, newmax) time[nowmax] += L-nowtime print(time.index(max(time)))
s022671770
p00277
u494314211
1492293097
Python
Python3
py
Runtime Error
0
0
783
N, R, L = list(map(int, input().split(" "))) i = 1 while i<N*2: i<<=1 tree = [0 for j in range(i)] time = [0 for j in range(N)] def foo(a,x): newmax = -1 def bar(k,a,x,l,r): mid = (l+r)//2 print(l,mid,r) if r-l == 1: tree[k] += x newmax = r return(tree[k]) elif a<mid: tree[k] = max(bar(k*2,a,x,l,mid), tree[k]) else: tree[k] = max(bar(k*2+1,a,x,mid,r), tree[k]) bar(1,a,x,0,i//2) return(tree[1],newmax) nowtime = 0 nowmax = 0 nowpoint = 0 for j in range(R): d,t,x = map(int, input().split(" ")) time[nowmax] += d-nowtime nowtime = d newpoint, newmax = foo(d,x) if nowpoint < newpoint: nowmax = newmax nowpoint = newpoint elif nowpoint == newpoint: nowmax = min(nowmax, newmax) time[nowmax] += L-nowtime print(time.index(max(time)))
s392940488
p00277
u811733736
1506600154
Python
Python3
py
Runtime Error
2590
9324
1543
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0282 TLE """ import sys from sys import stdin from heapq import heappop, heappush input = stdin.readline pq = [] # list of entries arranged in a heap entry_finder = {} # mapping of tasks to entries REMOVED = '<removed-task>' # placeholder for a removed task def add_team(team, score): if team in entry_finder: remove_team(team) entry = [score, team] entry_finder[team] = entry heappush(pq, entry) def remove_team(team): entry = entry_finder.pop(team) entry[-1] = REMOVED def pop_team(): while pq: score, team = heappop(pq) if team is not REMOVED: del entry_finder[team] return team raise KeyError('pop from an empty priority queue') def main(args): N, R, L = map(int, input().split()) on_tv = [0] * (N + 1) # ????????????????????¬???????????£??????????????????????¨? scores = [0] * (N + 1) # ????????????????????¨?????????l add_team(1, 0) last_time = 0 for i in range(R): d, t, x = [int(x) for x in input().split()] team = pop_team() on_tv[team] += (t - last_time) if d != team: add_team(team, scores[team]) scores[d] -= x add_team(d, scores[d]) last_time = t t = L team = pop_team() on_tv[team] += (t - last_time) print(on_tv.index(max(on_tv))) if __name__ == '__main__': main(sys.argv[1:])
s107147045
p00282
u119127920
1521192638
Python
Python3
py
Runtime Error
40
6800
1134
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" def main(): num = [10 ** 4, 10 ** 8, 10 ** 12, 10 ** 16, 10 ** 20, 10 ** 24, 10 ** 28, 10 ** 32, 10 ** 36, 10 ** 40, 10 ** 44, 10 ** 48, 10 ** 52, 10 ** 52, 10 ** 56, 10 ** 60, 10 ** 64, 10 ** 68] uni = ["Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Gas", "Asg", "Nyt", "Fks", "Mts"] while True: m, n = map(int, input().split()) if m == 0 and n == 0: break a = m ** n ans = "" for i in range(len(num) - 1, -1, -1): if a >= num[i]: ans += str(a // num[i]) + uni[i] a %= num[i] print(ans + str(a if a != 0 else "")) if __name__ == '__main__': main()
s019847685
p00284
u352394527
1530278400
Python
Python3
py
Runtime Error
20
5596
495
def atob(a, b): if a == b: return 0 if a == 0: ret = 0 while b: if b % 2: ret += 1 b //= 2 return ret acc = 1 tmp = a while tmp: if tmp % 2: break tmp //= 2 acc *= 2 return 1 + min(atob(a + acc, b), atob(a - acc, b)) n = int(input()) for _ in range(n): s, d = map(int, input().split()) a, b = abs(s), abs(d) a, b = min(a, b), max(a, b) if s * d >= 0: print(atob(a, b)) else: print(atob(0, a) + atob(0, b))
s442509327
p00285
u975539923
1458053275
Python
Python
py
Runtime Error
0
0
743
def get_energy(bm, bw): tmp = abs(bm-bw) return tmp * ((tmp-30) ** 2) def calc(bsa, bla): value = 0 if not bsa: return 0 bs = bsa.pop() sz = len(bla) for i in range(sz): bl = bla.pop(i) tmp = get_energy(bl, bs) + calc(bsa, bla) if tmp > value: value = tmp bla.insert(i, bl) bsa.append(bs) return value while True: s = map(int, raw_input().split()) M = s[0] W = s[1] if M == 0 and N == 0: break if M <= W: bsa = map(int, raw_input().split()) bla = map(int, raw_input().split()) else: bla = map(int, raw_input().split()) bsa = map(int, raw_input().split()) print "%d" % calc(bsa, bla)
s761868307
p00290
u301729341
1481459535
Python
Python3
py
Runtime Error
0
0
43
d,c = map(int,input(),split()) print(d * c)
s551921895
p00291
u334031393
1442472809
Python
Python
py
Runtime Error
0
0
148
values = [1, 5, 10, 50, 100, 500] coins = map(int, raw_input().split()) total = sum(map(lambda a,b: a * b, zip(value, coins))) print total>999?1:0
s147184035
p00292
u116766943
1422603668
Python
Python3
py
Runtime Error
0
0
143
import sys T = input() for i in range(0,T): K,P = raw_input().split(' ') K = int(K) P = int(P) print ( K % P - 1 + P ) % P + 1
s536916821
p00294
u724548524
1526885884
Python
Python3
py
Runtime Error
20
5604
200
n, m, p = map(int,input().split()) a = sorted([(int(input()) - p) % n for _ in range(m)]) print(min(a[-1], n - a[0], min([a[i] + n - a[i + 1] + min(a[i], n - a[i + 1]) for i in range(m - 1)])) * 100)
s464228405
p00294
u724548524
1526885950
Python
Python3
py
Runtime Error
20
5608
234
n, m, p = map(int,input().split()) a = sorted([(int(input()) - p) % n for _ in range(m)]) print(min(a[-1], n - a[0], min([a[i] + n - a[i + 1] + min(a[i], n - a[i + 1]) for i in range(m - 1)])) * 100 if m > 0 else min(a[0], n - a[0]))
s391730861
p00296
u369093003
1501939962
Python
Python3
py
Runtime Error
0
0
345
N,M,Q = map(int,input().split()) a = [] q = [] b = 0 y = 0 a.append(map(int,inout().split(' '))) q.append(map(int,inout().split(' '))) for i in range(M): x = a[b] if x % 2 == 0: y += x if y > N: y -= N else: y -= x if y < 0: y = n + y b += 1 b = 0 for j in range(Q): z = q[b] if z!=y: print(1) else: print(0) b += 1
s339707120
p00296
u369093003
1501940623
Python
Python3
py
Runtime Error
0
0
346
N,M,Q = map(int,input().split()) a = [] q = [] b = 0 y = 0 for c in range(M): a.append(input()) for d in range(Q): q.append(input()) for i in range(M): x = a[b] if x % 2 == 0: y += x if y > N: y -= N else: y -= x if y < 0: y = n + y b += 1 b = 0 for j in range(Q): z = q[b] if z!=y: print(1) else: print(0) b += 1
s801662720
p00296
u369093003
1501940742
Python
Python3
py
Runtime Error
0
0
349
N,M,Q = map(int,input().split(' ')) a = [] q = [] b = 0 y = 0 for c in range(M): a.append(input()) for d in range(Q): q.append(input()) for i in range(M): x = a[b] if x % 2 == 0: y += x if y > N: y -= N else: y -= x if y < 0: y = n + y b += 1 b = 0 for j in range(Q): z = q[b] if z!=y: print(1) else: print(0) b += 1
s315685177
p00296
u369093003
1501940880
Python
Python3
py
Runtime Error
0
0
399
N,M,Q = map(int,input().split(' ')) a = [] q = [] b = 0 y = 0 for c in range(M): a.append(map(int, raw_input().split(' '))) for d in range(Q): q.append(map(int, raw_input().split(' '))) for i in range(M): x = a[b] if x % 2 == 0: y += x if y > N: y -= N else: y -= x if y < 0: y = n + y b += 1 b = 0 for j in range(Q): z = q[b] if z!=y: print(1) else: print(0) b += 1
s804146388
p00296
u369093003
1501940906
Python
Python3
py
Runtime Error
0
0
393
N,M,Q = map(int,input().split(' ')) a = [] q = [] b = 0 y = 0 for c in range(M): a.append(map(int, raw_input().split())) for d in range(Q): q.append(map(int, raw_input().split())) for i in range(M): x = a[b] if x % 2 == 0: y += x if y > N: y -= N else: y -= x if y < 0: y = n + y b += 1 b = 0 for j in range(Q): z = q[b] if z!=y: print(1) else: print(0) b += 1
s929227794
p00296
u811733736
1507470480
Python
Python3
py
Runtime Error
0
0
789
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301 WA """ import sys from sys import stdin from collections import deque input = stdin.readline def main(args): # members = deque(list(range(10))) # numbers = [2, 6, 5, 18, 3] # queries = [3, 0, 5] N, M, Q = map(int, input().split(' ')) members = list(range(N)) numbers = [int(x) for x in input().split(' ')] queries = [int(x) for x in input().split(' ')] for n in numbers: if n % 2 == 0: members.rotate(-n) members.popleft() else: members.rotate(n) members.popleft() for q in queries: ans = 1 if q in members else 0 print(ans) if __name__ == '__main__': main(sys.argv[1:])
s967423596
p00296
u352394527
1529827998
Python
Python3
py
Runtime Error
20
5628
366
from bisect import bisect_left as bl n, m, q = map(int, input().split()) lst = [i for i in range(n)] alst = list(map(int, input().split())) ind = 0 for a in alst: if a % 2 == 0: ind += a else: ind -= a ind = ind % len(lst) lst.pop(ind) ind = ind % len(lst) qlst = list(map(int, input().split())) for q in qlst: print(int(lst[bl(lst, q)] == q))
s025403193
p00297
u352394527
1545583807
Python
Python3
py
Runtime Error
30
5748
3645
class MinTree: def __init__(self, iterable): self.iter_size = self.get_size(iterable) self.size = self.iter_size * 2 - 1 self.value = [None] * self.size for i, v in enumerate(iterable): self.value[self.iter_size + i - 1] = v self.set_value(0) self.range = [None] * self.size self.set_range(0, 0, self.iter_size - 1) def get_size(self, iterable): ret = 1 x = len(iterable) while ret < x: ret *= 2 return ret def set_range(self, x, left, right): self.range[x] = (left, right) if left != right: self.set_range(x * 2 + 1, left, (right + left) // 2) self.set_range(x * 2 + 2, (right + left) // 2 + 1, right) def set_value(self, x): if x >= self.iter_size - 1:return self.value[x] a = self.set_value(x * 2 + 1) b = self.set_value(x * 2 + 2) if a == None and b == None: self.value[x] = None elif a == None: self.value[x] = b elif b == None: self.value[x] = a else: self.value[x] = min(a, b) return self.value[x] def query(self, x, left, right): x_left, x_right = self.range[x] if right < x_left or x_right < left: return INF if left <= x_left and x_right <= right: return self.value[x] return min(self.query(x * 2 + 1, left, right), self.query(x * 2 + 2, left, right)) class MaxTree: def __init__(self, iterable): self.iter_size = self.get_size(iterable) self.size = self.iter_size * 2 - 1 self.value = [None] * self.size for i, v in enumerate(iterable): self.value[self.iter_size + i - 1] = v self.set_value(0) self.range = [None] * self.size self.set_range(0, 0, self.iter_size - 1) def get_size(self, iterable): ret = 1 x = len(iterable) while ret < x: ret *= 2 return ret def set_range(self, x, left, right): self.range[x] = (left, right) if left != right: self.set_range(x * 2 + 1, left, (right + left) // 2) self.set_range(x * 2 + 2, (right + left) // 2 + 1, right) def set_value(self, x): if x >= self.iter_size - 1:return self.value[x] a = self.set_value(x * 2 + 1) b = self.set_value(x * 2 + 2) if a == None and b == None: self.value[x] = None elif a == None: self.value[x] = b elif b == None: self.value[x] = a else: self.value[x] = max(a, b) return self.value[x] def query(self, x, left, right): x_left, x_right = self.range[x] if right < x_left or x_right < left: return 0 if left <= x_left and x_right <= right: return self.value[x] return max(self.query(x * 2 + 1, left, right), self.query(x * 2 + 2, left, right)) from bisect import bisect_left as bl n, d = map(int, input().split()) lst = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[2]) sorted_x = [] sorted_y = [] keys_to_ind = {} for i in range(n): x, y, b = lst[i] sorted_x.append(x) sorted_y.append(y) if b not in keys_to_ind: keys_to_ind[b] = i keys = list(keys_to_ind.keys()) mxt = MinTree(sorted_x) Mxt = MaxTree(sorted_x) myt = MinTree(sorted_y) Myt = MaxTree(sorted_y) def score(left, right): return (Mxt.query(0, left, right) - mxt.query(0, left, right)) * \ (Myt.query(0, left, right) - myt.query(0, left, right)) INF = 10 ** 20 kl = 0 kr = bl(keys, keys[0] + d) end = len(keys) ans = 0 while kr < end: ans = max(ans, score(keys_to_ind[keys[kl]], keys_to_ind[keys[kr]])) kl += 1 while kr < end and keys[kl] + d >= keys[kr]: kr += 1 kr -= 1 if kr == end - 1:break ans = max(ans, score(keys_to_ind[keys[kl]], keys_to_ind[keys[kr]])) print(ans)
s682546104
p00297
u352394527
1545585314
Python
Python3
py
Runtime Error
20
5748
3530
class MinTree: def __init__(self, iterable): self.iter_size = self.get_size(iterable) self.size = self.iter_size * 2 - 1 self.value = [None] * self.size for i, v in enumerate(iterable): self.value[self.iter_size + i - 1] = v self.set_value(0) self.range = [None] * self.size self.set_range(0, 0, self.iter_size - 1) def get_size(self, iterable): ret = 1 x = len(iterable) while ret < x: ret *= 2 return ret def set_range(self, x, left, right): self.range[x] = (left, right) if left != right: self.set_range(x * 2 + 1, left, (right + left) // 2) self.set_range(x * 2 + 2, (right + left) // 2 + 1, right) def set_value(self, x): if x >= self.iter_size - 1:return self.value[x] a = self.set_value(x * 2 + 1) b = self.set_value(x * 2 + 2) if a == None and b == None: self.value[x] = None elif a == None: self.value[x] = b elif b == None: self.value[x] = a else: self.value[x] = min(a, b) return self.value[x] def query(self, x, left, right): x_left, x_right = self.range[x] if right < x_left or x_right < left: return INF if left <= x_left and x_right <= right: return self.value[x] return min(self.query(x * 2 + 1, left, right), self.query(x * 2 + 2, left, right)) class MaxTree: def __init__(self, iterable): self.iter_size = self.get_size(iterable) self.size = self.iter_size * 2 - 1 self.value = [None] * self.size for i, v in enumerate(iterable): self.value[self.iter_size + i - 1] = v self.set_value(0) self.range = [None] * self.size self.set_range(0, 0, self.iter_size - 1) def get_size(self, iterable): ret = 1 x = len(iterable) while ret < x: ret *= 2 return ret def set_range(self, x, left, right): self.range[x] = (left, right) if left != right: self.set_range(x * 2 + 1, left, (right + left) // 2) self.set_range(x * 2 + 2, (right + left) // 2 + 1, right) def set_value(self, x): if x >= self.iter_size - 1:return self.value[x] a = self.set_value(x * 2 + 1) b = self.set_value(x * 2 + 2) if a == None and b == None: self.value[x] = None elif a == None: self.value[x] = b elif b == None: self.value[x] = a else: self.value[x] = max(a, b) return self.value[x] def query(self, x, left, right): x_left, x_right = self.range[x] if right < x_left or x_right < left: return 0 if left <= x_left and x_right <= right: return self.value[x] return max(self.query(x * 2 + 1, left, right), self.query(x * 2 + 2, left, right)) from bisect import bisect_right as br n, d = map(int, input().split()) lst = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[2]) sorted_x = [] sorted_y = [] keys = [] for i in range(n): x, y, b = lst[i] sorted_x.append(x) sorted_y.append(y) keys.append(b) mxt = MinTree(sorted_x) Mxt = MaxTree(sorted_x) myt = MinTree(sorted_y) Myt = MaxTree(sorted_y) def score(left, right): return (Mxt.query(0, left, right) - mxt.query(0, left, right)) * \ (Myt.query(0, left, right) - myt.query(0, left, right)) INF = 10 ** 20 kl = 0 kr = br(keys, keys[0] + d) - 1 end = len(keys) ans = 0 while kr < end: ans = max(ans, score(kl, kr)) kl += 1 while kr < end and keys[kl] + d >= keys[kr]: kr += 1 kr -= 1 if kr == end - 1:break if kl < end and kr < end: ans = max(ans, score(kl, kr)) print(ans)
s740032737
p00297
u567380442
1425079200
Python
Python3
py
Runtime Error
30
6956
1491
from math import ceil class sqrt_tree: def __init__(self,dat,f): self.dat = dat self.sq = int(len(dat) ** 0.5) self.f = f self.baqet = [self.f(dat[i * self.sq:(i + 1) * self.sq]) for i in range(self.sq)] #query def q(self,l,r): r += 1 if ceil(l / self.sq) >= r // self.sq: return self.f(self.dat[l:r]) ret = self.f(self.baqet[ceil(l / self.sq):r // self.sq]) if l % self.sq: ret = self.f(ret,self.f(self.dat[l:l + self.sq])) if r % self.sq: ret = self.f(ret,self.f(self.dat[r - r % self.sq:r])) return ret import sys f = sys.stdin _, d = map(int, f.readline().split()) x,y = {},{} for line in f: xi, yi, bi = map(int, line.split()) if bi not in x: x[bi],y[bi] = [],[] x[bi].append(xi) y[bi].append(yi) b = sorted(x.keys()) xmax = sqrt_tree([max(x[bi]) for bi in b],max) xmin = sqrt_tree([min(x[bi]) for bi in b],min) ymax = sqrt_tree([max(y[bi]) for bi in b],max) ymin = sqrt_tree([min(y[bi]) for bi in b],min) def get_lr(b,d): l = r = 0 while r < len(b) - 1: for k in range(r,-1,-1): if b[k] + d < b[r]: break l = k for k in range(l,len(b)): if b[l] + d < b[k]: break r = k yield l,r r += 1 max_size = max((xmax.q(l,r) - xmin.q(l,r)) * (ymax.q(l,r) - ymin.q(l,r)) for l,r in get_lr(b,d)) print(max_size)
s755521387
p00297
u567380442
1425080007
Python
Python3
py
Runtime Error
30
6952
1451
from math import ceil class sqrt_tree: def __init__(self,dat,f): self.dat = dat self.sq = int(len(dat) ** 0.5) self.f = f self.baqet = [self.f(dat[i * self.sq:(i + 1) * self.sq]) for i in range(self.sq)] #query def q(self,l,r): r += 1 if ceil(l / self.sq) >= r // self.sq: return self.f(self.dat[l:r]) ret = self.f(self.baqet[ceil(l / self.sq):r // self.sq]) if l % self.sq: ret = self.f(ret,self.f(self.dat[l:l + self.sq])) if r % self.sq: ret = self.f(ret,self.f(self.dat[r - r % self.sq:r])) return ret import sys f = sys.stdin _, d = map(int, f.readline().split()) x,y = {},{} for line in f: xi, yi, bi = map(int, line.split()) if bi not in x: x[bi],y[bi] = [],[] x[bi].append(xi) y[bi].append(yi) b = sorted(x.keys()) xmax = sqrt_tree([max(x[bi]) for bi in b],max) xmin = sqrt_tree([min(x[bi]) for bi in b],min) ymax = sqrt_tree([max(y[bi]) for bi in b],max) ymin = sqrt_tree([min(y[bi]) for bi in b],min) def get_lr(b,d): l = r = 0 while r < len(b) - 1: while b[l] + d < b[r]: l += 1 for k in range(l,len(b)): if b[l] + d < b[k]: break r = k yield l,r r += 1 l += 1 max_size = max((xmax.q(l,r) - xmin.q(l,r)) * (ymax.q(l,r) - ymin.q(l,r)) for l,r in get_lr(b,d)) print(max_size)
s703098376
p00297
u727466163
1440570720
Python
Python
py
Runtime Error
10
6464
618
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] k=1 while(a[k][2]<=a[0][2] + lightrange): if (a[k][0]<minx or a[k][0]>maxx or a[k][1]<miny or a[k][1]>maxy): minx = min(minx,a[k][0]) maxx = max(maxx,a[k][0]) miny = min(miny,a[k][1]) maxy = max(maxy,a[k][1]) k+=1 area = (maxx-minx)*(maxy-miny) scale = max(scale,area) del a[0] print scale
s247031682
p00297
u727466163
1440570843
Python
Python
py
Runtime Error
10
6488
710
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 try: while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] k=1 while(a[k][2]<=a[0][2] + lightrange): if (a[k][0]<minx or a[k][0]>maxx or a[k][1]<miny or a[k][1]>maxy): minx = min(minx,a[k][0]) maxx = max(maxx,a[k][0]) miny = min(miny,a[k][1]) maxy = max(maxy,a[k][1]) k+=1 area = (maxx-minx)*(maxy-miny) scale = max(scale,area) del a[0] except(RuntimeError): pass print scale
s036756954
p00297
u727466163
1440571276
Python
Python
py
Runtime Error
10
6396
618
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] k=1 while(a[k][2]<=a[0][2] + lightrange): if (a[k][0]<minx or a[k][0]>maxx or a[k][1]<miny or a[k][1]>maxy): minx = min(minx,a[k][0]) maxx = max(maxx,a[k][0]) miny = min(miny,a[k][1]) maxy = max(maxy,a[k][1]) k+=1 area = (maxx-minx)*(maxy-miny) scale = max(scale,area) del a[0] print scale
s426033718
p00297
u727466163
1440571847
Python
Python
py
Runtime Error
10
6496
651
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] k=1 while(a[k][2]<=a[0][2] + lightrange): if (a[k][0]<minx or a[k][0]>maxx or a[k][1]<miny or a[k][1]>maxy): minx = min(minx,a[k][0]) maxx = max(maxx,a[k][0]) miny = min(miny,a[k][1]) maxy = max(maxy,a[k][1]) k+=1 area = (maxx-minx)*(maxy-miny) scale = max(scale,area) del a[0] if(len(a)<2): break; print scale
s771178132
p00297
u727466163
1440571898
Python
Python
py
Runtime Error
10
6496
660
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] k=1 while(a[k][2]<=a[0][2] + lightrange): if (a[k][0]<minx or a[k][0]>maxx or a[k][1]<miny or a[k][1]>maxy): minx = min(minx,a[k][0]) maxx = max(maxx,a[k][0]) miny = min(miny,a[k][1]) maxy = max(maxy,a[k][1]) k+=1 area = (maxx-minx)*(maxy-miny) #scale = max(scale,area) if(area>scale): scale = area del a[0] print scale
s951387215
p00297
u727466163
1440572152
Python
Python
py
Runtime Error
10
6488
618
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = 0 while(len(a)>1): minx=maxx=a[0][0] miny=maxy=a[0][1] l=1 while (a[l][2] <= a[0][2] + lightrange): if(a[l][0]<minx): minx=a[l][0] if(a[l][0]>maxx): maxx=a[l][0] if(a[l][1]<miny): miny=a[l][1] if(a[l][1]>maxy): maxy=a[l][1] l+=1 area = (maxx-minx)*(maxy-miny) if (area > scale): scale = area del a[0] print scale
s773029344
p00297
u727466163
1440573845
Python
Python
py
Runtime Error
10
6456
455
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = [] while(len(a)>1): k=0 x=[] y=[] while(a[k][2]<=a[0][2] + lightrange): x.append(a[k][0]) y.append(a[k][1]) k+=1 if(k==len(a)): break scale.append((max(x)-min(x))*(max(y)-min(y))) del a[0] print max(scale)
s335188220
p00297
u727466163
1440574245
Python
Python
py
Runtime Error
10
6420
593
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = [] minlight = -1 while(len(a)>1): if a[0] == minlight: del a[0] else : k=0 x=[] y=[] while(a[k][2]<=a[0][2] + lightrange): x.append(a[k][0]) y.append(a[k][1]) k+=1 if(k==len(a)): break scale.append((max(x)-min(x))*(max(y)-min(y))) minlight = a[0][2] del a[0] print max(scale)
s194929724
p00297
u727466163
1440574371
Python
Python
py
Runtime Error
10
6400
625
data = map(int, raw_input().split()) stars = data[0] lightrange = data[1] a = [] for i in range(stars): a.append(map(int, raw_input().split())) a.sort(key=lambda x:x[2]) scale = [] minlight = -1 while(len(a)>1): if a[0] == minlight: del a[0] else : k=0 x=[] y=[] while(a[k][2]<=a[0][2] + lightrange): x.append(a[k][0]) y.append(a[k][1]) k+=1 if(k==len(a)): break scale.append((max(x)-min(x))*(max(y)-min(y))) minlight = a[0][2] del a[0] if len(a)==1: break print max(scale)
s082712707
p00297
u797673668
1456397778
Python
Python3
py
Runtime Error
30
8208
1108
from functools import reduce class Bound: min_x = 2000001 min_y = 2000001 max_x = -1 max_y = -1 def add(self, x, y): if self.min_x > x: self.min_x = x if self.min_y > y: self.min_y = y if self.max_x < x: self.max_x = x if self.max_y < y: self.max_y = y def expand(self, bound): if self.min_x > bound.min_x: self.min_x = bound.min_x if self.min_y > bound.min_y: self.min_y = bound.min_y if self.max_x < bound.max_x: self.max_x = bound.max_x if self.max_y < bound.max_x: self.max_y = bound.max_y return self def area(self): return (self.max_x - self.min_x) * (self.max_y - self.min_y) if self.max_x > -1 else 0 n, d = map(int, input().split()) input_store = set() max_b = -1 while n: x, y, b = map(int, input().split()) input_store.add((x, y, b)) if b > max_b: max_b = b n -= 1 stars = [Bound() for _ in range(max_b + 1)] for x, y, b in input_store: stars[b].add(x, y) print(max(reduce(Bound.expand, stars[i + 1:i + d + 1], stars[i]).area() for i in range(max_b - d + 1)))
s169101889
p00297
u566872786
1512383114
Python
Python3
py
Runtime Error
0
0
623
N,d = map(int,input().split()) L = [list(map(int,input().split())) for i in range(N)] L = sorted(L,key=lambda x:x[2]) def get_square(L): if not L or len(L) == 0:return 0 x=[L[0][0],L[0][0]] y=[L[0][1],L[0][1]] for i in L: if i[0] < x[0]:x[0] = i[0] if i[0] > x[1]:x[1] = i[0] if i[1] < y[0]:y[0] = i[1] if i[1] > y[1]:y[1] = i[1] return (x[1] - x[0]) * (y[1] - y[0]) result = 0 i = L[0][2] j = L[-1][2] while True: n = i + d l = [] while i <= n: l += [x[0:1] for x in L if x[2] == i] i += 1 s = get_square(l) if result < s:result = s i -= d if j < i + d:break print(result)
s902303997
p00297
u566872786
1512383475
Python
Python3
py
Runtime Error
0
0
541
L = sorted(L,key=lambda x:x[2]) def get_square(L): if not L or len(L) == 0:return 0 x=[L[0][0],L[0][0]] y=[L[0][1],L[0][1]] for i in L: if i[0] < x[0]:x[0] = i[0] elif i[0] > x[1]:x[1] = i[0] if i[1] < y[0]:y[0] = i[1] elif i[1] > y[1]:y[1] = i[1] return (x[1] - x[0]) * (y[1] - y[0]) result = 0 i = L[0][2] j = L[-1][2] while True: n = i + d l = [] while i <= n: l += [x[0:2] for x in L if x[2] == i] i += 1 s = get_square(l) if result < s:result = s i -= d if j < i + d:break print(result)
s677082745
p00297
u566872786
1512445347
Python
Python3
py
Runtime Error
0
0
1058
from sys import stdin from operator import itemgetter def get_square(L): if not L or len(L) == 0:return 0 x=[L[0][0][0],L[0][0][1]] y=[L[0][1][0],L[0][1][1]] for i in L: if i[0][0] < x[0]:x[0] = i[0][0] if i[0][1] > x[1]:x[1] = i[0][1] if i[1][0] < y[0]:y[0] = i[1][0] if i[1][1] > y[1]:y[1] = i[1][1] return (x[1] - x[0]) * (y[1] - y[0]) def get_xy(b,L): if not L or len(L) == 0:return None x=[L[0][0],L[0][0]] y=[L[0][1],L[0][1]] for i in L: if i[0] < x[0]:x[0] = i[0] elif i[0] > x[1]:x[1] = i[0] if i[1] < y[0]:y[0] = i[1] elif i[1] > y[1]:y[1] = i[1] return (b,x,y) N,d = map(int,input().split()) L = sorted(list(map([list(map(int,i.split())) for i in stdin.readlines()])),key=itemgetter(2)) B = set([i[2] for i in L]) D = [get_xy(n,[i for i in L if i[2] == n]) for n in B] i = 0 result = 0 while i < len(D): m = D[i][0] + d L = [D[i][1:3]] j = i+1 while j < len(D) and D[j][0] <= m: L.append(D[j][1:3]) j += 1 s = get_square(L) if result < s:result = s i += 1 print(result)
s430393738
p00297
u566872786
1512445458
Python
Python3
py
Runtime Error
0
0
1052
from sys import stdin from operator import itemgetter def get_square(L): if not L or len(L) == 0:return 0 x=[L[0][0][0],L[0][0][1]] y=[L[0][1][0],L[0][1][1]] for i in L: if i[0][0] < x[0]:x[0] = i[0][0] if i[0][1] > x[1]:x[1] = i[0][1] if i[1][0] < y[0]:y[0] = i[1][0] if i[1][1] > y[1]:y[1] = i[1][1] return (x[1] - x[0]) * (y[1] - y[0]) def get_xy(b,L): if not L or len(L) == 0:return None x=[L[0][0],L[0][0]] y=[L[0][1],L[0][1]] for i in L: if i[0] < x[0]:x[0] = i[0] elif i[0] > x[1]:x[1] = i[0] if i[1] < y[0]:y[0] = i[1] elif i[1] > y[1]:y[1] = i[1] return (b,x,y) N,d = map(int,input().split()) L = sorted(set([list(map(int,i.split())) for i in stdin.readlines()]),key=itemgetter(2)) B = set([i[2] for i in L]) D = [get_xy(n,[i for i in L if i[2] == n]) for n in B] i = 0 result = 0 while i < len(D): m = D[i][0] + d L = [D[i][1:3]] j = i+1 while j < len(D) and D[j][0] <= m: L.append(D[j][1:3]) j += 1 s = get_square(L) if result < s:result = s i += 1 print(result)
s354832406
p00297
u566872786
1512445505
Python
Python3
py
Runtime Error
0
0
1058
from sys import stdin from operator import itemgetter def get_square(L): if not L or len(L) == 0:return 0 x=[L[0][0][0],L[0][0][1]] y=[L[0][1][0],L[0][1][1]] for i in L: if i[0][0] < x[0]:x[0] = i[0][0] if i[0][1] > x[1]:x[1] = i[0][1] if i[1][0] < y[0]:y[0] = i[1][0] if i[1][1] > y[1]:y[1] = i[1][1] return (x[1] - x[0]) * (y[1] - y[0]) def get_xy(b,L): if not L or len(L) == 0:return None x=[L[0][0],L[0][0]] y=[L[0][1],L[0][1]] for i in L: if i[0] < x[0]:x[0] = i[0] elif i[0] > x[1]:x[1] = i[0] if i[1] < y[0]:y[0] = i[1] elif i[1] > y[1]:y[1] = i[1] return (b,x,y) N,d = map(int,input().split()) L = sorted(list(set([list(map(int,i.split())) for i in stdin.readlines()])),key=itemgetter(2)) B = set([i[2] for i in L]) D = [get_xy(n,[i for i in L if i[2] == n]) for n in B] i = 0 result = 0 while i < len(D): m = D[i][0] + d L = [D[i][1:3]] j = i+1 while j < len(D) and D[j][0] <= m: L.append(D[j][1:3]) j += 1 s = get_square(L) if result < s:result = s i += 1 print(result)
s600418840
p00297
u350064373
1512456193
Python
Python3
py
Runtime Error
20
5684
456
from sys import stdin from operator import itemgetter as it D={} result=[] _,d=map(int,input().split()) for i in stdin.readlines(): x,y,b=map(int,i.split()) if b not in D:D[b]=[] D[b].append((x,y)) for i in range(max(D)-d+1): l=[] for s in range(d+1): if i+s in D:l+=D[i+s] if len(l)>1: x=max(map(it(0),l))-min(map(it(0),l)) y=max(map(it(1),l))-min(map(it(1),l)) result.append(x*y) print(max(result))
s583576369
p00297
u350064373
1512456963
Python
Python3
py
Runtime Error
20
5680
456
from sys import stdin from operator import itemgetter as it D={} result=[] _,d=map(int,input().split()) for i in stdin.readlines(): x,y,b=map(int,i.split()) if b not in D:D[b]=[] D[b].append((x,y)) for i in range(max(D)-d+1): l=[] for s in range(d+1): if i+s in D:l+=D[i+s] if len(l)>1: x=max(map(it(0),l))-min(map(it(0),l)) y=max(map(it(1),l))-min(map(it(1),l)) result.append(x*y) print(max(result))
s301626262
p00297
u350064373
1512457323
Python
Python3
py
Runtime Error
20
5692
480
from sys import stdin from operator import itemgetter as it D={} result=[] N,d=map(int,input().split()) for i in stdin.readlines(): x,y,b=map(int,i.split()) if b not in D:D[b]=[] D[b].append((x,y)) for i in range(max(D)-d+1): l=[] for s in range(d+1): if i+s in D:l+=D[i+s] if len(l)>1: x=max(map(it(0),l))-min(map(it(0),l)) y=max(map(it(1),l))-min(map(it(1),l)) result.append(x*y) print(0 if len==(result) else max(result))
s453566671
p00297
u350064373
1512458771
Python
Python3
py
Runtime Error
20
5680
427
from sys import stdin from operator import itemgetter as it D={} result=[] N,d=map(int,input().split()) for i in stdin.readlines(): x,y,b=map(int,i.split()) if b not in D:D[b]=[] D[b].append((x,y)) for i in range(max(D)-d+1): l=[] for s in range(d+1): if i+s in D:l+=D[i+s] if len(l)>1:result.append((max(map(it(0),l))-min(map(it(0),l)))*(max(map(it(1),l))-min(map(it(1),l)))) print(max(result))
s271331721
p00297
u566872786
1512460446
Python
Python3
py
Runtime Error
0
0
851
from sys import stdin from operator import itemgetter from itertools import takewhile from random import randint from array import array def get_square(x_min,x_max,y_min,y_max): return (x_max - x_min) * (y_max - y_min) N,d = map(int,input().split()) L = [tuple(map(int,i.split())) for i in make_data(N)] B = sorted(set([i[2] for i in L])) D = {i:[] for i in B} [D[i[2]].append((i[0],i[1])) for i in L] for k,v in D.items(): i = tuple(zip(*v)) D[k] = array('L',(min(i[0]),max(i[0]),min(i[1]),max(i[1]))) print('test1') Max = B[-1] result = 0 for i in range(len(B)): b = B[i] + d L2 = (D[j] for j in takewhile( lambda x: x <= b, (B[n] for n in range(i,len(B))) )) L3 = tuple(zip(*L2)) s = get_square(min(L3[0]),max(L3[1]),min(L3[2]),max(L3[3])) if result < s:result = s if b > Max:break print(result)
s458524279
p00297
u566872786
1512471086
Python
Python3
py
Runtime Error
0
0
2471
from sys import stdin from operator import itemgetter from itertools import takewhile from random import randint from array import array MAX = 200000000 class Point: def __init__(self,x=-1,y=-1,b=-1): self.x=x self.y=y self.b=b class Points: def __init__(self,b,points): self.b=b self.xmin=points[0] self.xmax=points[1] self.ymin=points[2] self.ymax=points[3] def set_point(self,point): if self.xmin > point.x:self.xmin=point.x elif self.xmax < point.x:self.xmax=point.x if self.ymin > point.y:self.ymin=point.y elif self.ymax < point.y:self.ymax=point.y class Constellation: def __init__(self,bmin=0,bmax=0,xmin=0,xmax=0,ymin=0,ymax=0): self.D = { i:None for i in range(bmin,bmax+1) } self.bmin=bmin self.bmax=bmax self.xmin=xmin self.xmax=xmax self.ymin=ymin self.ymax=ymax def set_points(self,points): if points.b > self.bmax and points.b < self.bmin: raise Exception if self.xmin > points.xmin:self.xmin=points.xmin elif self.xmax < points.xmax:self.xmax=points.xmax if self.ymin > points.ymin:self.ymin=points.ymin elif self.ymax < points.ymax:self.ymax=points.ymax def square(self): return (self.xmax - self.xmin) * (self.ymax - self.ymin) def update_b(self,bmin=0,bmax=0): for i in range(self.bmin,bmin): del self.D[i] for i in range(self.bmax+1,bmax+1): self.D[i] = None self.bmin = bmin self.bmax = bmax N,d = map(int,input().split()) L = [tuple(map(int,i.split())) for i in stdin.readlines()] B = sorted(set([i[2] for i in L])) D = {i:[] for i in B} [D[i[2]].append((i[0],i[1])) for i in L] for k,v in D.items(): i = tuple(zip(*v)) D[k] = (min(i[0]),max(i[0]),min(i[1]),max(i[1])) Max = B[-1] result = 0 if d < 50000: for i in range(len(B)): b = B[i] + d L2 = tuple(zip(*(D[j] for j in takewhile( lambda x: x <= b, (B[n] for n in range(i,len(B))) )))) #L3 = tuple(zip(*L2)) s = (max(L3[1]) - min(L3[0])) * (max(L3[3]) - min(L3[2])) if result < s:result = s if b > Max:break print(result) else: results = 0 print(B[0]) print(B[0]+d) print(D[B[0]]) c = Constellation(B[0],B[0]+d,*D[B[0]]) for k,v in D.items(): # k b, v xminmax,yminmax if k <= c.bmax: c.set_points(Points(k,v)) continue s = c.square() if result < s:result = s c.update_b(k-d,k) c.set_points(Points(k,v)) print(result)
s249893435
p00297
u352394527
1529835167
Python
Python3
py
Runtime Error
20
5652
1827
from bisect import bisect_left as bl class Node: def __init__(self, val, sec): self.val = val self.sec = sec self.left = sec[0] self.right = sec[1] self.minx = val[0] self.maxx = val[1] self.miny = val[2] self.maxy = val[3] class SegTree: def __init__(self, num, lst): num_ = 1 while num_ < num: num_ *= 2 self.length = num_ * 2 - 1 self.arr = [None] * (num_ * 2 - 1) for i in range(num): self.arr[num_ - 1 + i] = Node(lst[i], (i, i)) self.make(0) def make(self, num): if num >= self.length: return None if self.arr[num] != None: return self.arr[num] else: self.arr[num] = self.con(self.make(num * 2 + 1), self.make(num * 2 + 2)) return self.arr[num] def con(self, n1, n2): if n1 != None and n2 != None: return Node((min(n1.minx, n2.minx), max(n1.maxx, n2.maxx), min(n1.miny, n2.miny), max(n1.maxy, n2.maxy)), (n1.left, n2.right)) if n1 != None: return n1 if n2 != None: return n2 return None def query(self, l, r, num): node = self.arr[num] if l <= node.left and node.right <= r: return node elif r < node.left or node.right < l: return None else: return self.con(self.query(l, r, num * 2 + 1), self.query(l, r, num * 2 + 2)) def main(): n, d = map(int, input().split()) stars = [] blst = [] for _ in range(n): x, y, b = map(int, input().split()) stars.append((x, y, b)) blst.append(b) blst.sort() stars.sort(key=lambda t:t[2]) stars = [(x, x, y, y) for x, y, _ in stars] tree = SegTree(n, stars) ans = 0 for l in range(n): r = bl(blst, blst[l] + d) if r >= n: r -= 1 a = tree.query(l, r, 0).val ans = max((a[1] - a[0]) * (a[3] - a[2]), ans) print(ans) main()
s326174147
p00299
u567380442
1426645808
Python
Python3
py
Runtime Error
0
0
1365
def create_edge(fr,to,weight,si): edges = [] if si == '-': edges.append((fr,to,weight)) edges.append((to,fr,0)) else: edges.append((to,fr,-weight)) return edges #????????????????????´???-1????????? def bellmanford(edges, length): start_vertex = 0 distance = [float('inf')] * length distance[start_vertex] = 0 for i in range(length): for fr, to, weight in edges: if distance[to] > distance[fr] + weight: distance[to] = distance[fr] + weight for fr, to, weight in edges: if distance[to] > distance[fr] + weight: return -1 return max(distance) import sys import re import math n,c = map(int, f.readline().split()) p = re.compile('(\d+)(\D+)(\d+)(\D+)(\d+)') constraints = [p.match(line).groups() for line in f] fixed_edges = [] floating_edges = [] for ai, oi, bi, si, di in constraints: fr,to,weight = int(ai) - 1,int(bi) - 1,int(di) if oi == '*': floating_edges.append((create_edge(fr,to,weight,si),create_edge(to,fr,weight,si))) else: if oi == '>=': fr, to = to, fr fixed_edges.extend(create_edge(fr,to,weight,si)) distance = [] for edges in itertools.product(*floating_edges): distance.append(bellmanford(fixed_edges + [y for x in edges for y in x], n)) print(max(distance))
s865849921
p00299
u567380442
1426645884
Python
Python3
py
Runtime Error
0
0
1382
def create_edge(fr,to,weight,si): edges = [] if si == '-': edges.append((fr,to,weight)) edges.append((to,fr,0)) else: edges.append((to,fr,-weight)) return edges #????????????????????´???-1????????? def bellmanford(edges, length): start_vertex = 0 distance = [float('inf')] * length distance[start_vertex] = 0 for i in range(length): for fr, to, weight in edges: if distance[to] > distance[fr] + weight: distance[to] = distance[fr] + weight for fr, to, weight in edges: if distance[to] > distance[fr] + weight: return -1 return max(distance) import sys import re import math import itertools n,c = map(int, f.readline().split()) p = re.compile('(\d+)(\D+)(\d+)(\D+)(\d+)') constraints = [p.match(line).groups() for line in f] fixed_edges = [] floating_edges = [] for ai, oi, bi, si, di in constraints: fr,to,weight = int(ai) - 1,int(bi) - 1,int(di) if oi == '*': floating_edges.append((create_edge(fr,to,weight,si),create_edge(to,fr,weight,si))) else: if oi == '>=': fr, to = to, fr fixed_edges.extend(create_edge(fr,to,weight,si)) distance = [] for edges in itertools.product(*floating_edges): distance.append(bellmanford(fixed_edges + [y for x in edges for y in x], n)) print(max(distance))
s100610718
p00304
u451187291
1503076910
Python
Python3
py
Runtime Error
30
7804
1521
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' def main(): '''main func. ''' node_n = int(input()) nodes = list() edges = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): edges.append(tuple([int(x) for x in input().split()])) for (i, j) in edges: nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % 1000000007) def product(lis): result = 1 for element in lis: result *= element return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result elif "R" in self.kind: result = product(map(lambda x: x+1, cases)) if "?" not in self.kind: result -= 1 return result else: raise Exception("unreachable.") if __name__ == '__main__': main()
s053176875
p00304
u451187291
1503077079
Python
Python3
py
Runtime Error
40
7848
1540
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() edges = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): edges.append(tuple([int(x) for x in input().split()])) for (i, j) in edges: nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): result = 1 for element in lis: result *= element return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product(map(lambda x: x+1, cases)) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s255219588
p00304
u451187291
1503077155
Python
Python3
py
Runtime Error
20
7760
1544
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() edges = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): edges.append(tuple([int(x) for x in input().split()])) for (i, j) in edges: nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): result = 1 for element in lis: result *= element % N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product(map(lambda x: x+1, cases)) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s546925205
p00304
u451187291
1503077534
Python
Python3
py
Runtime Error
30
7792
1520
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): '''product for list ''' result = 1 for element in lis: result *= element % N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product([x+1 for x in cases]) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s336360978
p00304
u451187291
1503077800
Python
Python3
py
Runtime Error
30
7748
1540
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): '''product for list ''' result = 1 for element in lis: result *= element % N result %= N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product([x+1 for x in cases]) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s696860560
p00304
u451187291
1503078574
Python
Python3
py
Runtime Error
30
7876
1705
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' import sys from math import log10 N = 1000000007 LOGN = 9 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): '''product for list ''' result = 1 for element in lis: if log10(result) + log10(element) > 9: result = ((result-N) * (element-N)) % N else: result *= element % N result %= N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product([x+1 for x in cases]) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s431655351
p00304
u451187291
1503078846
Python
Python3
py
Runtime Error
30
7884
1773
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' from math import log10 N = 1000000007 LOGN = 9 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): '''product for list ''' result = 1 for element in lis: if log10(result) + log10(element) > LOGN: if log10(result) > LOGN-4: result = result-N if log10(element) > LOGN-4: element = element-N result *= element % N result %= N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product([x+1 for x in cases]) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s601081368
p00304
u451187291
1503079559
Python
Python3
py
Runtime Error
30
7784
1541
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(lis): '''product for list ''' result = 1 for element in lis: result *= element % N result %= N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = [child.number_of_cases() for child in self.children] if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product([x+1 for x in cases]) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") if __name__ == '__main__': main()
s878879958
p00304
u451187291
1503080044
Python
Python3
py
Runtime Error
20
7840
1670
'''aizu 0309 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309 ''' # encoding: 'utf-8' N = 1000000007 def main(): '''main func. ''' node_n = int(input()) nodes = list() for _ in range(node_n): nodes.append(Node(input())) for _ in range(node_n - 1): i, j = tuple([int(x) for x in input().split()]) nodes[i-1].children.append(nodes[j-1]) print(nodes[0].number_of_cases() % N) def product(iterator): '''product for iterator ''' result = 1 for element in iterator: result *= element % N result %= N return result class Node: '''Node class ''' def __init__(self, kind, children=None): self.kind = kind if children is None: children = list() self.children = children def number_of_cases(self): ''' calc the number of cases. ''' cases = self.generate_cases() if "E" in self.kind: result = product(cases) if "?" in self.kind: result += 1 return result % N elif "A" in self.kind: result = sum(cases) if "?" in self.kind: result += 1 return result % N elif "R" in self.kind: result = product((x+1 for x in cases)) if "?" not in self.kind: result -= 1 return result % N else: raise Exception("unreachable.") def generate_cases(self): '''generate cases ''' for child in self.children: yield child.number_of_cases() if __name__ == '__main__': main()
s422190135
p00305
u072053884
1530635077
Python
Python3
py
Runtime Error
0
0
1334
def solve(): file_input = stdin N = int(file_input.readline()) img = tuple(tuple(map(int, line.split())) for line in file_input) acc_row = (tuple(accumulate(line)) + (0,) for line in img) acc_col = tuple(tuple(accumulate(line)) + (0,) for line in zip(*img)) ans = 0 for i, tpl_1 in enumerate(zip(img, acc_row)): img_i, acc_row_i = tpl_1 for j, img_j in enumerate(img[i:], start=i): if acc_row_i[j] - acc_row_i[i - 1] > ans: ans = acc_row_i[j] - acc_row_i[i - 1] if i == j: continue col = acc_col[0] col_max = col[j] - col[i - 1] for acc_col_k, img_i_k, img_j_k in zip(acc_col[1:], img_i[1:], img_j[1:]): col = acc_col_k[j] - acc_col_k[i - 1] if col_max > 0: c_ans = col_max + col if c_ans > ans: ans = c_ans else: if col > ans: ans = col t_col_max = col_max + img_i_k + img_j_k if t_col_max > col: col_max = t_col_max else: col_max = col print(ans) solve()
s311019679
p00305
u072053884
1530635123
Python
Python3
py
Runtime Error
0
0
1334
def solve(): file_input = stdin N = int(file_input.readline()) img = tuple(tuple(map(int, line.split())) for line in file_input) acc_row = (tuple(accumulate(line)) + (0,) for line in img) acc_col = tuple(tuple(accumulate(line)) + (0,) for line in zip(*img)) ans = 0 for i, tpl_1 in enumerate(zip(img, acc_row)): img_i, acc_row_i = tpl_1 for j, img_j in enumerate(img[i:], start=i): if acc_row_i[j] - acc_row_i[i - 1] > ans: ans = acc_row_i[j] - acc_row_i[i - 1] if i == j: continue col = acc_col[0] col_max = col[j] - col[i - 1] for acc_col_k, img_i_k, img_j_k in zip(acc_col[1:], img_i[1:], img_j[1:]): col = acc_col_k[j] - acc_col_k[i - 1] if col_max > 0: c_ans = col_max + col if c_ans > ans: ans = c_ans else: if col > ans: ans = col t_col_max = col_max + img_i_k + img_j_k if t_col_max > col: col_max = t_col_max else: col_max = col print(ans) solve()
s231846835
p00310
u546285759
1507867529
Python
Python3
py
Runtime Error
0
0
36
print(sum(map(int, input().split()))
s440110071
p00312
u546285759
1507987179
Python
Python3
py
Runtime Error
0
0
44
print(sum(divmod(map(int, input().split())))
s395041168
p00314
u260980560
1499595883
Python
Python
py
Runtime Error
0
0
109
input();Q=[0]*101 for p in map(int,input().split()):Q[p]+=1 print(max(i for i in range(101)if sum(Q[i:])>=i))
s528792491
p00314
u855694108
1506567549
Python
Python3
py
Runtime Error
0
0
369
def main(): N = int(input()) p = list(map(int, input().split())) p.sort() pp = list(set(p)) cnt = 0 for i in range(len(pp)): cnt += 1 scnt = 0 for j in range(len(p)): if pp[i] <= pp[j]: scnt += 1 if cnt == scnt: break print(cnt) if __name__ == "__main__": main()
s670071951
p00314
u546285759
1509139039
Python
Python3
py
Runtime Error
0
0
176
N = int(input()) p = list(map(int, input().split())) score = [0] * 101 for x in p: score[x] += 1 while True: if sum(score[i:]) < i: break i += 1 print(i-1)
s226049417
p00330
u498511622
1501504952
Python
Python3
py
Runtime Error
0
0
73
try: while True: i=int(input()) print(i*32) except EOFError: pass
s583299444
p00331
u623996423
1541073115
Python
Python3
py
Runtime Error
0
0
66
h, r = list(map(int, input().split())) print(int((h+r)/abs(h+r)))
s725041389
p00333
u772726453
1501232130
Python
Python3
py
Runtime Error
0
0
91
import math W,H,C = map(int,input().split(' ')) x = math.gcd(W,H) print((W//x)*(H//x)*C)
s329988994
p00333
u772726453
1501232138
Python
Python3
py
Runtime Error
0
0
91
import math W,H,C = map(int,input().split(' ')) x = math.gcd(W,H) print((W//x)*(H//x)*C)
s222517420
p00333
u772726453
1501232322
Python
Python3
py
Runtime Error
0
0
91
import math W,H,C = map(int,input().split(' ')) x = math.gcd(W,H) print((W//x)*(H//x)*C)
s227247454
p00333
u051218320
1528756070
Python
Python3
py
Runtime Error
0
0
114
import fractions A, B, C = [int(k) for k in raw_input().split(' ')] print((A * B)/ (fractions.gcd(A, B) ** 2 ))
s267616679
p00333
u051218320
1528756134
Python
Python3
py
Runtime Error
0
0
120
import fractions A, B, C = [int(k) for k in raw_input().split(' ')] print(C * ((A * B)/ (fractions.gcd(A, B) ** 2 )))
s715572239
p00334
u805464373
1555760144
Python
Python
py
Runtime Error
0
0
164
N=int(input()) c=set() for i in range(N): ls=input().split() ls.sort() ls_sum=ls[0]*1000**2+ls[1]*1000+ls[2] c.add(ls_sum) print(N-len(c))
s055635850
p00334
u805464373
1555760161
Python
Python
py
Runtime Error
0
0
164
N=int(input()) c=set() for i in range(N): ls=input().split() ls.sort() ls_sum=ls[0]*1000**2+ls[1]*1000+ls[2] c.add(ls_sum) print(N-len(c))
s987920323
p00334
u369093003
1501655531
Python
Python3
py
Runtime Error
0
0
328
l = [] N = int(input()) for i in range(N): a,b,c = map(int,input().split(' ')) d = a + b + c l.append(d) e = l.count(9) f = l.count(8) g = l.count(7) h = l.count(6) ans = 0 if e>1: ans += e - 1 if f>1: ans += f - 1 if g>1: ans += g - 1 if h>1: ans += h - 1 if e = 1 and f = 1 and g = 1 and h = 1: ans = 4 print(ans)
s232602700
p00334
u369093003
1501657713
Python
Python3
py
Runtime Error
0
0
762
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int[] I = new int[N]; int D = 0; int E = 0; int F = 0; int G = 0; int ans = 0; for(int i=0;i<N;i++){ int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int n = a + b + c; I[i] = n; } for(int j=0;j<N;j++){ int d = I[j]; if(d==9){ if(D!=1){ D += 1; }else{ ans += 1; } } if(d==8){ if(E!=1){ E += 1; }else{ ans += 1; } } if(d==7){ if(F!=1){ F += 1; }else{ ans += 1; } } if(d==6){ if(G!=1){ G += 1; }else{ ans += 1; } } } System.out.println(ans); } }
s942935751
p00334
u369093003
1501935069
Python
Python3
py
Runtime Error
0
0
121
N = int(input()) s = set() for i in range(N): a = map(int,input().split(' ')) b = sorted(a) s.add(d) print(N - len(s))
s687452602
p00334
u369093003
1501935165
Python
Python3
py
Runtime Error
0
0
140
N = int(input()) s = set() for i in range(N): a,b,c = map(str,input().split(' ')) e = a + b + c e = sorted(d) s.add(e) print(N - len(s))
s678308486
p00334
u369093003
1501935259
Python
Python3
py
Runtime Error
0
0
156
N = int(input()) s = set() l = [] for i in range(N): a,b,c = map(int,input().split(' ')) l.append(a,b,c) e = sorted(l) s.add(e) l = 0 print(N - len(s))
s845614904
p00334
u369093003
1501935749
Python
Python3
py
Runtime Error
0
0
142
N = int(input()) l = [] for i in range(N): a,b,c = map(int,input().split(' ')) l.append(a,b,c) l.sort() s.add(l) l = [] print(N - len(s))
s267709874
p00334
u369093003
1501935800
Python
Python3
py
Runtime Error
0
0
164
N = int(input()) l = [] for i in range(N): a,b,c = map(int,input().split(' ')) l.append(a) l.append(b) l.append(c) l.sort() s.add(l) l = [] print(N - len(s))
s588245310
p00334
u369093003
1501935937
Python
Python3
py
Runtime Error
0
0
174
N = int(input()) l = [] s = set() for i in range(N): a,b,c = map(int,input().split(' ')) l.append(a) l.append(b) l.append(c) l.sort() s.add(l) l = [] print(N - len(s))
s631700093
p00334
u451187291
1503071647
Python
Python3
py
Runtime Error
0
0
200
# encoding: 'utf-8' N = int(input()) ls = list() for _ in range(N): e = sorted([int(x) for x in split(input())]) if e in ls: continue else: ls.append(e) print(N - len(ls))
s470734653
p00335
u260980560
1501296701
Python
Python3
py
Runtime Error
20
7736
292
n = int(input()) *P, = map(int, input().split()) memo = {(n-1, i): i for i in range(P[-1]+1)} def dfs(pos, t): if (pos, t) in memo: return memo[pos, t] res = memo[pos, t] = dfs(pos+1, max(0, P[pos+1]-t)) + t*2 return res print(min(dfs(0, P[0]-i)+i for i in range(P[0]+1)))
s714109773
p00335
u451187291
1503113130
Python
Python3
py
Runtime Error
20
7784
987
'''aizu 0340 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0340 ''' # encoding: 'utf-8' def main(): input() hill = [int(x) for x in input().split()] _hill = [0] * len(hill) count = 0 while hill != _hill: # print(count, hill) _hill = hill hill, c = step(hill) count += c count += finalize(hill) print(count) def step(hill): c = 0 for i in range(1, len(hill)-1): if hill[i] > 0 and hill[i+1] > 0: scraped = min(hill[i], hill[i+1]) hill[i] -= scraped hill[i+1] -= scraped c += 2 * scraped i = 0 if hill[i] > 0 and hill[i+1] > 0: scraped = min(hill[i], hill[i+1]) hill[i] -= scraped hill[i+1] -= scraped c += 2 * scraped return (hill, c) def finalize(hill): assert(hill[1] == 0) assert(hill[-2] == 0) c = hill[0] + hill[-1] + sum(hill[1:-1])*2 return c if __name__ == '__main__': main()
s049046817
p00335
u451187291
1503113175
Python
Python3
py
Runtime Error
20
7748
961
'''aizu 0340 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0340 ''' # encoding: 'utf-8' def main(): input() hill = [int(x) for x in input().split()] _hill = [0] * len(hill) count = 0 while hill != _hill: # print(count, hill) _hill = hill hill, c = step(hill) count += c count += finalize(hill) print(count) def step(hill): c = 0 for i in range(1, len(hill)-1): if hill[i] > 0 and hill[i+1] > 0: scraped = min(hill[i], hill[i+1]) hill[i] -= scraped hill[i+1] -= scraped c += 2 * scraped i = 0 if hill[i] > 0 and hill[i+1] > 0: scraped = min(hill[i], hill[i+1]) hill[i] -= scraped hill[i+1] -= scraped c += 2 * scraped return (hill, c) def finalize(hill): assert(hill[1] == 0) c = hill[0] + hill[-1] + sum(hill[1:-1])*2 return c if __name__ == '__main__': main()
s944512988
p00340
u858885710
1481551410
Python
Python3
py
Runtime Error
0
0
89
a, b, c, d = sorted(map(int, input().split()) print("YES" if a == b and c == d else "NO")
s071293288
p00340
u546285759
1502765344
Python
Python3
py
Runtime Error
0
0
83
e = sorted(map(int, input().split())) print("yes" if e[0] == e[1] and e[2] == e[3])
s945495754
p00341
u350064373
1501505716
Python
Python3
py
Runtime Error
0
0
179
ls = list(map(int, input().split())) ls.sort() if ls[0]==ls[1]==ls[2]==ls[3] and ls[4==ls[5]==ls[6]==ls[7] and ls[8]==ls[9]==ls[10]==ls[11]: print('yes') else: print('no')
s804111321
p00341
u498511622
1501505954
Python
Python3
py
Runtime Error
0
0
179
lst=list(input().split()) lst.sort() if lst[0]==lst[1]==lst[2]==lst[3] and lst[4]==lst[5]==lst[6]==lst[7] and lst[8]==lst[9]==lst[10]==lst[11]: print('yes') else: print('no')
s237676855
p00341
u498511622
1501505980
Python
Python3
py
Runtime Error
0
0
176
lst=list(input().split()) lst.sort() if lst[0]==lst[1]==lst[2]==lst[3]andlst[4]==lst[5]==lst[6]==lst[7]andlst[8]==lst[9]==lst[10]==lst[11]: print('yes') else: print('no')
s766155499
p00342
u724548524
1526977025
Python
Python3
py
Runtime Error
0
0
585
n = int(input()) a = sorted(map(int,input().split())) b = [(a[i + 1] - a[i], i) for i in range(n -1)] b.sort(key = lambda x:x[0]) if b[0][1] < n - 2:print((a[-1] + a[-2]) / c) elif b[0][1] == n - 3: if b[1][1] == n - 2:print(max((a[-1] + a[-2]) / b[2][0], (a[-1] + a[-4]) / b[0][0], (a[-3] + a[-4]) / b[1][0])) else:print(max((a[-1] + a[-2]) / b[1][0], (a[-1] + a[-4]) / b[0][0])) else: if b[1][1] == n - 3:print(max((a[-1] + a[-2]) / b[2][0], (a[-1] + a[-4]) / b[1][0], (a[-3] + a[-4]) / b[0][0])) else:print(max((a[-1] + a[-2]) / b[1][0], (a[-3] + a[-4]) / b[0][0]))
s736673918
p00343
u260980560
1501322731
Python
Python3
py
Runtime Error
0
0
791
n = int(input()) for i in range(n): F = set(map(int, input().split())) fl = min(F); fr = max(F) G = {*range(1, 14)} - F - {7} gl = min(G); gr = max(G) memo = {} def dfs(s, t, u): if (s, t, u) in memo: return memo[s, t, u] T = [G, F][u] res = 0 if s-1 in T: if s-1 <= [gl, fl][u] and [gr, fr][u] <= t: res = 1 else: res |= dfs(s-1, t, u^1)^1 if t+1 in T: if s <= [gl, fl][u] and [gr, fr][u] <= t+1: res = 1 else: res |= dfs(s, t+1, u^1)^1 if s-1 not in T and t+1 not in T: res = dfs(s, t, u^1)^1 memo[s, t, u] = res return res print(["no", "yes"][dfs(7, 7, 1)])
s696995232
p00344
u320316900
1523337338
Python
Python3
py
Runtime Error
0
0
474
fi = int(input()) tramp = [int(input()) for i in range(fi)] is_reachable = [0 for i in range(fi)] def jump(n): is_reachable[n] = 1 if n == fi: return for j in range(min(tramp[n] // 10, fi-n-1)): if not is_reachable[n+j+1]: jump(n+j+1) jump(0) if not is_reachable[-1]: print("no") exit() tramp = tramp[::-1] is_reachable = [0 for i in range(fi)] jump(0) if not is_reachable[-1]: print("no") exit() print("yes")
s611200991
p00344
u352394527
1529927404
Python
Python3
py
Runtime Error
290
48092
904
n = int(input()) alst = list(map(int, input().split())) edges = [[] for _ in range(n)] rev_edges = [[] for _ in range(n)] for i in range(n): edges[i].append((i + alst[i]) % n) rev_edges[(i + alst[i]) % n].append(i) def dfs(x, ret, edges, visited): visited[x] = True for e in edges[x]: if not visited[e]: dfs(e, ret, edges, visited) ret.append(x) def dfs_rev(x, cycles, rev_edges, visited): visited[x] = True flag = False for e in rev_edges[x]: if not visited[e]: cycles.add(e) dfs_rev(e, cycles, rev_edges, visited) flag = True elif x == e: flag = True if flag: cycles.add(x) order = [] visited = [False] * n for i in range(n): if not visited[i]: dfs(i, order, edges, visited) order.reverse() visited = [False] * n cycles = set() for i in order: if not visited[i]: dfs_rev(i, cycles, rev_edges, visited) print(len(cycles))
s365330132
p00347
u260980560
1501341909
Python
Python3
py
Runtime Error
20
7796
742
w, h = map(int, input().split()) S = [list(map(int, input().split())) for i in range(h)] SW = [[0]*w for i in range(h)] SH = [[0]*w for i in range(h)] for i in range(h): cnt = 0 for j in range(w-1, -1, -1): cnt += S[i][j] SW[i][j] = cnt for j in range(w): cnt = 0 for i in range(h-1, -1, -1): cnt += S[i][j] SH[i][j] = cnt memo = {} def dfs(x, y): if (x, y) in memo: return memo[x, y] if x == w or y == h: return 0 if (x+y) % 2 == 0: # first res = max(dfs(x+1, y) - SH[y][x], dfs(x, y+1) + SW[y][x]) else: # second res = min(dfs(x+1, y) - SH[y][x], dfs(x, y+1) + SW[y][x]) memo[x, y] = res return res print(abs(dfs(0, 0)))
s353565584
p00350
u133119785
1499510137
Python
Python3
py
Runtime Error
0
0
586
n = int(raw_input()) u = raw_input() q = int(raw_input()) def cmd_set(q,u): x = int(q[0]) y = int(q[1]) z = q[2] h = u[:x-1] t = u[y:] zz= z*(y-x+1) return h+zz+t def cmd_comp(q, u): a = int(q[0]) b = int(q[1]) c = int(q[2]) d = int(q[3]) s = u[a-1:b] t = u[c-1:d] if s < t: print "s" elif s > t: print "t" else: print "e" for i in range(q): q = raw_input().split() cmd = q[0] q.pop(0) if cmd == 'comp': cmd_comp(q, u) elif cmd == 'set': u = cmd_set(q, u)
s541729624
p00352
u116766943
1506238397
Python
Python3
py
Runtime Error
0
0
38
a,b = map(int,input()) print((a+b)//2)
s307783708
p00352
u855989123
1513681020
Python
Python
py
Runtime Error
0
0
48
l = raw_input().split() print (l[0] + l[1] / 2)
s736629206
p00352
u584779197
1514005353
Python
Python
py
Runtime Error
0
0
48
a,b=map(int,input().split()) print(int((a+b)/2))