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
s003313329
p03504
u768951609
1512358761
Python
Python (2.7.6)
py
Runtime Error
473
18780
310
N,C=map(int,raw_input().split(' ')) table=[0]*10**5 end=[[] for i in range(10**5)] for _ in range(N): s,t,c=map(int,raw_input().split(' ')) end[t].append(c) i=s if not (c in end[i] or end[i]==[]) and i!=0: table[i-1]+=1 table[i]+=1 i+=1 while i<t: table[i]+=1 i+=1 print max(table)
s670723971
p03504
u768951609
1512358685
Python
Python (2.7.6)
py
Runtime Error
473
18780
301
N,C=map(int,raw_input().split(' ')) table=[0]*10**5 end=[[] for i in range(10**5)] for _ in range(N): s,t,c=map(int,raw_input().split(' ')) end[t].append(c) i=s if not (c in end[i] or end[i]==[]): table[i-1]+=1 table[i]+=1 i+=1 while i<t: table[i]+=1 i+=1 print max(table)
s266557550
p03504
u677421794
1512358542
Python
Python (3.4.3)
py
Runtime Error
2107
51636
588
# -*- coding: utf-8 -*- N, C = list(map(int,input().split())) channel = [[0 for i in range(2*N+7)] for j in range(C)] arr = [0 for i in range(2*N+7)] for i in range(N): s, t, c = list(map(int,input().split())) channel[c-1][2*s-1] = 1 channel[c-1][2*t] = -1 for i in range(2*N+6): for j in range(...
s490910879
p03504
u639444166
1512358116
Python
Python (2.7.6)
py
Runtime Error
281
22212
348
#!usr/bim/python #! -*- coding: utf-8 -*- import numpy as np nc = raw_input() nc = nc.split() n,c = map(int,nc) tt = np.zeros([(10**2),c],int) for i in range(n): stc = raw_input() stc = stc.split() s,t,c = map(int,stc) j = s while j <= t: tt[j-1][c-1] = 1 j += 1 ans = np.max(np....
s765383626
p03504
u498401785
1512357013
Python
Python (3.4.3)
py
Runtime Error
572
22108
518
n, c_no = list(map(int, input().split())) s, t = [], [] c = [] for i in range(c_no): c.append([]) for i in range(n): stc = list(map(int, input().split())) c[stc[2] - 1].append([stc[0], stc[1]]) a = 10**5*[0] for i in range(len(c)): tmp = 10**5*[0] c[i].sort() for j in range(len(c[i])): f...
s543291182
p03504
u136413513
1512356894
Python
Python (3.4.3)
py
Runtime Error
353
12508
372
N, C = map(int, input().split(' ')) ss = [0 ] * N tt = [0 ] * N cc = [0 ] * N for n in range(N): ss[n], tt[n], cc[n] = map(int, input().split(' ')) timeline = [0] * (10 ** 5) for n in range(N): timeline[ss[n] - 1] += 1 timeline[tt[n]] -= 1 max_ = 0 stack = 0 for t in timeline: stack += t if sta...
s169616430
p03504
u612721349
1512356640
Python
Python (3.4.3)
py
Runtime Error
554
29216
1111
#!/usr/bin/env python # -*- coding: utf-8 -*- def solve(): n, c = map(int, input().split()) c_info = [[int(i) for i in input().split()] for _ in range(n)] c_info.sort(key=lambda x: (x[2], x[0])) info = [] cnt = 0 while cnt < n: if cnt == n - 1: info.append(c_info[cnt]) ...
s038941346
p03504
u339443002
1512356390
Python
Python (2.7.6)
py
Runtime Error
11
2568
480
from heapq import heappop as pop, heappush as push peak, curr = 0, 0 stuff = [] n, c = map(int, raw_input().split()) for _ in xrange(n): stuff.append(map(float, raw_input().split())) stuff = sorted(stuff) has_camera = [False] * c ending = [] for st, end, ch in stuff: while ending[0][0] <= st - 0.5: _, cch ...
s815647816
p03504
u226155577
1512356308
Python
Python (3.4.3)
py
Runtime Error
558
23092
555
N, C = map(int, input().split()) su = [0]*(10**5+1) Q = [[] for i in range(C)] for i in range(N): s, t, c = map(int, input().split()) Q[c-1].append([s, t]) R = [[] for i in range(C)] for i in range(C): q = Q[i]; q.sort() r = R[i] r.append(q[0]) for j in range(1, len(q)): if r[-1][1] == ...
s237810422
p03504
u341855122
1512355566
Python
Python (3.4.3)
py
Runtime Error
486
3928
256
n,c = map(int,input().split()) table = [0 for i in range(100000)] count = 0 while(count < n): count += 1 s,t,c2 = map(int,input().split()) cou2 = s while(cou2 <= t): table[cou2] = table[cou2]+ 1 cou2 += 1 print(max(table))
s006294669
p03504
u341855122
1512355367
Python
Python (3.4.3)
py
Runtime Error
1787
25608
283
import numpy as np n,c = map(int,input().split()) table = list(np.zeros(100000,dtype="int")) count = 0 while(count < n): count += 1 s,t,c2 = map(int,input().split()) cou2 = s while(cou2 <= t): table[cou2] = table[cou2]+ 1 cou2 += 1 print(max(table))
s973039107
p03504
u341855122
1512355152
Python
Python (3.4.3)
py
Runtime Error
998
25336
282
import numpy as np n,c = map(int,input().split()) table = list(np.zeros(100000,dtype="int")) count = 0 while(count < c): count += 1 s,t,c = map(int,input().split()) cou2 = s while(cou2 <= t): table[cou2] = table[cou2]+ 1 cou2 += 1 print(max(table))
s714917342
p03505
u970308980
1584914755
Python
Python (3.4.3)
py
Runtime Error
17
3060
198
ceil = lambda a, b: -(-a // b) K, A, B = map(int, input().split()) if A >= K: print(1) exit() p = A - B if p < 0: print(-1) exit() ans = 1 ans += ceil(K - A, A - B) * 2 print(ans)
s411471227
p03505
u970308980
1584833889
Python
Python (3.4.3)
py
Runtime Error
17
2940
198
ceil = lambda a, b: -(-a // b) K, A, B = map(int, input().split()) if A >= K: print(1) exit() p = A - B if p < 0: print(-1) exit() ans = 1 ans += ceil(K - A, A - B) * 2 print(ans)
s288525941
p03505
u619819312
1577777346
Python
Python (3.4.3)
py
Runtime Error
17
3064
308
from itertools import accumulate as ac n=int(input()) a,b=[],[] for i in range(n): x,s=map(int,input().split()) a.append(x) b.append(s) r=[0]+list(ac(b)) l=r[:] for i in range(n): r[i]+=-a[i] l[i+1]+=-a[i] q,d=r[0],0 for i in range(1,n+1): d=max(l[i]-q,d) q=min(q,r[i-1]) print(d)
s813764225
p03505
u936985471
1575299181
Python
Python (3.4.3)
py
Runtime Error
17
2940
134
K,A,B=map(int,input().split()) if A>=K: print(1) elif A<B: print(-1) else: bef=((K-A)//(A-B))+((K-A)%(A-B)!=0) print(2*bef+1)
s804541512
p03505
u223904637
1574055866
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
99
k,a,b=map(int,input().split()) z=a-b if z<=0 and a<k: print(-1) exit() print(-(k-a)//z*2+1)
s593027776
p03505
u399721252
1568080949
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38440
159
k, a, b = [ int(v) for v in input().split() ] if a >= k: ans = 1 elif b > a: ans = -1 else: ans = 1 + ( ( k - b - 1 ) // (a - b) ) * 2 print(ans)
s013414991
p03505
u143509139
1557831538
Python
Python (3.4.3)
py
Runtime Error
17
2940
148
k, a, b = map(int, input().split()) k = max(0, k - a) if k > 0 and a <= b: print(-1) else: print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)
s866681113
p03505
u619819312
1554722945
Python
Python (3.4.3)
py
Runtime Error
18
2940
70
k,a,b=map(int,input().split());print(-1if a<b else 2*((k-1)//(a-b))+1)
s825751555
p03505
u785578220
1554261060
Python
Python (3.4.3)
py
Runtime Error
18
3060
103
K,N,M=map(int,input().split()) if N>= K: print(i) elif N-M>0: print(2*K//(N-M)+1) else: print(-1)
s787409823
p03505
u905715926
1551627219
Python
Python (3.4.3)
py
Runtime Error
18
3188
150
p,a,b = map(int,input().split()) if(a<=b): print(-1) else: p-=a up=a-b if(p<=0): print(1) else num=p//up+(p%up!=0) print(num*2+1)
s014837594
p03505
u723721005
1541873378
Python
Python (3.4.3)
py
Runtime Error
17
3064
218
s =input().split() a=0 b=0 while a<int(s[0]) : b+=1 a+=int(s[1]) if a>int(s[0]) : break b+=1 a=a-int(s[2]) if a<0 : break if a<0 : print(-1) if a>int(s[0]) : print(int(b)
s355347369
p03505
u200239931
1526853845
Python
Python (3.4.3)
py
Runtime Error
17
3064
899
def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" "))...
s939317156
p03505
u200239931
1526818612
Python
Python (3.4.3)
py
Runtime Error
17
3064
727
def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" "))...
s137412550
p03505
u200239931
1526818422
Python
Python (3.4.3)
py
Runtime Error
17
3064
719
def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" "))...
s765590328
p03505
u200239931
1526817969
Python
Python (3.4.3)
py
Runtime Error
17
3064
691
def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" "))...
s809671168
p03505
u729707098
1525499489
Python
Python (3.4.3)
py
Runtime Error
17
3060
132
k,a,b = (int(i) for i in input().split()) num = k-a if num<0: print(1) elif a<b: print(-1) else: print(((num-num%(a-b))//(a-b))*2+3)
s991534246
p03505
u356832650
1512521263
Python
Python (2.7.6)
py
Runtime Error
11
2568
238
import sys import math K, A, B = list(map(int, input().split())) if (A >= K): print('1') sys.exit() elif (A - B) <= 0: print('-1') sys.exit() d = A-B p = K-A q = int(p//d) if ((p % d) != 0): q += 1 print(str(2*q + 1))
s697345681
p03505
u356832650
1512521140
Python
Python (2.7.6)
py
Runtime Error
10
2568
238
import sys import math K, A, B = list(map(int, input().split())) if (A >= K): print('1') sys.exit() elif (A - B) <= 0: print('-1') sys.exit() d = A-B p = K-A q = int(p/d) if ((p % d) != 0): q += 1 print(str(2*q + 1))
s573758289
p03505
u363299657
1512520184
Python
Python (3.4.3)
py
Runtime Error
55
5716
242
import math from decimal import * k, a, b = map(int, input().split()) inc = a - b if inc < 0: if k <= a: print(1) else: print(-1) exit() getcontext().prec = 500 print(math.ceil(Decimal(k-a) / Decimal(inc))*2+1)
s025209823
p03505
u356832650
1512519706
Python
Python (3.4.3)
py
Runtime Error
17
2940
251
import sys import math K, A, B = list(map(int, input().split())) if A >= K: print(1) sys.exit() elif (A - B) <= 0: print(-1) sys.exit() d = A - B p = K-A q = math.ceil(p/d) if p % d != 0: q += 1 print(int(2*q + 1))
s720074139
p03505
u363299657
1512519423
Python
Python (3.4.3)
py
Runtime Error
17
2940
187
import math k, a, b = map(int, input().split()) p = 0 inc = a - b if inc < 0: if k >= a: print(1) else: print(-1) exit() print(math.ceil((k-a) / inc)*2+1)
s299811824
p03505
u498631675
1512518214
Python
Python (2.7.6)
py
Runtime Error
13
2692
206
# coding:utf-8 K, A, B = map(int, raw_input().split()) n=0 if A <= B: print '-1' else: for i in range(K+1): if (A*(n+2)-B*(n+1))>K and (A*(n+1)-B*n)<K: print 2*n+3 n+=1
s566356353
p03505
u534757746
1511950640
Python
Python (3.4.3)
py
Runtime Error
17
3060
116
K,A,B=map(int,input().split()) n = (K-A-1) // (A-B) + 1 if A>=K: print(1) elif A-B<=0: print(-1) else: print(2*n +1)
s983996361
p03505
u534757746
1511950279
Python
Python (3.4.3)
py
Runtime Error
18
2940
87
import math K,A,B=map(int,input().split()) ini=K-A up=A-B print(2*math.ceil(ini/up) +1)
s057421274
p03505
u297467990
1511823981
Python
Python (3.4.3)
py
Runtime Error
19
3060
200
#!/usr/bin/env python3 def solve(k, a, b): if a - b <= 0 and a < k: return -1 return 1 + (k - a + (a - b) - 1) // (a - b) * 2 k, a, b = map(int, input().split()) print(solve(k, a, b))
s003968778
p03506
u223904637
1581872457
Python
Python (3.4.3)
py
Runtime Error
20
3064
350
import sys import math input=sys.stdin.readline n,q=map(int,input().split()) for i in range(q): u,v=map(int,input().split()) u-=1 v-=1 while u!=v: if u>v: u=(u-1)//(n**(max(1,math.floor(math.log(n,u/(1.0*v))-1)))) else: v=(v-1)//(n**(max(1,math.floor(math.log(n,v/...
s051319250
p03506
u532966492
1578590926
Python
Python (3.4.3)
py
Runtime Error
2105
30180
290
def main(): n,m=map(int,input().split()) if n==1: for a,b in ab: print(min(a,b)) ab=[list(map(int,input().split())) for _ in [0]*m] for a,b in ab: while a!=b: a,b=min(a,b),max(a,b) b=(b+n-2)//n print(a) main()
s849119338
p03506
u532966492
1578590616
Python
Python (3.4.3)
py
Runtime Error
1642
449908
229
def main(): n,m=map(int,input().split()) ab=[list(map(int,input().split())) for _ in [0]*n] for a,b in ab: while a!=b: a,b=min(a,b),max(a,b) b=(b+1)//3 print(a) main()
s684638937
p03506
u155024797
1569296001
Python
PyPy3 (2.4.0)
py
Runtime Error
1332
54232
711
from bisect import bisect_left def query(tree, a, b): idxa = bisect_left(tree, a) idxb = bisect_left(tree, b) while a != b: cond1 = idxa >= idxb cond2 = idxa <= idxb if cond1: a = (a - tree[idxa-1]-1)//3 + tree[idxa-2]+1 idxa -= 1 if cond2: ...
s425285552
p03506
u399721252
1568084818
Python
PyPy3 (2.4.0)
py
Runtime Error
1498
58976
814
import bisect n, q = [ int(v) for v in input().split() ] tree_list = [0] + [ (n**(i+1)-1) // (n-1) for i in range(100) if (n**(i+1)-1) // (n-1) <= 10**9 ] def upward(a): d = bisect.bisect_left(tree_list,a) - 1 outlist = [] for i in range(d+1): outlist.append(a) if i < d: a -= t...
s036952345
p03506
u619819312
1567732294
Python
Python (3.4.3)
py
Runtime Error
2103
3956
282
n,q=map(int,input().split()) if n==1: for i in range(q): v,w=map(int,input().split()) print(min(v,w)) for i in range(q): v,w=map(int,input().split()) while v!=w: if v>w: v=(v+n-2)//n else: w=(w+n-2)//n print(v)
s464344985
p03506
u905715926
1551671167
Python
Python (3.4.3)
py
Runtime Error
19
2940
1294
n,q = map(int,input().split()) for i in range(q): a,b = map(int,input().split()) #include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ull unsigned long long #define vi vector<ll> #de...
s175802489
p03506
u340781749
1514611163
Python
Python (3.4.3)
py
Runtime Error
2108
80308
630
from bisect import bisect from itertools import accumulate def solve(v, w): vl = bisect(table, v) wl = bisect(table, w) if vl > wl: for i in range(vl - wl): v = (v + m) // n elif wl < vl: for i in range(wl - vl): w = (w + m) // n while v != w: if v >...
s819672505
p03507
u814986259
1583606487
Python
Python (3.4.3)
py
Runtime Error
19
3064
417
import sys def main(): N, K = map(int, input().split()) input = sys.stdin.readline wd = [tuple(map(int, input().split())) for i in range(N)] wd.sort() d = 0 dp = [0]*N l = 0 r = wd[0][0] + wd[0][1]*K while(r - l > 1): tmp = (l+r)//2 num = 0 for w, d in wd: if w <= tmp: num ...
s435034786
p03507
u981861542
1513674260
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
496
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) #define INF (1LL << 62) using namespace std; typedef long long ll; ll N, K, W[100000], D[100000]; bool ok(ll x) { ll s = 0; REP(i, 0, N) if(x - W[i] >= 0) s += (x - W[i]) / D[i] + 1; return s >= K; } int main(void) { cin >>...
s070586167
p03507
u981861542
1513674177
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38448
521
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) #define INF (1LL << 62) using namespace std; typedef long long ll; ll N, K; vector<ll> W, D; bool ok(ll x) { ll s = 0; REP(i, 0, N) if(x - W[i] >= 0) s += (x - W[i]) / D[i] + 1; return s >= K; } int main(void) { cin >> N >>...
s590844785
p03508
u223904637
1584803447
Python
PyPy3 (2.4.0)
py
Runtime Error
190
45680
1075
class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def union(...
s802996947
p03508
u052499405
1572532416
Python
Python (3.4.3)
py
Runtime Error
587
18344
1946
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.node_size = [1] * n self.edge_size = [0] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) ...
s889036925
p03508
u052499405
1572531578
Python
Python (3.4.3)
py
Runtime Error
719
18344
1963
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.node_size = [1] * n self.edge_size = [0] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) ...
s961558920
p03508
u052499405
1572531270
Python
Python (3.4.3)
py
Runtime Error
558
18344
2031
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.node_size = [1] * n self.edge_size = [0] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x...
s494521697
p03508
u052499405
1572530777
Python
Python (3.4.3)
py
Runtime Error
568
18368
2007
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.node_size = [1] * n self.edge_size = [0] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x...
s503786355
p03508
u399721252
1568087753
Python
PyPy3 (2.4.0)
py
Runtime Error
670
66592
703
n, m = [ int(v) for v in input().split() ] connect_list = [ [] for i in range(n) ] for i in range(m): a, b = [ int(v)-1 for v in input().split() ] connect_list[a].append(b) connect_list[b].append(a) def dfs(a): color = [ 0 for i in range(n) ] color[a] = 1 stack = collections.deque([a]) r =...
s646271542
p03508
u619819312
1567954434
Python
Python (3.4.3)
py
Runtime Error
2104
9104
487
from collections import Counter n,m=map(int,input().split()) a=[i for i in range(n+1)] b=[0]*(n+1) def f(x): if a[x]==x: return x x=a[x] return(f(x)) def s(x,y): x=f(x) y=f(y) if x!=y: if b[x]>b[y]: a[y]=x b[y]+=1 else: a[x]=y ...
s768936027
p03508
u619819312
1567954416
Python
PyPy3 (2.4.0)
py
Runtime Error
2111
128204
487
from collections import Counter n,m=map(int,input().split()) a=[i for i in range(n+1)] b=[0]*(n+1) def f(x): if a[x]==x: return x x=a[x] return(f(x)) def s(x,y): x=f(x) y=f(y) if x!=y: if b[x]>b[y]: a[y]=x b[y]+=1 else: a[x]=y ...
s923425120
p03508
u296290704
1512102824
Python
PyPy3 (2.4.0)
py
Runtime Error
934
108576
359
N, M = map(int, input().split()) G = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) used = [0] * N def dfs(s): used[s] = 1 res = 1 for t in G[s]: if not used[t]: res += dfs(t) return res g = min(dfs(0), dfs...
s528367133
p03510
u619819312
1577777075
Python
Python (3.4.3)
py
Runtime Error
712
34724
305
from itertools import accumulate as ac n=int(input()) a,b=[],[] for i in range(n): x,s=map(int,input().split()) a.append(x) b.append(s) r=[0]+list(ac(b)) l=b[:] for i in range(n): r[i]+=-a[i] l[i+1]+=-a[i] q,d=0,0 for i in range(1,n+1): d=max(l[i]-q,d) q=min(q,r[i-1]) print(d)
s177035102
p03511
u223904637
1587944647
Python
Python (3.4.3)
py
Runtime Error
1735
1063364
232
n=int(input()) s=input() t=input() if s>t: s,t=t,s for i in range(n//len(s),-1,-1): if (n-i*len(s))%len(t)==0: ans=s*i ans+=t*((n-i*len(s)//len(t))) print(ans) exit()
s095303202
p03511
u356832650
1521121898
Python
Python (3.4.3)
py
Runtime Error
17
3064
392
from math import gcd import sys def lcm(a, b): return int(a*b/gcd(a,b)) L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t t = min(s,t) tl = len(t) l_n = lcm(len(tmps), len(tmpt)) s = min(tmps*l_n,tmpt*l_n) sl = len(s) p = L//sl q = L%sl for i in range(0,p+1): if (q + i*sl)%tl == 0: ...
s539588060
p03511
u356832650
1521121769
Python
Python (3.4.3)
py
Runtime Error
17
3064
392
from math import gcd import sys def lcm(a, b): return int(a*b/gcd(a,b)) L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t t = min(s,t) tl = len(t) l_n = lcm(len(tmps), len(tmpt)) s = min(tmps*l_n,tmpt*l_n) sl = len(s) p = L//sl q = L%sl for i in range(0,p+1): if (q + i*sl)%tl == 0: ...
s240815911
p03511
u356832650
1521121445
Python
Python (3.4.3)
py
Runtime Error
17
3064
387
from math import gcd import sys def lcm(a, b): return a*b/gcd(a,b) L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t t = min(s,t) tl = len(t) l_n = lcm(len(tmps), len(tmpt)) s = min(tmps*l_n,tmpt*l_n) sl = len(s) p = L//sl q = L%sl for i in range(0,p+1): if (q + i*sl)%tl == 0: S ...
s626773619
p03511
u356832650
1521121273
Python
Python (3.4.3)
py
Runtime Error
17
3064
387
from math import gcd import sys def lcm(a, b): return a*b/gcd(a,b) L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t t = min(s,t) tl = len(t) l_n = lcm(len(tmps), len(tmpt)) s = max(tmps*l_n,tmpt*l_n) sl = len(t) p = L//sl q = L%sl for i in range(0,p+1): if (q + i*sl)%tl == 0: S ...
s961683165
p03511
u356832650
1521121151
Python
Python (3.4.3)
py
Runtime Error
18
3064
386
from math import gcd import sys def lcm(a, b): return a*b/gcd(a,b) L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t t = min(s,t) tl = len(t) l_n = lcm(len(tmps), len(tmpt)) s = max(tmps*l_n,tmpt*l_n) sl = len(t) p = L//sl q = L%sl for i in range(0,p+1): if (q + i*sl)%tl == 0: S ...
s966497616
p03511
u494610174
1521070039
Python
Python (3.4.3)
py
Runtime Error
3620
38248
703
l = int(input()) a = input() b = input() if len(a) > len(b): k = b b = a a = k mina = None maxa = None f = [None] * (l + 1) f[0] = '' #print(f) for i in range(l): tmpa = None tmpb = None if i + 1 >= len(a) and f[i + 1 - len(a)] is not None: tmpa = a + f[i + 1 - len(a)] if i + 1 >...
s539982983
p03511
u356832650
1521067925
Python
Python (3.4.3)
py
Runtime Error
613
1847668
301
import sys L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t s = min(s,t) sl = len(s) t = max(tmps,tmpt) tl = len(t) p = L//sl q = L%sl if q == 0: print(s*p) else: for i in range(0,p+1): if (q + i*sl) == tl: print(s*(p-i) + t*i) sys.exit()
s500975635
p03511
u356832650
1521067737
Python
Python (3.4.3)
py
Runtime Error
613
1847668
301
import sys L = int(input()) s = str(input()) t = str(input()) tmps = s tmpt = t s = min(s,t) sl = len(s) t = max(tmps,tmpt) tl = len(t) p = L//sl q = L%sl if q == 0: print(s*p) else: for i in range(1,p+1): if (q + i*sl) == tl: print(s*(p-i) + t*i) sys.exit()
s383290782
p03511
u969174266
1511768098
Python
Python (3.4.3)
py
Runtime Error
989
104556
394
def main(): L = int(input()) S, T = (input() for _ in [0] * 2) s = S * len(T) t = T * len(S) if s < t: a = S b = T else: a = T b = S i = 0 while 1: x = L - (len(b) * i) div_, mod_ = divmod(x, len(a)) if not mod_: ans =...
s147416637
p03512
u340781749
1539906167
Python
Python (3.4.3)
py
Runtime Error
19
3064
368
q = int(input()) mmm = dict(tuple(map(int, input().split())) for _ in range(q)) ans = 0 checked_m = set() for m, x in sorted(mmm.items(), reverse=True): if x >= 0: checked_m.add(m) continue y = x for cm in checked_m: if cm % m == 0: mmm[cm] += mmm[m] del mmm[...
s139162806
p03515
u332385682
1511720187
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
141656
1100
import sys def solve(): n = int(sys.stdin.readline()) adj = [[] for i in range(n + 1)] dp = [dict() for i in range(n + 1)] cnt = [dict() for i in range(n + 1)] for i in range(n - 1): ai, bi, ci = map(int, sys.stdin.readline().split()) if ci > 2: return adj[ai...
s517178519
p03515
u226155577
1511716931
Python
PyPy3 (2.4.0)
py
Runtime Error
919
125732
1077
import sys sys.setrecursionlimit(10**6) N = int(input()) G = [[] for i in range(N)] mc = 100 for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) mc = min(c, mc) if N <= 1000: memo = {} def dfs(u, p, co): if (u, p, co) in memo: ...
s572500816
p03515
u226155577
1511716798
Python
PyPy3 (2.4.0)
py
Runtime Error
929
125728
1071
import sys sys.setrecursionlimit(10**6) N = int(input()) G = [[] for i in range(N)] mc = 100 for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) mc = min(c, mc) if N <= 1000: memo = {} def dfs(u, p, co): if (u, p, co) in memo: ...
s171223493
p03515
u226155577
1511716587
Python
PyPy3 (2.4.0)
py
Runtime Error
708
68828
1071
import sys sys.setrecursionlimit(10**6) N = int(input()) G = [[] for i in range(N)] mc = 100 for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) mc = min(c, mc) if N <= 1000: memo = {} def dfs(u, p, co): if (u, p, co) in memo: ...
s205808948
p03515
u226155577
1511716492
Python
PyPy3 (2.4.0)
py
Runtime Error
669
68700
1071
import sys sys.setrecursionlimit(10**6) N = int(input()) G = [[] for i in range(N)] mc = 100 for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) mc = min(c, mc) if N <= 1000: memo = {} def dfs(u, p, co): if (u, p, co) in memo: ...
s008041996
p03515
u226155577
1511716400
Python
PyPy3 (2.4.0)
py
Runtime Error
687
68828
1023
import sys sys.setrecursionlimit(10**6) N = int(input()) G = [[] for i in range(N)] mc = 100 for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) mc = min(c, mc) if N <= 1000: memo = {} def dfs(u, p, co): if (u, p, co) in memo: ...
s284530706
p03515
u226155577
1511715801
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
209660
469
N = int(input()) G = [[] for i in range(N)] for i in range(N-1): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) memo = {} def dfs(u, p, co): if (u, p, co) in memo: return memo[u, p, co] res = co for v, c in G[u]: if v == p: contin...
s675549387
p03517
u570522509
1552643115
Python
Python (3.4.3)
py
Runtime Error
17
2940
4850
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #define _GLIBCXX_DEBUG #include "dump.hpp" #else #define dump(...) #endif #define int long long #define ll long long #define ll1 1ll #define ONE 1ll #define DBG 1 #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; ...
s007668506
p03517
u226155577
1511713585
Python
PyPy3 (2.4.0)
py
Runtime Error
1671
130312
1521
N, M, K = map(int, input().split()) *C, = map(int, input().split()) G = [[] for i in range(N)] E = [] for i in range(M): a, b, w = map(int, input().split()) G[a-1].append((b-1, w)) G[b-1].append((a-1, w)) E.append((w, a-1, b-1)) def root(parent, x): if x == parent[x]: return x parent[x]...
s408677439
p03517
u226155577
1511713490
Python
PyPy3 (2.4.0)
py
Runtime Error
1609
130312
1458
N, M, K = map(int, input().split()) *C, = map(int, input().split()) G = [[] for i in range(N)] E = [] for i in range(M): a, b, w = map(int, input().split()) G[a-1].append((b-1, w)) G[b-1].append((a-1, w)) E.append((w, a-1, b-1)) def root(parent, x): if x == parent[x]: return x parent[x]...
s865694693
p03518
u226155577
1511714178
Python
PyPy3 (2.4.0)
py
Runtime Error
2117
221268
571
import sys sys.setrecursionlimit(10**6) N = int(input()) *P, = map(int, input().split()) if N > 10: exit(1) memo = set() *A, = range(N) ans = [] def dfs(state): key = tuple(state) if key in memo: return if state == A: return 1 memo.add(key) for i in range(1, N): n_state...
s691538054
p03518
u226155577
1511714086
Python
PyPy3 (2.4.0)
py
Runtime Error
326
47088
531
N = int(input()) *P, = map(int, input().split()) if N > 10: exit(1) memo = set() *A, = range(N) ans = [] def dfs(state): key = tuple(state) if key in memo: return if state == A: return 1 memo.add(key) for i in range(1, N): n_state = state[:] for j in range(i, N)...
s194377037
p03518
u226155577
1511714047
Python
PyPy3 (2.4.0)
py
Runtime Error
296
46448
530
N = int(input()) *P, = map(int, input().split()) if N > 7: exit(1) memo = set() *A, = range(N) ans = [] def dfs(state): key = tuple(state) if key in memo: return if state == A: return 1 memo.add(key) for i in range(1, N): n_state = state[:] for j in range(i, N):...
s838533880
p03518
u226155577
1511713958
Python
PyPy3 (2.4.0)
py
Runtime Error
323
68464
517
N = int(input()) *P, = map(int, input().split()) if N > 7: exit(1) memo = set() *A, = range(N) ans = [] def dfs(state): key = tuple(state) if key in memo: return if state == A: return 1 memo.add(key) for i in range(1, N): n_state = state[:] for j in range(i, N):...
s463071370
p03519
u467736898
1592131691
Python
Python (3.4.3)
py
Runtime Error
607
58820
1401
import sys from heapq import heappop, heappush, heapify def main(): input = sys.stdin.readline N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ls = [b-a for a, b in zip(A, B)] st = set(ls[1:-1]) q_m = [-v for v in ls[1:-1] i...
s678377483
p03519
u467736898
1592131372
Python
Python (3.4.3)
py
Runtime Error
596
58820
1400
import sys from heapq import heappop, heappush, heapify def main(): input = sys.stdin.readline N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ls = [b-a for a, b in zip(A, B)] st = set(ls[1:-1]) q_m = [-v for v in ls[1:-1] i...
s831624715
p03520
u532966492
1578537826
Python
Python (3.4.3)
py
Runtime Error
974
84508
1915
def main(): n = int(input()) ab = [list(map(int, input().split())) for _ in [0]*(n-1)] s = list(map(int, input().split())) g = [[] for _ in [0]*n] [g[a-1].append(b-1) for a, b in ab] [g[b-1].append(a-1) for a, b in ab] root = 0 # 根 d = [-1]*n # 根からの距離 d[root] = 0 q = [root] ...
s048416942
p03520
u532966492
1578537569
Python
Python (3.4.3)
py
Runtime Error
973
84500
1789
def main(): n = int(input()) ab = [list(map(int, input().split())) for _ in [0]*(n-1)] s = list(map(int, input().split())) g = [[] for _ in [0]*n] [g[a-1].append(b-1) for a, b in ab] [g[b-1].append(a-1) for a, b in ab] root = 0 # 根 d = [-1]*n # 根からの距離 d[root] = 0 q = [root] ...
s817165632
p03520
u532966492
1578537201
Python
Python (3.4.3)
py
Runtime Error
969
84500
1626
def main(): n = int(input()) ab = [list(map(int, input().split())) for _ in [0]*(n-1)] s = list(map(int, input().split())) g = [[] for _ in [0]*n] [g[a-1].append(b-1) for a, b in ab] [g[b-1].append(a-1) for a, b in ab] root = 0 # 根 d = [-1]*n # 根からの距離 d[root] = 0 q = [root] ...
s004699067
p03521
u244646068
1511676814
Python
Python (3.4.3)
py
Runtime Error
3156
21016
1881
# -*- coding: utf-8 -*- numAns = 0 class Node: def __init__(self,init): self.addr = None self.boss = init self.subordinate = [] def printBoss(self): print(self.boss) def showTree(self,tmp_node): print(self.addr,self.boss,self.subordinate) for sub in self.sub...
s414812023
p03521
u244646068
1511676576
Python
Python (3.4.3)
py
Runtime Error
3156
21072
1847
# -*- coding: utf-8 -*- numAns = 0 class Node: def __init__(self,init): self.addr = None self.boss = init self.subordinate = [] def printBoss(self): print(self.boss) def showTree(self,tmp_node): print(self.addr,self.boss,self.subordinate) for sub in self.sub...
s018476786
p03523
u998741086
1600402260
Python
Python (3.8.2)
py
Runtime Error
22
8920
242
#!/usr/bin/env python import re s = input() STR = 'AKIHABARA' if len(s) > len(STR): print('NO') exit() regex = re.compile('A?KIHA?BA?RA?') mo = regex.search(s) if mo == None: print('NO') else: print('YES') ~
s796271950
p03523
u703823201
1599775722
Python
Python (3.8.2)
py
Runtime Error
28
9060
398
import sys S = list(input()) L = list("KIHBR") for l in L: if not l in "".join(S): print("NO") sys.exit(0) N = [] for i in range(len(S)-1): if S[i] == "H" or S[i] == "B" or S[i] == "R": if S[i+1] != "A": N.append(i+1) i = 0 for n in N: S.insert(n+i, "A") i ...
s704356255
p03523
u397953026
1599152184
Python
Python (3.8.2)
py
Runtime Error
23
8984
384
s = input() # AKIHABARA if (s == "AKIHABARA") or (s == "AKIHABAR") or (s == "AKIHABRA") or (s == "AKIHABR") or (s == "AKIHBARA") or (s == "AKIHBAR") or (s == "AKIHBRA") or (s == "AKIHBR") or (s == "KIHABARA") or (s == "KIHABAR") or (s == "KIHABRA") or (s == "KIHABR") or (s == "KIHBARA") or (s == "KIHBAR") or (s == "KIH...
s752759782
p03523
u696919316
1598653488
Python
Python (3.8.2)
py
Runtime Error
30
9108
525
s = list(input()) z = s.copy() arr = [] result = [] req = list("AKIHABARA") if s == []: print("NO") exit() while s.count("A") >= 1: result.append(s.index("A")) s.remove("A") m = "".join(z) k = z.index("K") for d in range(len(result)-1): if result[d] - result[d+1] == 0: print("NO") ex...
s228435586
p03523
u696919316
1598653349
Python
Python (3.8.2)
py
Runtime Error
28
9064
486
s = list(input()) z = s.copy() arr = [] result = [] req = list("AKIHABARA") while s.count("A") >= 1: result.append(s.index("A")) s.remove("A") m = "".join(z) k = z.index("K") for d in range(len(result)-1): if result[d] - result[d+1] == 0: print("NO") exit() else: arr.append("T") ...
s116232472
p03523
u380412651
1598547289
Python
PyPy3 (7.3.0)
py
Runtime Error
86
74740
188
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; regex re("^A?KIHA?BA?RA?$"); cout << (regex_match(s, re) ? "YES\n" : "NO\n"); return 0; }
s210528863
p03523
u670567845
1598528649
Python
PyPy3 (7.3.0)
py
Runtime Error
89
74548
352
S = list(input()) for i in range(len(S)): if S[0] == "K": S.insert(0,"A") for i in range(len(S)): if S[i] == "H" and S[i+1] != "A": S.insert(i+1,"A") for i in range(len(S)): if S[i] == "B" and S[i+1] != "A": S.insert(i+1,"A") for i in range(len(S)): if S[-1] == "R": if "".join(S) == "AKIHABARA": p...
s703551763
p03523
u617037231
1598092480
Python
Python (3.8.2)
py
Runtime Error
29
8996
663
s = [c for c in "AKIHABARA"] L = [] for i in range(0, 2): for j in range(0, 2): for k in range(0, 2): for l in range(0, 2): if i == 0: s[0] = "X" if j == 0: s[4] = "X" if k == 0: s[6] = "X...
s198624494
p03523
u888092736
1596636305
Python
Python (3.8.2)
py
Runtime Error
25
9116
256
from itertools import product candidates = [] non_as = ["KIH", "B", "R", ""] for seps in product(["A", ""], repeat=4): candidates.add("".append(sep + non_a for sep, non_a in zip(seps, non_as))) print("YES") if input() in candidates else print("NO")
s419548699
p03523
u629350026
1595005722
Python
Python (3.8.2)
py
Runtime Error
29
9104
256
s=str(input()) s=list(s) if s[0]!="A": s.insert(0,"A") if len(s)>=4: if s[4]!="A": s.insert(4,"A") if len(s)>=6: if s[6]!="A": s.insert(6,"A") if s[len(s)-1]!="A": s.append("A") if "".join(s)=="AKIHABARA": print("YES") else: print("NO")