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
s759270365
p03683
u293072892
1498509288
Python
Python (2.7.6)
py
Runtime Error
11
2568
433
N, M = (int(i) for i in input().split()) ans = 1 if N == (M + 1) or N == (M - 1): for n in range(1, N+1): ans *= n ans %= 1e9 + 7 for m in range(1, M+1): ans *= m ans %= 1e9 + 7 elif N == M: for n in range(1, N+1): ans *= n ans %= 1e9 + 7 for m in range(1...
s716409838
p03683
u293072892
1498509064
Python
Python (2.7.6)
py
Runtime Error
11
2692
989
l = input().split() N = l[0] M = l[1] ans = 1 # N = 100000 ...
s137245501
p03683
u293072892
1498508920
Python
Python (2.7.6)
py
Runtime Error
11
2692
689
l = raw_input().split() N = l[0] M = l[1] ans = 1 if N == (M + 1...
s070985941
p03683
u235539935
1498450390
Python
Python (2.7.6)
py
Runtime Error
24
3516
437
# coding:utf-8 n,m=map(int,raw_input().split()) def kaijo(n): if n==1: return 1 return n*kaijo(n-1) # 引数として、nかmのうちの小さい方の数字を受け取る def count(n,m): return kaijo(n)*kaijo(m) if n-m==-1 or n-m==1: result=count(n,m) amari=result%(10**9+7) print amari elif n-m==0: result=count(n,m) r...
s018134843
p03683
u235539935
1498449925
Python
Python (2.7.6)
py
Runtime Error
22
3516
385
# coding:utf-8 n,m=map(int,raw_input().split()) def kaijo(n): if n==1: return 1 return n*kaijo(n-1) # 引数として、nかmのうちの小さい方の数字を受け取る def count(n,m): return kaijo(n)*kaijo(m) if n-m==-1 or n-m==1: result=count(n,m) print result elif n-m==0: result=count(n,m) result*=2 print result ...
s607098232
p03683
u235539935
1498449785
Python
Python (2.7.6)
py
Runtime Error
23
3664
347
# coding:utf-8 n,m=map(int,raw_input().split()) def kaijo(n): if n==1: return 1 return n*kaijo(n-1) # 引数として、nかmのうちの小さい方の数字を受け取る def count(n,m): print kaijo(n)*kaijo(m) if n-m==-1 or n-m==1: count=count(n,m) elif n-m==0: count=count(n,m) count*=2 else: print "0"
s280198787
p03683
u735154525
1498435428
Python
Python (2.7.6)
py
Runtime Error
11
2692
418
#!/usr/bin/python # coding: UTF-8 import itertools dog = input() mon = input() n = dog + mon list_d = ["0"] * dog list_m = ["1"] * mon list_d.extend(list_m) p = list(itertools.permutations(list_d)) ans = 0 length = len(p) print length for i in range(length): for j in range(len(p[i]) - 1): if p[i][j...
s012848296
p03683
u059940903
1498433153
Python
Python (2.7.6)
py
Runtime Error
11
2696
1015
R, C, N = map(int, raw_input().split()) lines = [] for i in range(N): x, y, xx, yy = map(int, raw_input().split()) if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]): if x <= y: first = x+y else: first = (R*2 + C*2)-(x+y) if xx <= yy: second = xx+yy else: second = (R*2 + C*2)-(xx+...
s853793574
p03683
u054556734
1498426876
Python
Python (3.4.3)
py
Runtime Error
72
3984
189
n,m=map(int,input().split()) def fact(n): if n==1: return 1 return n*fact(n-1) if abs(n-m)>1: ans=0 elif n==m: ans=fact(n)**2*2 else: ans=fact(n)*fact(m) ans%=10**9+7 print(ans)
s827812541
p03683
u054556734
1498426453
Python
Python (3.4.3)
py
Runtime Error
72
3896
230
n,m=map(int,input().split()) def fact(n): if n==1: return 1 return n*fact(n-1) if abs(n-m)>1: ans=0 elif n==m: ans=(fact(n)%(10**9+7))**2*2 else: ans=(fact(n)%(10**9+7))*(fact(m)%(10**9+7)) ans=ans%(10**9+7) print(ans)
s788644031
p03683
u054556734
1498426170
Python
Python (3.4.3)
py
Runtime Error
17
3060
155
import math as m n,m=map(int,input().split()) if abs(n-m)>1: ans=0 elif n==m: ans=m.factorial(n)**2*2 else: ans=m.factorial(n)*m.factorial(m) print(ans)
s628564619
p03683
u054556734
1498426018
Python
Python (3.4.3)
py
Runtime Error
74
3896
175
n,m=map(int,input().split()) def fact(n): if n==1: return 1 return n*fact(n-1) if abs(n-m)>1: ans=0 elif n==m: ans=fact(n)**2*2 else: ans=fact(n)*fact(m) print(ans)
s937903470
p03683
u886790158
1498357482
Python
Python (3.4.3)
py
Runtime Error
2107
89788
349
import sys sys.setrecursionlimit(100000) d = 10**9 + 7 def factorial(n): if (n > 1): return (n % d) * factorial(n - 1) return 1 n, m = map(int, input().split()) if abs(n - m) <= 1: ans = (factorial(n) % d) * (factorial(m) % d) ans %= d if n == m: ans *= 2 # ans %= d pr...
s685794275
p03683
u777923818
1498357410
Python
Python (3.4.3)
py
Runtime Error
18
3192
1392
# -*- coding: utf-8 -*- from math import factorial N = int(input()) cities = [[int(m) for m in input().split()] for n in range(N)] def reasonable_way(A, B): A = list(sorted(set(A))) B = list(sorted(set(B))) a = 0 b = 0 cheap = 10**9 + 1 while a < len(A) and b < len(B): i...
s348839820
p03683
u104282757
1498356560
Python
Python (3.4.3)
py
Runtime Error
286
22932
789
# D import numpy as np N = int(input()) X = np.zeros(N, dtype=int) Y = np.zeros(N, dtype=int) for i in range(N): x, y = map(int, input().split()) X[i] = x Y[i] = y # edges X_s = np.argsort(X) Y_s = np.argsort(Y) edge_list = [] edge_weight = [] for i in range(N-1): edge_list.append([X_s[i], X_s[i+1]])...
s248253966
p03683
u886790158
1498354665
Python
Python (3.4.3)
py
Runtime Error
2106
89792
271
import sys sys.setrecursionlimit(100000) d = 10**9 + 7 def factorial(n): if (n > 1): return (n % d) * factorial(n-1) return 1 n, m = map(int, input().split()) ans = (factorial(n) % d) * (factorial(m) % d) ans %= d if n == m: ans *= 2 print(ans)
s160207053
p03683
u781758937
1498353854
Python
Python (3.4.3)
py
Runtime Error
702
5188
238
import math N, M = input().split() N = int(N) M = int(M) if abs(N - M) > 1: print(0) elif N == M: res = math.factorial(N) * math.factorial(M) * 2 else: res = math.factorial(N) * math.factorial(M) print(res % int(1e9 + 7))
s516624907
p03683
u346308892
1498353337
Python
Python (3.4.3)
py
Runtime Error
32
3064
394
def Factorial(integer) : global M product = 1 if integer == 0 : return 1 for num in range(1 ,integer + 1): product *= num product%=M return product d=sorted(list(map(int,input().split(" ")))) M=10**9+7 if abs(d[0]-d[1])>1: res=0 elif d[0]==d[1]: res=((Factorial(d[0])%M)*...
s693067236
p03683
u346308892
1498352939
Python
Python (3.4.3)
py
Runtime Error
72
3944
242
def kaijo(x): if x>1: return x*kaijo(x-1) return 1 d=sorted(list(map(int,input().split(" ")))) if abs(d[0]-d[1])>1: res=0 elif d[0]==d[1]: res=(kaijo(d[0])**2)*2 else: res=kaijo(d[1])*kaijo(d[0]) print(res)
s819060977
p03683
u854685751
1498352913
Python
Python (3.4.3)
py
Runtime Error
231
4036
238
from math import factorial N,M = map(int,input().split()) def foo(N,M): if N == M+1 or N+1 == M: tm = factorial(min(N,M)) return(tm*max(N,M)+tm) elif N==M: return(2*factorial(N)*2) else: return(0) print(foo(N,M)/(10**9+7))
s278127755
p03684
u884087839
1591064984
Python
Python (3.4.3)
py
Runtime Error
601
49320
3257
#!/usr/bin/env python3 import sys class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[...
s372303998
p03684
u884087839
1591064651
Python
Python (3.4.3)
py
Runtime Error
1122
72408
3292
#!/usr/bin/env python3 import sys class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[...
s106974601
p03684
u884087839
1591063768
Python
Python (3.4.3)
py
Runtime Error
1665
64624
3219
#!/usr/bin/env python3 import sys class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[...
s266399213
p03684
u884087839
1590881797
Python
Python (3.4.3)
py
Runtime Error
1611
62684
3266
#!/usr/bin/env python3 import sys class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[...
s098114705
p03684
u134238756
1570393308
Python
Python (3.4.3)
py
Runtime Error
1139
48708
597
N=int(input()) city=[0]*N for i in range(N): x,y=map(int,input().split()) city[i]=(i,x,y) city.sort(key=lambda x:x[1]) data=[(city[i][0],city[i+1][0],city[i+1][1]-city[i][1]) for i in range(N-1)] city.sort(key=lambda x:x[2]) data+=[(city[i][0],city[i+1][0],city[i+1][2]-city[i][2]) for i in range(N-1)] data.sort...
s928124955
p03684
u619819312
1568867560
Python
Python (3.4.3)
py
Runtime Error
1508
87984
645
from heapq import heappop,heappush n=int(input()) s=[] for i in range(n): s.append(list(map(int,input().split()))+[i]) x=sorted(s,key=lambda x:x[0]) y=sorted(s,key=lambda x:x[1]) t=[[]for i in range(n)] for i in range(1,n): t[x[i-1][2]].append([x[i][0]-x[i-1][0],x[i][2]]) t[x[i][2]].append([x[i][0]-x[i-1][0...
s950938124
p03684
u619819312
1568859955
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
139224
624
n=int(input()) s=[] for i in range(n): a,b=map(int,input().split()) s.append([a,b,i]) x=sorted(s) y=sorted(s,key=lambda x:x[1]) t=[] for i in range(1,n): t.append([x[i-1][2],x[i][2],x[i][0]-x[i-1][0]]) t.append([y[i-1][2],y[i][2],y[i][1]-y[i-1][1]]) t=sorted(t,key=lambda x:x[2]) d=[i for i in range(n+1)...
s706244548
p03684
u619819312
1568859899
Python
Python (3.4.3)
py
Runtime Error
2107
68524
635
n=int(input()) s=[] for i in range(n): a,b=map(int,input().split()) s.append([a,b,i]) x=sorted(s) y=sorted(s,key=lambda x:x[1]) print(x,y) t=[] for i in range(1,n): t.append([x[i-1][2],x[i][2],x[i][0]-x[i-1][0]]) t.append([y[i-1][2],y[i][2],y[i][1]-y[i-1][1]]) t=sorted(t,key=lambda x:x[2]) d=[i for i in...
s218645843
p03684
u231685196
1568440535
Python
Python (3.4.3)
py
Runtime Error
1653
55244
1626
class uf_tree(): def __init__(self,n): self.n = n self.par = [i for i in range(n)] def indep(self): dep =0 for i in range(self.n): if i == self.par[i]: dep += 1 return dep def unite(self,child,mas): if self.root(child) == sel...
s254549137
p03684
u231685196
1568440424
Python
Python (3.4.3)
py
Runtime Error
1757
55256
1685
class uf_tree(): def __init__(self,n): self.n = n self.par = [i for i in range(n)] def indep(self): dep =0 for i in range(self.n): if i == self.par[i]: dep += 1 return dep def unite(self,child,mas): if self.root(child) == sel...
s798326241
p03684
u865741247
1562642216
Python
PyPy3 (2.4.0)
py
Runtime Error
624
66520
2180
import heapq import collections import heapq def input_as_int(): return list(map(int,input().split())) def get_comb(n): # n C n まで fac = get_fact(n) com = [["error" for _ in range(n+1)] for _ in range (n + 1)] for i in range(n + 1): for j in range(i + 1): if i >= j: ...
s085930186
p03684
u171366497
1559672935
Python
Python (3.4.3)
py
Runtime Error
1250
47596
756
N=int(input()) city=[0]*N for i in range(N): x,y=map(int,input().split()) city[i]=(i,x,y) city.sort(key=lambda x:x[1]) data=[(city[i][0],city[i+1][0],city[i+1][1]-city[i][1]) for i in range(N-1)] city.sort(key=lambda x:x[2]) data+=[(city[i][0],city[i+1][0],city[i+1][2]-city[i][2]) for i in range(N-1)] data.sort...
s100483012
p03684
u278479217
1529800030
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
2119
#!/usr/bin/env python3 import sys from typing import List, Tuple, Dict def debug(*args): print(*args, file=sys.stderr) def exit(): sys.exit(0) class UnionFind: def __init__(self, N): # type: (int) -> None self.N = N self.parent = list(range(N)) # type: List[int] def root(self, x): ...
s189977554
p03684
u059586440
1522364929
Python
Python (3.4.3)
py
Runtime Error
1843
58296
850
n = int(input()) xs = [] ys = [] for i in range(n): x, y = map(int, input().split()) xs.append((x, i)) ys.append((y, i)) xs.sort() ys.sort() es = [] for i in range(n-1): es.append((xs[i+1][0] - xs[i][0], xs[i][1], xs[i+1][1])) es.append((ys[i+1][0] - ys[i][0], ys[i][1], ys[i+1][1])) es.sort() ...
s512331824
p03684
u674569298
1507999440
Python
Python (3.4.3)
py
Runtime Error
1184
39880
916
n = int(input()) a = []*n for i in range(n): x,y = map(int,input().split()) a.append([x,y,i]) e = [[None for i in range(3)]for j in range(n)] a.sort() for i in range(n-1): idx1 = a[i][2] idx2 = a[i+1][2] c = abs(a[i][0]-a[i+1][0]) if e[idx1][2] is not None: if e[idx1][2] > c: ...
s705996984
p03684
u674569298
1507997419
Python
Python (3.4.3)
py
Runtime Error
1315
38584
714
n = int(input()) a = []*n for i in range(n): x,y = map(int,input().split()) a.append([x,y,i]) e = [0]*n a.sort() for i in range(n-1): idx1 = a[i][2] idx2 = a[i+1][2] c = abs(a[i][0]-a[i+1][0]) e[idx1] = [idx1,idx2,c] a.sort(key=lambda a:a[1]) for i in range(n-1): idx1 = a[i][2] idx2...
s432113292
p03684
u830580569
1501626854
Python
Python (2.7.6)
py
Runtime Error
91
10524
1087
import numpy as np from collections import defaultdict import networkx as nx def build_road_3(): n = int(raw_input()) cords = [] for i in range(n): cords.append([int(e) for e in raw_input().split(" ")]) cords = np.array(cords) x_cord = cords[:, 0] y_cord = cords[:, 1] # print x_cord sorted_indecies_x = np.a...
s479806035
p03684
u830580569
1501625518
Python
Python (2.7.6)
py
Runtime Error
434
32976
1101
import numpy as np from scipy.sparse import csr_matrix from collections import defaultdict from scipy.sparse.csgraph import minimum_spanning_tree def build_road_2(): n = int(raw_input()) cords = [] for i in range(n): cords.append([int(e) for e in raw_input().split(" ")]) cords = np.array(cords) x_cord = cords[:...
s793192099
p03684
u830580569
1501622582
Python
Python (2.7.6)
py
Runtime Error
628
43292
645
import numpy as np from scipy.sparse import csr_matrix def build_road(): n = int(raw_input()) cords = [] for i in range(n): cords.append([int(e) for e in raw_input().split(" ")]) # print cords mutual_distance = np.zeros((n, n)) # print mutual_distance for i in range(n): for j in range(n): mutual_distance...
s756346052
p03684
u830580569
1501621706
Python
Python (2.7.6)
py
Runtime Error
627
44568
561
from scipy.sparse.csgraph import minimum_spanning_tree import numpy as np def build_road(): n = int(raw_input()) cords = [] for i in range(n): cords.append([int(e) for e in raw_input().split(" ")]) # print cords mutual_distance = np.zeros((n, n)) # print mutual_distance for i in range(n): for j in range(n):...
s653455421
p03684
u830580569
1501621463
Python
Python (2.7.6)
py
Runtime Error
554
40296
562
import numpy as np def build_road(): n = int(raw_input()) cords = [] for i in range(n): cords.append([int(e) for e in raw_input().split(" ")]) # print cords mutual_distance = np.zeros((n, n)) # print mutual_distance for i in range(n): for j in range(n): mutual_distance[i][j] = \ min(abs(cords[i][0]-c...
s119362788
p03684
u835482198
1500833287
Python
Python (3.4.3)
py
Runtime Error
17
2940
1170
s UnionFind(object): def __init__(self, n): self.n = n self.par = list(range(n)) self.rank = [1] * n def is_same(self, a, b): return self.root(a) == self.root(b) def root(self, x): if self.par[x] == x: return x self.par[x] = self.root(self.par[x...
s198084605
p03684
u594567187
1498800251
Python
Python (3.4.3)
py
Runtime Error
1055
31524
2246
length = int(input()) target = [] for i in range(length): a,b = (int(n) for n in input().split(" ")) target.append([a,b,i]) target.sort() bef_x,bef_y = -1,-1 for i in range(length-1,-1,-1): if bef_x == target[i][0] and bef_y == target[i][1]: target.pop(i) length -= 1 else: bef_x ...
s337473723
p03684
u033407970
1498714444
Python
Python (3.4.3)
py
Runtime Error
17
2940
2649
#include <iostream> #include <vector> #include <tuple> #include <algorithm> using namespace std; int Nmax = 100; vector <tuple <int,int,int>> xbe; // x,y,index vector <tuple <int,int,int>> ybe; // y,x,index int n; int counter = 0; int result = 0; struct graph{ int name = 0; vector <pair <int ,int>> nodes; }; ve...
s517295131
p03684
u177481830
1498522587
Python
Python (3.4.3)
py
Runtime Error
460
14044
763
import numpy as np N=int(input()) pos_mat=np.zeros((N,2)) for i in range(N): buf=input().split() pos_mat[i,0]=int(buf[0]) pos_mat[i,1]=int(buf[1]) cost_mat=np.zeros((N,N)) for u in range(N): for v in range(u+1, N): cost_mat[u,v]=min(abs(pos_mat[u, 0]-pos_mat[v,0]), abs(pos_mat[u, 1]-pos_mat[v,...
s777687561
p03684
u177481830
1498522184
Python
Python (3.4.3)
py
Runtime Error
470
13960
758
import numpy as np N=int(input()) pos_mat=np.zeros((N,2)) for i in range(N): buf=input().split() pos_mat[i,0]=int(buf[0]) pos_mat[i,1]=int(buf[1]) cost_mat=np.zeros((N,N)) for u in range(N): for v in range(u+1, N): cost_mat[u,v]=min(abs(pos_mat[u, 0]-pos_mat[v,0]), abs(pos_mat[u, 1]-pos_ma...
s806969425
p03684
u458486313
1498517052
Python
Python (3.4.3)
py
Runtime Error
1105
50904
1157
import sys stdin = sys.stdin ns = lambda: stdin.readline() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) class UnionFind: def __init__(self, size): self.table = [-1 for _ in range(size)] def find(self, x): if self.table[x] < 0: return x else...
s283613560
p03684
u177481830
1498500838
Python
Python (3.4.3)
py
Runtime Error
632
22968
777
import numpy as np from heapq import * N=int(input()) pos_mat=np.zeros((N,2)) for i in range(N): buf=input().split() pos_mat[i,0]=int(buf[0]) pos_mat[i,1]=int(buf[1]) cost_mat=np.zeros((N,N)) for u in range(N): for v in range(u+1, N): cost_mat[u,v]=min(abs(pos_mat[u, 0]-pos_mat[v,0]), abs(...
s606526508
p03684
u765237551
1498434910
Python
Python (3.4.3)
py
Runtime Error
18
3064
1000
class UnionFind: def __init__(self, size): self.parents = list(range(size)) def find(self, i): ret = i path = [] while self.parents[ret]!=ret: path.append(ret) ret = self.parents[ret] for p in path: self.parents[p] = ret return...
s799959648
p03684
u104282757
1498358561
Python
Python (3.4.3)
py
Runtime Error
1347
75548
1321
# D import numpy as np N = int(input()) X = np.zeros(N, dtype=int) Y = np.zeros(N, dtype=int) for i in range(N): x, y = map(int, input().split()) X[i] = x Y[i] = y # edges X_s = np.argsort(X) Y_s = np.argsort(Y) edge_list = [] edge_weight = [] for i in range(N-1): edge_list.append([X_s[i], X_s[i+1]])...
s380072078
p03684
u104282757
1498358382
Python
Python (3.4.3)
py
Runtime Error
1391
78600
1255
# D import numpy as np N = int(input()) X = np.zeros(N, dtype=int) Y = np.zeros(N, dtype=int) for i in range(N): x, y = map(int, input().split()) X[i] = x Y[i] = y # edges X_s = np.argsort(X) Y_s = np.argsort(Y) edge_list = [] edge_weight = [] for i in range(N-1): edge_list.append([X_s[i], X_s[i+1]])...
s309252473
p03684
u229757277
1498357826
Python
Python (3.4.3)
py
Runtime Error
18
2940
349
vs = $stdin.each_line.drop(1).map { |row| row.split(' ').map { |c| c.to_i } }.map.with_index do |row, i| [i, row[0], row[1]] end v_new = [] v_new.push(vs.pop) e_cost_sum = 0 while !vs.empty? do v = vs.pop edge_min = v_new.map { |u| [(u[1] - v[1]).abs, (u[2] - v[2]).abs].min }.min v_new.push(v) e_cost_sum += ...
s865676957
p03684
u725662235
1498357509
Python
Python (2.7.6)
py
Runtime Error
1486
67140
692
from collections import defaultdict n = input() cs = [] for i in xrange(n): xi, yi = map(int, raw_input().split()) cs.append((i, xi, yi)) csx = sorted(cs, key=lambda c: c[1]) csy = sorted(cs, key=lambda c: c[2]) xd = [] yd = [] for i in xrange(n-1): xd.append((csx[i+1][1] - csx[i][1], (csx[i], csx[i+1])...
s524785096
p03684
u886790158
1498354625
Python
Python (3.4.3)
py
Runtime Error
18
3060
271
import sys sys.setrecursionlimit(100000) d = 10**9 + 7 def factorial(n): if (n > 1): return (n % d) * factorial(n-1) return 1 n, m = map(int, input().split()) ans = (factorial(n) % d) * (factorial(m) % d) ans %= d if n == m: ans *= 2 print(ans)
s757604564
p03685
u143509139
1594350471
Python
PyPy3 (7.3.0)
py
Runtime Error
698
126516
1199
r, c, n = map(int, input().split()) l = [] for i in range(n): x1, y1, x2, y2 = map(int, input().split()) if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c): if x1 == 0: l.append((y1, i)) elif y1 == c: l.append((c + x1, i)) ...
s364643512
p03685
u794173881
1574138644
Python
PyPy3 (2.4.0)
py
Runtime Error
3081
2069248
1977
import random import sys input = sys.stdin.readline class BIT(): """区間加算、一点取得クエリをそれぞれO(logN)で答える add: 区間[l, r)にvalを加える get_val: i番目の値を求める i, l, rは0-indexed """ def __init__(self, n): self.n = n self.bit = [0] * (n + 1) def _add(self, i, val): while i > 0: ...
s939462741
p03685
u794173881
1574138212
Python
PyPy3 (2.4.0)
py
Runtime Error
2184
2063880
1566
import random import sys input = sys.stdin.readline class BIT(): """区間加算、一点取得クエリをそれぞれO(logN)で答える add: 区間[l, r)にvalを加える get_val: i番目の値を求める i, l, rは0-indexed """ def __init__(self, n): self.n = n self.bit = [0] * (n + 1) def _add(self, i, val): while i > 0: ...
s730383526
p03685
u794173881
1574138084
Python
PyPy3 (2.4.0)
py
Runtime Error
2878
2070532
1514
import random class BIT(): """区間加算、一点取得クエリをそれぞれO(logN)で答える add: 区間[l, r)にvalを加える get_val: i番目の値を求める i, l, rは0-indexed """ def __init__(self, n): self.n = n self.bit = [0] * (n + 1) def _add(self, i, val): while i > 0: self.bit[i] += val i -=...
s108008447
p03685
u892251744
1573442815
Python
PyPy3 (2.4.0)
py
Runtime Error
485
93472
1234
import sys input = sys.stdin.buffer.readline R, C, N = map(int, input().split()) class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(s...
s889696034
p03685
u892251744
1573442803
Python
Python (3.4.3)
py
Runtime Error
559
44648
1234
import sys input = sys.stdin.buffer.readline R, C, N = map(int, input().split()) class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(s...
s275027535
p03685
u980322611
1569451325
Python
PyPy3 (2.4.0)
py
Runtime Error
613
74844
1369
def main(): import sys input = sys.stdin.readline R,C,N = map(int,input().split()) P = [] X = {0,R} Y = {0,C} M = 0 for i in range(N): x1,y1,x2,y2 = map(int,input().split()) if (x1 in X or y1 in Y) and (x2 in X or y2 in Y): if y1==0: L1 =...
s873442383
p03685
u980322611
1569451197
Python
PyPy3 (2.4.0)
py
Runtime Error
628
74972
1369
def main(): import sys input = sys.stdin.readline R,C,N = map(int,input().split()) P = [] X = {0,R} Y = {0,C} M = 0 for i in range(N): x1,y1,x2,y2 = map(int,input().split()) if (x1 in X or y1 in Y) and (x2 in X or y2 in Y): if y1==0: L1 =...
s788635789
p03685
u980322611
1569450839
Python
Python (3.4.3)
py
Runtime Error
448
24848
1352
def main(): import sys input = sys.stdin.readline R,C,N = map(int,input().split()) P = [] X = {0,R} Y = {0,C} M = 0 for i in range(N): x1,y1,x2,y2 = map(int,input().split()) if (x1 in X or y1 in Y) and (x2 in X or y2 in Y): if y1==0: L1 =...
s631603326
p03685
u980322611
1569450247
Python
PyPy3 (2.4.0)
py
Runtime Error
611
74844
1352
def main(): import sys input = sys.stdin.readline R,C,N = map(int,input().split()) P = [] X = {0,R} Y = {0,C} M = 0 for i in range(N): x1,y1,x2,y2 = map(int,input().split()) if (x1 in X or y1 in Y) and (x2 in X or y2 in Y): if y1==0: L1 =...
s339395069
p03685
u980322611
1569449814
Python
PyPy3 (2.4.0)
py
Runtime Error
610
74972
1390
def main(): import sys input = sys.stdin.readline R,C,N = map(int,input().split()) P = [] X = {0,R} Y = {0,C} M = 0 for i in range(N): x1,y1,x2,y2 = map(int,input().split()) if (x1 in X or y1 in Y) and (x2 in X or y2 in Y): M += 1 if y1==0: ...
s579477166
p03685
u751488284
1555646697
Python
Python (3.4.3)
py
Runtime Error
19
3064
2445
#include "bits/stdc++.h" #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i) #define BUGAVOID(x) x #define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__)) #define sz(c) (int)(c.size()) #define all(c) c.begin(),c....
s716480739
p03685
u476418095
1543464576
Python
Python (3.4.3)
py
Runtime Error
18
3060
278
import math n,m = list(map(int, input().split())) n, m = max(n,m), min(n, m) if n - m > 1: ans = 0 elif n - m == 1: k = math.factorial(m) % (10**9 + 7) ans = k*k*n % (10**9 + 7) else: k = math.factorial(m) % (10**9 + 7) ans = k*k*2 % (10**9 + 7) print(ans)
s891762984
p03685
u329749432
1499907214
Python
Python (3.4.3)
py
Runtime Error
2107
3188
877
import sys R,C,N = [int(i) for i in input().split()] lec = [[0] * (C+1) for i in range(R+1)] x1 = [0]*N x2 = [0]*N y1 = [0]*N y2 = [0]*N ngx1 = [] ngx2 = [] ngy1 = [] ngy2 = [] for i in range(0,N): x1[i], y1[i], x2[i], y2[i] = [int(i) for i in input().split()] for i in range(0,N): if (x1[i] in [0,R] or y1[i...
s280369100
p03685
u059940903
1498437765
Python
Python (2.7.6)
py
Runtime Error
2104
8948
1284
R, C, N = map(int, raw_input().split()) false_flag = False lines = [] for i in range(N): if false_flag: x = raw_input() continue else: x, y, xx, yy = map(int, raw_input().split()) if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]): if x == 0 or y == C: first = x+y else: first = (R*2 ...
s651549507
p03685
u059940903
1498427185
Python
Python (2.7.6)
py
Runtime Error
2617
1052116
644
R, C, N = map(int, raw_input().split()) line = [-1 for _ in range(R*2 + C*2)] for i in range(N): x, y, xx, yy = map(int, raw_input().split()) if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]): line_pos = 0 if x <= y: line_pos = x+y else: line_pos = (R*2 + C*2)-(x+y) line[line_pos] = i ...
s890356579
p03685
u059940903
1498426736
Python
Python (2.7.6)
py
Runtime Error
2505
1053248
644
R, C, N = map(int, raw_input().split()) line = [-1 for _ in range(R*2 + C*2)] for i in range(N): x, y, xx, yy = map(int, raw_input().split()) if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]): line_pos = 0 if x <= y: line_pos = x+y else: line_pos = (R*2 + C*2)-(x+y) line[line_pos] = i ...
s312002604
p03685
u243492642
1498367496
Python
Python (3.4.3)
py
Runtime Error
17
3064
1841
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s821253565
p03685
u243492642
1498367242
Python
Python (3.4.3)
py
Runtime Error
503
40156
1838
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s486106722
p03685
u243492642
1498367168
Python
Python (3.4.3)
py
Runtime Error
500
40152
1838
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s719158017
p03685
u243492642
1498367085
Python
Python (3.4.3)
py
Runtime Error
506
40152
1901
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s163759233
p03685
u243492642
1498362375
Python
Python (3.4.3)
py
Runtime Error
602
49468
1814
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s170890422
p03686
u488401358
1597723166
Python
PyPy3 (7.3.0)
py
Runtime Error
87
74704
6242
from collections import deque class LazySegtree(): def __init__(self,n,init_val,merge_func,ide_ele): self.n=n self.ide_ele=ide_ele self.merge_func=merge_func self.val=[0 for i in range(1<<n)] self.merge=[0 for i in range(1<<n)] self.parent=[-1 for i in range(1<<n)] ...
s392959196
p03686
u488401358
1597723113
Python
PyPy3 (7.3.0)
py
Runtime Error
1033
151472
6276
from collections import deque class LazySegtree(): def __init__(self,n,init_val,merge_func,ide_ele): self.n=n self.ide_ele=ide_ele self.merge_func=merge_func self.val=[0 for i in range(1<<n)] self.merge=[0 for i in range(1<<n)] self.parent=[-1 for i in range(1<<n)] ...
s688886827
p03686
u875291233
1594457894
Python
PyPy3 (7.3.0)
py
Runtime Error
2227
606572
2338
# https://tjkendev.github.io/procon-library/python/max_flow/dinic.html # Dinic's algorithm from collections import deque class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backwa...
s348864777
p03687
u465699806
1594138225
Python
PyPy3 (7.3.0)
py
Runtime Error
95
74708
12481
#ifndef TEMPLATE_HPP #define TEMPLATE_HPP #include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <set> #include <string> #include <tuple> #inc...
s637425455
p03687
u039623862
1593645484
Python
Python (3.8.2)
py
Runtime Error
57
9856
594
import string s = input() n = len(s) min_cnt = float('inf') for c in string.ascii_lowercase: if c not in s: continue cnt = 0 s_ = s[:] while s_: is_same = True for d in s_: if d != c: is_same = False break if is_same: ...
s006635790
p03687
u771007149
1593283521
Python
Python (3.8.2)
py
Runtime Error
62
9188
549
#AGC016-A from collections import Counter s = input() alphabet = "abcdefghijklmnopqrstuvwxyz" cnt = 0 result = [] for i in alphabet: s_tmp = s cnt = 0 for k in range(len(s_tmp)): s_new= "" for j in range(len(s_tmp)-1): if s_tmp[j] == i or s_tmp[j+1] == i: s_new ...
s270321475
p03687
u760636024
1591222557
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38384
184
S = list(input()) res = len(S) kind_all = set(S) for i in kind_all: temp = S.split(i) cnt = 0 for j in temp: cnt = max(cnt,len(j)) res = min(res,cnt) print(res)
s286421990
p03687
u593567568
1590764742
Python
Python (3.4.3)
py
Runtime Error
21
3316
592
from collections import Counter S = input() uni_s = list(set(list(S))) ans = len(S) - 1 # -1,1 for s in uni_s: L = len(S) T = list(S) all_same = [s == t for t in S] cnt = 0 while not all(all_same): newT = [False] * (L-1) for i in range(L): t = T[i] if s == t: newT[i] = t ...
s060560160
p03687
u241159583
1588044929
Python
Python (3.4.3)
py
Runtime Error
22
3316
586
from collections import Counter s = input() if len(set(s)) ==1: print(0) exit() if len(set(s)) != len(s): cs = Counter(s) I = 0 n = cs.most_common()[0][1] ans = 100 while cs.most_common()[I][1] == n: id = [x for x, v in enumerate(s) if v == cs.most_common()[I][0]] x = 0 ...
s493817865
p03687
u241159583
1588042122
Python
Python (3.4.3)
py
Runtime Error
22
3316
509
from collections import Counter s = input() if len(set(s)) ==1: print(0) exit() if len(set(s)) != len(s): cs = Counter(s) I = 0 n = cs.most_common()[0][1] ans = 100 while cs.most_common()[I][1] == n: id = [x for x, v in enumerate(s) if v == cs.most_common()[I][0]] x = 0 ...
s820348540
p03687
u477320129
1587533978
Python
Python (3.4.3)
py
Runtime Error
18
3064
995
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, a: "List[int]"): from collections import Counter ma, mi = max(a), min(a) if ma >= N or mi < 1: raise if ma - mi > 1: return False if ma == mi: return ma == N - 1 or 2 * ma ...
s056644039
p03687
u757584836
1586396388
Python
Python (3.4.3)
py
Runtime Error
17
2940
394
s = input() c = [0]*26 v = [] m = 0 for i in range(0, len(s)): c[(int)s[i]-'a'] += 1 for i in range(0, 26): m = max(m, c[i]) for i in range(0, 26): if c[i] == m: v.append((char)'a'+i) a = 10000 for i in range(0, len(c)): n = 0 t = 0 for j in range(0, len(s)): if s[j] != v[i]: t += 1 else: ...
s506128915
p03687
u022979415
1584724428
Python
Python (3.4.3)
py
Runtime Error
19
3188
1015
def main(): word = input() count = {} for w in word: if w in count: count[w] += 1 else: count[w] = 1 count = sorted(count.items(), key=lambda x: x[1]) target_list = [] if count[-1][1] == 1: target_list.append(word[len(word) // 2]) else: ...
s484402058
p03687
u788337030
1579837436
Python
Python (3.4.3)
py
Runtime Error
18
3064
444
n = int(input()) a = list(map(int, input().split())) fewer = 0 m = min(a) M = max(a) if M - m >= 2: print("No") else: if m == M: if m == n-1: print("Yes") else: if m <= n/2: print("Yes") else: print("No") else: for i in range(n): if a[i] == m: fewer += 1...
s517012773
p03687
u263830634
1565730205
Python
Python (3.4.3)
py
Runtime Error
17
3064
466
s = list(input()) N = len(s) if N == 1: print (0) exit() ans = 99 for i in range(1, N): #残す文字数 tmp = 0 #残す文字以外の最大連続数 count = 0 #残す文字以外が何文字続いているかをカウント for j in range(i): if s[j] == s[i]: tmp = max(tmp, count) count = 0 else: count += 1 tmp ...
s846543027
p03687
u921773161
1565437898
Python
Python (3.4.3)
py
Runtime Error
39
5276
250
import statistics import math l = list(input()) mode = statistics.mode(l) mode = l.count(mode) check = 0 """ mode * 2 ** i > len(l) - i """ for i in range(len(l)): if mode * (2**i) >= len(l) -i : ans = i break print(ans)
s392724576
p03687
u227082700
1562528551
Python
Python (3.4.3)
py
Runtime Error
17
3064
210
s=input() ans=len(s) def a(s,t): ss="" a=0 b=False for i in range(len(s)-1): if s[i]!=t!=s[i+1]:ss+=s[i];b=True else:ss+=t if b:a=a(ss,t) return a+1 for i in s:ans=min(ans,a(s,i)) print(ans)
s852482623
p03687
u163320134
1556865135
Python
Python (3.4.3)
py
Runtime Error
17
2940
336
check='abcdefghijklmnopqrstuvwxyz' s=input() l=len(s) pos=[0]*26 for i in range(l): for j in range(26): if s[i]==check[j]: pos[j].append(i) ans=10**9: for i in range(26): tmp=0 for j in range(len(pos[i])-1): tmp=max(tmp,pos[i][j+1]-pos[i][j]) tmp=max(tmp,(l-1)-pos[i][-1]) ans=min(ans...
s943445948
p03687
u798129018
1556432649
Python
PyPy3 (2.4.0)
py
Runtime Error
173
39764
529
import itertools import math from collections import deque from collections import defaultdict from itertools import permutations import heapq import bisect from scipy.sparse.csgraph import floyd_warshall as wf from collections import Counter from itertools import* from bisect import bisect_left,bisect_right from colle...
s908354532
p03687
u798129018
1556431977
Python
PyPy3 (2.4.0)
py
Runtime Error
189
38256
312
s = input() A = set() ans = inf for i in range(len(s)): A.add(s[i]) for v in A: cur = 0 vstep = 0 for i in range(len(s)): if s[i] != v: cur += 1 else: vstep = max(cur,vstep) cur = 0 vstep = max(cur,vstep) ans = min(ans,vstep) print(ans)
s713923091
p03687
u619819312
1550415412
Python
Python (3.4.3)
py
Runtime Error
18
3064
471
s=list(input()) p=[chr(ord("a")+i)for i in range(26)] q=100 if len(list(set(d)))==1: print(0) else: for i in range(26): t=p[i] d=s[:] c=0 while len(d)>0: c+=1 for j in range(len(d)-1): if d[j]==t or d[j+1]==t: d[j]=t ...
s092047056
p03687
u624475441
1545593919
Python
Python (3.4.3)
py
Runtime Error
18
2940
135
S = input() ans = min(max(map(len, S.split(c))) for c in [chr(i + 97) for i in range(26)] if c not in S) print(ans)
s027369558
p03687
u624475441
1545593862
Python
Python (3.4.3)
py
Runtime Error
18
2940
136
S = input() ans = min(max(map(len, S.split(c))) for c in [chr(i + 97) for i in range(26)] if c not in S)) print(ans)
s857503330
p03687
u879870653
1541469894
Python
Python (3.4.3)
py
Runtime Error
17
2940
198
S = input() P = list(set(P)) ANS = [] for i in range(len(P)) : T = list(S.split(P[i])) U = [] for j in range(len(T)) : U.append(len(T[j])) ANS.append(max(U)) print(min(ANS))