id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_301 | class SegmentTree:
def __init__(self, a):
self.padding = float('inf')
self.n = len(a)
self.N = 2 ** (self.n-1).bit_length()
self.seg_data = [self.padding]*(self.N-1) + a + [self.padding]*(self.N-self.n)
for i in range(2*self.N-2, 0, -2):
self.seg_data[(i-1... | ConDefects/ConDefects/Code/abc262_f/Python/48961945 |
condefects-python_data_302 | import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
class SWAG():
def __init__(self, op, e):
self.op = op
self.e = e
self.top = []
self.bottom = []
... | ConDefects/ConDefects/Code/abc262_f/Python/35966715 |
condefects-python_data_303 | N,K = map(int,input().split())
P = list(map(int,input().split()))
d = {}
for i in range(N):
d[P[i]] = i
for p in range(1,N+1):
k = d[p]
kk = N - k
if min(k,kk) > K:
continue
Q = P[:k]
R = P[k:]
ans = []
n = kk
if n > K:
ans = P
else:
for r in R:
if len(ans) == 0:
ans.appen... | ConDefects/ConDefects/Code/abc262_f/Python/47638667 |
condefects-python_data_304 | import itertools
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def get_root(s):
if s ^ root[s]:
root[s] = get_root(root[s])
return root[s]
return s
def unite(s, t):
rs, rt = get_root(s), get_root(t)
if not rs ^ rt:
return
root[rt] = rs
... | ConDefects/ConDefects/Code/abc296_h/Python/40275095 |
condefects-python_data_305 | import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
import sys
sys.setrecursionlimit(10**8)
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if A[0]!=1:
print(-1)
exit()
result=[[0]*2 for i in range(N+1)]
place=[0]*(N+1)
for i in range(N):
place[B[i]]=i
def dfs(l1,r1,l2,r2)... | ConDefects/ConDefects/Code/abc255_f/Python/50474364 |
condefects-python_data_306 | def main():
# write code here.
N = II()
P = LM_1()
I = LM_1()
inv = [0]*N
for i,e in enumerate(I):
inv[e] = i
left_child = [0]*N
right_child = [0]*N
if P[0]!=0:
print(-1)
return
def rec(PL, PR, IL, IR):
root = P[PL]
idx = inv[root]
... | ConDefects/ConDefects/Code/abc255_f/Python/53267275 |
condefects-python_data_307 | import sys
input = lambda: sys.stdin.readline().strip()
h, w = map(int, input().split())
rc = [input() for _ in range(h)]
snuke = 'snuke'
# 横
for i in range(h):
for j in range(w-4):
if rc[i][j:j+5] == snuke:
for k in range(j, j+5):
print(i+1, k+1)
if ''.join(list(reversed... | ConDefects/ConDefects/Code/abc302_b/Python/45763953 |
condefects-python_data_308 | import sys
readline = sys.stdin.readline
def gcd(a,b):
while b:
a, b = b, a%b
return abs(a)
def lcm(a, b):
return a*b//gcd(a, b)
class UFP():
def __init__(self, num, N):
self.par = [-1]*num
self.dist = [0]*num
self.gg = [N]*num
def find(self, x):
if self.par... | ConDefects/ConDefects/Code/arc141_e/Python/32093401 |
condefects-python_data_309 | P, B, N, M = map(int, input().split())
N += 1
G = [[False] * N for _ in range(N)]
for _ in range(M):
l, r = map(int, input().split())
l -= 1
G[l][r] = G[r][l] = True
INF = 10**18
dp = [INF] * (1 << N)
for msk in range(1 << N):
cnt = 0
for i in range(N):
for j in range(i + 1, N):
... | ConDefects/ConDefects/Code/arc171_d/Python/51665861 |
condefects-python_data_310 | import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
def popcount(x):
x = ((x >> 1) & 0x55555555) + (x & 0x55555555)
... | ConDefects/ConDefects/Code/arc171_d/Python/50018799 |
condefects-python_data_311 | p, b, n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
if p > 16:
print("Yes")
exit()
n += 1
ok = []
for i in range(1 << n):
for l, r in lr:
if (1 << (l - 1)) & i and (1 << r) & i:
ok.append(False)
break
else:
ok.append(T... | ConDefects/ConDefects/Code/arc171_d/Python/50321760 |
condefects-python_data_312 | P,B,N,M = map(int,input().split())
LR = [tuple(map(int,input().split())) for _ in range(M)]
if P >= N:
exit(print('Yes'))
INF = 10**18
N += 1
_dp = [INF] * (1<<N)
_dp[0] = 0
for b in range(1,1<<N):
for l,r in LR:
l -= 1
if b&(1<<l) and b&(1<<r):
break
else:
_dp[b] = 1
d... | ConDefects/ConDefects/Code/arc171_d/Python/50985599 |
condefects-python_data_313 | N,a,b = map(int,input().split())
A = list(map(int,input().split()))
left = 0
right = 10**9
while right-left>1:
mid = (left+right)//2
plus_cnt = 0
minus_cnt = 0
for i in range(N):
if A[i]<mid:
plus_cnt += (mid-A[i]+a-1)//a
else:
minus_cnt += (A[i]-mid)//b
if... | ConDefects/ConDefects/Code/arc144_b/Python/42258051 |
condefects-python_data_314 | def check(m, al, a, b):
a_cnt = 0
b_cnt = 0
for num in al:
diff = abs(num - m)
if num < diff:
cnt = diff // a
if diff % a != 0:
cnt += 1
a_cnt += cnt
else:
cnt = diff // b
b_cnt += cnt
return a_cnt <= b_... | ConDefects/ConDefects/Code/arc144_b/Python/41927392 |
condefects-python_data_315 | N,a,b=map(int,input().split())
A=list(map(int,input().split()))
def is_ok(mid):
lcnt=0
hcnt=0
for i in A:
if mid>i:
if (mid-i)%a==0:
lcnt+=(mid-i)//a
else:
lcnt+=(mid-i)//a+1
else:
hcnt+=(i-mid)//b
if lcnt<=hcnt:
... | ConDefects/ConDefects/Code/arc144_b/Python/37994644 |
condefects-python_data_316 | from sys import stdin
n, d = map(int, stdin.readline().split())
e = n*d
if e > (n*(n-1))//2:
print('No')
exit()
edge = []
u = 1
while e:
for i in range(1, n-u+1):
if e == 0:
break
if u+i > n:
edge.append([u, u+i-n])
else:
edge.append([u, u+i])
e -= 1
u += 1
print('Yes')
for u, v in edge:
print... | ConDefects/ConDefects/Code/arc161_d/Python/43311492 |
condefects-python_data_317 | from collections import deque, defaultdict
from math import log, asin, acos, cos, sin, tan, atan2, floor, gcd, sqrt, pi
# from math import *
from heapq import *
from bisect import bisect, bisect_left
import sys
from itertools import combinations, permutations, count
from functools import lru_cache, cmp_to_key
from oper... | ConDefects/ConDefects/Code/arc161_d/Python/42021171 |
condefects-python_data_318 | N, D = map(int, input().split())
if 2 * D > N - 1:
print("No")
exit()
print("Yes")
ans = set()
for i in range(N):
for j in range(1, N):
if (i, (i+j) % N) in ans or ((i + j) % N, i) in ans:
continue
ans.add((i, (i + j) % N))
if len(ans) == N * D:
break
... | ConDefects/ConDefects/Code/arc161_d/Python/43182082 |
condefects-python_data_319 | # import sys
# sys.setrecursionlimit(10**7)
# input = sys.stdin.readline
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def lm1(LIST): return list(map(lambda x:x-1, LIST))
def mps(A):return [tuple(map(int, input().... | ConDefects/ConDefects/Code/arc161_d/Python/44101361 |
condefects-python_data_320 | n,d=map(int,input().split())
if (n*(n-1))//2<n*d:
print("No")
exit()
print("Yes")
for i in range(1,d+1):
for j in range(n):
print(j+1,(j+d)%n+1)
n,d=map(int,input().split())
if (n*(n-1))//2<n*d:
print("No")
exit()
print("Yes")
for i in range(1,d+1):
for j in range(n):
p... | ConDefects/ConDefects/Code/arc161_d/Python/41819669 |
condefects-python_data_321 | ii = lambda: int(input())
li = lambda: list(map(int, input().split()))
ldi = lambda: list(map(lambda x: int(x) - 1, input().split()))
n, d = li()
if n - 1 < 2 * d:
print('No')
else:
print('Yes')
for i in range(n):
for j in range(1, d + 1):
print(i + 1, (i + d) % n + 1)
ii = lambda: in... | ConDefects/ConDefects/Code/arc161_d/Python/42297972 |
condefects-python_data_322 | from heapq import heappush, heappop
from math import inf
from sys import stdin
class FastIO:
def __init__(self):
self.random_seed = 0
self.flush = False
self.inf = 1 << 32
return
@staticmethod
def read_int():
return int(stdin.readline().rstrip())
@staticmethod... | ConDefects/ConDefects/Code/abc243_e/Python/52524531 |
condefects-python_data_323 | import sys
input = sys.stdin.readline
INF = 10**18
N, M = map(int, input().split())
dist = [[(INF, 0)] * N for _ in range(N)]
dist2 = [[(INF, 0)] * N for _ in range(N)]
for i in range(N):
dist[i][i] = (0, 0)
edges = []
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
dist[a][b]... | ConDefects/ConDefects/Code/abc243_e/Python/49785483 |
condefects-python_data_324 | A,B = (map(int,input().split()))
if A==1 and B==2:
print(3)
elif A==1 and B==3:
print(2)
elif A==2 and B==1:
print(3)
elif A==1 and B==2:
print(3)
elif A==3 and B==2:
print(1)
elif A==2 and B==3:
print(1)
else:
print(-1)
A,B = (map(int,input().split()))
if A==1 and B==2:
print(3)
elif A... | ConDefects/ConDefects/Code/abc355_a/Python/55137190 |
condefects-python_data_325 | A,B = map(int,input().split())
if A + B == 3:
print("3")
elif A + B == 4:
print("2")
elif A + B == 5:
print("1")
else:
print("-1")
A,B = map(int,input().split())
if A + B == 3:
print("3")
elif A + B == 4 and A != B:
print("2")
elif A + B == 5:
print("1")
else:
print("-1") | ConDefects/ConDefects/Code/abc355_a/Python/54910949 |
condefects-python_data_326 | s = str(input())
t = str(input())
pre = [False for i in range(len(t)+1)]
back = [False for i in range(len(t)+1)]
pre[0] = True
for i in range(1,len(t)+1):
if s[i-1] == t[i-1] or (s[i-1] == "?" or t[i-1] == "?"):
pre[i] = True
else:
break
back[len(t)] = True
for i in range(1,len(t)+1):
if ... | ConDefects/ConDefects/Code/abc287_d/Python/45092019 |
condefects-python_data_327 | S = input()
T = input()
# 前/後からnケタ一致する場合は front_match[n], back_match[n]
front_match = [False] * (len(T) + 1)
back_match = [False] * (len(T) + 1)
front_match[0] = True
back_match[0] = True
for idx, st in enumerate(zip(S[:len(T)], T)):
s, t = st
now = idx + 1
if s == '?' or t == '?' or s == t:
if fr... | ConDefects/ConDefects/Code/abc287_d/Python/46181501 |
condefects-python_data_328 | # import sys
# sys.setrecursionlimit(1000000)
import re
import copy
import bisect
import math
import itertools
import more_itertools
from collections import deque
from collections import defaultdict
from collections import Counter
from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from functools imp... | ConDefects/ConDefects/Code/abc287_d/Python/45345625 |
condefects-python_data_329 | s=input()
t=input()
m=len(s)
n=len(t)
ng=set()
for i in range(n):
if s[i-n+m]!=t[i] and s[i-n+m]!="?"!=t[i]:
ng.add(i)
print("Yes" if len(ng)==0 else "No")
for j in range(n):
if t[j]!="?" and s[j]!=t[j]:
ng.add(j)
else:
ng.discard(j)
print("Yes" if len(ng)==0 else "No")
s=input(... | ConDefects/ConDefects/Code/abc287_d/Python/45271287 |
condefects-python_data_330 | s = input()
t = input()
head, tail = 0, 0
for i in range(len(t)):
if s[i] != "?" and t[i] != "?" and s[i] != t[i]:
break
head += 1
for i in range(len(t)):
if s[i + len(s) - len(t)] != "?" and t[i] != "?" and s[i + len(s) - len(t)] != t[i]:
break
tail += 1
for i in range(len(t) + 1):
... | ConDefects/ConDefects/Code/abc287_d/Python/45342192 |
condefects-python_data_331 | def ip():return int(input())
def mp():return map(int, input().split())
def lmp():return list(map(int, input().split()))
# ABC287 D 796 - Match or Not
# 英小文字と ? からなる文字列 S,T が与えられます。
# ここで、|S| > |T| が成り立ちます(文字列 X に対し、|X| で X の長さを表します)。
# また、|X| = |Y| を満たす文字列 X,Y は、次の条件を満たすとき及びそのときに限りマッチするといいます。
# ・X,Y に含まれる ? をそれぞれ独立に好きな... | ConDefects/ConDefects/Code/abc287_d/Python/45533288 |
condefects-python_data_332 | N, K = map(int, input().split())
A = set(map(int, input().split()))
M = 400001
fact = [1] * M
mod = 998244353
for i in range(1, M):
fact[i] = fact[i-1]*i
fact[i] %= mod
inv_fact = [1] * M
inv_fact[-1] = pow(fact[-1], mod-2, mod)
for i in range(M-1, 0, -1):
inv_fact[i-1] = inv_fact[i]*i
inv_fact[i-1] %= mod
d... | ConDefects/ConDefects/Code/arc156_b/Python/40932797 |
condefects-python_data_333 | from collections import defaultdict, deque, Counter
from itertools import combinations, permutations, product, accumulate
from heapq import heapify, heappop, heappush
import math
import bisect
import sys
# sys.setrecursionlimit(700000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
... | ConDefects/ConDefects/Code/arc156_b/Python/39326078 |
condefects-python_data_334 | n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict as df
d=df(int)
for i in range(n):
d[a[i]]+=1
mex=[0]*(k+1)
now=0
for i in range(k+1):
while d[now]>0:
now+=1
mex[i]=now
now+=1
ans=0
fib=[1]*(n+k)
mod=998244353
for i in range(n+k-1):
fib[i+1]=fib[i]*(i+2)%m... | ConDefects/ConDefects/Code/arc156_b/Python/45544495 |
condefects-python_data_335 | MOD = 998244353
IMAG = 911660635
IIMAG = 86583718
rate2 = (0, 911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 867605899, 0)
irate2 = (0, 8... | ConDefects/ConDefects/Code/abc225_h/Python/40522843 |
condefects-python_data_336 | import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush... | ConDefects/ConDefects/Code/abc225_h/Python/41061041 |
condefects-python_data_337 | N = int(input())
log_table = [0]*(N+1)
a = 1
cnt = 0
for i in range(1,N+1):
if i == a*2:
a += 2
cnt += 1
log_table[i] = cnt
K = log_table[N]
table = [[-1]*(K+1) for _ in range(N)]
M = 0
for i in range(N):
table[i][0] = M
M += 1
for k in range(1,K+1):
for i in range(N):
if i+(... | ConDefects/ConDefects/Code/abc282_f/Python/45960750 |
condefects-python_data_338 | import sys
sys.setrecursionlimit(10**8)
N=int(input())
graph=[[] for _ in range(N)]
inf=10**18
for _ in range(N-1):
u,v=map(int,input().split())
graph[u-1].append(v-1)
graph[v-1].append(u-1)
visited=[0 for _ in range(N)]
answers=[[inf,0] for _ in range(N)]
number=1
def dfs(v):
global number
if len... | ConDefects/ConDefects/Code/abc240_e/Python/45982558 |
condefects-python_data_339 | n,m,*E=map(int,open(0).read().split())
*X,=*D,=C=[0]*2**n
*F,P=1,998244353
while m:m-=1;C[1<<E[m]-1]+=1;D[1<<E[~m]-1]+=1;F+=F[-1]*len(F)%P,
for i in range(1<<n):
j=k=i-1&i;c=C[i]=C[j]+C[i^j];d=D[i]=D[j]+D[i^j];x=F[c]
while j:x-=X[i^j]*F[C[j]];j=j-1&k
X[i]=x*(c==d)%P
print(sum(x*F[c]for x,c in zip(X,C[::-1]))*pow(F[-... | ConDefects/ConDefects/Code/abc321_g/Python/45920869 |
condefects-python_data_340 | n,m,p=map(int,input().split())
count=0
while m<n:
m+=p
count+=1
print(count)
n,m,p=map(int,input().split())
count=0
while m<=n:
m+=p
count+=1
print(count) | ConDefects/ConDefects/Code/abc318_a/Python/45771932 |
condefects-python_data_341 | #入力
n, m, p = map(int, input().split())
ans = 1
while m <= n:
ans += 1
m += p
print(ans)
#入力
n, m, p = map(int, input().split())
ans = 0
while m <= n:
ans += 1
m += p
print(ans) | ConDefects/ConDefects/Code/abc318_a/Python/45742364 |
condefects-python_data_342 | n,m,p=map(int,input().split())
print((n-m)//p)
n,m,p=map(int,input().split())
print((n-m)//p+1) | ConDefects/ConDefects/Code/abc318_a/Python/45804770 |
condefects-python_data_343 | n,m,p = input().split()
n,m,p = int(n),int(m),int(p)
count = 0
for i in range(n):
temp = m + (i*p)
if (i==temp):
count+=1
print(count)
n,m,p = input().split()
n,m,p = int(n),int(m),int(p)
count = 0
for i in range(n):
temp = m + (i*p)
if (temp<=n):
count+=1
print(count) | ConDefects/ConDefects/Code/abc318_a/Python/45737474 |
condefects-python_data_344 | N, M, P = map(int, input().split())
count = 0
for i in range(1, N + 1):
if(i == M):
count += 1
M = M + P * count
print(count)
N, M, P = map(int, input().split())
count = 0
for i in range(1, N + 1):
if(i == M):
count += 1
M = M + P
print(count) | ConDefects/ConDefects/Code/abc318_a/Python/46049626 |
condefects-python_data_345 | # スタックサイズの変更
import sys
sys.setrecursionlimit(10**6)
a, b ,c = map(int, input().split())
if(a-b>0):
print((a-b)//c+1)
else:
print(0)
# スタックサイズの変更
import sys
sys.setrecursionlimit(10**6)
a, b ,c = map(int, input().split())
if(a-b>0):
print((a-b)//c+1)
elif(a==b):
print(1)
else:
print(0) | ConDefects/ConDefects/Code/abc318_a/Python/46140133 |
condefects-python_data_346 | N, M, P = map(int, input().split())
ans = 0
if N > M:
ans += 1 + int((N - M) / P)
print(ans)
N, M, P = map(int, input().split())
ans = 0
if N >= M:
ans += 1 + int((N - M) / P)
print(ans) | ConDefects/ConDefects/Code/abc318_a/Python/45733281 |
condefects-python_data_347 | N,M,P = map(int,input().split())
count = 0
while M < N:
count += 1
M += P
print(count)
N,M,P = map(int,input().split())
count = 0
while M <= N:
count += 1
M += P
print(count)
| ConDefects/ConDefects/Code/abc318_a/Python/45771132 |
condefects-python_data_348 | N,M,P=map(int,input().split())
print((N-M)//P+1 if N>M else 0)
N,M,P=map(int,input().split())
print((N-M)//P+1 if N>=M else 0) | ConDefects/ConDefects/Code/abc318_a/Python/45803682 |
condefects-python_data_349 | moon = list(map(int, input().split()))
N = moon[0]
M = moon[1]
P = moon[2]
count = 0
while M < N:
count = count + 1
M = M + P
print(count)
moon = list(map(int, input().split()))
N = moon[0]
M = moon[1]
P = moon[2]
count = 0
while M <= N:
count = count + 1
M = M + P
print(count) | ConDefects/ConDefects/Code/abc318_a/Python/45807403 |
condefects-python_data_350 | n, m, p = map(int, input().split())
ans = 0
day = m
for i in range(2*(10**5)):
if day > n:
ans = i
break
day += p
print(ans)
n, m, p = map(int, input().split())
ans = 0
day = m
for i in range(3*(10**5)):
if day > n:
ans = i
break
day += p
print(ans) | ConDefects/ConDefects/Code/abc318_a/Python/45920497 |
condefects-python_data_351 | n, m, p = map(int, input().split())
print((n - m + 1) // p)
n, m, p = map(int, input().split())
print(((n - m + 1) + p - 1) // p) | ConDefects/ConDefects/Code/abc318_a/Python/46036999 |
condefects-python_data_352 | N,M,P = map(int,input().split())
count = 0
while M < N:
M +=P
count+=1
print(count)
N,M,P = map(int,input().split())
count = 0
while M <= N:
M +=P
count+=1
print(count) | ConDefects/ConDefects/Code/abc318_a/Python/45773988 |
condefects-python_data_353 | X,Y = map(int, input().split())
def di(a,b,mod): #b/a ax≡b(mod mod)
d=pow(a,-1,mod)
return b*d%mod
if X==0:
if abs(Y)==1 : print("2 0")
elif abs(Y)==2 : print("1 0")
else : print(-1)
elif Y==0:
if abs(X)==1 : print("0 2")
elif abs(X)==2 : print("0 1")
else : print(-1)
else:
import m... | ConDefects/ConDefects/Code/abc340_f/Python/52406082 |
condefects-python_data_354 | def extgcd(a,b,c):
if a==0:
if b==0 or c%b:return (0,0,0)
else:return(1,0,c//b)
if b==0:
if a==0 or c%a:return(0,0,0)
else:return(1,c//a,0)
if b<0:
a=-a
b=-b
c=-c
x1,y1=a%b,c%b
x2,y2=b-x1,b-y1
if x1<x2:
x1,x2=x2,x1
y1,y2=y2,... | ConDefects/ConDefects/Code/abc340_f/Python/53251643 |
condefects-python_data_355 | def extended_euclid(a, b):
c, d, e, f = 1, 0, 0, 1
while b != 0:
c, d = d, c - a // b * d
e, f = f, e - a // b * f
a, b = b, a % b
return (c, e)
def gcd(a,b):
if a%b==0:
return b
else:
return gcd(b,a%b)
X,Y=list(map(int,input().split()))
if X==0:
if abs(Y)==... | ConDefects/ConDefects/Code/abc340_f/Python/52511513 |
condefects-python_data_356 | def extended_gcd(a, b):
"""拡張ユークリッドの互除法を使用して ax + by = gcd(a, b) の解を求める"""
if a == 0:
return b, 0, 1
gcd, x1, y1 = extended_gcd(b % a, a)
x = y1 - (b // a) * x1
y = x1
return gcd, x, y
def find_integer_solution(X, Y):
gcd, A, B = extended_gcd(X, Y)
if 2 % gcd != 0:
... | ConDefects/ConDefects/Code/abc340_f/Python/55112719 |
condefects-python_data_357 | def tridiv(n):
pf, f = dict(), 2
while f*f<=n:
if n%f == 0 :
if f not in pf : pf[f]=0
pf[f]+=1
n//=f
else : f = f+2 if f>2 else 3
if n>1 :
if n not in pf : pf[n]=0
pf[n]+=1
return [k**v for k,v in pf.items()]
mod = 998244353
N,M = map(... | ConDefects/ConDefects/Code/abc349_f/Python/53462819 |
condefects-python_data_358 | S = list(input())
L = len(S)
count = [0] * 26
flag = False
for i in range(L):
count[ord(S[i]) - ord('a')] += 1
ans = 0
for i in range(25):
for j in range(i+1, 26):
ans += count[i] * count[j]
if count[i] > 1:
flag = True
if flag:
ans += 1
print(ans)
S = list(input())
L = len(S)
c... | ConDefects/ConDefects/Code/abc345_c/Python/54753666 |
condefects-python_data_359 | N=int(input())
cnt=[0]*3
div=[2,3,5]
for i in range(3):
x=div[i]
while True:
if N%x:
break
cnt[i]+=1
N//=x
if N>1:
print(0)
else:
a,b,c=cnt
dp=[[[0]*(c+1) for j in range(b+1)] for i in range(a+1)]
mod=998244353
dp[0][0][0]=1
inv=pow(5,mod-2,mod)
... | ConDefects/ConDefects/Code/abc300_e/Python/45250612 |
condefects-python_data_360 | def ezpow(a, b):
c = 1
for i in range(b):
c = c * a
return c
class PowMod:
def __init__(self, A, m=998244353):
self.memory = {}
self.A = A
self.m = m
def pow(self, b):
if (b == 0):
return 1
if (b == 1):
return self.A
if... | ConDefects/ConDefects/Code/abc300_e/Python/45218169 |
condefects-python_data_361 | N, M = map(int, input().split())
graph = [[] for _ in range(N+M+1)]
for i in range(N):
A = int(input())
S = set(map(int, input().split()))
for j in S:
graph[j].append(i+M+1)
graph[i+M+1].append(j)
from collections import deque
q = deque([])
q.append(1)
D = [1<<61] * (N+M+1)
D[1] = 0
while ... | ConDefects/ConDefects/Code/abc302_f/Python/45576163 |
condefects-python_data_362 | import math
import numpy
N,M = input().split()
N = int(N)
K = int(M)
#print(N+K)
list1 = list(map(int, input().split()))
list2 = []
counter1 = 0
counter2 = 0
counter3 = 0
counter4 = 0
counter5 = 0
#print(list1)
for a in range(N-1):
if list1[a] <= list1[a+1]:
counter1 += 1
counter2 = max(counter1, counter2)
... | ConDefects/ConDefects/Code/arc165_b/Python/45995987 |
condefects-python_data_363 | import sys
input = sys.stdin.readline
from random import randint
N,M,K=map(int,input().split())
if N<=K<=N*M and K%2==N%2:
print("Yes")
else:
print("No")
exit()
ANS=[["+"]*(2*M+1) for i in range(2*N+1)]
for i in range(1,2*N):
for j in range(1,2*M):
if i%2==1 and j%2==1:
ANS[i][j... | ConDefects/ConDefects/Code/abc358_f/Python/54701655 |
condefects-python_data_364 | def create_end_wall(hall):
return "+" * (2 * M - 1) + hall + "+"
def create_road(walls):
if isinstance(walls, int):
walls = [walls]
walls = set(map(lambda x: M - x - 2, walls))
ret = ["+o"]
for x in range(M - 1):
if x in walls:
ret.append("|")
else:
... | ConDefects/ConDefects/Code/abc358_f/Python/54691582 |
condefects-python_data_365 | n = int(input())
a = sorted(list(map(int, input().split())))
avg = sum(a) // n
extra = sum(a) % n
ans = 0
avg_list = [avg if i<extra else avg+1 for i in range(n)]
for i in range(n):
ans += abs(a[i] - avg_list[i])
print(ans // 2)
n = int(input())
a = sorted(list(map(int, input().split())))
avg = sum(a) // n
extr... | ConDefects/ConDefects/Code/abc313_c/Python/45773299 |
condefects-python_data_366 | MOD = 998244353
N = int(input())
ans = pow(1, N, MOD)
for i in range(N+2, N*2+1):
ans *= i
ans %= MOD
print(ans)
MOD = 998244353
N = int(input())
ans = pow(2, N, MOD)
for i in range(N+2, N*2+1):
ans *= i
ans %= MOD
print(ans) | ConDefects/ConDefects/Code/arc145_c/Python/40098177 |
condefects-python_data_367 | import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import math
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict
#from collections import deque
#import copy #DeepCopy: hoge =... | ConDefects/ConDefects/Code/arc145_c/Python/34717448 |
condefects-python_data_368 | h,w = list(map(int,input().split(' ')))
b = [[0 for j in range(h)] for i in range(w)]
for i in range(h):
tmp = list(map(int,input().split(' ')))
for j in range(w):
b[j][h-1-i] = tmp[j]
for b_ in b:
print(*b_)
h,w = list(map(int,input().split(' ')))
b = [[0 for j in range(h)] for i in range(w)]
for i in range... | ConDefects/ConDefects/Code/abc237_b/Python/52801286 |
condefects-python_data_369 | from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
idx = defaultdict(list)
for i in range(N - 1, -1, -1):
idx[A[i]].append(i)
used = set()
ans = []
for a in A:
if a in used:
continue
while ans and ans[-1] > a and idx[ans[-1]]:
used.dis... | ConDefects/ConDefects/Code/abc299_g/Python/52236570 |
condefects-python_data_370 | #!/usr/bin/env python3
import sys
import heapq
def solve(N: int, M: int, A: "list[int]"):
last_index = [0 for _ in range(M+1)]
for i in range(N):
last_index[A[i]] = i
partitions = []
for i in range(1, M+1):
partitions.append(last_index[i])
partitions.sort(reverse=True)
l = -1
... | ConDefects/ConDefects/Code/abc299_g/Python/43242154 |
condefects-python_data_371 | k = int(input())
if k > 60:
k = k-60
if k < 10:
print("22:0"+str(k))
else:
print("22:"+ str(k))
else:
if k < 10:
print("21:0"+str(k))
else:
print("21:"+ str(k))
k = int(input())
if k >= 60:
k = k-60
if k < 10:
print("22:0"+str(k))
else:
print("22:"+ str(k))
else:
if k < 10:
... | ConDefects/ConDefects/Code/abc258_a/Python/46135145 |
condefects-python_data_372 | # https://atcoder.jp/contests/abc258/tasks/abc258_a
K = int(input())
if K > 69:
print(f"22:{K - 60}")
elif K > 59:
print(f"22:0{K - 60}")
else:
print(f"21:{K}")
# https://atcoder.jp/contests/abc258/tasks/abc258_a
K = int(input())
if K > 69:
print(f"22:{K - 60}")
elif K > 59:
print(f"22:0{K - 60... | ConDefects/ConDefects/Code/abc258_a/Python/44904869 |
condefects-python_data_373 | k = int(input())
print(f"{21 + k // 60}:{k % 60}")
k = int(input())
print(f"{21 + k // 60:02}:{k % 60:02}") | ConDefects/ConDefects/Code/abc258_a/Python/45012247 |
condefects-python_data_374 | N, X, Y, Z = map(int, input().split())
if (X<Y and Y<Z) or (X>Y and Y>Z):
print("Yes")
else:
print("No")
N, X, Y, Z = map(int, input().split())
if (X<Z and Z<Y) or (X>Z and Z>Y):
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc352_a/Python/55109662 |
condefects-python_data_375 | import bisect
import collections
import functools
import heapq
import itertools
import math
import operator
import string
import sys
readline = sys.stdin.readline
LS = lambda: readline().strip()
LI = lambda: int(readline().strip())
LLS = lambda: readline().strip().split()
LL = lambda: list(map(int, readline().strip().... | ConDefects/ConDefects/Code/abc352_a/Python/54917636 |
condefects-python_data_376 | N,X,Y,Z = map(int,input().split())
if X <= Z and Z <= Y:
print("Yes")
else:
print("No")
N,X,Y,Z = map(int,input().split())
if (X <= Z and Z <= Y) or (Y <= Z and Z <= X):
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc352_a/Python/55005308 |
condefects-python_data_377 | n, x, y, z = map(int, input().split())
if x<z<y or y<z<x:
print("YES")
else:
print("No")
n, x, y, z = map(int, input().split())
if x<z<y or y<z<x:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc352_a/Python/54737577 |
condefects-python_data_378 | N, X, Y, Z = input().split()
start = min(X, Y)
end = max(X, Y)
result = "No"
if start <= Z and end >= Z:
result = "Yes"
print(result)
N, X, Y, Z = map(int, input().split())
start = min(X, Y)
end = max(X, Y)
result = "No"
if start <= Z and end >= Z:
result = "Yes"
print(result)
| ConDefects/ConDefects/Code/abc352_a/Python/54864046 |
condefects-python_data_379 | N = int(input())
key = N
point = 0
l = []
while key > 0:
s = key % 10
key = key // 10
point += 1
l.append(s)
if point <= 3:
print(N)
elif point == 4:
l[0] = 0
for i in range(point-1, -1, -1):
print(l[i],end='')
elif point == 5:
l[0] = 0
l[1] = 1
for i in range(point-1, ... | ConDefects/ConDefects/Code/abc304_b/Python/45808253 |
condefects-python_data_380 | N = int(input())
def range(n):
if(n < 10**3):
return 0
elif(10**3 <= n < 10**4):
return 1
elif(10**4 <= n < 10**5):
return 2
elif(10**5 <= n < 10**6):
return 3
elif(10**6 <= n < 10**7):
return 4
elif(10**7 <= n < 10**8):
return 5
elif(10**8 <=... | ConDefects/ConDefects/Code/abc304_b/Python/46153900 |
condefects-python_data_381 | N = int(input())
if N <= 10 ** 3 - 1:
print(N)
elif 10 ** 3 <= N <= 10 ** 4 - 1:
print(N // 10 * 10)
elif 10 ** 4 <= N <= 10 ** 5 - 1:
print(N // 100 * 100)
elif 10 ** 5 <= N <= 10 ** 6 - 1:
print(N // 1000 * 1000)
elif 10 ** 6 <= N <= 10 ** 7 - 1:
print(N // 10000 * 10000)
elif 10 ** 7 <= N <= 10 ... | ConDefects/ConDefects/Code/abc304_b/Python/46194774 |
condefects-python_data_382 | n = int(input())
for i in range(6):
if n <= 10**(3 + i) - 1:
print((n // (10**i)) * 10**i)
break
n = int(input())
for i in range(7):
if n <= 10**(3 + i) - 1:
print((n // (10**i)) * 10**i)
break
| ConDefects/ConDefects/Code/abc304_b/Python/45306152 |
condefects-python_data_383 | n = int(input())
if n <= 10**3-1:
print(n)
elif n <= 10**4-1:
print(n - n%10)
elif n <= 10**5-1:
print(n - n%100)
elif n <= 10**6-1:
print(n - n%1000)
elif n <= 10**7-1:
print(n - n%10000)
elif n <= 10**8-1:
print(n - n%100000)
n = int(input())
if n <= 10**3-1:
print(n)
elif n <= 10**4-1:
... | ConDefects/ConDefects/Code/abc304_b/Python/45336297 |
condefects-python_data_384 | import sys
# sys.setrecursionlimit(100000)
input=lambda:sys.stdin.readline().strip()
# write=lambda x:sys.stdout.write(str(x)+'\n')
# from decimal import Decimal
# from random import randint
# from copy import deepcopy
from collections import deque,Counter
# from heapq import heapify,heappush,heappop
# from bisect imp... | ConDefects/ConDefects/Code/abc304_b/Python/45577481 |
condefects-python_data_385 | N = int(input())
S = input()
ans = []
pre = '0'
bottom = ['A', 'B']
for i in range(N-1, -1, -1):
if pre == S[i]:
continue
for j in range(i+1):
ans.append(bottom[int(pre)])
pre = S[i]
print(len(ans))
print(*ans)
N = int(input())
S = input()
ans = []
pre = '0'
bottom = ['A', 'B']
for i in range(N-1, -1,... | ConDefects/ConDefects/Code/arc177_b/Python/53566689 |
condefects-python_data_386 | N = int(input())
S = input()
ans = ''
for i in range(N-1, -1, -1):
s = S[i]
if s == '1':
print(i, 'A'*(i+1)+'B'*i)
ans += 'A'*(i+1)+'B'*i
print(len(ans))
print(ans)
N = int(input())
S = input()
ans = ''
for i in range(N-1, -1, -1):
s = S[i]
if s == '1':
#print(i, 'A'*(i+1)+'B'*... | ConDefects/ConDefects/Code/arc177_b/Python/53558819 |
condefects-python_data_387 | N = int(input())
S = input()
cur = 0
ans = ''
for i in range(N):
if int(S[N-i-1]) != (cur // 2**i) % 2:
X = (1 << N) - (1 << i)
if S[i] == '1':
ans += 'A' * (N-i)
cur = cur ^ X
else:
ans += 'B' * (N-i)
cur = cur ^ X
print(len(ans))
print(ans)
N = int(input())
S = input()
cur = 0
... | ConDefects/ConDefects/Code/arc177_b/Python/54054467 |
condefects-python_data_388 | def hantei(N,A):
for n1 in range(N):
for n2 in range(N):
if ((A[n1][n2] == "-" and A[n2][n1] == "-")
or (A[n1][n2] == "W" and A[n2][n1] == "L")
or (A[n1][n2] == "L" and A[n2][n1] == "W")
or (A[n1][n2] == "D" and A[n2][n1] == "D")):
... | ConDefects/ConDefects/Code/abc261_b/Python/45054015 |
condefects-python_data_389 | N = int(input())
A = [list(input()) for _ in range(N)]
for i in range(N):
for j in range(N):
if A[i][j] == 'W' and A[j][i] =='W' or A[i][j] == 'L' and A[j][i] =='L':
print('incorrect')
exit()
print('correct')
N = int(input())
A = [list(input()) for _ in range(N)]
for i in range(N):
for j in range... | ConDefects/ConDefects/Code/abc261_b/Python/45282531 |
condefects-python_data_390 | n = int(input())
a = [list(input()) for _ in range(n)]
b = []
for i in range(n):
tmp = []
for j in range(n):
tmp.append(a[j][i])
b.append(tmp)
ans = "correct"
for i in range(n):
for j in range(n):
if i == j:
continue
if a[i][j] == b[i][j] == 'D':
continue
if a[i][j] == b[i][j]:
... | ConDefects/ConDefects/Code/abc261_b/Python/45997045 |
condefects-python_data_391 | N = int(input())
A = [list(input()) for _ in range(N)]
for i in range(N):
for j in range(N):
if i != j and A[i][j] == 'W' and A[j][i] == 'L':
continue
elif i != j and A[i][j] == 'D' and A[j][i] == 'D':
continue
elif i == j:
continue
else:
print('incorrect')
exit()
print('correct')
N = int(i... | ConDefects/ConDefects/Code/abc261_b/Python/45074177 |
condefects-python_data_392 | N = int(input())
A = [list(input()) for _ in range(N)]
count = 0
for i in range(N):
for k in range(N):
if (i == k) and (A[i][k] == '-') :
count += 1
if (i != k) and (A[i][k] == 'W') and (A[k][i] == 'L'):
count += 1
if (i != k) and (A[k][i] == 'W') and (A[i][k] == 'L'):
count += 1
if coun... | ConDefects/ConDefects/Code/abc261_b/Python/45115214 |
condefects-python_data_393 | n = int(input())
kama = [list(input()) for i in range(n)]
for i in range(n):
for ipp in range(n):
if kama[i][ipp] == "W":
if kama[ipp][i] != "L":
print("incorrect")
exit()
elif kama[i][ipp] == "D":
if kama[ipp][i] != "D":
print(... | ConDefects/ConDefects/Code/abc261_b/Python/46179770 |
condefects-python_data_394 | n=int(input())
p=list(map(int,input().split()))
ans=p[0] if p.count(max(p))==1 and p[0]==max(p) else max(p)+1-p[0]
print(ans)
n=int(input())
p=list(map(int,input().split()))
ans=0 if p.count(max(p))==1 and p[0]==max(p) else max(p)+1-p[0]
print(ans) | ConDefects/ConDefects/Code/abc313_a/Python/45698032 |
condefects-python_data_395 | import sys
N, *P = map(int, sys.stdin.buffer.read().split())
if N > 1:
print(max(0, max(P[1:])-P[0]+1))
else:
print(P[0])
import sys
N, *P = map(int, sys.stdin.buffer.read().split())
if N > 1:
print(max(0, max(P[1:])-P[0]+1))
else:
print(0) | ConDefects/ConDefects/Code/abc313_a/Python/45811912 |
condefects-python_data_396 | N = int(input())
P = list(map(int,input().split()))
m = 0
for i in range(1,N):
m = max(m, P[i])
print(0,m+1-P[0])
N = int(input())
P = list(map(int,input().split()))
m = 0
for i in range(1,N):
m = max(m, P[i])
print(max(0,m+1-P[0])) | ConDefects/ConDefects/Code/abc313_a/Python/45785774 |
condefects-python_data_397 | N = int(input())
X = 0
Y = 0
for i in range(N):
x, y = map(int,input().split())
X += x
Y += y
if X > Y:
print("Takahasi")
elif X == Y:
print("Draw")
else:
print("Aoki")
N = int(input())
X = 0
Y = 0
for i in range(N):
x, y = map(int,input().split())
X += x
Y += y
if X > Y:
... | ConDefects/ConDefects/Code/abc337_a/Python/54540906 |
condefects-python_data_398 | n = int(input())
x = 0
y = 0
for i in range(n):
a, b= map(int,input().split())
x += a
y += b
if x > y: print("Takahashi")
elif x < y: print("Aoki")
else: print("Drow")
n = int(input())
x = 0
y = 0
for i in range(n):
a, b= map(int,input().split())
x += a
y += b
if x > y: print("Takahashi")
e... | ConDefects/ConDefects/Code/abc337_a/Python/54867325 |
condefects-python_data_399 | T = 0
A = 0
N = int(input())
for i in range(N):
a, t = map(int, input().split())
T += t
A += a
if T == A:
print('Draw')
elif T > A:
print('Takahashi')
else:
print('Aoki')
T = 0
A = 0
N = int(input())
for i in range(N):
a, t = map(int, input().split())
T += t
A += a
if T == A:
print('Draw')
... | ConDefects/ConDefects/Code/abc337_a/Python/54731532 |
condefects-python_data_400 | N = int(input())
scoreX = 0
scoreY = 0
for i in range(N):
X, Y = map(int, input().split())
scoreX += X
scoreY += Y
if scoreX > scoreY:
print('Takahashi')
elif scoreX < scoreY:
print('Aoki')
else:
print('draw')
N = int(input())
scoreX = 0
scoreY = 0
for i in range(N):
X, Y = map(int, input().split())
... | ConDefects/ConDefects/Code/abc337_a/Python/54518158 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.