id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_2401 | n,q=map(int,input().split())
X=list(map(int,input().split()))
ans=[0]*(n+1)
acc=[0]*(q+1)
add=[0]*(n+1)
se=set()
for i,x in enumerate(X):
if x not in se:
se.add(x)
add[x]=i
else:
se.discard(x)
ans[x]+=acc[i]-acc[add[x]]
add[x]=-1
acc[i+1]=acc[i]+len(se)
for i in range(1,n+1):
ans[i]+... | ConDefects/ConDefects/Code/abc347_e/Python/52950646 |
condefects-python_data_2402 | #############################################################
import sys
sys.setrecursionlimit(10**7)
from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
ipt = sys.stdin.readline
def... | ConDefects/ConDefects/Code/abc340_g/Python/50192467 |
condefects-python_data_2403 | import sys
from functools import lru_cache
sys.setrecursionlimit(50000)
def input_general():
return sys.stdin.readline().rstrip('\r\n')
def input_num():
return int(sys.stdin.readline().rstrip("\r\n"))
def input_multi(x=int):
return map(x, sys.stdin.readline().rstrip("\r\n").split())
def input_list(x... | ConDefects/ConDefects/Code/agc058_b/Python/34054427 |
condefects-python_data_2404 | MOD = 10**9+7
n = int(input())
arr = list(map(lambda x:n-int(x), input().split()))
dp = [[0]*n for i in range(n)]
dp[0][arr[0]] = 1
dp1 = [0]*n
dp1[0] = 1
for i in range(1, n):
a = arr[i]
j = i-1
while j >= 0 and arr[j] > a:
j -= 1
j += 1
if j == 0:
dp[0][a] = 1
dp1[0] += 1
... | ConDefects/ConDefects/Code/agc058_b/Python/34050152 |
condefects-python_data_2405 |
mod=998244353
N=int(input())
P=list(map(int,input().split()))
L=[i for i in range(N)]
R=[i for i in range(N)]
for i in range(N):
j=i
while j>=0:
if P[i]>=P[j]:
j-=1
else:
break
L[i]=j+1
j=i
while j<N:
if P[i]>=P[j]:
j+=1
else:
break
R[i]=j
print(L)
print(R)
DP=[0]*(N... | ConDefects/ConDefects/Code/agc058_b/Python/34045717 |
condefects-python_data_2406 | from collections import Counter, defaultdict
# from sortedcontainers import SortedSet, SortedList
n = int(input())
arr = list(map(int, input().split()))
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
l, r = i, i+1
while l > 0 and arr[l-1] < arr[i]:
l -= 1
while r < n and arr[r] < arr[i]:
r ... | ConDefects/ConDefects/Code/agc058_b/Python/34059476 |
condefects-python_data_2407 | import sys
def _bsf(n):
"n > 0"
return ((n & -n) - 1).bit_length()
def _bsr(n):
"n > 0"
return n.bit_length() - 1
class FastSet:
"""C++ like set (ordered set) whose elements are limited to integers less than about 10 ** 10.
The number `n` is supposed to be less than about 10 ** 10,
an... | ConDefects/ConDefects/Code/agc058_b/Python/34047806 |
condefects-python_data_2408 | n = int(input())
P = list(map(int, input().split()))
L = []
stack = [(n + 1, 0)]
for i, p in enumerate(P, 1):
while stack[-1][0] < p:
stack.pop()
L.append(stack[-1][1])
stack.append((p, i))
R = []
stack = [(n + 1, n)]
for i in range(n - 1, -1, -1):
p = P[i]
while stack[-1][0] < p:
s... | ConDefects/ConDefects/Code/agc058_b/Python/34067395 |
condefects-python_data_2409 |
from itertools import accumulate
from typing import List, Tuple
import sys
import os
sys.setrecursionlimit(int(1e9))
input = lambda: sys.stdin.readline().rstrip("\r\n")
MOD = 998244353
INF = int(4e18)
def getRange(
nums: List[int],
*,
isMax=False,
isLeftStrict=True,
isRightStrict=False,
) -> Li... | ConDefects/ConDefects/Code/agc058_b/Python/34060327 |
condefects-python_data_2410 | N = int(input())
A = list(map(int,input().split()))
if sum(A) > 0:
print(-sum(A))
else:
print(sum(A))
N = int(input())
A = list(map(int,input().split()))
if sum(A) > 0:
print(-sum(A))
else:
print(-sum(A)) | ConDefects/ConDefects/Code/abc349_a/Python/54914679 |
condefects-python_data_2411 | n = int(input())
a = list(map(int,input().split()))
a_n = abs(sum(a))
print(a_n)
n = int(input())
a = list(map(int,input().split()))
a_n = 0 - sum(a)
print(a_n) | ConDefects/ConDefects/Code/abc349_a/Python/54735340 |
condefects-python_data_2412 | import sys
input=sys.stdin.readline
N,H = map(int,input().split())
X = list(map(int,input().split()))
X = [0] + X
P = [0 for i in range(N+1)]
F = [0 for i in range(N+1)]
for i in range(1,N):
P[i],F[i] = map(int,input().split())
inf = 10**8
dp = [[[inf for i in range(H+1)] for i in range(H+1)] for i in range(N+1)]
f... | ConDefects/ConDefects/Code/abc320_f/Python/46034926 |
condefects-python_data_2413 | import math
import re
import functools
import random
import sys
import os
import typing
from math import gcd,comb,sqrt
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from itertools import accumulate, combinations, permutations
from heapq import nsmallest, nlargest, heappushp... | ConDefects/ConDefects/Code/abc320_f/Python/51972231 |
condefects-python_data_2414 | #!/usr/bin/env python3
import sys
def solve(N: int, H: int, X: "list[int]", P: "list[int]", F: "list[int]"):
INF = 99
L = []
cur = 0
for i in range(N):
L.append(X[i]-cur)
cur = X[i]
dp = [[[INF]*(H+1) for _ in range(H+1)] for _ in range(N+1)]
P.append(0)
F.append(0)
for... | ConDefects/ConDefects/Code/abc320_f/Python/47539324 |
condefects-python_data_2415 | n,h=map(int,input().split())
x=list(map(int,input().split()))+[0]
X=10**10
q=[[X]*(h+1) for i in range(h+1)]
for i in range(h+1):
q[h][i]=0
from atcoder import lazysegtree
for i in range(n):
nq=[[X]*(h+1) for j in range(h+1)]
p,f=0,0
if i<n-1:
p,f=map(int,input().split())
dx=x[i]-x[i-1]
for j in range(h... | ConDefects/ConDefects/Code/abc320_f/Python/48703794 |
condefects-python_data_2416 | import collections
T=int(input())
for t in range(T):
N,M=map(int,input().split())
C=list(map(int,input().split()))
G=[[] for i in range(N)]
for i in range(M):
u,v=map(int,input().split())
u-=1
v-=1
G[u].append(v)
G[v].append(u)
inf=10**9+10
D=[[in... | ConDefects/ConDefects/Code/abc289_e/Python/45463729 |
condefects-python_data_2417 | from collections import deque
def solve():
n, m = map(int,input().split())
c = list(map(int,input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int,input().split())
u -= 1
v -= 1
g[u].append(v)
g[v].append(u)
if c[0] == c[n-1]:
... | ConDefects/ConDefects/Code/abc289_e/Python/46186786 |
condefects-python_data_2418 | from ortools.linear_solver import pywraplp
l,r=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[list(map(int,input().split())) for i in range(l)]
p=pywraplp.Solver.CreateSolver("PDLP")
x=[p.NumVar(0,p.infinity(),"x_{}".format(i)) for i in range(l)]
y=[p.NumVar(0,p.infinity()... | ConDefects/ConDefects/Code/abc224_h/Python/48473722 |
condefects-python_data_2419 | mod = 998244353
n,*A = map(int,open(0).read().split())
A.append(A[-1])
C = [0]*(n+1)
ans = 1
l = r = 0
s = 0
c = 0
dp = [0]*n
for i in range(n):
c += C[A[i]] == 0
C[A[i]] = 1
while r < i-2 and c >= 3:
C[A[r]] -= 1
c -= C[A[r]] == 0
s += dp[r]
s %= mod
r += 1
if i == l:
t = 1
else:
... | ConDefects/ConDefects/Code/arc128_d/Python/26708943 |
condefects-python_data_2420 | import sys
readline = sys.stdin.readline
n = int(readline())
*a, = map(int,readline().split())
a.append(a[-1])
def solve(a):
# 隣接する同じ元がない
n = len(a)
if n <= 2: return 1
# ababa パターンはダメ、それ以外はok
same = list(range(n))
for i in range(2,n):
if a[i] == a[i-2]:
same[i] = same[i-2]... | ConDefects/ConDefects/Code/arc128_d/Python/26604143 |
condefects-python_data_2421 | import math
def distance_2d(x1, y1, x2, y2):
return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
n = int(input())
l = [0]*n
ans = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
l[i]=list(map(int, input().split()))
for i in range(n):
for j in range(n):
ans[i][j] = distance_2d(l[i][0], ... | ConDefects/ConDefects/Code/abc234_b/Python/45754993 |
condefects-python_data_2422 | 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): retu... | ConDefects/ConDefects/Code/abc235_g/Python/28594583 |
condefects-python_data_2423 | N, A, B, C = map(int,input().split())
mod = 998244353
fact = [1]*(N+1)
invf = [1]*(N+1)
for i in range(N):
fact[i+1] = fact[i] * (i+1) % mod
invf[-1] = pow(fact[-1], mod-2, mod)
for i in range(N, 0, -1):
invf[i-1] = invf[i] * i % mod
def comb(n, k):
if n < 0 or k < 0 or n < k:
return 0
return fact[n] * invf... | ConDefects/ConDefects/Code/abc235_g/Python/28640040 |
condefects-python_data_2424 | class CalcFactorial:
def __init__(self, n, mod=998244353):
self.n = n
self.mod = mod
self.fact = [0] * (n + 1)
self.fact[0] = 1
for i in range(n):
self.fact[i + 1] = self.fact[i] * (i + 1) % mod
# i! のmodにおける逆元
self.inv = [0] * (n + 1)
sel... | ConDefects/ConDefects/Code/abc235_g/Python/48493148 |
condefects-python_data_2425 | # InlineImporter
import os as _os
import sys as _sys
from functools import lru_cache as _lru_cache
from importlib.abc import ExecutionLoader, MetaPathFinder
from importlib.machinery import ModuleSpec
class InlineImporter(ExecutionLoader, MetaPathFinder):
version = None
inlined_modules = {}
namespace_pack... | ConDefects/ConDefects/Code/abc235_g/Python/28570313 |
condefects-python_data_2426 | n,a,b,c = map(int,input().split())
mod = 998244353
## nCkのmodを求める関数
# テーブルを作る(前処理)
max_n = n + 10
fac, finv, inv = [0]*max_n, [0]*max_n, [0]*max_n
def comInit(max_n):
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,max_n):
fac[i] = fac[i-1]* i% mod
inv[i] = mod - inv... | ConDefects/ConDefects/Code/abc235_g/Python/30010913 |
condefects-python_data_2427 | import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n, a, b, c = map(int, input().split())
mod = 998244353
l = n + 5
fact = [1] * (l + 1)
for i in range(1, l + 1):
fact[i] = i * fact[i - 1] % mod
inv = [1] * (l + 1)
inv[l] = pow(fact[l], mod - 2, mod)
for i in range(l - 1, -1, -1):
... | ConDefects/ConDefects/Code/abc235_g/Python/43758724 |
condefects-python_data_2428 | import itertools
def main():
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a, b, c in itertools.combinations(xy, 3):
s = abs((a[0] - c[0]) * (b[1] - c[1]) - (b[0] - c[0]) * (a[1] - c[1])) // 2
if s > 0:
ans += 1
print(ans)
if __... | ConDefects/ConDefects/Code/abc224_c/Python/46196808 |
condefects-python_data_2429 | N=int(input())
XY=[]
for i in range(N):
XY.append(list(map(int, input().split())))
#print(N)
#print(XY)
count=0
for i in range(N):
for j in range(i+1,N):
for k in range(j+1,N):
#print(i,j,k)
if (XY[k][1]-XY[i][1])*(XY[j][0]-XY[i][0])!=(XY[j][0]-XY[i][0])*(XY[k][0]-XY[i][0]):
count+=1
print(... | ConDefects/ConDefects/Code/abc224_c/Python/44477761 |
condefects-python_data_2430 | # 凸四角形の十分条件→対角線が交わればOK
def getIntTuple():
return tuple(map(int, input().split()))
def isIntersect(A, B, C, D):
tb = (B[1] - A[1])*(C[0] - A[0])-(C[1] - A[1])*(B[0] - A[0])
td = (D[1] - A[1])*(C[0] - A[0])-(C[1] - A[1])*(D[0] - A[0])
ta = (A[1] - B[1])*(D[0] - B[0])-(D[1] - B[1])*(A[0] - B[0])
tc ... | ConDefects/ConDefects/Code/abc266_c/Python/44375735 |
condefects-python_data_2431 | s=[list(map(int,input().split())) for i in range(4)]
for i in range(4):
cn=0
for j in range(1,4):
a,b=0,10
for k in range(1,4):
if k!=j:
a=k;b=min(b,k)
x=[s[(i+a)%4][0]-s[(i+b)%4][0],s[(i+a)%4][1]-s[(i+b)%4][1]]#0=x[1]*x-x[0]*y+c
c=x[0]*s[(i+b)%4][1]-x[1]*s[(i+b)%4][0]
if (x[1]*s[i... | ConDefects/ConDefects/Code/abc266_c/Python/45522626 |
condefects-python_data_2432 | # coding: utf-8
from fractions import Fraction
from functools import partial
try:
dummy = src
minp = partial(src.pop, 0)
except NameError:
minp = input
def ints():
return list(map(int, minp().rstrip().split(' ')))
def int1():
return int(minp().rstrip())
def above_below(p, p1, p2):
'''
点(x... | ConDefects/ConDefects/Code/abc266_c/Python/45028964 |
condefects-python_data_2433 | N = int(input())
A = [int(input()) for i in range(N)]
MOD = [998244353, 1000000007, 1000000009]
M = len(MOD)
C = [[A[i] % MOD[c] for i in range(N)] for c in range(M)]
d = [{} for _ in range(M)]
for c in range(M):
for i in range(N):
if C[c][i] not in d[c]:
d[c][C[c][i]] = 1
else:
... | ConDefects/ConDefects/Code/abc339_f/Python/53281757 |
condefects-python_data_2434 | import sys
sys.set_int_max_str_digits(0)
input = sys.stdin.readline
from bisect import bisect_left
N = int(input())
A = sorted(int(input()) for _ in range(N))
ans = 0
for i in range(N-1):
for j in range(i, N):
x = A[i] * A[j]
idx = bisect_left(A, x)
if idx == N: break
while idx < N and x == A[idx]:... | ConDefects/ConDefects/Code/abc339_f/Python/52982584 |
condefects-python_data_2435 | import sys
from typing import Counter
inf = 1e9
def input():
return sys.stdin.readline().strip()
def solution(nums):
MOD = 10**9 + 9
N = len(nums)
nums = [x % MOD for x in nums]
count = Counter(nums)
ans = 0
for i in range(N):
for j in range(N):
ans += count[(nums[... | ConDefects/ConDefects/Code/abc339_f/Python/53967299 |
condefects-python_data_2436 | from collections import defaultdict
from random import randint
n = int(input())
a_list = [int(input()) for _ in range(n)]
m = randint(10 ** 32, 10 ** 33)
d = defaultdict(lambda: 0)
for a in a_list:
d[a] += 1
ans = 0
for p in a_list:
for q in a_list:
ans += d[p * q % m]
print(ans)
from collections import de... | ConDefects/ConDefects/Code/abc339_f/Python/54497544 |
condefects-python_data_2437 | n = int(input())
mod = 2**127-1
a = [int(input())%mod for _ in range(n)]
d = dict()
for i in a:
d.setdefault(i,0)
d[i] += 1
ans = 0
for i in a:
for j in a:
value = i*j%mod
if value in d: ans += d[value%mod]
print(ans)
n = int(input())
mod = 98080989074039189058908908209991
a = [int(input... | ConDefects/ConDefects/Code/abc339_f/Python/52897763 |
condefects-python_data_2438 | S = input()
print(S[:-1] + "1")
S = input()
print(S[:-1] + "4") | ConDefects/ConDefects/Code/abc335_a/Python/54722195 |
condefects-python_data_2439 | s = input()
s[:-1]
print(s + "4")
s = input()
s = s[:-1]
print(s + "4") | ConDefects/ConDefects/Code/abc335_a/Python/54743914 |
condefects-python_data_2440 | N,M=map(int,input().split())
mod=998244353
answer=(-1)**(N%2)*(M-1)+pow(M-1,N,mod)
print(answer)
N,M=map(int,input().split())
mod=998244353
answer=(-1)**(N%2)*(M-1)+pow(M-1,N,mod)
print(answer%mod) | ConDefects/ConDefects/Code/abc307_e/Python/46214607 |
condefects-python_data_2441 | 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_c/Python/42020807 |
condefects-python_data_2442 | import sys
sys.setrecursionlimit(10**7)
def dfs(u,v):
seen[v]=True
temp=0
X[v]=u
for next_v in G[v]:
if seen[next_v]:
continue
temp+=1
dfs(u,next_v)
if ans[next_v] in set(['',S[v]]) :
count[v]+=1
if temp>0:
if (count[v]>len(G[v])//2):
... | ConDefects/ConDefects/Code/arc161_c/Python/42743947 |
condefects-python_data_2443 | from collections import deque
T=int(input())
for _ in range(T):
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
a,b=map(int,input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
S=input()
ans=[""]*N
Ecnt=[0]*N
todo=deque()
for i in range(N):
... | ConDefects/ConDefects/Code/arc161_c/Python/41901042 |
condefects-python_data_2444 | from heapq import *
n, m = map(int, input().split())
A = [*map(int, input().split())]
G = [set() for _ in range(n)]
score = [0] * n
for _ in range(m):
u, v = map(int, input().split())
G[u - 1].add(v - 1)
G[v - 1].add(u - 1)
score[u - 1] += A[v - 1]
score[v - 1] += A[u - 1]
Q = [(c, i) for i, c in e... | ConDefects/ConDefects/Code/abc267_e/Python/46128146 |
condefects-python_data_2445 | from typing import Generic, Iterable, Iterator, List, Tuple, TypeVar, Optional
from collections import deque, defaultdict
from decimal import Decimal
from bisect import bisect_left, bisect_right
from heapq import heapify, heappush, heappop
from itertools import permutations, combinations
from random import randrange, c... | ConDefects/ConDefects/Code/abc267_e/Python/44930062 |
condefects-python_data_2446 | n, m = map(int, input().split())
x = list(map(int, input().split()))
imos_l = [0] * (n + 1)
for i in range(m - 1):
st, en = x[i], x[i + 1]
dist1 = max(st, en) - min(st, en)
dist2 = n - dist1
short_dist = min(dist1, dist2)
long_dist = max(dist1, dist2)
dist_diff = long_dist - short_dist
# 短... | ConDefects/ConDefects/Code/abc338_d/Python/52942487 |
condefects-python_data_2447 | n, m = map(int, input().split())
x = list(map(int, input().split()))
cost = [0]*(n + 1)
for i in range(m - 1):
l, r = min(x[i], x[i + 1]), max(x[i], x[i + 1])
cost[1] += r - l
cost[l] += n - 2*(r - l)
cost[r] -= n - 2*(r - l)
ans = 1 << 32
for i in range(1, n + 1):
cost[i] += cost[i - 1]
if co... | ConDefects/ConDefects/Code/abc338_d/Python/53178716 |
condefects-python_data_2448 |
def main():
N, M = map(int, input().split())
A = list(map(int, input().split()))
cost = [0]*(2*N)
ans = 0
for i in range(M-1):
s, t = A[i], A[i+1]
s, t = min(s, t), max(s, t)
if 2*(t-s) < N:
ans += t-s
d = N + 2*s - 2*t
cost[s] += d
... | ConDefects/ConDefects/Code/abc338_d/Python/52286746 |
condefects-python_data_2449 | n=11
s=bin(n).replace('0b','').replace('1','2')
print(s)
n=int(input())
s=bin(n).replace('0b','').replace('1','2')
print(s) | ConDefects/ConDefects/Code/abc234_c/Python/45751042 |
condefects-python_data_2450 | k=int(input())
ans=bin(k).replace('1','2')
print(ans)
k=int(input())
ans=bin(k)[2:].replace('1','2')
print(ans)
| ConDefects/ConDefects/Code/abc234_c/Python/46127385 |
condefects-python_data_2451 | from collections import defaultdict
inf = 2 * 10 ** 18
N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])[::-1]
X = defaultdict(list)
L = [inf]
for _ in range(M):
x, y = map(int, input().split())
X[x].append(x - y)
L.append(x - y)
for x in X:
X[x].sort()
SA = sorted(X.keys()... | ConDefects/ConDefects/Code/abc255_g/Python/35788058 |
condefects-python_data_2452 | 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/abc255_g/Python/32458462 |
condefects-python_data_2453 | DEBUG = 0
class BitSet():
def __init__(self, L = [], X = None):
self.m = 63
if X is None:
self.n = (len(L) - 1) // self.m + 1
self.X = [0] * self.n
for i in range(self.n):
for j in range(self.m):
ij = i * self.m + j
... | ConDefects/ConDefects/Code/abc276_h/Python/36292897 |
condefects-python_data_2454 | DEBUG = 0
class VectorSpace01:
def __init__(self):
self.E = []
def __contains__(self, n):
for e in self.E:
n = min(n, n ^ e)
return 1 if n == 0 else 0
def add(self, n):
for e in self.E:
n = min(n, n ^ e)
if n:
self.E.appen... | ConDefects/ConDefects/Code/abc276_h/Python/36291832 |
condefects-python_data_2455 | num = list(map(int ,input().split(" ")))
N = num[0]
M = num[1]
S = input()
T = input()
if T == S:
print(0)
elif T[:N] == S:
print(1)
elif T[-N:] == S:
print(2)
else:
print(3)
num = list(map(int ,input().split(" ")))
N = num[0]
M = num[1]
S = input()
T = input()
if T[:N] == S and T[-N:] == S:
print(0)
eli... | ConDefects/ConDefects/Code/abc322_b/Python/46194153 |
condefects-python_data_2456 | n,m=map(int,input().split())
s=input()
t=input()
k=3
if t[0:n]==s:
k-=2
elif t[-n::]==s:
k-=1
print(k)
n,m=map(int,input().split())
s=input()
t=input()
k=3
if t[0:n]==s:
k-=2
if t[-n::]==s:
k-=1
print(k) | ConDefects/ConDefects/Code/abc322_b/Python/46209097 |
condefects-python_data_2457 | N,M=input().split()
S=tuple(input())
T=tuple(input())
if S==T[:int(N)]:
if S==T[int(M)-int(N)+1:]:
print(0)
else:
print(1)
else:
if S==T[int(M)-int(N):]:
print(2)
else:
print(3)
N,M=input().split()
S=tuple(input())
T=tuple(input())
if S==T[:int(N)]:
if S==T[int(M)-int(N):]:
print(0)
e... | ConDefects/ConDefects/Code/abc322_b/Python/46203237 |
condefects-python_data_2458 | N,M = map(int,input().split())
S = input()
T = input()
if(S==T):
print(0)
else:
atama = T.find(S) == 0
sippo = T.find(S) == len(T) - len(S)
if(atama and sippo):
print(0)
elif(atama):
print(1)
elif(sippo):
print(2)
else:
print(3)
N,M = map(int,i... | ConDefects/ConDefects/Code/abc322_b/Python/46203055 |
condefects-python_data_2459 | n,m=map(int,input().split())
s=input()
t=input()
if t == s:
print(0)
elif t.find(s)==0:
print(1)
elif t.rfind(s)==m-n:
print(2)
else:
print(3)
n,m=map(int,input().split())
s=input()
t=input()
if (t.find(s)==0)and(t.rfind(s)==m-n):
print(0)
elif t.find(s)==0:
print(1)
elif t.rfind(s)==m-n:
print(2)
else... | ConDefects/ConDefects/Code/abc322_b/Python/54956037 |
condefects-python_data_2460 | length1, length2 = map(int,input().split())
word1 = str(input())
word2 = str(input())
if word2[length1:length2] == word1:
a = True
else:
a = False
if word2[0:length1] == word1:
b = True
else:
b = False
if a == True and b == True:
print(0)
elif a == False and b == True:
print(1)
elif a == True and b == False:
pr... | ConDefects/ConDefects/Code/abc322_b/Python/55147333 |
condefects-python_data_2461 | N,M = map(int,input().split())
S = input()
T = input()
is_head = True
is_tail = True
for i in range(N):
if S[i] != T[i]:
is_head = False
break
for i in range(N):
if S[-i] != T[-i]:
is_tail = False
break
if is_head and is_tail:
print(0)
elif is_head and is_tail == False:
... | ConDefects/ConDefects/Code/abc322_b/Python/46196763 |
condefects-python_data_2462 | n,m = map(int,input().split())
s = input()
t = input()
if s == t:
print(0)
elif s == t[:n]:
print(1)
elif s == t[-n:]:
print(2)
else:
print(3)
n,m = map(int,input().split())
s = input()
t = input()
if s == t[:n] and s == t[-n:]:
print(0)
elif s == t[:n]:
print(1)
elif s == t[-n:]:
print(2... | ConDefects/ConDefects/Code/abc322_b/Python/54506289 |
condefects-python_data_2463 | #!/usr/bin/env python3
n, m = map(int, input().split())
s = input()
t = input()
if s == t:
print(0)
elif s == t[:n]:
print(1)
elif s == t[-n:]:
print(2)
else:
print(3)
#!/usr/bin/env python3
n, m = map(int, input().split())
s = input()
t = input()
if s == t[:n] and s == t[-n:]:
print(0)
elif s ==... | ConDefects/ConDefects/Code/abc322_b/Python/55147125 |
condefects-python_data_2464 | T = int(input())
for i in range(T):
N = int(input())
if N < 7:
print(-1)
continue
tem = str(bin(N))[2:]
res = [0 for i in range(len(tem))]
count = 0
flag = True
for i in reversed(range(len(tem))):
if tem[i] == "1":
count += 1
if count >= 3:
cou... | ConDefects/ConDefects/Code/arc161_b/Python/45955580 |
condefects-python_data_2465 | t=int(input())
bits=[1<<i for i in range(60)]
def r(x):
if x<7:
return -1
cnt=0
bs = []
for i in range(60)[::-1]:
if t&bits[i]:
if cnt==2:
return bits[bs[0]]+bits[bs[1]]+bits[i]
bs.append(i)
cnt+=1
if cnt==1:
return bits[bs[0]-1]+bits[bs[0]-2]+bits[bs[0]-3]
else:
if... | ConDefects/ConDefects/Code/arc161_b/Python/43559540 |
condefects-python_data_2466 | T = int(input())
for _ in range(T):
N = int(input())
if N < 7:
print(-1)
continue
cnt = bin(N).count('1')
if cnt == 1:
print((N>>1) + (N>>2) + (N>>3))
elif cnt == 2:
if N & 1 or N & 2:
print((N>>1) + (N>>2) + (N>>3))
else:
s = 0
... | ConDefects/ConDefects/Code/arc161_b/Python/45311674 |
condefects-python_data_2467 | a=1
flg=[]
while a < 10**18:
flg.append(a)
a*=2
s=set()
l=len(flg)
for i in range(l):
for j in range(l):
for k in range(l):
if i != j and i != k and j != k:
if flg[i]+flg[j]+flg[k] <= 10**18:
s.add(flg[i]+flg[j]+flg[k])
l=list(s)
l.sort()
le=len(l)
i... | ConDefects/ConDefects/Code/arc161_b/Python/43572863 |
condefects-python_data_2468 | N = int(input())
XY = [[int(i) for i in input().split()] for _ in range(N)]
INF = 10**13
maC = 30
dp = [INF]*((N)*(maC+1))
def pos2ind(n,c):
return n*(maC+1) + c
dp[0] = 0
for i in range(1, N):
x,y = XY[i]
for j in range(maC+1):
if j>i-1:
break
for k in range(1, j+2):
... | ConDefects/ConDefects/Code/abc315_f/Python/46136201 |
condefects-python_data_2469 | import math
N = int(input())
XY = [[int(i) for i in input().split()] for _ in range(N)]
inf = 1e10
M = min(20, N)
dp = [[inf] * (M + 1) for _ in range(N + 1)]
dp[0][0] = 0.0
for i in range(N - 1):
for c in range(M):
if dp[i][c] == inf:
continue
for c2 in range(c, M):
np = ... | ConDefects/ConDefects/Code/abc315_f/Python/46043300 |
condefects-python_data_2470 | N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = K*(K+1)//2
for a in set(A):
if a < K:
ans -= a
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = K*(K+1)//2
for a in set(A):
if a <= K:
ans -= a
print(ans) | ConDefects/ConDefects/Code/abc346_c/Python/55155506 |
condefects-python_data_2471 | N, K = map(int, input().split())
A = list(map(int, input().split()))
sa = set(A)
dis = 0
for a in sa:
if a < K:
dis += a
print((K + 1) * K // 2 - dis)
N, K = map(int, input().split())
A = list(map(int, input().split()))
sa = set(A)
dis = 0
for a in sa:
if a <= K:
dis += a
print((K + 1) * K // 2 - d... | ConDefects/ConDefects/Code/abc346_c/Python/55135268 |
condefects-python_data_2472 | N, K = map(int, input().split())
A = set(map(int, input().split()))
sum = int((K * (K + 1)) / 2)
for a in A:
if 1 <= a <= K:
sum -= a
print(sum)
N, K = map(int, input().split())
A = set(map(int, input().split()))
sum = K * (K + 1) // 2
for a in A:
if 1 <= a <= K:
sum -= a
print(sum)
| ConDefects/ConDefects/Code/abc346_c/Python/54986100 |
condefects-python_data_2473 | from bisect import bisect_right
import sys
input = sys.stdin.readline
def comb_preprocess(n, mod):
fact = [1] * (n+1)
fact_inv = [1] * (n+1)
for i in range(1, n+1):
fact[i] = i * fact[i-1] % mod
fact_inv[n] = pow(fact[n], mod-2, mod)
for i in range(1, n+1)[::-1]:
fact_inv[i-1] = i *... | ConDefects/ConDefects/Code/arc139_d/Python/31251082 |
condefects-python_data_2474 | x1,y1,x2,y2 = map(int,input().split())
if (abs(x1-x2)==1 or abs(x1-x2)==3) and (abs(y1-y2)==1 or abs(y1-y2)==3) :
print("Yes")
else:
print("No")
x1,y1,x2,y2 = map(int,input().split())
if ((abs(x1-x2)==1 or abs(x1-x2)==3) and (abs(y1-y2)==1 or abs(y1-y2)==3)) or ((abs(x1-x2)==2 and abs(y1-y2)==4) or (abs(x1-x2)==4 ... | ConDefects/ConDefects/Code/abc239_c/Python/45467238 |
condefects-python_data_2475 | import sys
sys.setrecursionlimit(10**9)
def main():
x1, y1, x2, y2 = map(int, input().split())
if abs(x1 - x2) <= 4 and abs(y1 - y2) <= 4:
if abs(x1 - x2) == 1 and abs(y1 - y2) in [1, 3]:
print("Yes")
elif abs(x1 - x2) == 0 and abs(y1 - y2) in [2, 4]:
print("Yes")
... | ConDefects/ConDefects/Code/abc239_c/Python/44818357 |
condefects-python_data_2476 | p, q, r, s = [int(x) for x in input().split()]
d = (p - r) ** 2 + (q - s) ** 2
if d in (2, 4, 10, 16, 20):
print("Yes")
else:
print("No")
p, q, r, s = [int(x) for x in input().split()]
d = (p - r) ** 2 + (q - s) ** 2
if d in (2, 4, 10, 16, 18, 20):
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc239_c/Python/46171405 |
condefects-python_data_2477 | x1,y1,x2,y2 = map(int,input().split())
def culc(a,b,c,d):
return (a-c)**2+(b-d)**2
for i in range(x1-2,y1+3):
for j in range(y1-2,y1+3):
if culc(i,j,x2,y2)==5 and culc(i,j,x1,y1)==5 :
print("Yes")
exit()
print("No")
x1,y1,x2,y2 = map(int,input().split())
def culc(a,b,c,d):
... | ConDefects/ConDefects/Code/abc239_c/Python/45558170 |
condefects-python_data_2478 | N = int(input())
W,X = [],[]
for i in range(N) :
w,x = map(int,input().split())
W.append(w)
X.append(x)
max_count = 0
for j in range(24):
count = 0
for i in range(N):
now_time = (X[i]+j)%24
if ((now_time >= 9)and(now_time <= 18)):
count += W[i]
max_count = max(max_... | ConDefects/ConDefects/Code/abc325_b/Python/54778964 |
condefects-python_data_2479 | #0509
N = int(input())
C = [0] * 24
for i in range(N):
W, X = map(int, input().split())
C[X] = W
B = 0
for j in range(24):
A = 0
for k in range(9):
A += C[(k + j) % 24]
B = max(A, B)
print(B)
#0509
N = int(input())
C = [0] * 24
for i in range(N):
W, X = map(int, input().split())
... | ConDefects/ConDefects/Code/abc325_b/Python/54237927 |
condefects-python_data_2480 | N = int(input())
A = [0 for _ in range(24)]
for _ in range(N) :
w, x = map(int, input().split())
A[x] += w
A += A
res = 0
for i in range(0, 24) :
res = max(res, max(A[9 + i : 19 + i]))
print(res)
N = int(input())
A = [0 for _ in range(24)]
for _ in range(N) :
w, x = map(int, input().split())
A[x] += w
A += ... | ConDefects/ConDefects/Code/abc325_b/Python/54888009 |
condefects-python_data_2481 | N = int(input())
W = [0] * N
X = [0] * N
for i in range(N):
w, x = (int(x) for x in input().split())
W[i] = w
X[i] = x
ans = 0
for i in range(24):
c = 0
for j in range(N):
t = (X[j] + i) % 24
if 9 < t < 18:
c += W[j]
ans = max(ans, c)
print(ans)
N = int(input())... | ConDefects/ConDefects/Code/abc325_b/Python/54669093 |
condefects-python_data_2482 | MOD = 998244353
class ml(list):
def __setitem__(self, key, value):
super().__setitem__(key, value%MOD)
n = int(input())
a = list(map(int, input().split()))
dp = [ml([0] * (1<<10)) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
inv = pow(a[i], -1, MOD)
for bit in range(1<<10):
if dp[... | ConDefects/ConDefects/Code/abc310_f/Python/50729164 |
condefects-python_data_2483 |
BigPrime = 998244353
N = int(input())
# ac ¥equiv 1 mod b となるcを求める
# @lru_cache(maxsize=4096)
# def modinv(a, b):
# b0 = b
# x0, x1 = 0, 1
# while a > 1:
# q = a // b
# a, b = b, a % b
# x0, x1 = x1 - q * x0, x0
# if x1 < 0:
# x1 += b0
# return x1
def modinv(a, b)... | ConDefects/ConDefects/Code/arc174_c/Python/51488503 |
condefects-python_data_2484 | import sys
sys.setrecursionlimit(10**6)
def e(x):
if dp[x] != -1:
return dp[x]
if x == 0:
dp[x] = 0
return 0
if x == 1:
dp[x] = n*(n-1)*pow(2*n-1,mod-2,mod)%mod
return dp[x]
inv = pow(2*n*x-x**2,mod-2,mod)
res = inv*(x*(x-1)*e(x-2) + (2*n*x-2*x*x+x)*e(x-1) + (... | ConDefects/ConDefects/Code/arc174_c/Python/54909674 |
condefects-python_data_2485 | H,W = map(int,input().split())
C = []
for i in range(H):
C.append(list(input()))
def check(y,x):
size = 0
while True:
if (y + (size + 1) < H and x + (size + 1) < W and C[y+(size+1)][x+(size+1)] == '#') and \
(y + (size + 1) < H and x - (size + 1) >= 0 and C[y+(size+1)][x-(size+1)] == '... | ConDefects/ConDefects/Code/abc300_c/Python/45723345 |
condefects-python_data_2486 | # Copyright (c) 2023, Le Duc Phuc Long
# If you don't think twice, you have to code twice.
# Import session
import sys
#input = sys.stdin.readline
from collections import defaultdict
############ ---- Input Functions ---- ############
def inp():
return int(input())
def inlt():
return list(map(int, input().s... | ConDefects/ConDefects/Code/abc300_c/Python/45749744 |
condefects-python_data_2487 | import sys,random,bisect,copy, time
from math import gcd, comb
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from functools import lru_cache, cmp_to_key
from itertools import permutations, combinations
from math import gcd,log,sqrt
from sortedcontainers import SortedList
from atco... | ConDefects/ConDefects/Code/abc247_f/Python/49035803 |
condefects-python_data_2488 |
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
f = [0]*(200001)
f[1] = 1
f[2] = 3
mod = 998244353
for i in range(3,200001):
f[i] = (f[i-1] + f[i-2])%mod
dp = [0]*(200001)
dp[1] = 1
dp[2] = 3
dp[3] = 4
for i in range(4,200001):
dp[i] = (f[i-3] + f[i-1])%mod
edge = [... | ConDefects/ConDefects/Code/abc247_f/Python/55036523 |
condefects-python_data_2489 | from collections import defaultdict
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n+1)
self.rank = [0]*(n+1)
def find(self, x):
if(self.root[x] < 0):
return x
else:
self.root[x] = self.find(self.root[x])
retur... | ConDefects/ConDefects/Code/abc247_f/Python/52972964 |
condefects-python_data_2490 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, *A = map(int, read().split())
inf = 1 << 60
ans = inf
dp = [[inf, inf] for _ in range(N + 1)]
dp[1][0] = 0
for i in range(1, N):
dp[i + 1][0] = dp[i][1]
dp[i + 1][1] = min(dp[i]) + A[i]
ans = min(ans, dp[N][1... | ConDefects/ConDefects/Code/abc251_e/Python/45556624 |
condefects-python_data_2491 | import numpy as np
import sys
from functools import lru_cache
import math
sys.setrecursionlimit(int(1e7))
from collections import *
from fractions import Fraction
import heapq
import bisect
import itertools
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(... | ConDefects/ConDefects/Code/abc251_e/Python/45699667 |
condefects-python_data_2492 | n,t=[int(x) for x in input().split()]
s=input()
x=[int(x) for x in input().split()]
x0=[]
x1=[]
for i,s1 in enumerate(s):
if(s1=="0"):
x0.append(x[i])
else:
x1.append(x[i])
nx0=len(x0)
nx1=len(x1)
i=0
j=0
ans=0
#print(x0)
#print(x1)
for y in x1:
while(i<(nx0) and x0[i]<y):
i+=1
while(j<(nx0) and x0... | ConDefects/ConDefects/Code/abc360_d/Python/55144134 |
condefects-python_data_2493 | from bisect import bisect_right
N, T = map(int, input().split())
S = list(input())
X = list(map(int, input().split()))
LS = len(S)
ans = 0
Z = []
for i in range(LS):
if S[i] == '0':
Z.append(X[i])
Z.sort()
for i in range(LS):
if S[i] == '1':
ans += bisect_right(Z, X[i] * 2 * T) - bisect_right(Z,... | ConDefects/ConDefects/Code/abc360_d/Python/55158034 |
condefects-python_data_2494 | import sys, math, string
from collections import Counter
from bisect import bisect_right as upper_bound, bisect_left as lower_bound
input = lambda: sys.stdin.readline().rstrip()
read = lambda: int(input())
reads = lambda: map(int, input().split())
readlist = lambda n=None: (
list(map(int, input().split()))
if ... | ConDefects/ConDefects/Code/abc360_d/Python/55135895 |
condefects-python_data_2495 | def query(a, x):
l = 0
r = len(a)
m = (l+r)//2
while l < r:
if a[m] <= x:
l = m+1
else:
r = m
m = (l+r)//2
return m
n, t = tuple(map(int,input().split()))
s = input()
x = list(map(int,input().split()))
pos = []
neg = []
for i in range(n):
if s[i]... | ConDefects/ConDefects/Code/abc360_d/Python/55161015 |
condefects-python_data_2496 | import bisect
n,t = map(int, input().split())
s = input()
x = list(map(int, input().split()))
x.sort()
r = []
l = []
for i in range(n):
if s[i] == "1":
r.append(x[i])
else:
l.append(x[i])
s = 0
for i in r:
s += bisect.bisect_right(l, i+t*2) - bisect.bisect_right(l, i)
print(s)
import bis... | ConDefects/ConDefects/Code/abc360_d/Python/55163205 |
condefects-python_data_2497 | from collections import deque
N, T = map(int, input().split())
S = input()
X = list(map(int, input().split()))
num_l_ants = S.count('0')
l_ants = [0] * num_l_ants
r_ants = [0] * (N - num_l_ants)
l = 0
r = 0
for i, (c, x) in enumerate(zip(S, X)):
if c == '0':
l_ants[l] = x
l += 1
else:
... | ConDefects/ConDefects/Code/abc360_d/Python/55130899 |
condefects-python_data_2498 | mod=67280421310721
class segtree:
def __init__(self,n):
self.size=1
self.height=0
while self.size<n:
self.size*=2
self.height+=1
self.dat=[10**10]*(self.size*2)
self.lazy=[10**10]*(self.size*2)
def update(self,l,r,a):
l+=self.size
r+=se... | ConDefects/ConDefects/Code/abc257_g/Python/45268157 |
condefects-python_data_2499 | s = input()
print("Yes" if s[0].isupper() and s[1:].islower() else "No")
s = input()
print("Yes" if s.istitle() else "No") | ConDefects/ConDefects/Code/abc338_a/Python/54692987 |
condefects-python_data_2500 | print("YNeos"[input().istitle()::2])
print("NYoe s"[input().istitle()::2]) | ConDefects/ConDefects/Code/abc338_a/Python/54708656 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.