id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_201 | from heapq import heappop,heappush
import sys
read = sys.stdin.buffer.read
N,M,*DATA = map(int,read().split())
ST = DATA[:2*M]
it = iter(DATA[2*M:])
LR = [[0,0]]
for l,r in zip(it,it):
LR.append([l,r])
links = [[] for _ in range(N+1)]
links_rev = [[] for _ in range(N+1)]
it = iter(ST)
for s,t in zip(it,it):
l... | ConDefects/ConDefects/Code/abc304_h/Python/42019155 |
condefects-python_data_202 | import os,sys
from io import BytesIO, IOBase
sys.setrecursionlimit(10**6)
from typing import *
# only use pypyjit when needed, it usese more memory, but speeds up recursion in pypy
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
# sys.stdout = open('output.txt', 'w')
# Fast IO Region
BUFSIZE = 8192
cla... | ConDefects/ConDefects/Code/abc304_h/Python/42210009 |
condefects-python_data_203 | n, k = map(int,input().split())
A = list(map(int,input().split()))
seen = [-1]*n
now_pos = 0
candy = [0]
cnt = 0
while seen[now_pos] == -1:
seen[now_pos] = cnt
candy.append(candy[-1] + A[now_pos])
cnt += 1
if cnt == k:
print(candy[-1])
exit()
now_pos = candy[-1] % n
start_loop = see... | ConDefects/ConDefects/Code/abc241_e/Python/45018675 |
condefects-python_data_204 | """
Author ankisho
Created 2023/09/10 22:47JST
"""
N,K = map(int,input().split())
A = list(map(int,input().split()))
nset = set()#すでに出現したあまり
ls = []
ncandy = 0
while True:
idx = ncandy%N
if idx in nset:
cycle_st = idx
break
else:
ls.append(idx)
nset.add(idx)
ncandy += ... | ConDefects/ConDefects/Code/abc241_e/Python/45450212 |
condefects-python_data_205 | def ip():return int(input())
def mp():return map(int, input().split())
def lmp():return list(map(int, input().split()))
# ABC241 E 1248 - Putting Candies
# 長さ N の数列 A = (A0,A1,…,A_{N-1}) が与えられます。
# 最初の時点では空の皿があり、高橋君は次の操作を K 回繰り返します。
# ・皿の中のアメの個数を X とする。皿に A_(X mod N) 個のアメを追加する。
# K 回の操作の後で、皿の中には何個のアメがあるか求めてください。
# ・2 ≤... | ConDefects/ConDefects/Code/abc241_e/Python/46162583 |
condefects-python_data_206 | import math
MOD = 998244353
def main():
n = int(input())
k = math.floor(math.log10(n)) + 1
y = pow(10**k - 1, MOD - 2, MOD)
ans = ((n % MOD) * (pow(10, n * k, MOD) - 1) * y) % MOD
print(ans)
if __name__ == "__main__":
main()
import math
MOD = 998244353
def main():
n = int(input())
... | ConDefects/ConDefects/Code/abc357_d/Python/54944133 |
condefects-python_data_207 | def Arithmetic_Sequence_Sum(N,first_term,common_ratio,mod):
return first_term*(Matrix(matrix=[[common_ratio,1],[0,1]],mod=mod)@N)[0][1]%mod
class Matrix:
def __init__(self,H=0,W=0,matrix=False,eps=0,mod=0,identity=0):
if identity:
if H:
self.H=H
self.W=H
... | ConDefects/ConDefects/Code/abc357_d/Python/54746473 |
condefects-python_data_208 | def extgcd(a, b):
if b:
d, y, x = extgcd(b, a % b)
y -= (a // b) * x
return d, x, y
return a, 1, 0
def remainder(V):
x = 0; d = 1
for X, Y in V:
g, a, b = extgcd(d, Y)
x, d = (Y*b*x + d*a*X) // g, d*(Y // g)
x %= d
return x, d
lis = [4, 9, 5, 7, 11, ... | ConDefects/ConDefects/Code/abc286_f/Python/45090669 |
condefects-python_data_209 | n, k = map(int, input().split())
a = list(map(int, input().split()))
seat_count = k
dep_count = 0
for i in range(n):
if seat_count > a[i]:
seat_count -= a[i]
elif seat_count < a[i]:
dep_count += 1
seat_count = k
seat_count -= a[i]
if seat_count == 0:
dep_coun... | ConDefects/ConDefects/Code/abc353_b/Python/54945668 |
condefects-python_data_210 | N,K=map(int,input().split())
A=list(map(int,input().split()))
i,num=0,0
for x in range(N):
if A[x]+i<=K:
i=i+A[x]
print(i,"now1")
elif A[x]+i>K:
num+=1
i=0
i=i+A[x]
print(i,"now2")
print(num+1)
N,K=map(int,input().split())
A=list(map(int,input().split()))
i,num=0... | ConDefects/ConDefects/Code/abc353_b/Python/55018999 |
condefects-python_data_211 | n, m, *a = map(int, open(0).read().split())
a.sort()
ans = sum(i*i for i in a)
pairs = n - m
for i in range(pairs):
ans += 2 * a[i] * a[i+pairs]
print(ans)
n, m, *a = map(int, open(0).read().split())
a.sort()
ans = sum(i*i for i in a)
pairs = n - m
for i in range(pairs):
ans += 2 * a[i] * a[pairs+pairs-1-i]
... | ConDefects/ConDefects/Code/arc167_a/Python/52183660 |
condefects-python_data_212 | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
single_sz = n - (n-m)*2
print(single_sz)
ans = 0
for i in range(single_sz):
ans += a[i]**2
for i in range(n-m):
i1 = single_sz+i
i2 = n-1-i
ans += (a[i1]+a[i2])**2
print(ans)
n, m = map(int, input().split())
... | ConDefects/ConDefects/Code/arc167_a/Python/51403165 |
condefects-python_data_213 | from string import ascii_uppercase
N, X = map(int, input().split())
print(ascii_uppercase[X // N - 1])
from string import ascii_uppercase
N, X = map(int, input().split())
print(ascii_uppercase[(X - 1) // N])
| ConDefects/ConDefects/Code/abc257_a/Python/46189766 |
condefects-python_data_214 | import sys
sys.setrecursionlimit(500*500)
# if 'pypyjit' in sys.builtin_module_names:
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
input = sys.stdin.readline
from math import gcd
from functools import reduce
# product('ABCD', repeat=2) => AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD
from ... | ConDefects/ConDefects/Code/abc257_a/Python/45289055 |
condefects-python_data_215 | n,x=map(int,input().split())
print(chr(64+x//n))
n,x=map(int,input().split())
print(chr(64-(-x//n))) | ConDefects/ConDefects/Code/abc257_a/Python/45802027 |
condefects-python_data_216 | n=int(input())
s=input()
dango=0
lv=0
x=0
for i in range(n):
if s[i]=="-":
lv=0
dango=1
else:
if dango==1:
lv+=1
if lv>x:
x=lv
dango=0
lv=0
y=0
for i in range(n):
if s[n-1-i]=="-":
lv=0
dango=1
else:
if dango==1:
lv+=1
if lv>y:
y=lv
if x!=0 and y!=0:
print(ma... | ConDefects/ConDefects/Code/abc299_c/Python/45695018 |
condefects-python_data_217 | N=input()
S=input()
sec = 0
ans = 0
for i in S:
if i == "o":
sec += 1
else:
if sec > ans:
ans = sec
sec = 0
if ans == 0:
print(-1)
else:
print(ans)
N=input()
S=input()
sec = 0
ans = 0
if "-" in S:
S += "-"
for i in S:
if i == "o":
sec += 1
else:
if sec > ans:
ans = sec
... | ConDefects/ConDefects/Code/abc299_c/Python/45929496 |
condefects-python_data_218 | n = int(input())
s = input()
ans = -1
cnt = 0
for i in range(n):
if s[i] == "o":
cnt += 1
else:
if s != "o"*n and cnt != 0:
ans = max(ans,cnt)
cnt = 0
print(ans)
n = int(input())
s = input()
ans = -1
cnt = 0
for i in range(n):
if s[i] == "o":
cnt += 1
if ... | ConDefects/ConDefects/Code/abc299_c/Python/46056786 |
condefects-python_data_219 | import io
import sys
import math
import collections
import itertools
from operator import mul
from functools import reduce, wraps
from collections import defaultdict, deque
import bisect
import time
import heapq
from copy import deepcopy
import sys
sys.setrecursionlimit(1000000000)
# input
# -------------------------... | ConDefects/ConDefects/Code/abc299_c/Python/46165545 |
condefects-python_data_220 | def main():
n = int(input())
s = list(input())
if n == 1:
print(-1)
return
dango = 0
max_dango = -1
stick = False
for i in range(n):
if s[i] == "o":
dango += 1
else:
stick = True
if dango > max_dango:
... | ConDefects/ConDefects/Code/abc299_c/Python/45999829 |
condefects-python_data_221 | n = int(input())
s = input()
sr=''.join(reversed(s))
ans=0
cnt=0
flag=0
for i in range(n):
if s[i]=="-":
if flag == 0:
flag = 1
else:
ans=max(ans,cnt)
cnt=0
else:
if flag == 1:
cnt+=1
flag=0
cnt=0
for i in range(n):
if sr[i]=="-":
... | ConDefects/ConDefects/Code/abc299_c/Python/46050962 |
condefects-python_data_222 | N=int(input())
S=input()
ans=0
flg=False
tmp=0
for i in range(N):
if flg:
if S[i]=="o":
tmp+=1
else:
ans=max(ans,tmp)
tmp=0
else:
if S[i]=="-":
flg=True
flg=False
tmp=0
for i in range(N-1,-1,-1):
if flg:
if S[i]=="o":
... | ConDefects/ConDefects/Code/abc299_c/Python/45797933 |
condefects-python_data_223 | n=int(input())
s=input()
ok=False
cnt=0
ans=0
for i in range(n):
if s[i]=="o":
cnt+=1
else:
ok=True
ans=max(ans,cnt)
print(cnt)
cnt=0
if ok:
ans=max(ans,cnt)
print(cnt)
print(ans if ans>0 else -1)
n=int(input())
s=input()
ok=False
cnt=0
ans=0
for i in range(n):
... | ConDefects/ConDefects/Code/abc299_c/Python/45334014 |
condefects-python_data_224 | N = int(input())
S = input()
ox = 0
ans = -1
cnt = -1
for s in S:
if s=="-":
ox |= 0b01
ans = max(ans, cnt)
cnt = 0
elif s=="o":
ox |= 0b10
cnt += 1
if ox ==0b11:
ans = max(ans, cnt)
else:
ans = -1
print(ans)
N = int(input())
S = input()
ox = 0
ans = -1
cnt = 0
for s in S:
if s=="-":
ox |= 0b01
a... | ConDefects/ConDefects/Code/abc299_c/Python/45524936 |
condefects-python_data_225 | n=int(input())
s=input()
right,now,ans=0,0,0
for left in range(n):
while(right<n and s[right]=='o'):
now+=1
right+=1
ans=max(ans,right-left)
if right==left:right+=1
else:now-=1 if s[left]=="o" else 0
print(ans if ans!=0 else -1)
n=int(input())
s=input()
right,now,ans=0,0,0
for left in range(n):
while(right... | ConDefects/ConDefects/Code/abc299_c/Python/45513147 |
condefects-python_data_226 | # 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/abc299_c/Python/45750635 |
condefects-python_data_227 | N=int(input())
S=input()
left=0 if S[0]=="o" else -1
max_L=-1
for right in range(1,N):
if S[right-1]=="-" and S[right]=="o":
left = right
elif S[right-1]=="o" and S[right]=="-":
#print(left, right, right-left)
if 0<=left-1 and S[left-1]=="-" or right+1<N and S[right+1]=="-":
max_L = max(max_L, rig... | ConDefects/ConDefects/Code/abc299_c/Python/46032299 |
condefects-python_data_228 | N = int(input())
S = input()
max = 0
count = 0
for i in range(N):
if S[i] == "o":
count += 1
if count > max:
max = count
else:
count = 0
if max == len(S) and S[0] == "-" and S[len(S) - 1] == "-":
print(-1)
elif max == 0:
print(-1)
else:
print(max)
N = int(in... | ConDefects/ConDefects/Code/abc299_c/Python/45333505 |
condefects-python_data_229 | import sys
f = sys.stdin
N = int(f.readline().rstrip())
S = f.readline().rstrip()
d, td = 0, 0
s = 0
for i in range(N):
if S[i] == 'o':
td += 1
else:
s = 1
d = max(d, td)
td = 0
print(d if (0 < d and s == 1) else -1)
import sys
f = sys.stdin
N = int(f.readline().rstrip())
S... | ConDefects/ConDefects/Code/abc299_c/Python/45221667 |
condefects-python_data_230 | n=int(input())+2
s='-'+input()+'-'
m=0
x=0
for i in range(n):
if s[i]=='-':
m=max(m,x)
x=0
else: x+=1
if m==n-2:
print(-1)
else: print(m)
n=int(input())+2
s='-'+input()+'-'
m=0
x=0
for i in range(n):
if s[i]=='-':
m=max(m,x)
x=0
else: x+=1
if m==n-2 or m==0:
print(-1)
else: print(m) | ConDefects/ConDefects/Code/abc299_c/Python/45439049 |
condefects-python_data_231 | n = int(input())
a_s = list(map(int, input().split()))
m = int(input())
b_s = list(map(int, input().split()))
l = int(input())
c_n = list(map(int, input().split()))
q = int(input())
x_s = list(map(int, input().split()))
comb_sum = []
for a in a_s:
for b in b_s:
for c in c_n:
comb_sum.append(a ... | ConDefects/ConDefects/Code/abc344_c/Python/54709044 |
condefects-python_data_232 | # https://atcoder.jp/contests/arc158/tasks/arc158_c
n = int(input())
a = list(map(int,input().split()))
ans = 0
# 思考按数位进行枚举?进位再进位何解?
# 单独去掉进位的部分
for i in a:
while i:
ans += i%10 *2*n
i //= 10
import bisect
for i in range(1,14):
b = sorted([x%(10**i) for x in a])
for x in b:
ans -= ... | ConDefects/ConDefects/Code/arc158_c/Python/40365558 |
condefects-python_data_233 | from bisect import bisect_left as bl
N,P,Q,R = list(map(int,input().split()))
A = list(map(int,input().split()))
asum = [0]
for n in range(N):
asum.append(asum[-1]+A[n])
for x in range(N):
a = asum[x]
y = bl(asum,P+a)
if y>=N or asum[y]-a!=P : continue
a = asum[y]
z = bl(asum,Q+a)
if z>=N or... | ConDefects/ConDefects/Code/abc265_d/Python/45075464 |
condefects-python_data_234 | import sys
sys.setrecursionlimit(500*500)
# if 'pypyjit' in sys.builtin_module_names:
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
input = sys.stdin.readline
from math import gcd
from functools import reduce
# product('ABCD', repeat=2) => AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD
from ... | ConDefects/ConDefects/Code/abc265_d/Python/45966660 |
condefects-python_data_235 | # Python3/Pypy3テンプレート集
#ライブラリ-------------------------------------------------------------------
from bisect import *
import heapq
import collections
from collections import deque
from queue import Queue
from itertools import groupby
import itertools
import math
import array
import string
import copy
from decimal impo... | ConDefects/ConDefects/Code/abc265_d/Python/45502599 |
condefects-python_data_236 | # Aの累積和を出すと、Ax がわかれば、あとは SA[x] + P SA[x] + P + Q, SA[x] + P + Q + Z
# の数字が累積和中に出現するか調べればよい ただそのまま配列を走査すると、O(N)かかり
# X の走査と併せて O(N**2) となってしまうので、累積和の値をset または dict に突っ込んで
# 存在判定するとよい
import numpy
N, P, Q, R = map(int, input().split())
A = list(map(int, input().split()))
SA = numpy.cumsum(A)
sa_set = set()
for sa in ... | ConDefects/ConDefects/Code/abc265_d/Python/46180053 |
condefects-python_data_237 | N,M=map(int, input().split())
ans=1<<60
for i in range(1, int(M**(1/2))+1):
if i>N: break
b=(M+i-1)//i
if b>N: continue
ans=min(ans, i*b)
if ans==1<<60: ans=-1
print(ans)
N,M=map(int, input().split())
ans=1<<60
for i in range(1, int(M**(1/2))+2):
if i>N: break
b=(M+i-1)//i
if b>N: continue
... | ConDefects/ConDefects/Code/abc296_d/Python/45931532 |
condefects-python_data_238 | # D - M<=ab
import math
def main():
N, M = map(int, input().split())
n = int(math.sqrt(M*10))
ans = []
for a in range(1, n+1):
b = ceil(M, a)
if b <= N:
ans.append(a*b)
if len(ans) == 0:
print(-1)
else:
print(min(ans))
def ceil(dividend, divisor):
q = dividend // divisor
i... | ConDefects/ConDefects/Code/abc296_d/Python/45933759 |
condefects-python_data_239 | import math
n,m=map(int,input().split(' '))
ans=-1
for i in range(1, min(n,int(math.sqrt(m)))+1):
k = (m+i-1)//i
if(k>=1 and k<=n):
if(ans==-1):
ans=k*i
else:
ans=min(ans, k*i)
print(ans)
import math
n,m=map(int,input().split(' '))
ans=-1
for i in range(1, min(n,int(math.sqrt(m))+1)+1):
k = (... | ConDefects/ConDefects/Code/abc296_d/Python/45553301 |
condefects-python_data_240 | import math
from math import ceil
n, m = map(int, input().split())
ans = n ** 2 + 2
if m > n ** 2:
print(-1)
exit()
for i in range(1, 10 ** 6 + 1):
p = ceil(m / i)
if 1 <= p <= n and m <= i * p <= n ** 2:
ans = min(ans, i * p)
if ans == n ** 2 + 2:
print(-1)
else:
print(ans)
import math
from math im... | ConDefects/ConDefects/Code/abc296_d/Python/45799143 |
condefects-python_data_241 | n, m = map(int, input().split())
if n**2 < m:
print(-1)
exit()
sq = int(m**0.5)
ans = 10**12 + 1
for i in range(1, sq + 1):
j = m // i + 1
if i * j >= m and 1 <= i <= n and 1 <= j <= n:
ans = min(ans, i * j)
j = m // i
if i * j >= m and 1 <= i <= n and 1 <= j <= n:
ans = min(an... | ConDefects/ConDefects/Code/abc296_d/Python/45976166 |
condefects-python_data_242 | N,M = map(int,input().split())
if N**2 < M:
print(-1)
exit()
ans = 10**100
for i in range(1,int(M**0.5)+10):
if M%i == 0 and M//i <= N and i<=N:
ans = min(ans,M)
continue
elif i * (M//i+1) >= M and i<=N and M//i+1:
ans = min(ans,i*(M//i+1))
continue
if ans == 1... | ConDefects/ConDefects/Code/abc296_d/Python/45768294 |
condefects-python_data_243 | n,m=map(int,input().split())
ans=float('inf')
for a in range(1,int(m**0.5)+1):
b=-(-m//a)
if a<=n and b<=n:
ans=min(ans,a*b)
if ans==float('inf'):
print(-1)
else:
print(ans)
n,m=map(int,input().split())
ans=float('inf')
for a in range(1,int(m**0.5)+2):
b=-(-m//a)
if a<=n and b<=n:
... | ConDefects/ConDefects/Code/abc296_d/Python/45742817 |
condefects-python_data_244 | x,k = list(map(int,input().split(" ")))
for i in range(k):
x = round(x+0.0001,-(i+1))
print(int(x))
x,k = list(map(int,input().split(" ")))
for i in range(k):
x = round(x+0.9,-(i+1))
print(int(x)) | ConDefects/ConDefects/Code/abc273_b/Python/45324083 |
condefects-python_data_245 | def change(i,rnk):
s=str(i)
if len(s)>rnk+1:
if int(s[-rnk-1])>=5:
return str(int(s[:-rnk-1])+1)+"0"*(rnk+1)
else:
return s[:-rnk-1]+"0"*(rnk+1)
elif len(s)==rnk+1:
if int(s[0])>=5:
return "1"+"0"*len(s)
else:
return "0"*len(... | ConDefects/ConDefects/Code/abc273_b/Python/45948106 |
condefects-python_data_246 | x,k=map(int,input().split())
for i in range(k):
if x%10**i<5*10**i:
x=x//10**(1+i)*10**(1+i)
else:
x=(x//10**(1+i)+1)*10**(1+i)
print(x)
x,k=map(int,input().split())
for i in range(k):
if x%10**(1+i)<5*10**i:
x=x//10**(1+i)*10**(1+i)
else:
x=(x//10**(1+i)+1)*10**(1+i)
print(x) | ConDefects/ConDefects/Code/abc273_b/Python/46029599 |
condefects-python_data_247 | x, k = map(int,input().split())
p = 1
for i in range(k):
x /= p
m = x % 10
if m <= 4:
x -= m
else:
x += 10 - m
x *= p
p *= 10
print(x)
x, k = map(int,input().split())
p = 1
for i in range(k):
x /= p
m = x % 10
if m <= 4:
x -= m
else:
x += 10 ... | ConDefects/ConDefects/Code/abc273_b/Python/46013086 |
condefects-python_data_248 | x, k = map(int, input().split())
for i in range(k):
p, q = divmod(x, 10**(i+1))
if q >= 5:
p += 1
x = p*10**(i+1)
print(x)
x, k = map(int, input().split())
for i in range(k):
p, q = divmod(x, 10**(i+1))
if q//10**i >= 5:
p += 1
x = p*10**(i+1)
print(x)
| ConDefects/ConDefects/Code/abc273_b/Python/45010464 |
condefects-python_data_249 | N = int(input())
S = input()
d = S.split("C")
d = ["A" * p.count("A") + "B" * p.count("B") for p in d]
print("C".join(d))
N = int(input())
S = input()
d = S.split("C")
d = ["A" * (p.count("A") + p.count("B") // 2) + "B" * (p.count("B") % 2) for p in d]
print("C".join(d)) | ConDefects/ConDefects/Code/arc136_a/Python/43450838 |
condefects-python_data_250 | n=int(input())
s=input()
L=[]
for i in range(n):
if s[i]=="A":
L.append("B")
L.append("B")
else:
L.append(s[i])
now=0
while now<len(L):
if now==len(L)-1:
print(L[i])
now+=1
elif L[now]=="B" and L[now+1]=="B":
print("A",end="")
now+=2
else:
print(L[now],end="")
now+=1
n=int... | ConDefects/ConDefects/Code/arc136_a/Python/44851620 |
condefects-python_data_251 | N = int(input())
S = input()
while "A" in S:
S = S.replace("A", "B")
while "BB" in S:
S = S.replace("BB", "A")
print(S)
N = int(input())
S = input()
while "A" in S:
S = S.replace("A", "BB")
while "BB" in S:
S = S.replace("BB", "A")
print(S)
| ConDefects/ConDefects/Code/arc136_a/Python/45786138 |
condefects-python_data_252 | # LUOGU_RID: 117445639
print(input().replace('A','BB').replace('BB','A'))
input()
print(input().replace('A','BB').replace('BB','A')) | ConDefects/ConDefects/Code/arc136_a/Python/43956932 |
condefects-python_data_253 | def main():
# write code here.
N,H = MI()
time2coord = LM()
coord2idx = DD(int)
idx2coord = [-1]*N
for idx,coord in enumerate(sorted(time2coord)):
coord2idx[coord] = idx
idx2coord[idx] = coord
time2idx = [coord2idx[time2coord[idx]] for idx in range(N)]
idx2island_ID... | ConDefects/ConDefects/Code/arc177_d/Python/53453584 |
condefects-python_data_254 | from collections import defaultdict
import sys
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.size=1<<self.log
self.d=[E for i in ran... | ConDefects/ConDefects/Code/arc177_d/Python/53430198 |
condefects-python_data_255 | import sys
# input = sys.stdin.readline
# input = lambda :sys.stdin.readline().rstrip()
readline = sys.stdin.readline
input = lambda :readline().rstrip()
sys.setrecursionlimit(6*10**5)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
from heapq import heappush,heappop,heapify
from collections import defaultd... | ConDefects/ConDefects/Code/abc281_d/Python/45096639 |
condefects-python_data_256 | n,K,D,*a=map(int,open(0).read().split())
dp=[[[-1]*D for _ in range(K+1)]for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
for j in range(K+1):
for k in range(D):
dp[i][j][k]=dp[i-1][j][k]
if j and dp[i-1][j-1][k]!=-1:
nk=(k+a[i-1])%D
dp[i][j][nk]=max(dp[i][j][nk],dp[i-1][j-1][... | ConDefects/ConDefects/Code/abc281_d/Python/45944263 |
condefects-python_data_257 | n, k, d = map(int, input().split())
a = list(map(int, input().split()))
dp = [[[-1]* d for _ in range(k+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
for j in range(k):
for l in range(d):
if dp[i][j][l] == -1:
continue
dp[i+1][j][l] = max(dp[i+1][j][l]... | ConDefects/ConDefects/Code/abc281_d/Python/45212447 |
condefects-python_data_258 | n, k, d = map(int, input().split())
aa = list(map(int, input().split()))
inf = 2**63 - 1
dp = [[-inf] * d for _ in range(k + 1)]
dp[0][0] = 0
nx = [x[:] for x in dp]
for a in aa:
for i in range(k):
for j in range(d):
nxj = (j + a) % d
nx[i + 1][nxj] = max(nx[i + 1][nxj], dp[i][j] + a... | ConDefects/ConDefects/Code/abc281_d/Python/44892775 |
condefects-python_data_259 | import sys
from collections import *
input = sys.stdin.readline
from math import *
def mrd(): return [int(x) for x in input().split()]
def rd(): return int(input())
MAXN = 2 * 10**5 + 5
INF = 10**16 * 2
mod = 10**9 + 7
#----------------------------------------------------------------------------------#
'''
https://atco... | ConDefects/ConDefects/Code/arc148_c/Python/38559514 |
condefects-python_data_260 | 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])
retu... | ConDefects/ConDefects/Code/arc148_c/Python/39976054 |
condefects-python_data_261 | def main():
H, W = map(int, input().split())
C = []
for i in range(H):
C.append(list(input()))
for i in range(H):
for j in range(W):
if C[i][j] != ".": continue
d = set(["1","2","3","4","5"])
if i > 0: d.discard(C[i-1][j])
if j > 0: d.discard(C[i][j-1])
if i < H-1: d.discar... | ConDefects/ConDefects/Code/arc131_b/Python/38447849 |
condefects-python_data_262 | from sortedcontainers import SortedSet, SortedList, SortedDict
from collections import defaultdict
N, K = map(int,input().split())
P = list(map(int,input().split()))
INF = 10 ** 20
ans = [-1] * N
dic = defaultdict(list)
S = SortedSet([-INF, INF])
for i, value in enumerate(P):
key = S[S.bisect_left(value)]
if ... | ConDefects/ConDefects/Code/abc260_d/Python/53288501 |
condefects-python_data_263 | from atcoder.dsu import DSU
from atcoder.segtree import SegTree
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = [-1] * (N + 1)
if K == 1:
for i,p in enumerate(P,start= 1):
ans[p] = i
print(*ans)
exit()
dsu = DSU(N + 1)
st = SegTree(max, 0, [0] * (N + 1))
dic ... | ConDefects/ConDefects/Code/abc260_d/Python/51017696 |
condefects-python_data_264 | n,k=map(int,input().split())
a=list(map(int,input().split()))
asort=sorted(a)
ak=[[] for _ in range(k)]
for i in range(n):
ak[i%k].append(a[i])
aksort=[0]*k
for i in range(k):
aksort[i] = sorted(ak[i])
print(aksort)
print(asort)
for i in range(n):
if asort[i] != aksort[i%k][i//k]:
print("No")
exit()
pr... | ConDefects/ConDefects/Code/abc254_c/Python/44995126 |
condefects-python_data_265 | n = int(input())
s = input()
t = input()
p = 0
for i in range(n):
if s[i] == "1" or s[i] == "l":
if t[i] == "1" or t[i] == "l":
p += 1
elif s[i] == "0" or t[i] == "o":
if t[i] == "0" or t[i] == "o":
p += 1
elif s[i] == t[i]:
p += 1
... | ConDefects/ConDefects/Code/abc303_a/Python/46127283 |
condefects-python_data_266 | #!/usr/bin/env python3
n, m = map(int, input().split())
S = input()
muji_t = m
logo_t = 0
ans = 0
for s in S:
if s == '2':
if logo_t == 0:
ans += 1
else:
logo_t -= 1
elif s == '1':
if muji_t == 0 and logo_t == 0:
ans += 1
elif muji_t == 0:
... | ConDefects/ConDefects/Code/abc332_c/Python/54711529 |
condefects-python_data_267 | n,m = map(int,input().split())
s = input()
used_m = 0
used_r = 0
muji = m
rogo = 0
buy_t = 0
for i in s:
if i == "1":
if muji > 0:
muji -= 1
used_m += 1
elif rogo > 0:
rogo -= 1
used_r += 1
else:
buy_t += 1
used_r += 1
... | ConDefects/ConDefects/Code/abc332_c/Python/54021349 |
condefects-python_data_268 | n, m = map(int, input().split())
s = list(input())
ans = 0
cnt = 0
muji = 0
for c in s:
match c:
case "0":
cnt =0
muji = m
case "1":
if muji == 0:
cnt += 1
else:
muji -= 1
case "2":
cnt += 1
ans = max(cnt, ans)
print(ans)
n, m = map(int, input().split())
... | ConDefects/ConDefects/Code/abc332_c/Python/54029466 |
condefects-python_data_269 | n, m = map(int, input().split())
s = str(input())
m_real = m
logo_T = 0
logo_T_real = 0
for i in range (n):
if s[i] == "0":
m_real = m
logo_T_real = logo_T
if s[i] == "1":
if m_real > 0:
m_real -= 1
else:
logo_T += 1
if s[i] == "2":
if logo_T_r... | ConDefects/ConDefects/Code/abc332_c/Python/54228100 |
condefects-python_data_270 |
def rint(): return list(map(int, input().split()))
N, M = rint()
S = input()
shirts = M
buy = 0
logo = 0
for i in range(N):
if S[i] == '1':
if shirts == 0:
buy += 1
else:
shirts -= 1
elif S[i] == '2':
if logo == 0:
buy += 1
else:
... | ConDefects/ConDefects/Code/abc332_c/Python/54741421 |
condefects-python_data_271 | def solve_C():
n, m = map(int, input().split())
s = [int(day) for day in list(input())]
logo = 0
plain = m
buy = 0
for day in s:
if day == 1:
if plain > 0:
plain -= 1
else:
buy += 1
if day == 2:
buy += 1
... | ConDefects/ConDefects/Code/abc332_c/Python/54522217 |
condefects-python_data_272 | from collections import Counter
N=int(input())
S=[input() for _ in range(N)]
win_result=[]
for i in range(N):
counter=Counter(S[i])
win_result.append(counter["o"])
c=N-1
rank=[]
for i in range(N):
for j in range(N):
if win_result[j]==c:
rank.append(j+1)
c-=1
print(rank)
from collect... | ConDefects/ConDefects/Code/abc323_b/Python/54780741 |
condefects-python_data_273 | n = int(input())
s = [str(input()) for _ in range(n)]
dic = {}
for i in range(n):
dic[i] = 0
for i in range(n):
for k in range(n):
if i > k and s[i][k] == "o":
dic[i] += 1
dic = sorted(dic.items(), key=lambda x:x[1], reverse=True)
for i in dic:
print(i[0]+1, end=" ")
n = int(input())
s = [s... | ConDefects/ConDefects/Code/abc323_b/Python/54226184 |
condefects-python_data_274 | N = int(input())
S = [""] * N
for i in range(N):
S[i] = input()
C = 0
A = [0] * N
for i in range(N):
for j in range(N):
if S[i][j] == "o":
C += 1
A[i] = [C, i+1]
C = 0
print(A)
Y = 0
for i in range(N):
Y = max(Y, A[i][0])
for i in range(N):
A[i][0] = Y - A[i][0]
A.sort... | ConDefects/ConDefects/Code/abc323_b/Python/54238360 |
condefects-python_data_275 | Sx,Sy = map(int,input().split())
Tx,Ty = map(int,input().split())
if (Sx + Sy)%2 != 0:
posS = "right"
Sx -= 1
if (Tx + Ty)%2 != 0:
Tx -= 1
if abs(Tx-Sx) > abs(Ty-Sy):
print(abs(Tx-Sx))
else:
print(abs(Ty-Sy))
Sx,Sy = map(int,input().split())
Tx,Ty = map(int,input().split())
if (Sx + Sy)%2 != 0:
... | ConDefects/ConDefects/Code/abc359_c/Python/55038783 |
condefects-python_data_276 | Sx, Sy = map(int, input().split())
Tx, Ty = map(int, input().split())
Sx -= (Sy - Sx) % 2
Tx -= (Ty - Tx) % 2
Tx -= Sx
Ty -= Sy
Tx = abs(Tx)
Ty = abs(Ty)
print(Ty + max(0, Tx - Ty) / 2)
Sx, Sy = map(int, input().split())
Tx, Ty = map(int, input().split())
Sx -= (Sy - Sx) % 2
Tx -= (Ty - Tx) % 2
Tx -= Sx
Ty -... | ConDefects/ConDefects/Code/abc359_c/Python/55129367 |
condefects-python_data_277 | Sx, Sy = map(int, input().split())
Tx, Ty = map(int, input().split())
# S, T ともに左側基準に
if (Sx + Sy) % 2 == 1:
Sx -= 1
if (Tx + Ty) % 2 == 1:
Tx -= 1
# (Sx, Sy) = (0, 0) と考えたとき、(Tx, Ty)を第一第一象限に移動させる
Tx -= Sx
Ty -= Sy
Tx = abs(Tx)
Ty = abs(Ty)
Tx = max(Tx - Ty, 0)
print(Tx+Ty)
Sx, Sy = map(int, input().split(... | ConDefects/ConDefects/Code/abc359_c/Python/55101823 |
condefects-python_data_278 |
Sx, Sy = map(int, input().split())
Tx, Ty = map(int, input().split())
if (Sx + Sy) % 2 == 1:
Sx -= 1
if (Tx + Ty) % 2 == 1:
Tx -= 1
x = abs(Sx - Tx)
y = abs(Sy - Ty)
if y >= x:
print(y)
else:
print(y + x // 2)
Sx, Sy = map(int, input().split())
Tx, Ty = map(int, input().split())
if (Sx + Sy) % 2... | ConDefects/ConDefects/Code/abc359_c/Python/55043442 |
condefects-python_data_279 | t=int(input())
for おはよう in range(t):
n,a,b=map(int,input().split())
if n<a:
print("No")
continue
if n%2==1:
N=n
else:
N=n+1
if min(n-a,(N+1)//2)*(n-a)>=b:
print("Yes")
else:
print("No")
t=int(input())
for おはよう in range(t):
n,a,b=map(int,input().sp... | ConDefects/ConDefects/Code/arc171_a/Python/54909908 |
condefects-python_data_280 | T = int(input())
for _ in range(T):
N, A, B = map(int,input().split())
if N < A:
print("No")
continue
if N//2 >= A:
tate = (N - 2*A + 1)//2 + A
yoko = N - A
if tate*yoko >= B:
print("Yes")
else:
print("No")
else:
yoko = N - ... | ConDefects/ConDefects/Code/arc171_a/Python/51436402 |
condefects-python_data_281 | #ルークとポーンを互いに取れない状態で設置が可能かを判断
# ルークは斜めに設置していけば取られることはない→斜めに設置
# ポーンは隣接しなければよい
# ルークは詰めておいてもいい?→正方形を小さくするだけ?
T = int(input())
for _ in range(T):
N,A,B = map(int, input().split())
#残りにおけるマス数
b = N-A
c = min((N+1)//2,b)
print("yes" if N-A >= 0 and c * (N-A) >= B else "no")
#ルークとポーンを互いに取れない状態で設置が可能かを判断
#... | ConDefects/ConDefects/Code/arc171_a/Python/52986573 |
condefects-python_data_282 | T=int(input())
for i in range(T):
Nx,A,B=map(int,input().split())
Ny=Nx
Ny2=Ny/2
Nx-=A
if(Ny2<A):
Ny-=(A-Ny2)
Ny-=Ny2
if(Nx<0 or Ny*Nx<B):
print("No")
else:
print("Yes")
T=int(input())
for i in range(T):
Nx,A,B=map(int,input().split())
Ny=Nx
Ny2=int(... | ConDefects/ConDefects/Code/arc171_a/Python/52479572 |
condefects-python_data_283 | T = int(input())
for _ in range(T):
N, A, B = map(int, input().split())
if A > N:
print('No')
continue
if A == 0:
h = (N + 1) // 2
elif N % 2 == 0:
if A <= N // 2:
h = N // 2
else:
h = N - A
else:
if A <= N // 2 + 1:
... | ConDefects/ConDefects/Code/arc171_a/Python/55000897 |
condefects-python_data_284 | #!/usr/bin/env python3
T = int(input())
def solve(n, a, b):
if a >= n + 1:
return 0
if a == n:
if b == 0:
return 1
else:
return 0
c = (b + n - a - 1) // (n - a)
if a + c <= n:
return 1
return 0
for _ in range(T):
n, a, b ... | ConDefects/ConDefects/Code/arc171_a/Python/54529613 |
condefects-python_data_285 | for _ in range(int(input())):
N, A, B = map(int, input().split())
if A <= N // 2:
print("Yes" if B <= ((N + 1) // 2) * (N - A) else "No")
elif A < N:
print("Yes" if B <= (N - A) ** 2 else "No")
else:
print("No")
for _ in range(int(input())):
N, A, B = map(int, input().split())
if A <= N // 2:
print("Yes"... | ConDefects/ConDefects/Code/arc171_a/Python/53564647 |
condefects-python_data_286 | n, q = map(int, input().split())
p = [0] * n
for _ in range(q):
t, x = map(int, input().split())
x -= 1
if t == 1:
p[x] += 1
elif t == 2:
p[x] += 2
else:
if p[x] == 2:
print("Yes")
else:
print("No")
n, q = map(int, input().s... | ConDefects/ConDefects/Code/abc292_b/Python/45575109 |
condefects-python_data_287 | # B - Yellow and Red Card
def main():
N, Q = map(int, input().split())
cards = [0] * (N+1)
for _ in range(Q):
c, x = map(int, input().split())
if c == 1:
cards[x] += 1
elif c == 2:
cards[x] += 2
else:
if cards[x] == 2:
print('Yes')
else:
print('No')
... | ConDefects/ConDefects/Code/abc292_b/Python/44986856 |
condefects-python_data_288 | n, q = map(int, input().split())
player = [0] * n
for i in range(q):
c, x = map(int,input().split())
if c == 1:
player[x - 1] += 1
elif c == 2:
player[x - 1] += 2
else:
if player[x - 1] == 2:
print("Yes")
else:
print("No")
n, q = map(int, input... | ConDefects/ConDefects/Code/abc292_b/Python/45695205 |
condefects-python_data_289 | n, m = map(int, input().split())
cnts = [0]*n
for i in range(m):
s = list(map(int, input().split()))
player = s[1]-1
if s[0] == 1:
cnts[player] += 1
elif s[0] == 2:
cnts[player] += 2
elif s[0] == 3:
if cnts[player] == 2:
print("Yes")
else:
pri... | ConDefects/ConDefects/Code/abc292_b/Python/45300323 |
condefects-python_data_290 | N, Q = map(int, input().split())
T = [2] * N
for i in range(Q):
c, x = map(int, input().split())
if c == 1:
T[x-1] -= 1
elif c == 2:
T[x-1] -= 2
else:
if (T[x-1] == 0):
print('Yes')
else:
print('No')
N, Q = map(int, input().split())
T = [2] * N
for i in range(Q):
c, x = map(int... | ConDefects/ConDefects/Code/abc292_b/Python/45444129 |
condefects-python_data_291 | n=int(input())
f=[[0]*101 for i in range(101)]
for i in range(n):
a,b,c,d=map(int,input().split())
for x in range(a,b):
for y in range(c,d):
# print(x,y)
f[x][y]=1
ans=0
for i in range(10):
ans+=sum(f[i])
print(ans)
n=int(input())
f=[[0]*101 for i in range(101)]
for i in range(n):
a,b,c,d=map(int,input()... | ConDefects/ConDefects/Code/abc318_b/Python/54678489 |
condefects-python_data_292 | from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
xor_sum = 0
cnt = defaultdict(lambda: 0)
for elem in a:
xor_sum = xor_sum ^ elem
cnt[elem] += 1
if xor_sum > 0:
print(-1)
exit(0)
elem_and_cnt = list(cnt.items())
elem_and_cnt.sort(key=lambda elem: elem[0], reverse=True)... | ConDefects/ConDefects/Code/arc168_b/Python/47858758 |
condefects-python_data_293 | from collections import*
n = int(input())
a = list(map(int, input().split()))
dic = defaultdict(int)
cnt = 0
for ai in a:
dic[ai] += 1
cnt ^= ai
if cnt:
print(-1)
exit()
cnt = 0
for k in dic.keys():
if dic[k]%2: cnt = k
if cnt:
print(cnt-1)
else:
print(0)
from collections import*
n = int(i... | ConDefects/ConDefects/Code/arc168_b/Python/50455727 |
condefects-python_data_294 | # ABC263D - Left Right Operation
#####segfunc#####
def segfunc(x, y):
return min(x, y)
#################
#####ide_ele#####
ide_ele = 10**18
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN... | ConDefects/ConDefects/Code/abc263_d/Python/45558657 |
condefects-python_data_295 | N,L,R=map(int,input().split())
A=list(map(int,input().split()))
A=[0]+A
f=[0]*(N+1)
for i in range(1,N+1):
f[i]=min(f[i-1]+A[i],L*i)
A=A[::-1]
A=[0]+A
g=[0]*(N+1)
for i in range(1,N+1):
g[i]=min(g[i-1]+A[i],R*i)
ans=10*15
for i in range(N+1):
ans=min(ans,f[i]+g[N-i])
print(ans)
N,L,R=map(int,input(... | ConDefects/ConDefects/Code/abc263_d/Python/45092562 |
condefects-python_data_296 | class Input_kyopro:
def II(self): return int(input())
def MI(self): return map( int,input().split())
def MS(self): return map(str,input().split())
def LMI(self): return list(self.MI())
def LMS(self): return list(self.MS())
def LLI(self,N): return [self.LMI() for _ in range(N)]
def LLS(self,N... | ConDefects/ConDefects/Code/abc263_d/Python/46128003 |
condefects-python_data_297 | n, l, r = map(int, input().split())
a = list(map(int, input().split()))
sma = 0
smb = 0
mx = 0
ans = float("INF")
for i in range(n):
sma += a[i]
smb += a[i] - l
mx = max(mx, smb)
ans = min(ans, sma + (n - i - 1) * r - mx)
print(ans)
n, l, r = map(int, input().split())
a = list(map(int, input().split()... | ConDefects/ConDefects/Code/abc263_d/Python/45700792 |
condefects-python_data_298 | N,L,R=map(int,input().split())
A=list(map(int,input().split()))
result=sum(A)
result=min(result,L*N,R*N)
v=[0]*N
for i in range(N):
x=v[i-1]+A[i]
if x>(i+1)*L:
v[i]=(i+1)*L
else:
v[i]=x
for i in range(N-1,0,-1):
p=v[i]+(N-1-i)*R
result=min(result,p)
print(result)
N,L,R=map(int,input().split())
A=list... | ConDefects/ConDefects/Code/abc263_d/Python/46033883 |
condefects-python_data_299 | N,L,R = map(int,input().split())
A = list(map(int,input().split()))
dpL=[0]*(N+1)
dpR=[0]*(N+1)
for i in range(N):
dpL[i+1] = min(dpL[i]+A[i],L*(i+1))
for j in range(N-1,-1,-1):
dpR[j]= min(dpR[j+1]+A[j],R*(N-j))
ans=10**18
for i in range(N):
ans = min(ans,dpL[i]+dpR[i])
print(ans)
N,L,R = map(int,inpu... | ConDefects/ConDefects/Code/abc263_d/Python/45504816 |
condefects-python_data_300 | from heapq import heappush, heappop, heapify
from collections import defaultdict, deque, Counter
from itertools import permutations, combinations, accumulate
from math import gcd, sqrt, factorial, ceil
from bisect import bisect_left, bisect_right
import sys
from decimal import Decimal, ROUND_HALF_UP, getcontext
sys.se... | ConDefects/ConDefects/Code/abc263_d/Python/44705646 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.