id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_1301 | s = input()
row = [1]*7
if s[0]=='1':
print('No')
else:
if s[6]=='0':
row[0]=0
if s[3]=='0':
row[1]=0
if s[1]=='0' and s[7]=='0':
row[2]=0
if s[4]=='0':
row[3]=0
if s[2]=='0' and s[8]=='0':
row[4]=0
if s[5]=='0':
row[5]=0
if s[9]=='0':
... | ConDefects/ConDefects/Code/abc267_b/Python/45233540 |
condefects-python_data_1302 | S = list(map(int, input()))
if S[0]:
exit(print("No"))
column = [S[6], S[3], S[1] | S[8], S[0] | S[4], S[2] | S[8], S[5], S[9]]
for i in range(7):
for j in range(i + 1, 7):
for k in range(j + 1, 7):
if column[i] and not column[j] and column[k]:
exit(print("Yes"))
print("No")... | ConDefects/ConDefects/Code/abc267_b/Python/45086999 |
condefects-python_data_1303 | import sys
S=list(input())
L=[0,0,0,0,0,0,0]
for i in range(10):
if S[i]=="1":
if i+1 in [1,5]:
L[3]=1
if i+1 in [2,8]:
L[2]=1
if i+1 in [3,9]:
L[4]=1
if i+1==4:
L[1]=1
if i+1==6:
L[5]=1
if i+1==7:
L[0]=1
if i+1==10:
L[6]=1
if S[0]==1:
print("No"... | ConDefects/ConDefects/Code/abc267_b/Python/45974485 |
condefects-python_data_1304 | def solve(h, w, m, t, a, x):
a = [_-1 for _ in a]
cnt = {color: 0 for color in x} # 色ごとの塗られたマスの個数
S_row = set() # すでに塗られた行の集合
S_col = set() # すでに塗られた列の集合
# 逆順に塗られたマスの数を調べていく
for k in range(m-1, -1, -1):
if t[k] == 1: # a[k]列目のマスを色x[k]で塗る
if not a[k] in S_row:
... | ConDefects/ConDefects/Code/abc346_e/Python/52762677 |
condefects-python_data_1305 | import sys
stdin = sys.stdin.readline
stdout = sys.stdout.write
MOD = 10 ** 9 + 7
INF = float("inf")
def next_int(): return int(stdin().strip())
def next_float(): return float(stdin().strip())
def next_array(): return list(map(int, stdin().split()))
def next_string(): return stdin().strip()
def solve():
h, w, ... | ConDefects/ConDefects/Code/abc346_e/Python/54144246 |
condefects-python_data_1306 | from sys import stdin
input=lambda :stdin.readline()[:-1]
import math
from bisect import bisect_left, bisect_right
from typing import Generic, Iterable, Iterator, TypeVar, Union, List
T = TypeVar('T')
class SortedSet(Generic[T]):
BUCKET_RATIO = 50
REBUILD_RATIO = 170
def _build(self, a=None) -> None:
... | ConDefects/ConDefects/Code/abc262_h/Python/40953311 |
condefects-python_data_1307 | import sys
input = sys.stdin.readline
from operator import itemgetter
N,M,Q=map(int,input().split())
LRX=[list(map(int,input().split())) for i in range(Q)]
mod=998244353
seg_el=1<<((N+1).bit_length()) # Segment treeの台の要素数
SEG=[M]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化
def getvalue(n,seg_el): # 一... | ConDefects/ConDefects/Code/abc262_h/Python/37417222 |
condefects-python_data_1308 | import math
n,m,k = (int(x) for x in input().split())
l = math.lcm(n,m)
low,high = 0,10**8
while high-low>1:
mid = (low+high)//2
if mid//n+mid//m-2*(mid//l) < k:
low = mid
else: high = mid
print(high)
import math
n,m,k = (int(x) for x in input().split())
l = math.lcm(n,m)
low,high = 0,10**18
while high-low... | ConDefects/ConDefects/Code/abc341_d/Python/53726659 |
condefects-python_data_1309 | import math
n,m,k=map(int,input().split())
q=(n*m)/math.gcd(n,m)
min=1
max=int(2e18)
while (max-min)>1:
x=(max+min)//2
if x//n + x//m - x//q*2 >= k:
max = x
else:
min = x
print(max)
import math
n,m,k=map(int,input().split())
q=(n*m)/math.gcd(n,m)
min=0
max=int(2e18)
while (max-min)>1:
x=(max+min)//2
... | ConDefects/ConDefects/Code/abc341_d/Python/54740423 |
condefects-python_data_1310 | from math import lcm
def count_divisible_by_either(x, n, m):
cnt_n = x // n
cnt_m = x // m
cnt_d = x // lcm(n, m)
return cnt_n + cnt_m - cnt_d * 2
n, m, k = map(int, input().split())
l = 1
r = 10**18
while r - l > 1:
mid = (l + r) // 2
cnt = count_divisible_by_either(mid, n, m)
# prin... | ConDefects/ConDefects/Code/abc341_d/Python/53927639 |
condefects-python_data_1311 | # import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
# import sys
# sys.setrecursionlimit(10**7)
import re
# import more_itertools
import functools
import sys
import bisect
import math
import itertools
from collections import deque
from collections import defaultdict
from collections import Counter
from copy... | ConDefects/ConDefects/Code/abc341_d/Python/53931924 |
condefects-python_data_1312 | import numpy as np
import scipy.optimize
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
xy = [(x-1, y-1) for _ in range(m) for x, y in [map(int, input().split())]]
for x, y in xy:
if x == y:
ab[x] = (max(ab[x]), min(ab[x]))
basis = sum(a for a, b in ab)
c = np.... | ConDefects/ConDefects/Code/abc313_f/Python/45736506 |
condefects-python_data_1313 | N = int(input())
A, B, C, D = 1, N, 1, N
count = N - 1
while B - A > 0:
M = (A + B) // 2
print(*["?", A, M, 1, N])
print("\n")
a = int(input())
if a <= count // 2:
B = M
count = a
else:
A = M + 1
count -= a
count = N - 1
while D - C > 0:
M = (C + D) // 2
... | ConDefects/ConDefects/Code/abc269_e/Python/45055935 |
condefects-python_data_1314 | # +-----------+--------------------------------------------------------------+
# | main | |
# +-----------+--------------------------------------------------------------+
def main():
global N
N = int(input())
x = query(0, N, axis=0)
x += ... | ConDefects/ConDefects/Code/abc269_e/Python/45214207 |
condefects-python_data_1315 | k = list(map(int, input().split()))
mod = 998244353
abc = (k[0]%mod)*(k[1]%mod)*(k[2]%mod)
deg = (k[3]%mod)*(k[4]%mod)*(k[5]%mod)
print((abc%mod)-(deg%mod))
k = list(map(int, input().split()))
mod = 998244353
abc = (k[0]%mod)*(k[1]%mod)*(k[2]%mod)
deg = (k[3]%mod)*(k[4]%mod)*(k[5]%mod)
print(((abc%mod)-(deg%mod)... | ConDefects/ConDefects/Code/abc275_b/Python/45102302 |
condefects-python_data_1316 | import bisect,collections,itertools,math,functools,heapq
import sys
# sys.setrecursionlimit(10**6)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LF(): return list(map(float,sys.stdin.readline().rstrip().split()))
def SI(): return sys.stdin.r... | ConDefects/ConDefects/Code/abc275_b/Python/45275005 |
condefects-python_data_1317 |
a,b,c,d,e,f=map(int,input().split())
mod=998244353
a1=a%mod*b%mod*c%mod
a2=d%mod*e%mod*f%mod
print(a1-a2)
a,b,c,d,e,f=map(int,input().split())
mod=998244353
a1=a%mod*b%mod*c%mod
a2=d%mod*e%mod*f%mod
print((a1-a2)%mod) | ConDefects/ConDefects/Code/abc275_b/Python/44663231 |
condefects-python_data_1318 | H,W,K = map(int,input().split())
S = [list(input()) for _ in [0]*H]
dic = {".":0,"o":1}
ans = -1
for s in S:
mx = -1
p = 0
leng = 0
for i in range(W):
if s[i] == "x" :
p,leng=0,0
else:
leng += 1
if 0<=leng<=K : p += dic[s[i]]
else :
p += dic[s[i]] - dic[s[i-K]]
... | ConDefects/ConDefects/Code/abc337_d/Python/54495605 |
condefects-python_data_1319 | H, W, K = list(map(int, input().split()))
N = (H+1)*(W+1)
ban = 2*(10**5)
line = [ban]*(2*N)
for h in range(H):
dh = h*(W+1) + N
for w, s in enumerate(input()):
if s == 'o':
line[dh+w] = 0
line[w*(H+1)+h] = 0
if s == '.':
line[dh+w] = 1
line[w*(H+1... | ConDefects/ConDefects/Code/abc337_d/Python/55025649 |
condefects-python_data_1320 | H,W,K=map(int,input().split())
S=[input() for i in range(H)]
dic=dict({'o':0,'x':1,'.':2})
ans=10**10
for i in range(H):
chk=[0,0,0]
if W<K:
break
for j in range(K):
chk[dic[S[i][j]]]+=1
if chk[1]==0:
ans=min(ans,chk[2])
for j in range(K,W):
chk[dic[S[i][j-K]]]-=1
chk[dic[S[i][j]]]+=1
if chk[1]==0:
... | ConDefects/ConDefects/Code/abc337_d/Python/54308671 |
condefects-python_data_1321 | n, m = map(int, input().split())
for i in range(2**m, 0, -1):
co = bin(i)[2:].zfill(m)
if co.count("1") == n:
print(*[t+1 for t in range(m) if co[t]=="1"])
n, m = map(int, input().split())
for i in range(2**m-1, 0, -1):
co = bin(i)[2:].zfill(m)
if co.count("1") == n:
print(*[t+1 for t in range(m) if ... | ConDefects/ConDefects/Code/abc263_c/Python/44826230 |
condefects-python_data_1322 | N,M=map(int,input().split())
import itertools
for p in itertools.combinations(range(1,N+1),M):
print(*p)
N,M=map(int,input().split())
import itertools
for p in itertools.combinations(range(1,M+1),N):
print(*p) | ConDefects/ConDefects/Code/abc263_c/Python/45092514 |
condefects-python_data_1323 | n,t=map(int,input().split())
s=[0 for _ in range(n)]
p={}
p[0]=n
for i in range(n):
a,b=map(int,input().split())
a-=1
p[s[a]]-=1
if p[s[a]]==0:
del p[s[a]]
s[a]+=b
if s[a] not in p:
p[s[a]]=0
p[s[a]]+=1
print(len(p))
n,t=map(int,input().split())
s=[0 for _ in range(n)]
p... | ConDefects/ConDefects/Code/abc343_d/Python/54888063 |
condefects-python_data_1324 | A,M,L,R = map(int,input().split())
x1 = -(-(L-A)//M)
x2 = (R-A)//M
if (L-A)%M == 0:
print(abs(x1-x2)+1)
else:
print(abs(x1-x2))
A,M,L,R = map(int,input().split())
x1 = (L-A)//M
x2 = (R-A)//M
if (L-A)%M == 0:
print(abs(x1-x2)+1)
else:
print(abs(x1-x2)) | ConDefects/ConDefects/Code/abc334_b/Python/54939914 |
condefects-python_data_1325 | # coding: utf-8
# Your code here!
MOD = 998244353
from itertools import groupby
N = int(input())
S = input()
last = 1
ans = 0
for key,val in groupby(S):
val = list(val)
key = int(key)
if (key>1 and len(val)>1) or (last>1 and key>1):
break
if key==1:
ans += (last-1)*ans+len(val)
else:... | ConDefects/ConDefects/Code/abc313_e/Python/45766127 |
condefects-python_data_1326 | S = input()
T = input()
g1 = ["AB", "BC", "CD", "DE", "EA"]
if S in g1 and T in g1:
print("Yes")
elif S not in g1 and T not in g1:
print("Yes")
else:
print("No")
S = input()
T = input()
g1 = ["AB","BA", "BC", "CB", "CD", "DC", "DE", "ED", "EA", "AE"]
if S in g1 and T in g1:
print("Yes")
elif S not... | ConDefects/ConDefects/Code/abc333_b/Python/54528600 |
condefects-python_data_1327 | s = input()
s1 = s[0]
s2 = s[1]
t = input()
t1 = t[0]
t2 = t[1]
if s1 == 'A' and s2 == 'C':
if t1 == 'E' and t2 == 'B' or t1 == 'B' and t2 == 'E' or t1 == 'D' and t2 == 'B' or t1 == 'B' and t2 == 'D' or t1 == 'A' and t2 == 'D' or t1 == 'D' and t2 == 'A' or t1 == 'E' and t2 == 'C' or t1 == 'C' and t2 == 'E' or t1 =... | ConDefects/ConDefects/Code/abc333_b/Python/54467069 |
condefects-python_data_1328 | K = "ABCDEABCDE"
S = input()
T = input()
if (S in K) == (T in K):
print("Yes")
else:
print("No")
K = "ABCDEAEDCBA"
S = input()
T = input()
if (S in K) == (T in K):
print("Yes")
else:
print("No")
| ConDefects/ConDefects/Code/abc333_b/Python/54487746 |
condefects-python_data_1329 | N = int(input())
MOD = 998244353
tree = [[] for _ in range(N)]
for _ in range(N-1):
u, v = map(int, input().split())
u -= 1; v -= 1
tree[u].append(v)
tree[v].append(u)
def calc_dist(fr):
dist = [-1] * N
dist[fr] = 0
stack = [fr]
while stack:
node = stack.pop()
for nex ... | ConDefects/ConDefects/Code/abc221_f/Python/45225814 |
condefects-python_data_1330 | from collections import deque
import sys
ipt = sys.stdin.readline
def calcDiameter(g):
'''
g := 木、隣接リスト表記
'''
n = len(g)
inf = 10**9
dst1,dst2 = [inf]*n, [inf]*n
d = deque()
d.append(0)
visited = [0]*n
visited[0] = 1
while d:
cur = d.popleft()
for n... | ConDefects/ConDefects/Code/abc221_f/Python/40898300 |
condefects-python_data_1331 | N, X = map(int, input().split())
S = list(map(int, input().split()))
count = 0
for s in S:
if s <= X:
count += 1
print(count)
N, X = map(int, input().split())
S = list(map(int, input().split()))
count = 0
for s in S:
if s <= X:
count += s
print(count) | ConDefects/ConDefects/Code/abc328_a/Python/55126003 |
condefects-python_data_1332 | A,B=map(int,input().split())
L=list(map(int,input().split()))
count=0
for i in range(A):
if L[i] <= B:
count+=B
print(count)
A,B=map(int,input().split())
L=list(map(int,input().split()))
count=0
for i in range(A):
if L[i] <= B:
count+=L[i]
print(count) | ConDefects/ConDefects/Code/abc328_a/Python/54463412 |
condefects-python_data_1333 | N, X = map(int, input().split())
S = list(map(int, input().split()))
ans = 0
for i in range(N):
if S[i] <= X:
ans += 1
print(ans)
N, X = map(int, input().split())
S = list(map(int, input().split()))
ans = 0
for i in range(N):
if S[i] <= X:
ans += S[i]
print(ans) | ConDefects/ConDefects/Code/abc328_a/Python/55136049 |
condefects-python_data_1334 | import itertools
def diff(A, B):
res = 0
for a, b in zip(A, B):
if a != b:
res += 1
return res
N, M = map(int, input().split())
S = [input() for _ in range(N)]
for T in itertools.permutations(S):
ok = True
for i in range(N-1):
if diff(T[i], T[i+1]) != 1:
ok = False
if ok:
print("Y... | ConDefects/ConDefects/Code/abc302_c/Python/45989052 |
condefects-python_data_1335 | import itertools
S = []
N,M = map(int,input().split())
for _ in range(N):
s = list(input())
S.append(s)
com = itertools.product(S,repeat = N)
for co in com:
ans = "Yes"
for k in range(len(co)-1):
no = 0
for j in range(M):
if co[k][j] != co[k+1][j]:
no+=1
if no != 1:
ans = "No"
... | ConDefects/ConDefects/Code/abc302_c/Python/45476546 |
condefects-python_data_1336 | import sys
from atcoder.dsu import DSU
MOD = 998_244_353
N, M = map(int, sys.stdin.readline().rstrip().split())
P = [int(x) - 1 for x in sys.stdin.readline().rstrip().split()]
uf = DSU(N)
for i in range(N):
uf.merge(i, P[i])
C = len(uf.groups())
ans = (pow(M, N, MOD) - pow(M, C, MOD)) // 2
print(ans % MOD)
i... | ConDefects/ConDefects/Code/arc151_b/Python/45906391 |
condefects-python_data_1337 | class UnionFind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [0]*n
self.size = [1]*n
def root(self,x):
if self.par[x]==-1:
return x
else:
stack=[]
while self.par[x]!=-1:
stack.append(x)
x=se... | ConDefects/ConDefects/Code/arc151_b/Python/45494468 |
condefects-python_data_1338 | from collections import defaultdict
def pow2(x, n,mod):
ans = 1
while n:
if n % 2:
ans *= x
ans %= mod
x *= x
x %= mod
n >>= 1
return ans
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n)
self.rank... | ConDefects/ConDefects/Code/arc151_b/Python/41325604 |
condefects-python_data_1339 | class UnionFind:
def __init__(self, n):
# 親要素のノード番号を格納。
# par[x]<0の時そのノードは根で、par[x]の絶対値はグループのサイズ
self.parents = [-1] * n
self.length = n
# 親の親の...を辿って根を見つける
def find(self, x):
if self.parents[x] < 0:
return x
else:
# 再度検索する時に手間がかからないよう... | ConDefects/ConDefects/Code/arc151_b/Python/36899282 |
condefects-python_data_1340 | A,X,M = map(int,input().split())
if A == 1:
print(X%M)
else:
print(pow(A,X,M*(A-1))//(A-1)%M)
A,X,M = map(int,input().split())
if A == 1:
print(X%M)
else:
print((pow(A,X,M*(A-1))-1)//(A-1)%M) | ConDefects/ConDefects/Code/abc293_e/Python/45509559 |
condefects-python_data_1341 | a,x,m=map(int,input().split())
if a==1:print(x)
else:
t=pow(a,x,(a-1)*m)
if t==0:t+=(a-1)*m
print((t-1)//(a-1))
a,x,m=map(int,input().split())
if a==1:print(x% m)
else:
t=pow(a,x,(a-1)*m)
if t==0:t+=(a-1)*m
print((t-1)//(a-1)) | ConDefects/ConDefects/Code/abc293_e/Python/45709875 |
condefects-python_data_1342 | a,x,m = map(int,input().split())
A = [[a,1]]
for i in range(60):
t = A[-1]
A.append([(t[0] ** 2) % m,(t[0]*t[1] + t[1]) % m])
x = bin(x - 1)
x = list(x[2:])
x.reverse()
ans = 1
for i,v in enumerate(x):
if v == "1":
ans = (ans * A[i][0] + A[i][1]) % m
print(ans)
a,x,m = map(int,input().split())
if m... | ConDefects/ConDefects/Code/abc293_e/Python/45811552 |
condefects-python_data_1343 | A, X, MOD = map(int, input().split())
def f(x):
if x == 0:
return 0
if x == 1:
return 1
res = f(x//2)
res += res * pow(A, x//2, MOD)
if x % 2 == 1:
res += pow(A, x-1, MOD)
res %= MOD
return res
print(f(X))
A, X, MOD = map(int, input().split())
def f(x):
... | ConDefects/ConDefects/Code/abc293_e/Python/45453097 |
condefects-python_data_1344 | A, X, M = map(int, input().split())
if A == 1:
print(X % M)
else:
print(
(pow(A, X, M * (A-1)-1) // (A-1)) % M
)
A, X, M = map(int, input().split())
if A == 1:
print(X % M)
else:
print(
((pow(A, X, M * (A-1))-1) // (A-1)) % M
) | ConDefects/ConDefects/Code/abc293_e/Python/46204765 |
condefects-python_data_1345 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
A, X, M = map(int, readline().split())
def f(X):
if X == 1:
return 1
num = f(X // 2)
ret = num + pow(A, X // 2, M) * num
ret %= M
if X % 2:
ret += pow(A, X - 1, M)
ret %= M
... | ConDefects/ConDefects/Code/abc293_e/Python/45761832 |
condefects-python_data_1346 | N = int(input())
H = list(map(int,input().split()))
ans = 0
M = 0
for i in range(1,N+1):
if H[i-1] > M:
M = H[i-1]
ans = i
print(i)
N = int(input())
H = list(map(int,input().split()))
ans = 0
M = 0
for i in range(1,N+1):
if H[i-1] > M:
M = H[i-1]
ans = i
print(ans) | ConDefects/ConDefects/Code/abc275_a/Python/45305644 |
condefects-python_data_1347 | N=int(input())
P=[]
T=0
total=0
for _ in range(N):
x,y,z=list(map(int, input().split()))
if x>y:
T+=z
else:
P.append((x,y,z))
total+=z
need = total//2+1
if need<=T:
print(0)
exit()
need-=T
dp = [[10**15]*(need+1) for _ in range(len(P)+1)]
dp[0][0]=0
for i in range(len(P)):
x... | ConDefects/ConDefects/Code/abc317_d/Python/52056192 |
condefects-python_data_1348 | n = int(input())
x, y, z = [None] * n, [None] * n, [None] * n
for i in range(n):
x[i], y[i], z[i] = map(int, input().split())
v = [None] * n
for i in range(n):
v[i] = max(0, y[i] - (x[i] + y[i]) // 2)
m = sum(z)
dp = [[10**10] * (m + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
for j in ... | ConDefects/ConDefects/Code/abc317_d/Python/53253616 |
condefects-python_data_1349 | N = int(input())
XYZ = [[int(x) for x in input().split()] for _ in range(N)]
lst = []
total = 0
for x, y, z in XYZ:
lst.append((max((y-x)//2+1, 0), z))
total += z
# dp[i][j]: i個目までの選挙区を見て、j議席を獲得するときに必要な最小コスト
dp = [[10**10]*(total+1) for _ in range(N+1)]
dp[0][0] = 0
for i, (c, w) in enumerate(lst):
for j in... | ConDefects/ConDefects/Code/abc317_d/Python/52641231 |
condefects-python_data_1350 | def gcd(a, b):
while b: a, b = b, a % b
return a
def isPrimeMR(n):
d = n - 1
d = d // (d & -d)
L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
for a in L:
t = d
y = pow(a, t, n)
if y == 1: continue
... | ConDefects/ConDefects/Code/abc245_h/Python/30480849 |
condefects-python_data_1351 | mod=998244353
def comb(n,r):
if r>n:
return 0
tmp1=1
tmp2=1
for i in range(r):
tmp1*=n-i
tmp2*=i+1
tmp1%=mod
tmp2%=mod
return (tmp1*pow(tmp2,mod-2,mod)%mod)
def fact(n):
if n==1:
return []
arr=[]
temp=n
for i in range(2,int(-(-n**0.5//1))+2):
if temp%i==0:
cnt=0
... | ConDefects/ConDefects/Code/abc245_h/Python/30541714 |
condefects-python_data_1352 | # For the sake of speed,
# this convolution is specialized to mod 998244353.
import math
import itertools
import functools
import collections
_fft_mod = 998244353
_fft_sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601,
842657... | ConDefects/ConDefects/Code/abc245_h/Python/30483110 |
condefects-python_data_1353 | N,X,Y,*A=map(int,open(0).read().split());f=0;s=["Second","First"]
for a in A:
if a%(X+Y)>=max(X,Y):f=1
elif a%(X+Y)>=min(X,Y):print([X<Y]);exit()
print(s[f])
N,X,Y,*A=map(int,open(0).read().split());f=0;s=["Second","First"]
for a in A:
if a%(X+Y)>=max(X,Y):f=1
elif a%(X+Y)>=min(X,Y):print(s[X<Y]);exit(... | ConDefects/ConDefects/Code/arc143_c/Python/33642213 |
condefects-python_data_1354 | n, x, y = map(int, input().split())
a_list = list(map(int, input().split()))
for i in range(n):
a_list[i] %= x+y
flag = True
for i in range(n):
if a_list[i] // x == 0 and a_list[i] // y > 0:
print("Second")
exit()
elif a_list[i] // x > 0 and a_list[i] // y > 0:
print("First")
... | ConDefects/ConDefects/Code/arc143_c/Python/37392747 |
condefects-python_data_1355 | a = input()
b = int(a[0])
c = int(a[-1])
d = []
e = []
for j in range(b):
d.append(input())
for j in range(b):
e.append(input())
def f(x, y):
for i in range(b):
for j in range(c):
if d[(i+x)%b][(j+y)%c] == e[i][j]:
pass
else:
return 0
ret... | ConDefects/ConDefects/Code/abc300_b/Python/45723196 |
condefects-python_data_1356 | def fprint(arys):
for i in range(len(arys)):
print(*arys[i])
print("-"*len(arys)*5)
return
h, w = map(int, input().split())
tableA = [[] for i in range(h)]
tableB = [[] for i in range(h)]
mp1 = [[""]*w for i in range(h)]
mp2 = [[""]*w for i in range(h)]
for i in range(h):
s = list(input())
... | ConDefects/ConDefects/Code/abc300_b/Python/45110485 |
condefects-python_data_1357 | def check(x):
sub = 0
for i in range(N):
a,b = ab[i]
if x<=a:
sub+=b
#print(sub)
if sub<=K:
return 1
else:
return 0
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
ng,ok = 0,10**9
while abs(ok-ng)>1:
ic = (ok+ng)//2
#print(ok,ic,ng)
if check(... | ConDefects/ConDefects/Code/abc309_c/Python/46123600 |
condefects-python_data_1358 | N, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()
medicines = 0
for i in range(N):
medicines += AB[i][1]
for i in range(N):
if medicines <= K:
if i == 0:
print(1)
exit(0)
else:
print(AB[i - 1][0] + 1)
... | ConDefects/ConDefects/Code/abc309_c/Python/45772102 |
condefects-python_data_1359 | N, K = map(int, input().split())
arr = []
total = 0
for i in range(N):
tmp1, tmp2 = map(int, input().split())
arr.append([tmp1,tmp2])
total += tmp2
arr.sort()
if total < K:
print(1)
exit()
i = 0
while 1:
total -= arr[i][1]
if total <= K:
print(arr[i][0]+1)
exit()
i += 1
N, K = map(int, input(... | ConDefects/ConDefects/Code/abc309_c/Python/45738581 |
condefects-python_data_1360 | n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
def calc(num):
global ab
res = 0
for j in range(n):
if ab[j][0] <= num:
continue
res += ab[j][1]
return res
l = -1
r = 9999999999999999
m = 0
while r > l + 1:
m = (r + l) // 2
... | ConDefects/ConDefects/Code/abc309_c/Python/46182298 |
condefects-python_data_1361 | # python3 answer.py < input.txt
# =list(map(int, input().split()))
#=int(input())
#import collections
#import itertools
#import numpy
#from collections import deque
#import heapq
#inf=10**100
#isok=True
#import numpy as np
#np.set_printoptions(suppress=True)
#k=int(input())
#n=int(input())
#lis=[]
n,k=list(map(int, in... | ConDefects/ConDefects/Code/abc309_c/Python/45895898 |
condefects-python_data_1362 | DEBUG = False
testcase = r"""
15 158260522
877914575 2436426
24979445 61648772
623690081 33933447
476190629 62703497
211047202 71407775
628894325 31963982
822804784 50968417
430302156 82631932
161735902 80895728
923078537 7723857
189330739 10286918
802329211 4539679
303238506 17063340
492686568 73361868
125660016 50287... | ConDefects/ConDefects/Code/abc309_c/Python/45788753 |
condefects-python_data_1363 | x, y, z = map(int, input().split())
s = input()
dp = [[0]*(len(s)) for _ in range(2)]
if s[0] == "A":
dp[0][0] = z+x
dp[1][0] = y
else:
dp[0][0] = z+y
dp[1][0] = x
for j in range(1, len(s)):
if s[j] == "A":
dp[0][j] = min(dp[0][j-1]+x, dp[1][j-1]+z+x)
dp[1][j] = min(dp[0][j-1]+z+x,... | ConDefects/ConDefects/Code/abc303_d/Python/45744343 |
condefects-python_data_1364 | import sys
import math
from collections import deque
sys.setrecursionlimit(10**6) #pythonの無限再起を防ぐための上限変更
input = sys.stdin.readline
# 303 D
X, Y , Z = map(int, input().split())
S = input()[:-1]
INF = 10000000000
Slen = len(S)
res = [[INF]*2 for i in range(Slen+1)]
res[0][0] = 0
for i in range(Slen):
if S[i] == 'a... | ConDefects/ConDefects/Code/abc303_d/Python/45489398 |
condefects-python_data_1365 | #Six characters
def solution(string):
if len(string) == 1:
return string * 6
elif len(string) == 2:
return string * 3
else:
return string * 2
#Six characters
def solution(string):
if len(string) == 1:
return string * 6
elif len(string) == 2:
return string * ... | ConDefects/ConDefects/Code/abc251_a/Python/44626841 |
condefects-python_data_1366 | S = input()
for i in range(6):
SS = S*i
if len(SS) == 6:
print(SS)
break
S = input()
for i in range(6+1):
SS = S*i
if len(SS) == 6:
print(SS)
break | ConDefects/ConDefects/Code/abc251_a/Python/45011950 |
condefects-python_data_1367 | DEBUG = 0
N, M, X = map(int, input().split())
if DEBUG:
print("N, M, X =", N, M, X)
K = 30
P = 998244353
nn = 1010
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
for i in range(nn):
fa[i+1] = fa[i] * (i + 1) % P
fainv[-1] = pow(fa[-1], P - 2, P)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i + 1) % P
def... | ConDefects/ConDefects/Code/abc288_h/Python/38697040 |
condefects-python_data_1368 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
Q = int(input())
queries = []
for i in range(Q):
l, r = map(lambda x:int(x)-1, input().split())
queries.append([l, r])
S = [[0] for i in range(K)]
for k in range(K):
for i in range(N):
if ((i*K+k)<N):
new = S[k][-1] +... | ConDefects/ConDefects/Code/abc288_d/Python/45491325 |
condefects-python_data_1369 | N, K = map(int,input().split())
A=list(map(int,input().split()))
Q=int(input())
S = [[0] for i in range(K)]
for i in range(N):
S[i%K].append(S[i%K][-1]+A[i])
for i in range(Q):
l, r = map(lambda x:int(x)-1,input().split())
s=set()
for k in range(K):
# s.add(S[k][(r-k)//K+1] - S[k][(l-k-1)//... | ConDefects/ConDefects/Code/abc288_d/Python/45491126 |
condefects-python_data_1370 | class segtreelazy3:
# 要素数、乗せる演算、単位元、作用、作用素の演算、恒等写像になる作用素
def __init__(self, N, op, e, act, comp, identity, A = []):
self.N = N
self.op = op
self.e = e
self.act = act
self.comp = comp
self.identity = identity
self.dat = [self.e] * (2 * self.N)
self.... | ConDefects/ConDefects/Code/abc265_g/Python/46700668 |
condefects-python_data_1371 | class UnionFind():
def __init__(self, n):
self.n = n
self.PA = [-1] * n
def root(self, a):
L = []
while self.PA[a] >= 0:
L.append(a)
a = self.PA[a]
for l in L:
self.PA[l] = a
return a
def unite(self, a, b):
ra, rb = ... | ConDefects/ConDefects/Code/abc235_h/Python/29171105 |
condefects-python_data_1372 | h,w=map(int,input().split())
g=[]
for i in range(h):
tmp=input()
g.append(list(tmp))
visited=[[False]*w for _ in range(h)]
i,j=0,0
for k in range(10**6):
if visited[i][j]==True:
print(-1)
exit()
if g[i][j]=="U":
if i==0:
print(i+1,j+1)
exit()
else:... | ConDefects/ConDefects/Code/abc265_c/Python/46154642 |
condefects-python_data_1373 | import sys
import math
N, M = map(int, input().split())
S = [[0]*500 for _ in range(500)]
base = list(range(23))
for i in range(500):
for j in range(500):
x = j//23
S[i][j] = (i+j+(x*(i//23)))%23
for i in range(N):
print(*S[i][:M])
import sys
import math
N, M = map(int, input().split())
S = ... | ConDefects/ConDefects/Code/arc140_e/Python/31730234 |
condefects-python_data_1374 | import copy
import gc
import itertools
from array import array
from fractions import Fraction
import heapq
import math
import operator
import os, sys
import profile
import cProfile
import random
import re
import string
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
from... | ConDefects/ConDefects/Code/arc140_e/Python/31744615 |
condefects-python_data_1375 | import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2 ** 63 - 1
mod = 998244353
n, m = mi()
a = [[0] * (m) for _ in range(n)]
for i in range(n):
for j in range(m):
a[i][j] = (i // 23 + j // 23 + i + j) % ... | ConDefects/ConDefects/Code/arc140_e/Python/32291548 |
condefects-python_data_1376 | n,m=map(int,input().split())
ans=[]
for i in range(n):
ans.append([])
for j in range(m):
ans[-1].append(1)
for i in range(n):
for j in range(m):
ans[i][j]=(i+j+i//23*j//23)%23+1
for i in range(n):
print(' '.join(map(str,ans[i])))
n,m=map(int,input().split())
ans=[]
for i in range(n):
ans.append([])
... | ConDefects/ConDefects/Code/arc140_e/Python/31727392 |
condefects-python_data_1377 | n = int(input())
c = input()
head = c[0]
tail = c[1:]
if head == "B":
# tail中のAとBを反転
tail = tail.replace("A", "C").replace("B", "A").replace("C", "B")
def sign2char(n):
if n == 0:
return "C"
elif n > 0:
return "A"
else:
return "B"
# 初期化
count = [1]
for t in tail:
if t ... | ConDefects/ConDefects/Code/arc172_c/Python/51141760 |
condefects-python_data_1378 | from collections import deque
import sys
import math
import heapq
import random
import itertools
from functools import cmp_to_key
from fractions import Fraction
def gs():
return sys.stdin.readline().split()[0]
def gd():
return float(sys.stdin.readline())
def gi():
return int(sys.stdin.readline())
def gi... | ConDefects/ConDefects/Code/arc151_a/Python/42888318 |
condefects-python_data_1379 | N = int(input())
S = input()
T = input()
diff = 0
for s, t in zip(S, T):
if s != t:
diff += 1
if diff % 2 == 1:
print(-1)
exit()
ds = diff // 2
dt = diff // 2
ans = []
for s, t in zip(S, T):
if s == t:
ans.append(s)
elif ds > 0 and s == "1":
ans.append("0")
ds -= 1
... | ConDefects/ConDefects/Code/arc151_a/Python/44645744 |
condefects-python_data_1380 | n=int(input())
s=list(input())
t=list(input())
L=[False for i in range(n)]
ans=["0" for i in range(n)]
miss=0
for i in range(n):
if s[i]==t[i]:
ans[i]=s[i]
L[i]=True
else:
miss+=1
if miss%2==1:
print(-1)
else:
SU=0
TU=0
for i in range(n):
if L[i]==False:
if s[i]=="1":
SU+=1
... | ConDefects/ConDefects/Code/arc151_a/Python/45669333 |
condefects-python_data_1381 | n=int(input())
s=input()
t=input()
cnt=0
ans=''
for i in range(n):
if(s[i]!=t[i]):
cnt+=1
if(cnt%2==1):
ans='-1'
else:
hum_s=0
hum_t=0
for i in range(n):
if(s[i]==t[i]):
ans+='0'
elif(s[i]==0):
if(hum_t<cnt//2):
ans+='0'
hum_t+=1
else:
ans+='1'
hum... | ConDefects/ConDefects/Code/arc151_a/Python/44901492 |
condefects-python_data_1382 | import sys
input = sys.stdin.readline
def ii(): return int(input())
def fi(): return float(input())
def si(): return input().rstrip()
def mii(): return map(int, input().split())
def fii(): return map(float, input().split())
def mii1(): return map(lambda x: int(x)-1, input().split())
def lii(): return list(map(int, inp... | ConDefects/ConDefects/Code/arc151_a/Python/45098095 |
condefects-python_data_1383 | N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
mod = 998244353
dp = [[0] * 2 for _ in range(N)]
dp[0][0] = 1
dp[0][1] = 1
for i in range(1, N):
if AB[i][0] != AB[i - 1][0]:
dp[i][0] += dp[i - 1][0]
if AB[i][0] != AB[i - 1][1]:
dp[i][0] += dp[i - 1][1]
if AB[i][1] !... | ConDefects/ConDefects/Code/abc291_d/Python/46165699 |
condefects-python_data_1384 | import sys
def input(): return sys.stdin.readline().rstrip()
def read(): return int(input())
def reads(): return list(map(int, input().split()))
def main():
MOD = 998244353
N = read()
AB = [reads() for _ in range(N)]
dp = [[0]*2 for _ in range(N)]
dp[0][0] = 1
dp[0][1] = 1
fo... | ConDefects/ConDefects/Code/abc291_d/Python/45745122 |
condefects-python_data_1385 | n=int(input())
mod=998244353
c=[]
for i in range(n):
a,b=map(int,input().split())
c.append((a,b))
if n==1:
print(0)
else:
dp=[[0]*2 for i in range(n)]
for j in range(2):
if c[1][j]!=c[0][j]:
dp[1][j]+=1
if c[1][j]!=c[0][(j+1)%2]:
dp[1][j]+=1
for i i... | ConDefects/ConDefects/Code/abc291_d/Python/45489809 |
condefects-python_data_1386 | import sys, heapq, math, bisect, itertools
from collections import defaultdict, deque
def main():
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 998244353
N = int(input())
cards = []
for _ in range(N):
A, B = map(int, input().split())
car... | ConDefects/ConDefects/Code/abc291_d/Python/46206336 |
condefects-python_data_1387 | import sys
input = sys.stdin.buffer.readline
N = int(input())
MOD = 998244353
dp = [[0] * 2 for _ in range(N)]
dp[0] = [1,1]
for i in range(N):
if i == 0:
old_a, old_b = map(int, input().split())
else:
A, B = map(int, input().split())
if old_a != A:
dp[i][0] += dp[i-1][0]
if old_b != A:
... | ConDefects/ConDefects/Code/abc291_d/Python/45519163 |
condefects-python_data_1388 | N = int(input())
S = [list(map(int, input().split())) for _ in range(N)]
MOD = 998244353
# dp[i][j]: i番目まで見たときに、カードが表か裏か(j=0:表, j=1:裏)の時の数
dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
if i == 0:
dp[i+1][0] += dp[i][0]
dp[i+1][1] += dp[i][0]
else:
preA, preB = S[i... | ConDefects/ConDefects/Code/abc291_d/Python/45954675 |
condefects-python_data_1389 | def main():
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = {}
tmp = {
'value': -1,
'list': set()
}
for _ in range(n):
i = list(map(int, input().split()))
if i[0] == 1:
tmp['value'] = i[1]
tmp['list'] = set()... | ConDefects/ConDefects/Code/abc278_d/Python/44926075 |
condefects-python_data_1390 | import sys
input = sys.stdin.readline
N=int(input())
LR=[list(map(int,input().split())) for i in range(N)]
for i in range(N-1):
x,y=LR[i]
z,w=LR[i+1]
if y>w:
LR[i][1]=max(w,x)
if w>y:
LR[i+1][1]=max(y,z)
for i in range(N-2,-1,-1):
x,y=LR[i]
z,w=LR[i+1]
if y>w:
L... | ConDefects/ConDefects/Code/arc175_c/Python/51662167 |
condefects-python_data_1391 | from bisect import bisect,bisect_left
from collections import *
from heapq import *
from math import gcd,ceil,sqrt,floor,inf,pi
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools import *
#----------------------------------------------------------------------
import os
impo... | ConDefects/ConDefects/Code/arc175_c/Python/54525913 |
condefects-python_data_1392 | import sys, random
input = lambda : sys.stdin.readline().rstrip()
write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda v=0: list(map(lambda i: int(i)-v, ... | ConDefects/ConDefects/Code/arc175_c/Python/53001483 |
condefects-python_data_1393 | N = int(input())
LR = []
for _ in range(N):
l, r = map(int, input().split())
LR.append((l, r))
D = []
INF = 10**18
mi, ma = -INF, INF
for l, r in reversed(LR):
if ma < l:
mi = ma = l
elif r < mi:
mi = ma = r
else:
mi = max(mi, l)
ma = min(ma, r)
D.append((mi, ma))... | ConDefects/ConDefects/Code/arc175_c/Python/51756772 |
condefects-python_data_1394 | import io,os
from copy import deepcopy
import heapq
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def getpattern(grid,d,sym):
n = len(grid)
newgrid = [[0 for _ in range(n)] for _ in range(n)]
ans = 0
for i in range(n):
for j in range(n):
rest = grid[i][j] % (2... | ConDefects/ConDefects/Code/agc066_a/Python/51924137 |
condefects-python_data_1395 | n,d=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
a2=[[0]*n for _ in range(n)]
for r in range(n):
for c in range(n):
tmp=0
x=(a[r][c]+d*(r+c&1))%(2*d)
if x<=d:
tmp+=x
a2[r][c]=a[r][c]-x
else:
tmp+=2*d-x
a2[r][c]=a[r][c]+(2*d-x)
if tmp<=((n**2)*d)... | ConDefects/ConDefects/Code/agc066_a/Python/53570827 |
condefects-python_data_1396 | N,C = map(int,input().split())
op = [tuple(map(int,input().split())) for _ in range(N)]
L = [[0]*2 for _ in range(N+1)]
n = C.bit_length()
L[0][0] = 0
L[0][1] = (1<<n)-1
for i in range(N):
t,a = op[i]
for j in range(2):
if t == 1:
L[i+1][j] = L[i][j]&a
if t == 2:
L[i+1][j... | ConDefects/ConDefects/Code/abc261_e/Python/46034687 |
condefects-python_data_1397 | N,K = map(int,input().split())
RK = int(str(K)[::-1])
ans = 0
if K%10!=0:
if K!=RK:
while RK<=N:
ans += 1
RK *= 10
while K<=N:
ans += 1
K *= 10
print(ans)
N,K = map(int,input().split())
RK = int(str(K)[::-1])
ans = 0
if K<=RK:
if K!=RK:
while RK<=N:
ans += 1
RK *= 10
while K<=N:
ans += 1
K ... | ConDefects/ConDefects/Code/arc142_a/Python/44935143 |
condefects-python_data_1398 | 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/arc142_a/Python/44825978 |
condefects-python_data_1399 | def solve(N, K):
def rev(x):
return int(''.join(reversed(list(str(x)))))
def cnt(x):
res = 0
while x <= N:
res += 1
x *= 10
return res
if K % 10 == 0:
return 0
if K > rev(K):
return 0
return cnt(K) + cnt(rev... | ConDefects/ConDefects/Code/arc142_a/Python/44613596 |
condefects-python_data_1400 | N, K = map(int, input().split())
sk = list(str(K))
rk = ''.join(reversed(sk))
if K > int(rk):
print(0)
exit()
array = []
for i in range(12):
array.append(int(rk + '0' * i))
array.append(int(''.join(sk) + '0' * i))
ans = 0
for a in array:
if a <= N:
ans += 1
print(ans)
N, K = map(int, inpu... | ConDefects/ConDefects/Code/arc142_a/Python/43246085 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.