id
stringlengths
24
27
content
stringlengths
37
384k
max_stars_repo_path
stringlengths
51
51
condefects-python_data_2201
import pypyjit pypyjit.set_param('max_unroll_recursion=-1') import sys sys.setrecursionlimit(10**7) import re # import more_itertools import functools import sys import bisect import math import itertools from collections import deque from collections import defaultdict from collections import Counter from copy import ...
ConDefects/ConDefects/Code/abc354_e/Python/54730171
condefects-python_data_2202
from functools import lru_cache N = int(input()) A, B = [None]*N, [None]*N for i in range(N): A[i], B[i] = map(int, input().split()) @lru_cache(maxsize = None) def DFS(M, turn): res = False for i in range(N-1): for j in range(i+1, N): if M & 1<<i and M & 1<<j: if A[i] ==...
ConDefects/ConDefects/Code/abc354_e/Python/54930119
condefects-python_data_2203
N = int(input()) A = list(map(lambda x:int(x)-1,input().split())) mod = 998244353 mv = 2*10**5+10 count = [0]*(mv) for i in A: count[i] += 1 ans = 0 dp = dict() dp[0] = 1 for i in range(mv): change = dict() value = [] for j in dp.keys(): cur = (count[i] + j) // 2 if cur not in change.key...
ConDefects/ConDefects/Code/arc160_c/Python/41479555
condefects-python_data_2204
# 2023-05-20 12:43:31 n = int(input()) A = list(map(int, input().split())) s = 4 * 10**5 + 10 B = [0] * s mod = 998244353 for a in A: B[a] += 1 dp = [1] for i in range(s): b = B[i] nl = b + (len(dp) - 1) // 2 + 1 + 1 ndp = [0] * nl for j in range(len(dp)): ndp[b] += dp[j] ndp...
ConDefects/ConDefects/Code/arc160_c/Python/41526904
condefects-python_data_2205
MOD = 998244353 N = int(input()) A = list(map(int,input().split())) NX = 2 * 10 ** 5 + 100 X = [0] * NX for a in A: X[a] += 1 dp =[1] inc = 0 for i in range(1,NX): x = X[i] dp2 = [0] * ((x+inc)//2+1) tmp = 0 for j in reversed(range((x+inc)//2+1)): if j <= x // 2: tmp += dp[0] ...
ConDefects/ConDefects/Code/arc160_c/Python/41518740
condefects-python_data_2206
MOD = 998244353 M = 2*10**5+2 N = int(input()) A = list(map(int,input().split())) B = [0]*M for a in A: B[a] += 1 dp = [1] for i in range(1,M): b = B[i] S = [0]*((len(dp)-1+b)//2+2) for i in range(len(dp)): S[0] += dp[i] S[(b+i)//2+1] += -dp[i] #print(S) S[0] %= MOD ...
ConDefects/ConDefects/Code/arc160_c/Python/41463787
condefects-python_data_2207
from math import log2 from collections import Counter import sys n, *alists = map(int, sys.stdin.read().split()) MOD = 998244353 if n == 1: print(1) exit() maxlen = max(alists) + int(log2(n)) li = [0] * (maxlen + 1) co = Counter(list(alists)) for k,v in co.items(): li[k] += v dp = [1] for i in ran...
ConDefects/ConDefects/Code/arc160_c/Python/42877627
condefects-python_data_2208
from collections import Counter MOD=998244353 N=int(input()) A=list(map(int, input().split())) M=max(A) C=Counter(A) dp=[1] for a in range(1,M+1): c=C[a] dp=[0]*c+dp ndp=[0]*(len(dp)//2+2) for i in range(len(dp)): ndp[i//2+1]-=dp[i] ndp[0]+=dp[i] ndp[i//2+1]%=MOD ndp...
ConDefects/ConDefects/Code/arc160_c/Python/44003371
condefects-python_data_2209
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) a = list(map(int,input().split())) mod = 998244353 d = defaultdict(int) for i i...
ConDefects/ConDefects/Code/arc160_c/Python/42565675
condefects-python_data_2210
import sys, random input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18 LI = lambda v=0: list(map(lambda i: int(i)-v, ...
ConDefects/ConDefects/Code/arc175_a/Python/52999116
condefects-python_data_2211
N = int(input()) P = list(map(int, input().split())) S = input() ans_l = 1 ans_r = 1 visited = [False]*N for p in P: visited[p-1] = True if visited[p%(N)]: if S[p-1] == "?": ans_l *= 2 else: if S[p-1] == "R": ans_l *= 0 if visited[p-2]: if S[p-1] == "?": ans_r *= 2 else: ...
ConDefects/ConDefects/Code/arc175_a/Python/53404790
condefects-python_data_2212
n = int(input()) oder = list(map(lambda x: int(x)-1, input().split())) lr = input() def calc(d): ret = 1 taken = [0] * n taken[oder[0]] = 1 for i in range(1, n): if taken[((oder[i] + (1 if d=='L' else (-1))) + n) % n] == 1: if lr[i] == "?": ret *= 2 r...
ConDefects/ConDefects/Code/arc175_a/Python/51898575
condefects-python_data_2213
MOD = 998244353 N = int(input()) P = list(map(lambda x: int(x)-1, input().split())) S = input() def pow(a, b): if b==0: return 1 ret = pow((a**2)%MOD, b//2) if b%2: ret = ret*a%MOD return ret def countL(): cnt = 0 spoon = [False]*N for p in P: match S[p]: ...
ConDefects/ConDefects/Code/arc175_a/Python/52650326
condefects-python_data_2214
MOD = 998244353 n = int(input()) p = list(map(lambda x: int(x) - 1, input().split())) s = list(input()) sp = [True for i in range(n)] ans1 = 1 for i in p: sp[i] = False if sp[(i + 1) % n]: if s[i] == "R": ans1 = 0 break else: if s[i] == "?": ans1 *= 2 ans1 %= MOD sp = [True for i i...
ConDefects/ConDefects/Code/arc175_a/Python/52661518
condefects-python_data_2215
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self...
ConDefects/ConDefects/Code/abc307_f/Python/51485146
condefects-python_data_2216
N,M=map(int, input().split()) E=[[] for _ in range(N+1)] V=[-1]*(N+1) V[0]=0;cost=[10**2]*(N+1);DD=[10**2]*(N+1) import heapq for i in range(M): a,b,t=map(int,input().split()) E[a].append((t,b));E[b].append((t,a)) K=int(input()) A=list(map(int, input().split())) L=int(input()) B=list(map(int, input().split())) hq=...
ConDefects/ConDefects/Code/abc307_f/Python/48677305
condefects-python_data_2217
import heapq n,m=map(int,input().split()) g=[[] for _ in range(n+1)] for _ in range(m): u,v,w=map(int,input().split()) g[u].append([v,w]) g[v].append([u,w]) k=int(input()) a=list(map(int,input().split())) ans=[-1]*(n+1) d=[10**18]*(n+1) hq=[] new=[] for i in range(k): ans[a[i]]=0 d[a[i]]=0 new.append(a...
ConDefects/ConDefects/Code/abc307_f/Python/53719250
condefects-python_data_2218
n, m = map(int, input().split()) c = input().split() d = input().split() p = list(map(int, input().split())) ds = {d[i]: p[1 + i] for i in range(m)} s = 0 for i in c: if i not in ds: print(p[0]) else: s += ds[i] print(s) n, m = map(int, input().split()) c = input().split() d = input().split() p...
ConDefects/ConDefects/Code/abc308_b/Python/45960039
condefects-python_data_2219
h, w = map(int, input().split()) r, c = map(int, input().split()) ans = 4 if r == 1: ans -= 1 if r == h: ans -= 1 if w == 1: ans -= 1 if w == c: ans -= 1 print(ans) h, w = map(int, input().split()) r, c = map(int, input().split()) ans = 4 if r == 1: ans -= 1 if r == h: ans -= 1 if c == 1: ans -= 1 if w =...
ConDefects/ConDefects/Code/abc250_a/Python/54768832
condefects-python_data_2220
t=int(input()) for _ in range(t): A = list(map(int, input().split())) P = list(map(int, input().split())) s=sum(A)*3 ans=0 for i,j in enumerate(A): s-=(i+1)*j if s<=0: print(0) break if P[3]*2<=P[4]: print(s*P[3]) else: if s%2==0: print...
ConDefects/ConDefects/Code/arc174_b/Python/51697010
condefects-python_data_2221
N = int(input()) An = [] Pn = [] for _ in range(N): An.append(list(map(int, input().split()))) Pn.append(list(map(int, input().split()))) for A, P in zip(An, Pn): po = 0 for i, a in enumerate(A, 1): po -= (i-3) * a if po <= 0: print(0) continue q, r = divmod(po, 2) ...
ConDefects/ConDefects/Code/arc174_b/Python/51471469
condefects-python_data_2222
# -*- coding: utf-8 -*- T=int(input()) for i in range(T): A=list(map(int,input().split())) P=list(map(int,input().split())) K=A[0]*-2+A[1]*-1+A[3]+A[4]*2 ans=0 if K<0: if P[3]<P[4]/2: ans=P[3]*abs(K) else: ans=P[4]*abs(K)//2 if K%2!=0: ...
ConDefects/ConDefects/Code/arc174_b/Python/51473065
condefects-python_data_2223
t = int(input()) for _ in range(t): A = list(map(int, input().split())) _, _, _, p4, p5 = map(int, input().split()) target = 2 * A[0] + A[1] - A[3] - 2 * A[4] if target <= 0: ans = 0 else: ans = min(target // 2 * p5, target * p4) if target % 2 != 0: ans += min(p5...
ConDefects/ConDefects/Code/arc174_b/Python/52291293
condefects-python_data_2224
T = int(input()) for _ in range(T): A = list(map(int, input().split())) P = list(map(int, input().split())) num_reviews = sum(A) original_score = sum([A[i] * (i + 1) for i in range(5)]) # print(original_score) rhs = 3 * num_reviews - original_score if original_score >= 3 * num_reviews: print(0) ...
ConDefects/ConDefects/Code/arc174_b/Python/53660002
condefects-python_data_2225
n = int(input()) for _ in range(n): arr = list(map(int, input().split())) brr = list(map(int, input().split())) avg = 0 sm = sum(arr) for i in range(5): avg += arr[i] * (i+1) #print(avg / sm) best_cost = 10**99 best = 10**99 l,r = 0, 10**20 for j in range(100): mid = (l+r) ...
ConDefects/ConDefects/Code/arc174_b/Python/51500083
condefects-python_data_2226
T = int(input()) for i in range(T): A = list(map(int, input().split())) P = list(map(int, input().split())) tmp = 0 for i in range(1, 6): tmp += (i-3)*A[i-1] if tmp >= 0: print(0) break x = (-tmp+1)//2 ans = -tmp*P[3] if 2*P[3]-P[4] >= 0: ans = min(ans, x*(2*P[3]-P[4])-tmp*(P[4]-P[3])) ...
ConDefects/ConDefects/Code/arc174_b/Python/52256842
condefects-python_data_2227
N, M, P = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) B.sort() S = [B[0]] for j in range(1, M) : S.append(B[j] + S[j - 1]) res = 0 for i in range(N) : l, r = -1, M while l + 1 < r : m = (l + r) // 2 if A[i] + B[m] <= P : l = m else : r = m res += ...
ConDefects/ConDefects/Code/abc321_d/Python/54470617
condefects-python_data_2228
n = int(input()) s: list[str] = [input().rstrip() for _ in range(n)] a = list(map(int, input().split())) ng = [[s[i].find(s[j]) != -1 or s[j].find(s[i]) != -1 for j in range(n)] for i in range(n)] import sys import ortools.linear_solver.pywraplp as lp solver = lp.Solver('SolveIntegerProblem', lp.Solver.CBC_MIXED_INT...
ConDefects/ConDefects/Code/abc354_g/Python/53647241
condefects-python_data_2229
n, q = map(int,input().split()) T = list(map(int,input().split())) hanuke = [0] * (n + 1) for t in T: hanuke[t] ^= 1 print(n - hanuke.count(1)) print(hanuke) n, q = map(int,input().split()) T = list(map(int,input().split())) hanuke = [0] * (n + 1) for t in T: hanuke[t] ^= 1 print(n - hanuke.count(1)) #print(ha...
ConDefects/ConDefects/Code/abc350_b/Python/54727667
condefects-python_data_2230
s=[] for i in range(9): s.append(input()) ans=0 for k in range(8): for i in range(8-k): for j in range(8-k): if s[i][j]=="#" and s[i+k+1][j]=="#" and s[i][j+k+1]=="#" and s[i+k+1][j+k+1]=="#": ans+=1 for k in range(4): for i in range(7-2*k): for j in range(7-2*k): if s[i+k+1][j]=="#" a...
ConDefects/ConDefects/Code/abc275_c/Python/44917428
condefects-python_data_2231
N = int(input()) for n in range(N, 920) : s = str(n) a = int(s[0]) b = int(s[1]) c = int(s[2]) if a * b == b * c : print(n) break N = int(input()) for n in range(N, 920) : s = str(n) a = int(s[0]) b = int(s[1]) c = int(s[2]) if a * b == c : print(n) break
ConDefects/ConDefects/Code/abc326_b/Python/54408960
condefects-python_data_2232
N = int(input()) def like326_Number(i): i_hundred = int(i/100) i_ten = int((i%100)/10) i_one = int(i%10) if i_hundred*i_ten == i_one: return True else: return False for i in range(N,919): if like326_Number(i): print(i) exit() N = int(input()) def lik...
ConDefects/ConDefects/Code/abc326_b/Python/54706855
condefects-python_data_2233
N = int(input()) for i in range(N, 919): N_str = str(i) if int(N_str[0]) * int(N_str[1]) == int(N_str[2]): print(i) exit() N = int(input()) for i in range(N, 920): N_str = str(i) if int(N_str[0]) * int(N_str[1]) == int(N_str[2]): print(i) exit()
ConDefects/ConDefects/Code/abc326_b/Python/54769546
condefects-python_data_2234
n = int(input()) for i in range(919): if i <= 99: continue elif i < n: continue else: if int(str(i)[0]) * int(str(i)[1]) == int(str(i)[2]): print(i) exit() n = int(input()) for i in range(920): if i <= 99: continue elif i < n: continue else: if int(str(i)[0]) * int(st...
ConDefects/ConDefects/Code/abc326_b/Python/55009435
condefects-python_data_2235
n = int(input()) for i in range(n,919): c = str(i) if int(c[0])*int(c[1])==int(c[2]): print(i) exit() n = int(input()) for i in range(n,920): c = str(i) if int(c[0])*int(c[1])==int(c[2]): print(i) exit()
ConDefects/ConDefects/Code/abc326_b/Python/55135461
condefects-python_data_2236
N = int(input()) for i in range(N,917): s = str(i) if int(s[0]) * int(s[1]) == int(s[2]): print(i) exit() N = int(input()) for i in range(N,920): s = str(i) if int(s[0]) * int(s[1]) == int(s[2]): print(i) exit()
ConDefects/ConDefects/Code/abc326_b/Python/54935249
condefects-python_data_2237
n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans1 = 0 ans2 = 0 for i in range(n): if a[i] == b[i]: ans1 += 1 for i in range(n): for j in range(n): if a[i] == b[j]: ans2 += 1 print(ans1) print(ans2) n = int(input()) a = list(map(int,input...
ConDefects/ConDefects/Code/abc243_b/Python/44827583
condefects-python_data_2238
n = int(input()) A = [input() for _ in range(n)] D = [(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1)] ans = [] for r in range(n): for c in range(n): for dr,dc in D: tmp = [] for i in range(n): tmp.append(A[(r+dr*i)%n][(c+dc*i)%n]) ans.append("".join(t...
ConDefects/ConDefects/Code/abc258_b/Python/44828873
condefects-python_data_2239
n = int(input()) a = [list(input()) for _ in range(n)] l, m = [], "0" for i in range(n): for j in range(n): if a[i][j]>m: m = a[i][j] l = [[i, j]] elif a[i][j]==m: l.append([i, j]) ans = set() for i in l: for x in range(-1, 2, 1): for y in range(-1, 2, 1): if x==y==0: bre...
ConDefects/ConDefects/Code/abc258_b/Python/45801553
condefects-python_data_2240
import sys import pypyjit pypyjit.set_param('max_unroll_recursion=-1') from itertools import combinations, permutations, product, accumulate, groupby from collections import defaultdict, deque, Counter from functools import reduce from operator import add, mul import heapq as hq import bisect sys.setrecursionlimit(10**...
ConDefects/ConDefects/Code/abc224_g/Python/32872217
condefects-python_data_2241
n,s,t,a,b=map(int,input().split()) def f(l:int)->float: if l<=s<=t:return (t-s)*a sm=t*(t-l+1)-(t+l)*(t-l+1)/2 w=t-l+1 return a*sm/w+b+(n-w)*b/w l=1 r=t while r-l>2: n1=(2*l+r)//3 n2=(l+2*r)//3 if f(n1)>f(n2):l=n1 else:r=n2 ans=10**50 for i in range(l-5,r+5): if 1<=i<=t: an...
ConDefects/ConDefects/Code/abc224_g/Python/52137623
condefects-python_data_2242
N,S,T,A,B=map(int,input().split()) ans=N*B for i in range(1000000): cost=B*N cost+=(N-T)*ans line=min(T-1,ans//A) cost+=(T-line-1)*ans cost+=(line*(line+1)//2)*A cost/=N ans=cost if T-S<0: print('{:f}'.format(ans)) else: print('{:f}'.format(ans)) N,S,T,A,B=map(int,input().split()) a...
ConDefects/ConDefects/Code/abc224_g/Python/46503439
condefects-python_data_2243
def expect(k): """expect""" global n, s, t, a, b p = t - k + 1 return b * (n / p) + a * (p - 1) / 2 n, s, t, a, b = [int(x) for x in input().split()] l = 1 r = t while r - l >= 3: d = (r - l) // 3 p1 = l + d * 1 p2 = l + d * 2 e1 = expect(p1) e2 = expect(p2) if e1 >= p2: l = p1 else: r...
ConDefects/ConDefects/Code/abc224_g/Python/27132818
condefects-python_data_2244
N, S, T, A, B = map(int, input().split()) def value(k): if k < S <= T: return A*(T-S)/2 elif k >= T: return float('inf') else: return B*N/(T-k)+A*(T-k-1)/2 l, r = 0, T if r-l == 1: print(min(value(0), value(1))) exit() if r-l == 2: print(min(value(0), value(1), value(...
ConDefects/ConDefects/Code/abc224_g/Python/28236524
condefects-python_data_2245
N=int(input()) A=list(map(int,input().split())) for i in range(1,N,2): A[i]^=1 if A==[0]*N: print("Yes") ; exit() for i in range(N): if A[i]==1: break S=[j%2 for j in range(N)] idx=0 for k in range(i,N): if idx>=N: break if A[k]!=S[idx]: idx+=2 else: idx+=1 if idx>=N: print("No") else: print("Yes") N=int(inp...
ConDefects/ConDefects/Code/arc138_b/Python/39937104
condefects-python_data_2246
n=int(input()) a=list(map(int,input().split())) l=0 while l<n: if a[l]^(l&1): l+=1 else: break r=0 a+=[0] for i in range(l,n): r+=a[i]^a[i+1] print ("Yes" if l>=r else "No") n=int(input()) a=list(map(int,input().split())) l=0 while l<n: if a[l]==(l&1): l+=1 else: break r=0 a+=[0] for i in ran...
ConDefects/ConDefects/Code/arc138_b/Python/45602873
condefects-python_data_2247
import sys input = sys.stdin.readline inf = float('inf') def getInt(): return int(input()) def getStr(): return input().strip() def getList(dtype=int, split=True): s = getStr() if split: s = s.split() return list(map(dtype, s)) t = 1 def solve(): n = getInt() a = getList() ...
ConDefects/ConDefects/Code/arc138_b/Python/39687485
condefects-python_data_2248
N = int(input()) A = list(map(int, input().split())) odd = [x for x in A if x%2==1] even = [x for x in A if x%2==0 and x != 0] odd.sort(reverse=True) even.sort(reverse=True) if len(odd) < 2 and len(even) < 2: print(-1) elif len(odd) < 2: print(even[0]+even[1]) elif len(even) < 2: print(odd[0]+odd[1]) else:...
ConDefects/ConDefects/Code/abc272_c/Python/45929207
condefects-python_data_2249
N = int(input()) A = list(map(int, input().split())) o = [] e = [] for a in A: if a % 2: o.append(a) else: e.append(a) if len(o) < 2 and len(e) < 2: print(-1) exit() co = o[-1] + o[-2] if len(o) >= 2 else -1 ce = e[-1] + e[-2] if len(e) >= 2 else -1 print(max(co,ce)) N = int(input()) A ...
ConDefects/ConDefects/Code/abc272_c/Python/46144815
condefects-python_data_2250
N = int(input()) A = [int(x) for x in input().split()] odd = [-10000000000, -10000000000] even = [-10000000000, -10000000000] for ai in A: if ai % 2 == 0: even.append(ai) else: odd.append(ai) odd.sort() even.sort() print(max(odd[-1] + even[-1], odd[-1] + odd[-2], even[-1] + even[-2], -1)) N = int(input()) ...
ConDefects/ConDefects/Code/abc272_c/Python/45973568
condefects-python_data_2251
n = int(input()) a = list(map(int,input().split())) odd = [] even = [] for i in range(n): if a[i] % 2 == 0: even.append(a[i]) else: odd.append(a[i]) if len(odd) <= 1 and len(even) <= 1: print(-1) elif len(odd) <= 1: print(even[-1] + even[-2]) elif len(even) <= 1: print(odd[-1] + odd[-2]) else: pri...
ConDefects/ConDefects/Code/abc272_c/Python/45985100
condefects-python_data_2252
N = int(input()) A = list(map(int, input().split())) even = [] #偶数 odd = [] #奇数 for i in range(N): #A[i]が偶数ならば if A[i]%2==0: even.append(A[i]) #A[i]が奇数ならば else: odd.append(A[i]) even.sort(reverse=True) odd.sort(reverse=True) ans = -1 if len(even)>=2: ans = max(ans, e...
ConDefects/ConDefects/Code/abc272_c/Python/45282989
condefects-python_data_2253
def resolve(): B = int(input()) for x in range(B+1): tmp = x**x if tmp==B: return x elif tmp>B: return -1 print(resolve()) def resolve(): B = int(input()) for x in range(1, B+1): tmp = x**x if tmp==B: return x elif tmp>...
ConDefects/ConDefects/Code/abc327_b/Python/54757356
condefects-python_data_2254
B=int(input()) for i in range(20): if i**i==B: print(i) break if i**i>=10**18: print(-1) break B=int(input()) for i in range(1,20): if i**i==B: print(i) break if i**i>=10**18: print(-1) break
ConDefects/ConDefects/Code/abc327_b/Python/55103874
condefects-python_data_2255
n = int(input()) for i in range(n+1): if i**i > n: break if i**i == n: print(i) exit() print(-1) n = int(input()) for i in range(1,n+1): if i**i > n: break if i**i == n: print(i) exit() print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/55112756
condefects-python_data_2256
B = int(input()) for x in range(18): if x**x == B: print(x) exit() print(-1) B = int(input()) for x in range(1,18): if x**x == B: print(x) exit() print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/54706960
condefects-python_data_2257
B=int(input()) a=-1 for i in range(1,B): if i**i==B: a=i break print(a) B=int(input()) a=-1 for i in range(1,17): if i**i==B: a=i break print(a)
ConDefects/ConDefects/Code/abc327_b/Python/54789222
condefects-python_data_2258
B = int(input()) for A in range(1,15) : pow = 1 for j in range(A) : pow *= A if pow == B : print(A) exit() print(-1) B = int(input()) for A in range(1,16) : pow = 1 for j in range(A) : pow *= A if pow == B : print(A) exit() p...
ConDefects/ConDefects/Code/abc327_b/Python/54881267
condefects-python_data_2259
B = int(input()) for i in range(19): if i ** i == B: print(i) exit() if i ** i > B: break print(-1) B = int(input()) for i in range(1, 19): if i ** i == B: print(i) exit() if i ** i > B: break print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/55166023
condefects-python_data_2260
b = int(input()) for i in range(1, 15): if i**i == b: print(i) exit() print(-1) b = int(input()) for i in range(1, 16): if i**i == b: print(i) exit() print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/55040351
condefects-python_data_2261
B=int(input()) Frag=-1 for i in range(200): X=i**i if B<X: break elif B==X: Frag=i break print(Frag) B=int(input()) Frag=-1 for i in range(1,200): X=i**i if B<X: break elif B==X: Frag=i break print(Frag)
ConDefects/ConDefects/Code/abc327_b/Python/54671379
condefects-python_data_2262
B = int(input()) i = 0 while pow(i,i) < B: i += 1 if pow(i,i) == B: print(i) else: print(-1) B = int(input()) i = 1 while pow(i,i) < B: i += 1 if pow(i,i) == B: print(i) else: print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/54666596
condefects-python_data_2263
B = int(input()) for i in range(20): if i ** i == B: print(i) exit() print(-1) B = int(input()) for i in range(1, 20): if i ** i == B: print(i) exit() print(-1)
ConDefects/ConDefects/Code/abc327_b/Python/54721670
condefects-python_data_2264
# import sys # sys.setrecursionlimit(10**6) # import pypyjit # pypyjit.set_param("max_unroll_recursion=-1") # sys.set_int_max_str_digits(10**6) # mod = 998244353 # ds = [(-1,0),(0,1),(1,0),(0,-1)] # inf = float('inf') # ni,nj=i+di,j+dj # 0<=ni<H and 0<=nj<W # alph = 'abcdefghijklmnopqrstuvwxyz' def rint(offset=0,base=...
ConDefects/ConDefects/Code/abc327_b/Python/55112773
condefects-python_data_2265
b = int(input()) flag = False for i in range(17): if i**i == b: flag = True break print(i if flag else -1) b = int(input()) flag = False for i in range(1, 17): if i**i == b: flag = True break print(i if flag else -1)
ConDefects/ConDefects/Code/abc327_b/Python/55043539
condefects-python_data_2266
b = int(input()) ans = -1 for a in range(16): if a**a == b: ans = a break print(ans) b = int(input()) ans = -1 for a in range(1, 17): if a**a == b: ans = a break print(ans)
ConDefects/ConDefects/Code/abc327_b/Python/54902111
condefects-python_data_2267
b = int(input()) answer = -1 for i in range(1,15): if i**i == b: answer = i else: pass print(answer) b = int(input()) answer = -1 for i in range(1,16): if i**i == b: answer = i else: pass print(answer)
ConDefects/ConDefects/Code/abc327_b/Python/54929751
condefects-python_data_2268
MOD = 998244353 n, x, y, z = map(int, input().split()) x = abs(x) y = abs(y) z = abs(z) def factorial(n): fact = [1] * (n + 1) ifact = [0] * (n + 1) for i in range(1, n + 1): fact[i] = fact[i-1] * i % MOD ifact[n] = pow(fact[n], MOD - 2, MOD) for i in range(n, 0, -1): ifact[i-1] = ...
ConDefects/ConDefects/Code/abc240_g/Python/35075785
condefects-python_data_2269
from math import gcd def distance(x1, y1, x2, y2, m): xa = x1 - x2 ya = y1 - y2 xb = x2 - x1 yb = y2 - y1 if xa == 0: ya //= abs(ya) yb //= abs(yb) elif ya == 0: xa //= abs(xa) xb //= abs(xb) else: g = gcd(xa, xb) xa //= g ya //= g ...
ConDefects/ConDefects/Code/abc226_d/Python/53188054
condefects-python_data_2270
import sys from math import * from bisect import * def solve(): N = int(input()) A = list(map(int, input().split())) dp = [] Len = [0 for i in range(N)] for i in range(N): j = bisect_left(dp, A[i]) Len[i] = j + 1 if j < len(dp): dp[j] = A[i] else: dp.append(A[i]) O = max(Len) Max = [-1 for i in ra...
ConDefects/ConDefects/Code/abc354_f/Python/54029773
condefects-python_data_2271
ImportType = 1 InputType = 1 ConstType = 1 if ImportType: import os, sys, random, threading from random import randint, choice, shuffle from copy import deepcopy from io import BytesIO, IOBase from types import GeneratorType from functools import lru_cache, reduce from bisect import bisect_l...
ConDefects/ConDefects/Code/abc354_f/Python/54039651
condefects-python_data_2272
N,M,K = map(int,input().split()) C = list(map(int,input().split())) if K == 1: for i in range(N): print(M) exit() C += C m = 0 d = [0 for i in range(N)] for i in range(N): d[C[i]-1] += 1 CC = [0 for i in range(N)] use = [0 for i in range(N)] ans = 0 for r in range(N): c = C[r] - 1 CC[c] += 1 if CC[c] % ...
ConDefects/ConDefects/Code/abc337_f/Python/50099741
condefects-python_data_2273
from collections import defaultdict def solution(): N, M, K = map(int, input().split()) c_lst = list(map(lambda s: int(s) - 1, input().split())) cnt = defaultdict(int) for c in c_lst: cnt[c] += 1 c_lst *= 2 res = 0 # number of total balls in boxes within range [i,i+N-1] box = 0 ...
ConDefects/ConDefects/Code/abc337_f/Python/49855272
condefects-python_data_2274
import bisect n, k = map(int, input().split()) a = list( map(int, input().split()) ) for i in range(k): a[i] -= 1 p = [] for _ in range(n): p.append(list(map(int, input().split()))) ans = 0 for i in range(n): minr = float("inf") for j in a: if i==j: continue dis0 = ( (p[i][0] - p[j][0])**2 + (p...
ConDefects/ConDefects/Code/abc255_b/Python/46036276
condefects-python_data_2275
import sys import os from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writabl...
ConDefects/ConDefects/Code/arc145_e/Python/33700944
condefects-python_data_2276
import sys import os from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writabl...
ConDefects/ConDefects/Code/arc145_e/Python/33700497
condefects-python_data_2277
s = input() ok = True for i in range(2, 16, 2): ok = s[i] == '0' and ok print('Yes' if ok else 'No') s = input() ok = True for i in range(1, 16, 2): ok = s[i] == '0' and ok print('Yes' if ok else 'No')
ConDefects/ConDefects/Code/abc323_a/Python/54475716
condefects-python_data_2278
s = input() ans = "Yes" for i in range(3,16): if i %2 == 1 and s[i] != "0": ans = "No" break print(ans) s = input() ans = "Yes" for i in range(16): if i %2 == 1 and s[i] != "0": ans = "No" break print(ans)
ConDefects/ConDefects/Code/abc323_a/Python/54490439
condefects-python_data_2279
S = input() count=0 for i in range(1, 16, 2): if S[i] == '0': break else: count+=1 if count==0: print("Yes") else: print("No") S = input() count=0 for i in range(1, 16, 2): if S[i] == '0': continue else: count+=1 if count==0: print("Yes") else: print("No")
ConDefects/ConDefects/Code/abc323_a/Python/54486886
condefects-python_data_2280
S = input().strip() for i in range(1, 9): if S[2 * i - 1] != 0: print("No") exit() print("Yes") S = input().strip() for i in range(1, 9): if S[2 * i - 1] != "0": print("No") exit() print("Yes")
ConDefects/ConDefects/Code/abc323_a/Python/54934224
condefects-python_data_2281
S = input() ans = True for i in range(1, 17, 2): if S[i-1]!='0': ans = False if ans: print("Yes") else: print("No") S = input() ans = True for i in range(1, 17, 2): if S[i]!='0': ans = False if ans: print("Yes") else: print("No")
ConDefects/ConDefects/Code/abc323_a/Python/54970529
condefects-python_data_2282
s = input() for i in range(2,2,16): if s[i] != "0": print("No") break else: print("Yes") s = input() for i in range(1,17,2): if s[i] != "0": print("No") break else: print("Yes")
ConDefects/ConDefects/Code/abc323_a/Python/54767961
condefects-python_data_2283
#https://atcoder.jp/contests/abc323/tasks/abc323_a S = input() flag = True for i, s in enumerate(S): if (i + 1) % 2 == 0: print((i + 1), s) if s == "0": continue else: flag = False break if flag: print("Yes") else: print("No") #https://atcoder.j...
ConDefects/ConDefects/Code/abc323_a/Python/54513324
condefects-python_data_2284
from sys import stdin from sys import setrecursionlimit from heapq import * setrecursionlimit(10**8) input = lambda : stdin.readline().strip() N = int(input()) A = list(map(int, input().split())) thp = [[(0, -1)] for i in range(4 * N)] delt = set() def add(i, x, y, l, r, info): if l >= y or r <= x: return...
ConDefects/ConDefects/Code/abc342_g/Python/50740919
condefects-python_data_2285
#ABC342G Retroactive Range Chmax_禊 import heapq import sys input = sys.stdin.readline #入力受取 N = int(input()) A = list(map(int,input().split())) #node[i]: 現在の最小値(正負反転して扱う点に注意) #delete[i]: ノードiのうち、削除待ちキュー logN = (N - 1).bit_length() size = 1 << logN node = [[] for _ in range(2 * size)] for i in range(N): node[i + ...
ConDefects/ConDefects/Code/abc342_g/Python/50668241
condefects-python_data_2286
H, W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] Flag = True for a in range(H-1): for b in range(a+1, H): for c in range(W-1): for d in range(b+1, W): if A[a][c] + A[b][d] > A[b][c] + A[a][d]: Flag = False if Flag: print('Yes') else: print('No') H, W = map(int,...
ConDefects/ConDefects/Code/abc224_b/Python/46150770
condefects-python_data_2287
info = list(map(int, input().split())) n_rows = info[0] n_columns = info[1] matrix = [] for i in range(n_rows): matrix.append(list(map(int, input().split()))) does_satisfy = True for i in range(n_rows): for j in range(n_rows): if i < j: for l in range(n_columns): for k in range(n_columns): if l < k: ...
ConDefects/ConDefects/Code/abc224_b/Python/44610651
condefects-python_data_2288
H, W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] flag = True for h in range(H): for w in range(W): for i in range(h+1, H): for j in range(w+1, W): if A[h][w] + A[i][j] < A[i][w] + A[h][j] : flag = False if flag : print("Yes") else : prin...
ConDefects/ConDefects/Code/abc224_b/Python/45096470
condefects-python_data_2289
N = int(input()) A = list(map(int, input().split())) C = sorted(A) B = [] ans = 0 for i in range(int(N/2),N): ans += C[i] for i in range(N): if A[i] < C[int(N/2)]: B.append(1) else : B.append(-1) sum = 0 minimum = 0 minkey = -1 for i in range(N): sum += B[i] if sum < minimum: ...
ConDefects/ConDefects/Code/arc138_c/Python/31560360
condefects-python_data_2290
import sys n=int(input()) a=list(map(int,input().split())) sa=sorted(a) ans=0 for i in range(n//2,n): ans+=sa[i] med,s,id,mins,c=sa[n//2-1],0,0,n,0 for i,x in enumerate(a): if x<=med and c*2<n: s+=1 c+=1 else: s-=1 if s<mins: id,mins=i,s print(id+1,ans) import sys n=int(input()) a=list(map(int,input().s...
ConDefects/ConDefects/Code/arc138_c/Python/31278965
condefects-python_data_2291
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return...
ConDefects/ConDefects/Code/arc138_c/Python/30923012
condefects-python_data_2292
def main(): import sys, operator, math if sys.implementation.name == 'pypy': import pypyjit pypyjit.set_param('max_unroll_recursion=1') from math import gcd, floor, ceil, sqrt, isclose, pi, sin, cos, tan, asin, acos, atan, atan2, hypot, degrees, radians, log, log2, log10 from array import array from c...
ConDefects/ConDefects/Code/arc138_c/Python/31643804
condefects-python_data_2293
import itertools N,W = list(map(int,input().split())) A = list(map(int,input().split())) ans = set() for n in range(1,4): for ss in itertools.combinations(A,n): m = sum(ss) if(m < W): ans.add(m) print(len(ans)) import itertools N,W = list(map(int,input().split())) A = list(map(int,input...
ConDefects/ConDefects/Code/abc251_b/Python/46014786
condefects-python_data_2294
n, w = map(int, input().split()) an = list(map(int, input().split())) an.append(0) an.append(0) an.append(0) ans = set() n += 3 for i in range(n): for j in range(n): for k in range(n): total = an[i] + an[j] + an[k] if total != 0 and total < w and i != j and i != k and j != k: ...
ConDefects/ConDefects/Code/abc251_b/Python/45950112
condefects-python_data_2295
from itertools import combinations def ans_count(num_list, num, W, ans): result = 0 combinations_list = list(combinations(num_list, num)) for combination in combinations_list: # print(combination) if sum(combination) < W: ans.append(sum(combination)) return ans N,W = map(...
ConDefects/ConDefects/Code/abc251_b/Python/45515530
condefects-python_data_2296
n, w = map(int, input().split()) a = list(map(int, input().split())) sum_set = set(a) #2個の和 for i in range(0, n-1): for j in range(i+1, n): s = a[i] + a[j] if s<=w: sum_set.add(s) #3個の和 for i in range(0, n-2): for j in range(i+1, n-1): for k in range(j+1, n): s ...
ConDefects/ConDefects/Code/abc251_b/Python/44443990
condefects-python_data_2297
from itertools import combinations def getIntMap(): return map(int, input().split()) def getIntList(): return list(map(int, input().split())) def main(): N, W = getIntMap() A = getIntList() res = set() for i in range(1, 4): for elem in combinations(A, i): if sum(elem) ...
ConDefects/ConDefects/Code/abc251_b/Python/44546670
condefects-python_data_2298
n = int(input()) a = "" for i in range(2*n): a += "1" if i%2 ==0 else "0" print(a) n = int(input()) a = "" for i in range(2*n+1): a += "1" if i%2 ==0 else "0" print(a)
ConDefects/ConDefects/Code/abc341_a/Python/54737422
condefects-python_data_2299
N, M = map(int, input().split()) MOD = 998244353 if N == 0 or M == 0: print(0) exit() A = [] n = 1 while n <= N: A.append(n) n *= 2 #print(A) B = [] NN = N + 1 for a in A: b = NN // a b1 = b // 2 b2 = b % 2 c = NN % a d = b1 * a + b2 * c d %= MOD B.append(d) B = B + [0] * 60 #print("B =", B) M...
ConDefects/ConDefects/Code/abc356_d/Python/54865160
condefects-python_data_2300
N,M = map(int, input().split()) ans=0 for i in range(60): if (M>>i&1)==1: p=2**(i+1) r=N%p ans+=(N-r)/2 if (r>=2**i): ans+=(r-(2**i)+1) print(int(ans%998244353)) N,M = map(int, input().split()) ans=0 for i in range(60): if (M>>i&1)==1: p=2**(i+1) r=N%p ans+=N//p*2**i if (r>=2...
ConDefects/ConDefects/Code/abc356_d/Python/54706203