id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_1201 | X = int(input())
ans = (X+10-1)/10
print(ans)
X = int(input())
ans = (X+10-1)//10
print(ans) | ConDefects/ConDefects/Code/abc345_b/Python/54755519 |
condefects-python_data_1202 | n,k,*A = map(int,open(0).read().split())
f = 1
x = 0
for d in range(50):
if k>>d&1:
g = 0
for a in A:
g ^= f<<a
f = g
g = 0
for i in range(f.bit_length()):
if i&1:
x ^= (f>>i&1)<<d
g ^= (f>>i&1)<<(i>>1)
f = g
print(x)
n,k,*A = map(int,open(0).read().split())
f = 1
x = 0
for d in... | ConDefects/ConDefects/Code/arc156_d/Python/41134585 |
condefects-python_data_1203 | import numpy as np
a, b, d = map(int, input().split())
theta = np.radians(d, dtype=np.float128)
c, s = np.cos(theta, dtype=np.float128), np.sin(theta, dtype=np.float128)
R = np.array(((c, -s), (s, c)), dtype=np.float128)
ret = np.dot(R, np.array((a, b), dtype=np.float128))
print(ret)
import numpy as np
a, b, d = ma... | ConDefects/ConDefects/Code/abc259_b/Python/45494335 |
condefects-python_data_1204 | import math
a, b, c = map(int, input().split())
x = a * round(math.cos(math.radians(c)), 8) + b * round(math.sin(math.radians(c)), 8)
y = a * round(math.sin(math.radians(c)), 8) + b * round(math.cos(math.radians(c)), 8)
print(x, y)
import math
a, b, c = map(int, input().split())
x = a * round(math.cos(math.radi... | ConDefects/ConDefects/Code/abc259_b/Python/45346319 |
condefects-python_data_1205 | import math
a, b, d = map(int, input().split())
sind = math.sin(math.radians(d))
cosd = math.cos(math.radians(d))
ans = [cosd*a-sind*b, sind*a+cosd*b]
print(ans)
import math
a, b, d = map(int, input().split())
sind = math.sin(math.radians(d))
cosd = math.cos(math.radians(d))
ans = [cosd*a-sind*b, sind*a+cosd*b]
print... | ConDefects/ConDefects/Code/abc259_b/Python/45800478 |
condefects-python_data_1206 | N = int(input())
T = input()
b = 26
h = 2**61 - 1
H = pow(b,N-1,h)
HH = pow(b,-1,h)
ans = 0
A = []
for i in range(N):
if i == 0:
X = 0
Y = 0
Z = 0
for j in range(N,2*N):
Z *= b
Z += (ord(T[j])-97)
Z %= h
for j in range(N):
n = N - 1 - j
Y *= b
Y += (ord(T[n])-9... | ConDefects/ConDefects/Code/abc284_f/Python/45510158 |
condefects-python_data_1207 | import bisect, heapq, sys, math, copy, itertools, decimal
from collections import defaultdict, deque
sys.setrecursionlimit(10**7)
def INT(): return int(input())
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return list(map(int, input().split()))
def LS(): return list(ma... | ConDefects/ConDefects/Code/arc150_b/Python/43756504 |
condefects-python_data_1208 | from math import ceil
for _ in range(int(input())):
a, b = map(int, input().split())
max_k = ceil((b-1)/a)
ans = 10**18
for k in range(1, max_k + 1):
x = max(ceil(b / k) - a, 0)
y = k * (a + x) - b
if x+y < ans:
ans = x+y
print(ans)
from math import ceil
fo... | ConDefects/ConDefects/Code/arc150_b/Python/40583945 |
condefects-python_data_1209 |
def solve(a,b):
sq_b = int(b**.5)+10
ans = a
for k in range(1,sq_b):
tmp = (k+1)*max(0,((b-1)//k)+1-a)+k*a-b
ans = min(ans,tmp)
for q in range(1,sq_b):
k = (b-1)//(q+1)+1
tmp = (k+1)*max(0,((b-1)//k)+1-a)+k*a-b
ans = min(ans,tmp)
return ans
for _ in range(in... | ConDefects/ConDefects/Code/arc150_b/Python/42077824 |
condefects-python_data_1210 | import math
T = int(input())
for _ in range(T):
A, B = map(int, input().split())
def f(k):
return (k + 1) * max(((B + k - 1) // k), A) - (A + B)
bo = math.floor((B - 1) ** 0.5)
if B == 1:
print(f(1))
continue
ans = 10 ** 18
for k in range(1, bo + 1):
ans = min(... | ConDefects/ConDefects/Code/arc150_b/Python/40524794 |
condefects-python_data_1211 | T = int(input())
for _ in range(T):
A, B = map(int, input().split())
if A > B:
print(A-B)
continue
ans = 10**18
for k in range(1, 10**7):
if A*k > B:
ans = min(ans, A*k-B)
break
d = B-A*k
x = -(-d//k)
ans = min(ans, (A+x)*k... | ConDefects/ConDefects/Code/arc150_b/Python/40750419 |
condefects-python_data_1212 | #まずはリストもmatrixに起こす
#h,w = map(int, input().split())
#mtx = []
#for i in range(h+2):
# tmp = [0] * (w + 2)
# if i != 0 and i != h + 1:
# s = input()
# for j in range(1, w+1):
# if s[j-1] == "#":
# tmp[j] = -1
# mtx.append(tmp)
#print(mtx)
#cnt = 2
#same = set()
#for i in... | ConDefects/ConDefects/Code/abc325_c/Python/54452348 |
condefects-python_data_1213 | import sys
readline = sys.stdin.buffer.readline
N, K = map(int, readline().split())
A = list(map(int, readline().split()))
if K >= 0:
print('Yes')
A.sort()
print(*A)
else:
if K > sum(A):
print('No')
else:
print('Yes')
A.sort(reverse=True)
print(*A)
import sys
read... | ConDefects/ConDefects/Code/arc179_a/Python/54940318 |
condefects-python_data_1214 | # https://atcoder.jp/contests/arc179/tasks/arc179_a
# Goal: all values less than K appear before numbers more than K in array's psa
# Case 1: K < 0: extra option to make everything in psa >= 0
# General case: sort array for smaller elements to come first
from itertools import accumulate
import sys
def check(psa):
... | ConDefects/ConDefects/Code/arc179_a/Python/54889248 |
condefects-python_data_1215 | def main():
N,K=map(int,input().split())
A=list(map(int,input().split()))
if K>=1:
print("Yes")
A.sort()
print(*A)
elif sum(A)>=0:
print("Yes")
A.sort(reverse=True)
print(*A)
else:
print("No")
if __name__=="__main__":
main()
def main():... | ConDefects/ConDefects/Code/arc179_a/Python/54763731 |
condefects-python_data_1216 | #!/usr/bin/env python3
# 再起関数,Decimal以外は、pypyを推奨(メモリを多く使用する場合遅くなる)
# pypyは,numpy使用不可
# pythonの実行時間のオーダーは、10^8まで
# 最小値の最大化(最大値の最小化)は二分探索
# O(2^n)はdpが多め
# べき乗はpowを使う(modで割る系は平衡二分木が組まれているため)
from collections import Counter, deque, defaultdict, OrderedDict
from heapq import heapify, heappop, heappush
from itertools impor... | ConDefects/ConDefects/Code/arc179_a/Python/55011877 |
condefects-python_data_1217 | n,k=map(int,input().split())
A=list(map(int,input().split()))
if k>0:
A.sort()
print("Yes")
print(*A)
elif k<sum(A):
A.sort(reverse=True)
print("Yes")
print(*A)
else:
print("No")
n,k=map(int,input().split())
A=list(map(int,input().split()))
if k>0:
A.sort()
print("Yes")
print(*A)
elif k<=sum(A)... | ConDefects/ConDefects/Code/arc179_a/Python/54967532 |
condefects-python_data_1218 | import math
import sys
import random
from collections import deque
from itertools import product
debug = lambda name, value, *args, **kwargs: print( f"{name}: {value}", *args, file=sys.stderr, **kwargs)
mod = 1000000007
m = random.randint(1,1000000)
iinf = 100000000000000005 #1e18 + 5
input = lambda: sys.stdin.read... | ConDefects/ConDefects/Code/abc330_c/Python/54910018 |
condefects-python_data_1219 | d=int(input())
ans=float("inf")
for x in range(1,d):
if x**2-d>=0:
ans=min(ans,x**2-d)
break
else:
c=d-x**2
y1=int(c**0.5)
y2=y1+1
ans=min(ans,abs(y1**2-c),abs(y2**2-c))
print(ans)
d=int(input())
ans=float("inf")
for x in range(1,d+1):
if x**2-d>=0:
a... | ConDefects/ConDefects/Code/abc330_c/Python/54320173 |
condefects-python_data_1220 | import math
def rint(offset=0,base=10): return list(map(lambda x: int(x, base)+offset, input().split()))
def full(s, f=int, *args): return [full(s[1:], f) if len(s) > 1 else f(*args) for _ in range(s[0])]
def shift(*args,offset=-1): return (a+offset for a in args)
D, = rint()
D2 = math.floor(math.sqrt(D))
ans = D
fo... | ConDefects/ConDefects/Code/abc330_c/Python/54990972 |
condefects-python_data_1221 | d = int(input())
x = 0
out = d
while 2 * x**2 < d:
y = int((d - x**2)**(0.5))
out = min(out, d - x**2 - y**2, x**2 + (y+1)**2 - d)
x += 1
print(out)
d = int(input())
x = 0
out = d
while x**2 < d:
y = int((d - x**2)**(0.5))
out = min(out, d - x**2 - y**2, x**2 + (y+1)**2 - d)
x += 1
print(out) | ConDefects/ConDefects/Code/abc330_c/Python/54054641 |
condefects-python_data_1222 | D = int(input())
square = []
for i in range(10**6+2):
if i**2 > D:
break
square.append(i**2)
ans = 10**12
x = 0
y = len(square)-1
while x < len(square):
value = square[x] + square[y]
ans = min(ans,abs(value-D))
if value < D:
x += 1
elif value > D:
y -= 1
elif value ... | ConDefects/ConDefects/Code/abc330_c/Python/54071794 |
condefects-python_data_1223 | d=int(input())
ans=1001001001001
for a in range(1,2*10**6+1):
b=(abs(d-a**2))**.5
b=int(b)
for nb in range(b-1,b+2):
ans=min(ans,abs(a**2+b**2-d))
print(ans)
d=int(input())
ans=1001001001001
for a in range(1,2*10**6+1):
b=(abs(d-a**2))**.5
b=int(b)
for nb in range(b-1,b+2):
ans=min(ans,abs(a**2+nb**2-d))
pr... | ConDefects/ConDefects/Code/abc330_c/Python/54284668 |
condefects-python_data_1224 | import math
D = int(input())
n = int(math.sqrt(D))
ans = 10**10
index = 0
for i in range(n, 0, -1):
for j in range(index, i):
ans = min(ans, abs(D-(i**2 + j**2)))
if i**2 + j**2 >= D:
index = j
break
print(ans)
import math
D = int(input())
n = int(math.sqrt(D))
ans = 10**10
index = 0
for i in r... | ConDefects/ConDefects/Code/abc330_c/Python/54881958 |
condefects-python_data_1225 | N, K = map(int, input().split())
MOD = 998244353
dp = [0]*(K+1)
dp[0] = 1
a = (N**2-2*N)%MOD*pow(N, -2, MOD)
b = 2*pow(N, -2, MOD)
for k in range(1, K+1):
dp[k] = (dp[k-1]*a+b)%MOD
if N == 1:
ans = 1
else:
ans = dp[K] + (1-dp[K])*(N+2)//2
print(ans%MOD)
N, K = map(int, input().split())
MOD = 998244353
... | ConDefects/ConDefects/Code/abc360_e/Python/55129894 |
condefects-python_data_1226 | import sys
from pprint import pprint
sys.setrecursionlimit(10**7)
read_int = lambda: int(sys.stdin.readline())
read_ints = lambda: list(map(int, sys.stdin.readline().split()))
read_float = lambda: float(sys.stdin.readline())
read_floats = lambda: list(map(float, sys.stdin.readline().split()))
def get_logger(debug=Tr... | ConDefects/ConDefects/Code/abc360_e/Python/55140371 |
condefects-python_data_1227 | def calculate_LCP(s1, s2):
lcp_length = 0
min_len = min(len(s1), len(s2))
for i in range(min_len):
if s1[i] == s2[i]:
lcp_length += 1
else:
break
return lcp_length
N = int(input())
L = [] #String, index, LCP
for i in range(N):
S = input()
L.append([S, i... | ConDefects/ConDefects/Code/abc287_e/Python/54006112 |
condefects-python_data_1228 | n = int(input())
s = [input() for _ in range(n)]
m = 2147483647 # 2**31-1
from collections import defaultdict
di = defaultdict(int)
for x in s:
num = 0
for y in x:
y = (ord(y)-ord('a')+1)
num = (y+num*100)%m
di[num] += 1
for x in s:
ans = 0
num = 0
for i, y in enumerate... | ConDefects/ConDefects/Code/abc287_e/Python/51264451 |
condefects-python_data_1229 | CHAR_SIZE = 26
class Trie:
def __init__(self):
self.isLeaf = False
self.children = [None] * CHAR_SIZE
self.cnt = 0
def insert(self, key):
curr = self
for i in range(len(key)):
index = ord(key[i]) - ord('a')
if curr.children[index] is None:
... | ConDefects/ConDefects/Code/abc287_e/Python/54495703 |
condefects-python_data_1230 | s = input()
S_part = set()
for i in range(len(s)):
for j in range(i+1,len(s)+1):
S_part.add(s[i:j])
print(S_part)
s = input()
S_part = set()
for i in range(len(s)):
for j in range(i+1,len(s)+1):
S_part.add(s[i:j])
print(len(S_part)) | ConDefects/ConDefects/Code/abc347_b/Python/54617710 |
condefects-python_data_1231 | def generate_substrings(s):
substrings = []
n = len(s)
for length in range(1, n + 1): # 長さ1からnまでの部分文字列を生成する
for start in range(n - length + 1):
substr = s[start:start + length]
substrings.append(substr)
return substrings
s = input()
print(len(generate_substrings(s)))
de... | ConDefects/ConDefects/Code/abc347_b/Python/55003393 |
condefects-python_data_1232 | s = input()
q = int(input())
def rec(t, k):
if t == 0:
return k
elif k == 0:
return ord(s[0]) - ord('A') + t
elif k % 2 == 0:
return rec(t-1, k//2) + 1
else:
return rec(t-1, k//2) + 2
def main():
for _ in range(q):
t, k = map(int, input().split())
pri... | ConDefects/ConDefects/Code/abc242_d/Python/45458203 |
condefects-python_data_1233 | S=input()
if S=='ACE' or S=='BDF' or S=='CEG' or S=='DFA' or S=='EGB' or S=='FAC' or S=='GBD ':
print('Yes')
else:
print('No')
S=input()
if S=='ACE' or S=='BDF' or S=='CEG' or S=='DFA' or S=='EGB' or S=='FAC' or S=='GBD':
print('Yes')
else:
print('No') | ConDefects/ConDefects/Code/abc312_a/Python/45974761 |
condefects-python_data_1234 | S=str(input())
if S=='ACE':
print('Yes')
elif S=='BDF':
print('Yes')
elif S=='CFG':
print('Yes')
elif S=='DFA':
print('Yes')
elif S=='EGB':
print('Yes')
elif S=='FAC':
print('Yes')
elif S=='GBD':
print('Yes')
else:
print('No')
S=str(input())
if S=='ACE':
print('Yes')
elif S=='BDF':
... | ConDefects/ConDefects/Code/abc312_a/Python/46035506 |
condefects-python_data_1235 | S = input()
YES = ["ACE", "BDF", "CFG", "DFA", "EGB", "FAC", "GBD"]
if S in YES:
print("Yes")
else:
print("No")
S = input()
YES = ["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GBD"]
if S in YES:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc312_a/Python/46185846 |
condefects-python_data_1236 | S = input()
if S == 'ACE' or 'BDF' or 'CEG' or 'DFA' or 'EGB' or 'FAC' or 'GBD':
print('Yes')
else:
print('No')
S = input()
if S == 'ACE' or S == 'BDF' or S == 'CEG' or S == 'DFA' or S == 'EGB' or S == 'FAC' or S == 'GBD':
print('Yes')
else:
print('No')
| ConDefects/ConDefects/Code/abc312_a/Python/45765051 |
condefects-python_data_1237 | S = input()
Flag = 0
string = ['ACE', 'BDF', 'CEG', 'DFA', 'EGB', 'FAC', 'GBD']
for i in range(len(string)):
if S == string[i]:
Flag = 1
if Flag == 1:
print('Yes')
else:
print('NO')
S = input()
Flag = 0
string = ['ACE', 'BDF', 'CEG', 'DFA', 'EGB', 'FAC', 'GBD']
for i in range(len(string)):
... | ConDefects/ConDefects/Code/abc312_a/Python/45975022 |
condefects-python_data_1238 | S = input()
curr = ["ACE", "BDF", "CEG", "DFA", "EFA", "FAC", "GBD"]
ans = "No"
for c in curr:
if S == c:
ans = "Yes"
break
print(ans)
S = input()
curr = ["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GBD"]
ans = "No"
for c in curr:
if S == c:
ans = "Yes"
break
print(ans) | ConDefects/ConDefects/Code/abc312_a/Python/45778739 |
condefects-python_data_1239 | tex=['ACE', 'BDF', 'CEG', 'DFA', 'EGB', 'FAC']
s=input()
ans=0
for i in range(len(tex)):
if s == tex[i]:
ans+=1
if ans==0:
print("No")
else:
print("Yes")
tex=['ACE', 'BDF', 'CEG', 'DFA', 'EGB', 'FAC', 'GBD']
s=input()
ans=0
for i in range(len(tex)):
if s == tex[i]:
ans+=1
if ans==0:
print("No")
e... | ConDefects/ConDefects/Code/abc312_a/Python/46047381 |
condefects-python_data_1240 | seikai=["ACE","BDF","CEG","DFA","EGB","FAC","GBD"]
S=input()
if(S in seikai):
print("Yse")
else:
print("No")
seikai=["ACE","BDF","CEG","DFA","EGB","FAC","GBD"]
S=input()
if(S in seikai):
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc312_a/Python/45893891 |
condefects-python_data_1241 | S = input()
list = [ "ACE","BDF","CEG","DFA","EGB","FAC","GBD"]
print("YES" if S in list else "NO")
S = input()
list = [ "ACE","BDF","CEG","DFA","EGB","FAC","GBD"]
print("Yes" if S in list else "No") | ConDefects/ConDefects/Code/abc312_a/Python/46206002 |
condefects-python_data_1242 | N, X, Y = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
u, v = map(int, input().split())
G[u].append(v)
G[v].append(u)
# 深さ優先探索のときはこれをつけるように!
# また、PyPy は再帰が遅いので CPython を使うように!
import sys
sys.setrecursionlimit(10**6)
def dfs(v, p, s):
s[v] = True
for neibor in G[v]:
if s[ne... | ConDefects/ConDefects/Code/abc270_c/Python/54301518 |
condefects-python_data_1243 | #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
def main():
n = int(input())
a = list(map(int,input().split()))
hull = [(0, a[0]), (1, a[1])]
for i in range(2, n):
nextv = (i, a[i])
while True:
v1 = hull[-1]
v2 = hull[-2]
gr... | ConDefects/ConDefects/Code/arc130_f/Python/27576444 |
condefects-python_data_1244 | import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
def calc(l,r):
x=abs(A[r]-A[l])
q=x//(r-l)
rr=x%(r-l)
if A[l]<A[r]:
for i in range(r-l):
if (r-(l+i))<=rr-1:
A[l+i]=min(A[l+i],rr-(r-(l+i))+A[l]+q*i)
... | ConDefects/ConDefects/Code/arc130_f/Python/27582246 |
condefects-python_data_1245 | h,w=map(int, input().split())
g=[input() for i in range(h)]
used=[[1]*w for i in range(h)]
def grid(nowh,noww):
if(0<=nowh<=h-1 and 0<=noww<=w-1):
return 1
else:
return 0
st={"#", ">", "v", "<", "^"}
for i in range(h):
for j in range(w):
now=g[i][j]
if(now==">"):
... | ConDefects/ConDefects/Code/abc317_e/Python/52926276 |
condefects-python_data_1246 | H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
for h in range(H):
for w in range(W):
if S[h][w] == "S":
sh, sw = h, w
elif S[h][w] == "G":
gh, gw = h, w
for h in range(H):
w = 0
flg = False
while w < W:
if S[h][w] not in ("*", "."):
flg = False
if ... | ConDefects/ConDefects/Code/abc317_e/Python/51930031 |
condefects-python_data_1247 | import sys
from collections import deque,defaultdict
import heapq
import math
import collections
import itertools
#sys.setrecursionlimit(10 ** 9)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
lli = lambda n: [li() for _ in range(n... | ConDefects/ConDefects/Code/abc243_d/Python/45981948 |
condefects-python_data_1248 | N,X = map(int,input().split())
S = input()
Move =[]
for i in range(N):
if len(Move) == 0:
Move.append(S[i])
else:
if S[i]== "L" or S[i] == "R":
Move.append(S[i])
else:
if Move[-1]=="L" or Move[-1] =="R":
Move.pop()
else:
... | ConDefects/ConDefects/Code/abc243_d/Python/44607569 |
condefects-python_data_1249 | N, M = map(int, input().split())
P = 1
ans = 0
for y in range(2, N + 1):
P = P * (N + 1 - y) % M
f = P * pow(N, N - y, M)
ans += f * (y - 1) * y // 2
ans %= M
print(ans * N % M)
N, M = map(int, input().split())
P = 1
ans = 0
for y in range(2, N + 1):
P = P * (N + 1 - y) % M
f = P * pow(N, N - y, ... | ConDefects/ConDefects/Code/abc284_g/Python/37908236 |
condefects-python_data_1250 | N, T = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
def main():
rows = [0 for i in range(N)]
cols = [0 for i in range(N)]
backwards = 0
forwards = 0
for i, a in enumerate(A):
cols[(a-1) % N] += 1
if cols[(a-1) % N] == N:
# print(cols)
... | ConDefects/ConDefects/Code/abc355_c/Python/55136098 |
condefects-python_data_1251 | N, T = [int(x) for x in input().split()]
A = [int(x) - 1 for x in input().split()]
boolss = []
for _ in range(N):
bools = N * [False]
boolss.append(bools)
bingo = False
for turn, a in enumerate(A):
i = a // N
j = a % N
boolss[i][j] = True
if all(boolss[i]):
bingo = True
vertical = Tr... | ConDefects/ConDefects/Code/abc355_c/Python/54860926 |
condefects-python_data_1252 | n, t = map(int, input().split())
a = list(map(int, input().split()))
r = {}
c = {}
d = {1: 0, 2: 0}
ans = -1
for l in range(t):
ai = a[l]
i = ai // n
j = ai % n
if j != 0:
if i+1 not in r:
r[i+1] = 1
else:
r[i+1] += 1
if r[i+1] == n:
ans = l ... | ConDefects/ConDefects/Code/abc355_c/Python/54869003 |
condefects-python_data_1253 | N,T = map(int, input().split())
A = list(map(int, input().split()))
horizontal = [[] for _ in range(N)]
vertical = [[] for _ in range(N)]
diagonal = [[],[]]
ans = -1
for i,a in enumerate(A):
row = (a-1) // N
col = (a-1) % N
horizontal[row].append(a)
vertical[col].append(a)
if row == col: diagonal[... | ConDefects/ConDefects/Code/abc355_c/Python/54926937 |
condefects-python_data_1254 | def row(x, n):
return (x-1)//n
def col(x, n):
return (x-1)%n
def diag1(x,n, lst1):
return (x-1) in lst1
def diag2(x,n, lst2):
return (x-1) in lst2
n, t = [int(num) for num in input().split()]
lst = [int(num) for num in input().split()]
lst1 = [num for num in range(0, n*n, n+1)]
lst2 = [num for num i... | ConDefects/ConDefects/Code/abc355_c/Python/55032844 |
condefects-python_data_1255 | from collections import defaultdict
n, t = map(int, input().split())
tate = defaultdict(set)
yoko = defaultdict(set)
naname = defaultdict(set)
for i in range(n):
for j in range(n):
tmp = n * i + j
tate[i].add(tmp)
yoko[j].add(tmp)
if i == j:
naname[0].add(tmp)
i... | ConDefects/ConDefects/Code/abc355_c/Python/54891333 |
condefects-python_data_1256 | n, t = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n * 2 + 2)
for i, ai in enumerate(a):
r = (ai - 1) % n
c = (ai - 1) // n
b[r] += 1
b[n + c] += 1
if r == c:
b[-2] += 1
if r + c == n:
b[-1] += 1
if max(b) == n:
print(i + 1)
e... | ConDefects/ConDefects/Code/abc355_c/Python/54884677 |
condefects-python_data_1257 | from itertools import permutations as perm
from itertools import combinations, product, combinations_with_replacement, groupby, accumulate
from fractions import Fraction
from collections import *
from sys import *
from bisect import *
from heapq import *
#@再起回数の上限を上げる
#sys.setrecursionlimit(10**7) # PyPy の再起関数は遅くなるので注... | ConDefects/ConDefects/Code/abc359_e/Python/55124422 |
condefects-python_data_1258 | def main():
r, c = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(2) ]
print(a[c-1][r-1])
if __name__ == '__main__':
main()
def main():
r, c = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(2) ]
print(a[r-1][c-1])
if __name__... | ConDefects/ConDefects/Code/abc255_a/Python/44829145 |
condefects-python_data_1259 | import sys
input = sys.stdin.readline
# Dinic's algorithm
from collections import deque
class Dinic:
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap):
forward = [to, cap, None]
forward[2] = backward = [fr, 0, forward]
self... | ConDefects/ConDefects/Code/abc320_g/Python/45654657 |
condefects-python_data_1260 | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque,defaultdict as dd
INF=10**18
##二部マッチング
##参考:https://snuke.hatenablog.com/entry/2019/05/07/013609
class Bipartile_Matching:
def __init__(self,L,R):
##L2R:Lから見たRのマッチングを記録
##R2L:Rから見たLのマッチングを記録
##backp... | ConDefects/ConDefects/Code/abc320_g/Python/45748637 |
condefects-python_data_1261 | import sys
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()
import bisect,string,math,time,functools,random,fractions
from bisect import*
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutation... | ConDefects/ConDefects/Code/arc132_c/Python/31137799 |
condefects-python_data_1262 | n,d = map(int,input().split())
a = [0] + list(map(int,input().split()))
dp = [[0] * (1<<(2*d+1)) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
for s in range(1<<(2*d+1)):
if a[i+1] != -1:
if ((s>>1) & (1<<(a[i+1]-(i+1)+d))) == 0:
dp[i+1][(s>>1) | (1<<(a[i+1... | ConDefects/ConDefects/Code/arc132_c/Python/35435888 |
condefects-python_data_1263 | N,D = map(int, input().split())
A =[int(i) for i in input().split()]
mod = 998244353
S = 1<<(2*D+2)
dp = [[0]*(S) for _ in range(N+1)]
dp[0][(1<<(D+1)) - 1] = 1
for i,a in enumerate(A):
if a>-1:
for s in range(S):
if s&1==0:
continue
t = s>>1
diff = a-(i+... | ConDefects/ConDefects/Code/arc132_c/Python/31270911 |
condefects-python_data_1264 | import sys;input=sys.stdin.readline
def bsearch(mn, mx, func):
#func(i)=False を満たす最大のi (mn<=i<mx)
idx = (mx + mn)//2
while mx-mn>1:
if func(idx):
idx, mx = (idx + mn)//2, idx
continue
idx, mn = (idx + mx)//2, idx
return idx
def f(k):
# print()
sm = 0
f... | ConDefects/ConDefects/Code/abc330_f/Python/48327716 |
condefects-python_data_1265 | import heapq
N,K = map(int, input().split())
X=[]
Y=[]
for _ in range(N):
x,y = map(int, input().split())
X.append(x)
Y.append(y)
X.sort()
Y.sort()
def solve(A,d):
h=A[:]
heapq.heapify(h)
for i in range(N):
l=heapq.heappushpop(h, A[i]-d)
ans=0
for a in A:
if a<l:
ans+=l-a
elif a>l+d:
... | ConDefects/ConDefects/Code/abc330_f/Python/48207650 |
condefects-python_data_1266 | N, mod = map(int, input().split())
con = [[0]*N for _ in range(N)]
sep = [[0]*(N+1) for _ in range(N)]
con[0][0] = 1
sep[0][1] = 1
for n in range(N)[1:]:
con[n][0] = 1
for m in range(n+1)[1:]:
con[n][m] = con[n-1][m] + con[n-1][m-1]*3 + sep[n-1][m]
con[n][m] %= mod
for m in range(n+2)[2:]:
... | ConDefects/ConDefects/Code/abc248_f/Python/53199737 |
condefects-python_data_1267 | #@markdown # 04 Tires
text=list(input())
lasttext="".join(text[-1:-2])
if lasttext=="er":
print("er")
else:
print("ist")
#@markdown # 04 Tires
text=list(input())
lasttext="".join(text[-2:])
if lasttext=="er":
print("er")
else:
print("ist") | ConDefects/ConDefects/Code/abc224_a/Python/45979243 |
condefects-python_data_1268 | s=input()
if s[-2:]=="er":
print("er")
if s[-2:]=="ist":
print("ist")
s=input()
if s[-2:]=="er":
print("er")
if s[-3:]=="ist":
print("ist") | ConDefects/ConDefects/Code/abc224_a/Python/45476747 |
condefects-python_data_1269 | s=input()
print('er' if s[-2:]=='er' else 'est')
s=input()
print('er' if s[-2:]=='er' else 'ist') | ConDefects/ConDefects/Code/abc224_a/Python/45312874 |
condefects-python_data_1270 | S = input()
if S[-2] == 'er':
print('er')
else:
print('ist')
S = input()
if S[-1] == 'r':
print('er')
else:
print('ist') | ConDefects/ConDefects/Code/abc224_a/Python/45433181 |
condefects-python_data_1271 | A = input()
if A[len(A) - 1] == "r":
print("er")
else:
print("st")
A = input()
if A[len(A) - 1] == "r":
print("er")
else:
print("ist")
| ConDefects/ConDefects/Code/abc224_a/Python/45808243 |
condefects-python_data_1272 | s = input()
a = len(s)
if s[a - 2 : a - 1] == "er":
print("er")
else:
print("ist")
s = input()
a = len(s)
if s[a - 2 :] == "er":
print("er")
else:
print("ist")
| ConDefects/ConDefects/Code/abc224_a/Python/45808674 |
condefects-python_data_1273 | s = input()
if s[-2:] == "er":
print("er")
elif s[-2:] == "ist":
print("ist")
s = input()
if s[-2:] == "er":
print("er")
else:
print("ist") | ConDefects/ConDefects/Code/abc224_a/Python/45545043 |
condefects-python_data_1274 | s=input()
if s[-2] == "er":
print("er")
else:
print("ist")
s=input()
if s[-2:] == "er":
print("er")
else:
print("ist") | ConDefects/ConDefects/Code/abc224_a/Python/46029165 |
condefects-python_data_1275 | def main():
N = int(input())
S = input()
S = [S[:N], S[N:2*N], S[2*N:]]
print(S)
d = [{"A": S[i].count("A"), "B": S[i].count("B"), "C": S[i].count("C")} for i in range(3)]
idx = [{"A": 0, "B": 0, "C": 0} for i in range(3)]
perm = ["ABC", "ACB", "BCA", "BAC", "CAB", "CBA"]
ans = [[0] * N for i in range(3... | ConDefects/ConDefects/Code/agc055_a/Python/37010633 |
condefects-python_data_1276 | from bisect import *
N = int(input())
S = input()
X = [[] for _ in range(3)]
for i, s in enumerate(S):
X[ord(s) - 65].append(i)
#print(X)
ans = ["0"] * (3 * N)
n = N
for i in range(1, 6):
start = 3 * N
for j in range(3):
if X[j][0] < start:
start = X[j][0]
c1 = j
stop ... | ConDefects/ConDefects/Code/agc055_a/Python/44002402 |
condefects-python_data_1277 | N = int(input())
S = [ord(s) - ord("a") for s in input()]
T = [ord(s) - ord("a") for s in input()]
Ns, Nt = len(S), len(T)
A = [[] for i in range(26)]
S = S + S
for i in range(2 * Ns):
A[S[i]].append(i)
for i in range(Nt):
if len(A[T[i]]) == 0:
print(0)
exit()
C = [[0] * (2 * Ns)... | ConDefects/ConDefects/Code/abc346_f/Python/54698915 |
condefects-python_data_1278 | N = int(input())
S = input()
T = input()
sl = len(S)
tl = len(T)
ind = [[] for i in range(26)]
for i in range(2 * sl):
ind[ord(S[i % sl]) - ord("a")].append(i)
cnt = [0 for i in range(26)]
for i in range(26):
cnt[i] = len(ind[i]) // 2
import bisect
def is_ok(k):
itr = -1
# f(S, N)[0, itr)まで見た状況
fo... | ConDefects/ConDefects/Code/abc346_f/Python/53286789 |
condefects-python_data_1279 | n = int(input())
s = input()
t = input()
# 定义p(a,b,c)为f(s,n)的下标a后的出现的第b个字符c的位置
# 1.如果a>len(s),可以等价为p(a-len(s),b,c)+len(s)
# 2.如果s.count(c)<b,可以等价为p(a+len(s),b-s.count(c),c)
# 以上两步可以将a,b转为0<=a<len(s), 0<=b<s.count(c)
cnt = [0]*26
pos = [[] for _ in range(26)]
pre = [[0]*26 for _ in range(len(s)+1)]
for i, c in enumerate... | ConDefects/ConDefects/Code/abc346_f/Python/53131253 |
condefects-python_data_1280 | import bisect
N=int(input())
eng="abcdefghijklmnopqrstuvwxyz"
engd=dict()
for i in range(26) : engd[eng[i]]=i
s=input()
S=[[]for _ in range(26)]
for i in range(len(s)) : S[engd[s[i]]].append(i)
t=input()
T=[]
for i in t : T.append(engd[i])
for i in T:
if len(S[i])==0 : exit(print(0))
def can(n):
n1,n2=0,-1
... | ConDefects/ConDefects/Code/abc346_f/Python/53725760 |
condefects-python_data_1281 | import heapq
inf = float("inf")
N, K = map(int, input().split())
A = [0]
B = []
T = []
for _ in range(N):
t, y = map(int, input().split())
if t == 1:
A.append(y)
B.append(T)
T = []
else:
T.append(y)
B.append(T)
ans = -float("inf")
hq = []
S = 0
sute = []
while A:
a = A... | ConDefects/ConDefects/Code/abc249_f/Python/45465070 |
condefects-python_data_1282 | import bisect
import collections
import copy
import heapq
import itertools
import math
import string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline... | ConDefects/ConDefects/Code/abc289_d/Python/44672786 |
condefects-python_data_1283 | INT = lambda : int(input())
MI = lambda : map(int, input().split())
MI_DEC = lambda : map(lambda x : int(x)-1, input().split())
LI = lambda : list(map(int, input().split()))
LI_DEC = lambda : list(map(lambda x : int(x)-1, input().split()))
INF = float('inf')
N = INT()
A = LI()
M = INT()
B = LI()
X = INT()
dp = [False... | ConDefects/ConDefects/Code/abc289_d/Python/46033056 |
condefects-python_data_1284 | N=int(input())
A=list(map(int,input().split()))
x=sum(A)//N
r=sum(A)%N
SUM=[0]
for a in A:
SUM.append(SUM[-1]+a)
DP=[1<<100]*(r+1) # x+1にしたものの個数
DP[0]=0
for i in range(N-1):
NDP=[1<<100]*(r+1)
for j in range(r+1):
if DP[j]==1<<100:
continue
# index iまでの総和は
S=(x+1)*j... | ConDefects/ConDefects/Code/abc307_g/Python/42990129 |
condefects-python_data_1285 | n = int(input())
a = list(map(int,input().split()))
pre = a[::1]
for i in range(1,n):
pre[i] += pre[i-1]
sm = sum(a)
x = sm//n
y = (sm+n-1)//n
dp = [[10**18]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(1,n):
now = pre[i-1]
for j in range(i+1):
dif = abs(now - (x*j + y*(i-j)))
dp... | ConDefects/ConDefects/Code/abc307_g/Python/42981473 |
condefects-python_data_1286 | inf = 10 ** 18
n = int(input())
a = list(map(int,input().split()))
dp = [[inf] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 0
asumm = 0
s = sum(a)
one = s // n
for i in range(1, n + 1):
asumm += a[i - 1]
for j in range(n):
if i == j == 0:
continue
dp[i][j] = min(dp[i - 1][j - 1],... | ConDefects/ConDefects/Code/abc307_g/Python/42993063 |
condefects-python_data_1287 | N = int(input())
A = list(map(int,input().split()))
x = sum(A)//N
for i in range(N):
A[i] -= x
S = [A[0]]
for i in range(1,N):
S.append(S[-1] + A[i])
r = S[-1]
dp = [[10**18 for j in range(r+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
s = S[i]
for rr in range(r+1):
dp[i+1][rr] = min(dp[i][rr],... | ConDefects/ConDefects/Code/abc307_g/Python/50088048 |
condefects-python_data_1288 | N = int(input())
A = list(map(int,input().split()))
sA = sum(A)
one = sA%N
zero = N-one
for i in range(N):
A[i]-=sA//N
#one個の1、残り全部0
A_sum = [0]
for i in range(N):
A_sum.append(A_sum[-1]+A[i])
last = [10**16 for i in range(N)]
last[0]=0
for i in range(N):
for j in reversed(range(N)):
#最後がjの場合
... | ConDefects/ConDefects/Code/abc307_g/Python/42982093 |
condefects-python_data_1289 | ## https://atcoder.jp/contests/abc307/tasks/abc307_g
def main():
N = int(input())
A = list(map(int, input().split()))
sum_a = sum(A)
if sum_a % N == 0:
border_a = sum_a // N
answer = 0
for i in range(N - 1):
b = border_a - A[i]
A[i + 1] -= b
... | ConDefects/ConDefects/Code/abc307_g/Python/51711769 |
condefects-python_data_1290 | n = int(input())
aaa = list(map(int, input().split()))
x, y = divmod(sum(aaa), n)
INF = 1 << 60
dp = [INF] * (y + 1)
dp[0] = 0
tmp_sum = 0
for i in range(n):
ndp = [INF] * (y + 1)
diff = tmp_sum - i * x
a = aaa[i]
for j in range(min(i, y) + 1):
d = diff - j # i+1 への調整残し
x0 = x - (a + ... | ConDefects/ConDefects/Code/abc307_g/Python/42999980 |
condefects-python_data_1291 | from collections import defaultdict
N,M,H,K = map(int,input().split())
S = list(input())
item = defaultdict(int)
for i in range(M):
x,y = map(int,input().split())
item[(x,y)] = 1
now = [0,0]
for i in range(N):
move = S[i]
if move == "R":
now[0] += 1
elif move == "L":
now[0] -= 1... | ConDefects/ConDefects/Code/abc303_c/Python/45491344 |
condefects-python_data_1292 | N, M, H, K = map(int, input().split())
S = input()
items = set(tuple(map(int, input().split())) for _ in range(M))
print(items)
# シミュレーションする
res = True
x, y = 0, 0
for c in S:
# 移動する
if c == 'R': x += 1
elif c == 'L': x -= 1
elif c == 'U': y += 1
else: y -= 1
# 体力を 1 減らす (0 未満になったら倒れる)
... | ConDefects/ConDefects/Code/abc303_c/Python/45578518 |
condefects-python_data_1293 | # import math
# import sys
# sys.setrecursionlimit(10**9)
# from itertools import permutations
# from itertools import combinations
# from functools import lru_cache
# import heapq
# DIV = 10**9+7
#data(yyyy-mm-dd):
#recursion使う時はCpythonで出す.それ以外は基本Pypy
def main():
n,m,hit_point,k = map(int,input().split(" "))
... | ConDefects/ConDefects/Code/abc303_c/Python/46045444 |
condefects-python_data_1294 | N, M, H, K = map(int, input().split())
S = input()
RLUD = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}
healing = set()
for _ in range(M):
x, y = map(int, input().split())
healing.add((x, y))
x, y = 0, 0
for s in S[:-1]:
H -= 1
if H < 0:
print('No')
exit()
x += RLUD[s][0]
... | ConDefects/ConDefects/Code/abc303_c/Python/46147196 |
condefects-python_data_1295 | N, Q = map(int, input().split())
X = []
S = {0, N}
for _ in range(Q):
l, r = map(int, input().split())
l -= 1
S.add(l)
S.add(r)
X.append((l, r))
SS = sorted(S)
D = {a: i for i, a in enumerate(SS)}
M = len(SS)
X = [(D[l], D[r]) for l, r in X]
d = 0
s = 1
while s < M:
s *= 2
d += 1
L = [0] * (... | ConDefects/ConDefects/Code/arc164_e/Python/43438224 |
condefects-python_data_1296 | import sys
input = sys.stdin.readline
n, q = map(int, input().split())
skips = [0] * (n + 1)
for _ in range(q):
l, r = map(int, input().split())
skips[l - 1] += 1
skips[r] += 1
skips.pop()
skips.pop(0)
comp = [v for v in skips if v]
#comp.sort()
sz = len(comp) + 1
o = 0
while pow(2, o) < sz:
o += 1... | ConDefects/ConDefects/Code/arc164_e/Python/43525175 |
condefects-python_data_1297 | import sys
readline = sys.stdin.readline
#n = int(readline())
#*a, = map(int,readline().split())
# b = [list(map(int,readline().split())) for _ in range()]
n,Q = map(int,readline().split())
LR = []
s = {0,n}
for _ in range(Q):
a,b = map(int,readline().split())
a -= 1
LR.append((a,b))
s.add(a)
s.ad... | ConDefects/ConDefects/Code/arc164_e/Python/43433582 |
condefects-python_data_1298 | import sys
input = sys.stdin.readline
from operator import itemgetter
N=int(input())
P=[list(map(int,input().split())) for i in range(N)]
hosei=10**30
ANS=float("inf")
Q=[]
for a,b,c in P:
a0=hosei*a//c
b0=hosei*b//c
Q.append((a0,b0))
if a0>b0:
ANS=min(ANS,a0)
else:
ANS=min(ANS,... | ConDefects/ConDefects/Code/abc275_g/Python/36145190 |
condefects-python_data_1299 | import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################... | ConDefects/ConDefects/Code/abc275_g/Python/37220565 |
condefects-python_data_1300 | pin = [0] * 7
s = input()
p = [[6],[3],[6,1],[4,0],[8,2],[5],[9]]
for i in range(len(p)):
cnt = 0
for j in range(len(p[i])):
if s[p[i][j]] == "1":
cnt += 1
if cnt:
pin[i] = 1
b = 0
ok = 0
e = 0
for i in range(7):
if pin[i] and b == 0:
b = 1
if b and pin[i] == 0:
ok = 1
if b and ok and ... | ConDefects/ConDefects/Code/abc267_b/Python/45810314 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.